Skip to content

Commit

Permalink
Merge eb9e413 into 94e7a95
Browse files Browse the repository at this point in the history
  • Loading branch information
arueckauer committed Nov 19, 2020
2 parents 94e7a95 + eb9e413 commit 7bfd490
Show file tree
Hide file tree
Showing 30 changed files with 332 additions and 264 deletions.
16 changes: 9 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,34 @@ env:
matrix:
fast_finish: true
include:
- php: 7.1
- php: 7.3
env:
- DEPS=lowest
- php: 7.1
- php: 7.3
env:
- DEPS=latest
- CS_CHECK=true
- TEST_COVERAGE=true
- php: 7.2
- php: 7.4
env:
- DEPS=lowest
- php: 7.2
- php: 7.4
env:
- DEPS=latest
- php: 7.3
- php: nightly
env:
- DEPS=lowest
- php: 7.3
- COMPOSER_ARGS="--no-interaction --ignore-platform-reqs"
- php: nightly
env:
- DEPS=latest
- COMPOSER_ARGS="--no-interaction --ignore-platform-reqs"

before_install:
- if [[ $TEST_COVERAGE != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi

install:
- travis_retry composer install $COMPOSER_ARGS --ignore-platform-reqs
- travis_retry composer install $COMPOSER_ARGS
- if [[ $LEGACY_DEPS != '' ]]; then travis_retry composer update $COMPOSER_ARGS --with-dependencies $LEGACY_DEPS ; fi
- if [[ $DEPS == 'latest' ]]; then travis_retry composer update $COMPOSER_ARGS ; fi
- if [[ $DEPS == 'lowest' ]]; then travis_retry composer update --prefer-lowest --prefer-stable $COMPOSER_ARGS ; fi
Expand Down
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
"extra": {
},
"require": {
"php": "^7.1",
"php": "^7.3 || ~8.0.0",
"ext-json": "*",
"composer/package-versions-deprecated": "1.11.99.1",
"laminas/laminas-code": "^2.6.3 || ^3.3",
"laminas/laminas-component-installer": "^2.0",
"laminas/laminas-composer-autoloading": "^2.0",
Expand All @@ -35,7 +36,6 @@
"laminas/laminas-zendframework-bridge": "^1.0",
"mezzio/mezzio": "^3.0",
"mezzio/mezzio-router": "^3.0",
"ocramius/package-versions": "^1.3",
"symfony/console": "^2.8 || ^3.0 || ^4.0 || ^5.0"
},
"require-dev": {
Expand All @@ -45,7 +45,8 @@
"mikey179/vfsstream": "^1.6.7",
"mockery/mockery": "^1.2.4",
"php-mock/php-mock-phpunit": "^2.5",
"phpunit/phpunit": "^7.5.17 || ^8.4.3"
"phpspec/prophecy-phpunit": "^2.0",
"phpunit/phpunit": "^9.3"
},
"autoload": {
"psr-4": {
Expand Down
19 changes: 13 additions & 6 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,23 @@
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheResultFile=".phpunit.cache/test-results"
executionOrder="depends,defects"
beStrictAboutCoversAnnotation="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
verbose="true"
colors="true">
<testsuites>
<testsuite name="mezzio-tooling">
<directory>./test</directory>
<testsuite name="default">
<directory suffix="Test.php">test</directory>
</testsuite>
</testsuites>

<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<coverage cacheDirectory=".phpunit.cache/code-coverage"
processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</whitelist>
</filter>
</include>
</coverage>
</phpunit>
3 changes: 3 additions & 0 deletions test/ConfigAndContainerTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@
use org\bovigo\vfs\vfsStream;
use org\bovigo\vfs\vfsStreamDirectory;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;
use Psr\Container\ContainerInterface;
use RuntimeException;
use stdClass;

class ConfigAndContainerTraitTest extends TestCase
{
use ProphecyTrait;

/** @var vfsStreamDirectory */
private $dir;

Expand Down
124 changes: 63 additions & 61 deletions test/CreateHandler/CreateHandlerCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use PHPUnit\Framework\Assert;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
use Prophecy\Prophecy\ObjectProphecy;
use Psr\Container\ContainerInterface;
use ReflectionMethod;
Expand All @@ -39,6 +40,7 @@
class CreateHandlerCommandTest extends TestCase
{
use MockeryPHPUnitIntegration;
use ProphecyTrait;

/** @var ContainerInterface|ObjectProphecy */
private $container;
Expand Down Expand Up @@ -113,90 +115,90 @@ private function mockApplication(string $forService = 'Foo\TestHandler')
public function testConfigureSetsExpectedDescriptionWhenRequestingAHandler()
{
$command = $this->createCommand();
$this->assertStringContainsString(CreateHandlerCommand::HELP_HANDLER_DESCRIPTION, $command->getDescription());
self::assertStringContainsString(CreateHandlerCommand::HELP_HANDLER_DESCRIPTION, $command->getDescription());
}

public function testConfigureSetsExpectedDescriptionWhenRequestingAnAction()
{
$command = new CreateHandlerCommand('action:create', null, $this->container->reveal());
$this->assertStringContainsString(CreateHandlerCommand::HELP_ACTION_DESCRIPTION, $command->getDescription());
self::assertStringContainsString(CreateHandlerCommand::HELP_ACTION_DESCRIPTION, $command->getDescription());
}

public function testConfigureSetsExpectedHelpWhenRequestingAHandler()
{
$command = $this->createCommand();
$this->assertEquals(CreateHandlerCommand::HELP_HANDLER, $command->getHelp());
self::assertEquals(CreateHandlerCommand::HELP_HANDLER, $command->getHelp());
}

public function testConfigureSetsExpectedHelpWhenRequestingAnAction()
{
$command = new CreateHandlerCommand('action:create', null, $this->container->reveal());
$this->assertEquals(CreateHandlerCommand::HELP_ACTION, $command->getHelp());
self::assertEquals(CreateHandlerCommand::HELP_ACTION, $command->getHelp());
}

public function testConfigureSetsExpectedArgumentsWhenRequestingAHandler()
{
$command = $this->createCommand();
$definition = $command->getDefinition();

$this->assertTrue($definition->hasArgument('handler'));
$this->assertFalse($definition->hasArgument('action'));
self::assertTrue($definition->hasArgument('handler'));
self::assertFalse($definition->hasArgument('action'));
$argument = $definition->getArgument('handler');
$this->assertTrue($argument->isRequired());
$this->assertEquals(CreateHandlerCommand::HELP_HANDLER_ARG_HANDLER, $argument->getDescription());
self::assertTrue($argument->isRequired());
self::assertEquals(CreateHandlerCommand::HELP_HANDLER_ARG_HANDLER, $argument->getDescription());
}

public function testConfigureSetsExpectedArgumentsWhenRequestingAnAction()
{
$command = new CreateHandlerCommand('action:create', null, $this->container->reveal());
$definition = $command->getDefinition();
$this->assertTrue($definition->hasArgument('action'));
$this->assertFalse($definition->hasArgument('handler'));
self::assertTrue($definition->hasArgument('action'));
self::assertFalse($definition->hasArgument('handler'));
$argument = $definition->getArgument('action');
$this->assertTrue($argument->isRequired());
$this->assertEquals(CreateHandlerCommand::HELP_ACTION_ARG_ACTION, $argument->getDescription());
self::assertTrue($argument->isRequired());
self::assertEquals(CreateHandlerCommand::HELP_ACTION_ARG_ACTION, $argument->getDescription());
}

public function testConfigureSetsExpectedOptionsWhenRequestingAHandler()
{
$command = $this->createCommand();
$definition = $command->getDefinition();

$this->assertTrue($definition->hasOption('no-factory'));
self::assertTrue($definition->hasOption('no-factory'));
$option = $definition->getOption('no-factory');
$this->assertFalse($option->acceptValue());
$this->assertEquals(CreateHandlerCommand::HELP_HANDLER_OPT_NO_FACTORY, $option->getDescription());
self::assertFalse($option->acceptValue());
self::assertEquals(CreateHandlerCommand::HELP_HANDLER_OPT_NO_FACTORY, $option->getDescription());

$this->assertTrue($definition->hasOption('no-register'));
self::assertTrue($definition->hasOption('no-register'));
$option = $definition->getOption('no-register');
$this->assertFalse($option->acceptValue());
$this->assertEquals(CreateHandlerCommand::HELP_HANDLER_OPT_NO_REGISTER, $option->getDescription());
self::assertFalse($option->acceptValue());
self::assertEquals(CreateHandlerCommand::HELP_HANDLER_OPT_NO_REGISTER, $option->getDescription());

$this->assertFalse($definition->hasOption('without-template'));
$this->assertFalse($definition->hasOption('with-template-namespace'));
$this->assertFalse($definition->hasOption('with-template-name'));
$this->assertFalse($definition->hasOption('with-template-extension'));
self::assertFalse($definition->hasOption('without-template'));
self::assertFalse($definition->hasOption('with-template-namespace'));
self::assertFalse($definition->hasOption('with-template-name'));
self::assertFalse($definition->hasOption('with-template-extension'));
}

public function testConfigureSetsExpectedOptionsWhenRequestingAnAction()
{
$command = new CreateHandlerCommand('action:create', null, $this->container->reveal());
$definition = $command->getDefinition();

$this->assertTrue($definition->hasOption('no-factory'));
self::assertTrue($definition->hasOption('no-factory'));
$option = $definition->getOption('no-factory');
$this->assertFalse($option->acceptValue());
$this->assertEquals(CreateHandlerCommand::HELP_ACTION_OPT_NO_FACTORY, $option->getDescription());
self::assertFalse($option->acceptValue());
self::assertEquals(CreateHandlerCommand::HELP_ACTION_OPT_NO_FACTORY, $option->getDescription());

$this->assertTrue($definition->hasOption('no-register'));
self::assertTrue($definition->hasOption('no-register'));
$option = $definition->getOption('no-register');
$this->assertFalse($option->acceptValue());
$this->assertEquals(CreateHandlerCommand::HELP_ACTION_OPT_NO_REGISTER, $option->getDescription());
self::assertFalse($option->acceptValue());
self::assertEquals(CreateHandlerCommand::HELP_ACTION_OPT_NO_REGISTER, $option->getDescription());

$this->assertFalse($definition->hasOption('without-template'));
$this->assertFalse($definition->hasOption('with-template-namespace'));
$this->assertFalse($definition->hasOption('with-template-name'));
$this->assertFalse($definition->hasOption('with-template-extension'));
self::assertFalse($definition->hasOption('without-template'));
self::assertFalse($definition->hasOption('with-template-namespace'));
self::assertFalse($definition->hasOption('with-template-name'));
self::assertFalse($definition->hasOption('with-template-extension'));
}

public function testConfigureSetsExpectedTemplateOptionsWhenRequestingAHandlerAndRendererIsPresent()
Expand All @@ -205,25 +207,25 @@ public function testConfigureSetsExpectedTemplateOptionsWhenRequestingAHandlerAn
$command = new CreateHandlerCommand('handler:create', null, $this->container->reveal());
$definition = $command->getDefinition();

$this->assertTrue($definition->hasOption('without-template'));
self::assertTrue($definition->hasOption('without-template'));
$option = $definition->getOption('without-template');
$this->assertFalse($option->acceptValue());
$this->assertEquals(CreateHandlerCommand::HELP_OPTION_WITHOUT_TEMPLATE, $option->getDescription());
self::assertFalse($option->acceptValue());
self::assertEquals(CreateHandlerCommand::HELP_OPTION_WITHOUT_TEMPLATE, $option->getDescription());

$this->assertTrue($definition->hasOption('with-template-namespace'));
self::assertTrue($definition->hasOption('with-template-namespace'));
$option = $definition->getOption('with-template-namespace');
$this->assertTrue($option->acceptValue());
$this->assertEquals(CreateHandlerCommand::HELP_OPTION_WITH_TEMPLATE_NAMESPACE, $option->getDescription());
self::assertTrue($option->acceptValue());
self::assertEquals(CreateHandlerCommand::HELP_OPTION_WITH_TEMPLATE_NAMESPACE, $option->getDescription());

$this->assertTrue($definition->hasOption('with-template-name'));
self::assertTrue($definition->hasOption('with-template-name'));
$option = $definition->getOption('with-template-name');
$this->assertTrue($option->acceptValue());
$this->assertEquals(CreateHandlerCommand::HELP_OPTION_WITH_TEMPLATE_NAME, $option->getDescription());
self::assertTrue($option->acceptValue());
self::assertEquals(CreateHandlerCommand::HELP_OPTION_WITH_TEMPLATE_NAME, $option->getDescription());

$this->assertTrue($definition->hasOption('with-template-extension'));
self::assertTrue($definition->hasOption('with-template-extension'));
$option = $definition->getOption('with-template-extension');
$this->assertTrue($option->acceptValue());
$this->assertEquals(CreateHandlerCommand::HELP_OPTION_WITH_TEMPLATE_EXTENSION, $option->getDescription());
self::assertTrue($option->acceptValue());
self::assertEquals(CreateHandlerCommand::HELP_OPTION_WITH_TEMPLATE_EXTENSION, $option->getDescription());
}

public function testConfigureSetsExpectedTemplateOptionsWhenRequestingAnActionAndRendererIsPresent()
Expand All @@ -232,25 +234,25 @@ public function testConfigureSetsExpectedTemplateOptionsWhenRequestingAnActionAn
$command = new CreateHandlerCommand('action:create', null, $this->container->reveal());
$definition = $command->getDefinition();

$this->assertTrue($definition->hasOption('without-template'));
self::assertTrue($definition->hasOption('without-template'));
$option = $definition->getOption('without-template');
$this->assertFalse($option->acceptValue());
$this->assertEquals(CreateHandlerCommand::HELP_OPTION_WITHOUT_TEMPLATE, $option->getDescription());
self::assertFalse($option->acceptValue());
self::assertEquals(CreateHandlerCommand::HELP_OPTION_WITHOUT_TEMPLATE, $option->getDescription());

$this->assertTrue($definition->hasOption('with-template-namespace'));
self::assertTrue($definition->hasOption('with-template-namespace'));
$option = $definition->getOption('with-template-namespace');
$this->assertTrue($option->acceptValue());
$this->assertEquals(CreateHandlerCommand::HELP_OPTION_WITH_TEMPLATE_NAMESPACE, $option->getDescription());
self::assertTrue($option->acceptValue());
self::assertEquals(CreateHandlerCommand::HELP_OPTION_WITH_TEMPLATE_NAMESPACE, $option->getDescription());

$this->assertTrue($definition->hasOption('with-template-name'));
self::assertTrue($definition->hasOption('with-template-name'));
$option = $definition->getOption('with-template-name');
$this->assertTrue($option->acceptValue());
$this->assertEquals(CreateHandlerCommand::HELP_OPTION_WITH_TEMPLATE_NAME, $option->getDescription());
self::assertTrue($option->acceptValue());
self::assertEquals(CreateHandlerCommand::HELP_OPTION_WITH_TEMPLATE_NAME, $option->getDescription());

$this->assertTrue($definition->hasOption('with-template-extension'));
self::assertTrue($definition->hasOption('with-template-extension'));
$option = $definition->getOption('with-template-extension');
$this->assertTrue($option->acceptValue());
$this->assertEquals(CreateHandlerCommand::HELP_OPTION_WITH_TEMPLATE_EXTENSION, $option->getDescription());
self::assertTrue($option->acceptValue());
self::assertEquals(CreateHandlerCommand::HELP_OPTION_WITH_TEMPLATE_EXTENSION, $option->getDescription());
}

public function testSuccessfulExecutionEmitsExpectedMessages()
Expand Down Expand Up @@ -280,7 +282,7 @@ public function testSuccessfulExecutionEmitsExpectedMessages()

$method = $this->reflectExecuteMethod($command);

$this->assertSame(0, $method->invoke(
self::assertSame(0, $method->invoke(
$command,
$this->input->reveal(),
$this->output->reveal()
Expand Down Expand Up @@ -314,7 +316,7 @@ public function testSuccessfulExecutionEmitsExpectedMessagesWhenRequestingAnActi

$method = $this->reflectExecuteMethod($command);

$this->assertSame(0, $method->invoke(
self::assertSame(0, $method->invoke(
$command,
$this->input->reveal(),
$this->output->reveal()
Expand Down Expand Up @@ -384,7 +386,7 @@ public function testCommandWillGenerateTemplateWhenRendererIsRegistered(

$method = $this->reflectExecuteMethod($command);

$this->assertSame(0, $method->invoke(
self::assertSame(0, $method->invoke(
$command,
$this->input->reveal(),
$this->output->reveal()
Expand Down Expand Up @@ -461,7 +463,7 @@ public function testCommandWillGenerateTemplateWithProvidedOptionsWhenRendererIs

$method = $this->reflectExecuteMethod($command);

$this->assertSame(0, $method->invoke(
self::assertSame(0, $method->invoke(
$command,
$this->input->reveal(),
$this->output->reveal()
Expand Down Expand Up @@ -511,7 +513,7 @@ public function testCommandWillNotGenerateTemplateWithProvidedOptionsWhenWithout

$method = $this->reflectExecuteMethod($command);

$this->assertSame(0, $method->invoke(
self::assertSame(0, $method->invoke(
$command,
$this->input->reveal(),
$this->output->reveal()
Expand Down

0 comments on commit 7bfd490

Please sign in to comment.