Skip to content
This repository was archived by the owner on Mar 24, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
language: php
sudo: false
cache:
directories:
- $HOME/.composer/cache/files
- $HOME/symfony-bridge/.phpunit

env:
global:
- SYMFONY_DEPRECATIONS_HELPER=max[direct]=0
- STABILITY="stable"

matrix:
fast_finish: true
include:
# Minimum supported dependencies with the latest and oldest PHP version
- php: 7.2
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="max[self]=0"
- php: 5.6
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="max[self]=0"

# Test the latest stable release
- php: 5.6
- php: 7.0
- php: 7.1
- php: 7.2
- php: 7.3

- php: 7.4
env: SYMFONY_VERSION="^3.4"
- php: 7.4
env: SYMFONY_VERSION="^4.0"
- php: 7.4
env: SYMFONY_VERSION="^5.0"

# Latest commit to master
- php: 7.4
env: STABILITY="dev"

allow_failures:
# Dev-master is allowed to fail.
- env: STABILITY="dev"

before_install:
- if [ "$STABILITY" != "" ]; then composer config minimum-stability ${STABILITY}; fi;
- if [ "$SYMFONY_VERSION" != "" ]; then composer require --no-update symfony/flex; composer config extra.symfony.require ${SYMFONY_VERSION} || true; fi

install:
- composer update ${COMPOSER_FLAGS} --prefer-dist --no-interaction
- ./vendor/bin/simple-phpunit install

script:
- composer validate --strict --no-check-lock
- ./vendor/bin/simple-phpunit --bootstrap vendor/autoload.php Tests/
12 changes: 11 additions & 1 deletion Command/WurstCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace MarcW\Bundle\WurstBundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
Expand All @@ -14,8 +15,15 @@
*
* @author Marc Weistroff <[email protected]>
*/
class WurstCommand extends ContainerAwareCommand
class WurstCommand extends Command
{
/**
* @var integer
*
* No error
*/
const NO_ERROR = 0;

/**
* @var integer
*
Expand Down Expand Up @@ -92,6 +100,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
$output->write($option);
}
}

return self::NO_ERROR;
}

/**
Expand Down
16 changes: 16 additions & 0 deletions DependencyInjection/MarcWWurstExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
namespace MarcW\Bundle\WurstBundle\DependencyInjection;

use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;

class MarcWWurstExtension extends Extension
{
public function load(array $configs, ContainerBuilder $container)
{
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.xml');
}
}
9 changes: 9 additions & 0 deletions MarcWWurstBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,17 @@

namespace MarcW\Bundle\WurstBundle;

use Symfony\Component\Console\Application;
use Symfony\Component\HttpKernel\Bundle\Bundle;

class MarcWWurstBundle extends Bundle
{
public function getContainerExtension()
{
if (!class_exists('Symfony\Component\DependencyInjection\Extension\Extension')) {
$this->extension = false;
}

return parent::getContainerExtension();
}
}
12 changes: 12 additions & 0 deletions Resources/config/services.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services
https://symfony.com/schema/dic/services/services-1.0.xsd">

<services>
<service class="MarcW\Bundle\WurstBundle\Command\WurstCommand" id="MarcW\Bundle\WurstBundle\Command\WurstCommand">
<tag name="console.command"/>
</service>
</services>
</container>
21 changes: 17 additions & 4 deletions Tests/Command/WurstCommandTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@

namespace MarcW\Bundle\WurstBundle\Tests\Command;

use MarcW\Bundle\WurstBundle\MarcWWurstBundle;
use Nyholm\BundleTest\BaseBundleTestCase;
use Symfony\Bridge\PhpUnit\SetUpTearDownTrait;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use MarcW\Bundle\WurstBundle\Command\WurstCommand;
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Finder\SplFileInfo;

class WurstCommandTestCase extends \PHPUnit_Framework_TestCase
class WurstCommandTestCase extends BaseBundleTestCase
{
use SetUpTearDownTrait;

protected $defaultWurst = 'classic';
protected $wurstResourcesDirectory;
protected $sideResourcesDirectory;
Expand All @@ -18,7 +23,7 @@ class WurstCommandTestCase extends \PHPUnit_Framework_TestCase
protected $wurstTypes;
protected $sides;

public function __construct()
private function doSetUp()
{
$resourceDirectory = $this->getResourceDirectory();
$this->wurstResourcesDirectory = $resourceDirectory.'wurst/';
Expand All @@ -31,6 +36,12 @@ public function __construct()
$this->sides = $this->findFilenamesFromGivenDirectory($this->sideResourcesDirectory);
}

protected function getBundleClass()
{
return MarcWWurstBundle::class;
}


protected function getResourceDirectory()
{
$sourceDirectory = __DIR__.'/../../';
Expand All @@ -41,8 +52,10 @@ protected function getResourceDirectory()

protected function setCommand()
{
$mockedKernel = $this->getMock('Symfony\\Component\\HttpKernel\\Kernel', array(), array(), '', false);
$application = new Application($mockedKernel);
$kernel = $this->createKernel();
$this->bootKernel();

$application = new Application($kernel);
$application->add(new WurstCommand());

$this->command = $application->find('wurst:print');
Expand Down
7 changes: 6 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,10 @@
"autoload": {
"psr-0": { "MarcW\\Bundle\\WurstBundle": "" }
},
"target-dir": "MarcW/Bundle/WurstBundle"
"target-dir": "MarcW/Bundle/WurstBundle",
"require-dev": {
"symfony/phpunit-bridge": "^4.4 || ^5.0",
"nyholm/symfony-bundle-test": "dev-master",
"symfony/console": "^3.0 || ^4.0 || ^5.0"
}
}