Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Commit

Permalink
Update dev-dependencies to allow tests on PHPUnit 8
Browse files Browse the repository at this point in the history
- mockery/mockery ^1.2.4
- php-mock/php-mock-phpunit ^2.5
- phpunit/phpunit ^7.5.17 || ^8.4.3
  • Loading branch information
michalbundyra committed Nov 22, 2019
1 parent f50973f commit 8ed56ec
Show file tree
Hide file tree
Showing 27 changed files with 404 additions and 335 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/.phpunit.result.cache
/clover.xml
/coveralls-upload.json
/phpunit.xml
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ matrix:
- php: 7.1
env:
- DEPS=locked
- LEGACY_DEPS="symfony/console"
- LEGACY_DEPS="phpunit/phpunit symfony/console"
- CS_CHECK=true
- TEST_COVERAGE=true
- php: 7.1
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
"require-dev": {
"malukenho/docheader": "^0.1.6",
"mikey179/vfsstream": "^1.6.7",
"mockery/mockery": "^1.0",
"php-mock/php-mock-phpunit": "^2.1",
"phpunit/phpunit": "^7.0.3",
"mockery/mockery": "^1.2.4",
"php-mock/php-mock-phpunit": "^2.5",
"phpunit/phpunit": "^7.5.17 || ^8.4.3",
"zendframework/zend-coding-standard": "~1.0.0"
},
"autoload": {
Expand Down
608 changes: 335 additions & 273 deletions composer.lock

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions test/CreateHandler/CreateHandlerCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class CreateHandlerCommandTest extends TestCase
/** @var ConsoleOutputInterface|ObjectProphecy */
private $output;

protected function setUp()
protected function setUp() : void
{
$this->input = $this->prophesize(InputInterface::class);
$this->output = $this->prophesize(ConsoleOutputInterface::class);
Expand Down Expand Up @@ -94,8 +94,8 @@ private function mockApplication(string $forService = 'Foo\TestHandler')
->run(
Argument::that(function ($input) use ($forService) {
Assert::assertInstanceOf(ArrayInput::class, $input);
Assert::assertContains('factory:create', (string) $input);
Assert::assertContains($forService, (string) $input);
Assert::assertStringContainsString('factory:create', (string) $input);
Assert::assertStringContainsString($forService, (string) $input);
return $input;
}),
$this->output->reveal()
Expand All @@ -112,13 +112,13 @@ private function mockApplication(string $forService = 'Foo\TestHandler')
public function testConfigureSetsExpectedDescriptionWhenRequestingAHandler()
{
$command = $this->createCommand();
$this->assertContains(CreateHandlerCommand::HELP_HANDLER_DESCRIPTION, $command->getDescription());
$this->assertStringContainsString(CreateHandlerCommand::HELP_HANDLER_DESCRIPTION, $command->getDescription());
}

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

public function testConfigureSetsExpectedHelpWhenRequestingAHandler()
Expand Down
18 changes: 9 additions & 9 deletions test/CreateHandler/CreateHandlerExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,31 @@ public function testMissingComposerJsonReturnsInstance()
{
$e = CreateHandlerException::missingComposerJson();
$this->assertInstanceOf(CreateHandlerException::class, $e);
$this->assertContains('Could not find a composer.json', $e->getMessage());
$this->assertStringContainsString('Could not find a composer.json', $e->getMessage());
}

public function testMissingComposerAutoloadersReturnsInstance()
{
$e = CreateHandlerException::missingComposerAutoloaders();
$this->assertInstanceOf(CreateHandlerException::class, $e);
$this->assertContains('PSR-4 autoloaders', $e->getMessage());
$this->assertStringContainsString('PSR-4 autoloaders', $e->getMessage());
}

public function testInvalidComposerJsonReturnsInstanceWithErrorMessage()
{
$error = 'Invalid or malformed JSON';
$e = CreateHandlerException::invalidComposerJson($error);
$this->assertInstanceOf(CreateHandlerException::class, $e);
$this->assertContains('Unable to parse composer.json: ', $e->getMessage());
$this->assertContains($error, $e->getMessage());
$this->assertStringContainsString('Unable to parse composer.json: ', $e->getMessage());
$this->assertStringContainsString($error, $e->getMessage());
}

public function testAutoloaderNotFoundReturnsInstanceUsingClassNameProvided()
{
$expected = __CLASS__;
$e = CreateHandlerException::autoloaderNotFound($expected);
$this->assertInstanceOf(CreateHandlerException::class, $e);
$this->assertContains('match ' . $expected, $e->getMessage());
$this->assertStringContainsString('match ' . $expected, $e->getMessage());
}

public function testUnableToCreatePathReturnsInstanceUsingPathAndClassProvided()
Expand All @@ -51,8 +51,8 @@ public function testUnableToCreatePathReturnsInstanceUsingPathAndClassProvided()
$class = __CLASS__;
$e = CreateHandlerException::unableToCreatePath($path, $class);
$this->assertInstanceOf(CreateHandlerException::class, $e);
$this->assertContains('directory ' . $path, $e->getMessage());
$this->assertContains('class ' . $class, $e->getMessage());
$this->assertStringContainsString('directory ' . $path, $e->getMessage());
$this->assertStringContainsString('class ' . $class, $e->getMessage());
}

public function testClassExistsReturnsInstanceUsingPathAndClassProvided()
Expand All @@ -61,7 +61,7 @@ public function testClassExistsReturnsInstanceUsingPathAndClassProvided()
$class = __CLASS__;
$e = CreateHandlerException::classExists($path, $class);
$this->assertInstanceOf(CreateHandlerException::class, $e);
$this->assertContains('directory ' . $path, $e->getMessage());
$this->assertContains('Class ' . $class, $e->getMessage());
$this->assertStringContainsString('directory ' . $path, $e->getMessage());
$this->assertStringContainsString('Class ' . $class, $e->getMessage());
}
}
4 changes: 2 additions & 2 deletions test/CreateHandler/CreateHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class CreateHandlerTest extends TestCase
/** @var string */
private $projectRoot;

public function setUp()
protected function setUp() : void
{
$this->dir = vfsStream::setup('project');
$this->projectRoot = vfsStream::url('project');
Expand Down Expand Up @@ -275,6 +275,6 @@ public function testTheClassSkeletonParameterOverridesTheConstant()
);

$classFileContents = file_get_contents($expectedPath);
$this->assertContains('class Foo\Bar\BazHandler', $classFileContents);
$this->assertStringContainsString('class Foo\Bar\BazHandler', $classFileContents);
}
}
2 changes: 1 addition & 1 deletion test/CreateHandler/CreateTemplateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class CreateTemplateTest extends TestCase
/** @var PlatesRenderer|TwigRenderer|ZendViewRenderer */
private $renderer;

public function setUp()
protected function setUp() : void
{
$this->dir = vfsStream::setup('project');
$this->projectRoot = vfsStream::url('project');
Expand Down
8 changes: 4 additions & 4 deletions test/CreateMiddleware/CreateMiddlewareCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class CreateMiddlewareCommandTest extends TestCase
/** @var CreateMiddlewareCommand */
private $command;

protected function setUp()
protected function setUp() : void
{
$this->input = $this->prophesize(InputInterface::class);
$this->output = $this->prophesize(ConsoleOutputInterface::class);
Expand Down Expand Up @@ -76,8 +76,8 @@ private function mockApplication()
->run(
Argument::that(function ($input) {
Assert::assertInstanceOf(ArrayInput::class, $input);
Assert::assertContains('factory:create', (string) $input);
Assert::assertContains('Foo\TestMiddleware', (string) $input);
Assert::assertStringContainsString('factory:create', (string) $input);
Assert::assertStringContainsString('Foo\TestMiddleware', (string) $input);
return $input;
}),
$this->output->reveal()
Expand All @@ -93,7 +93,7 @@ private function mockApplication()

public function testConfigureSetsExpectedDescription()
{
$this->assertContains('Create a PSR-15 middleware', $this->command->getDescription());
$this->assertStringContainsString('Create a PSR-15 middleware', $this->command->getDescription());
}

public function testConfigureSetsExpectedHelp()
Expand Down
18 changes: 9 additions & 9 deletions test/CreateMiddleware/CreateMiddlewareExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,31 @@ public function testMissingComposerJsonReturnsInstance()
{
$e = CreateMiddlewareException::missingComposerJson();
$this->assertInstanceOf(CreateMiddlewareException::class, $e);
$this->assertContains('Could not find a composer.json', $e->getMessage());
$this->assertStringContainsString('Could not find a composer.json', $e->getMessage());
}

public function testMissingComposerAutoloadersReturnsInstance()
{
$e = CreateMiddlewareException::missingComposerAutoloaders();
$this->assertInstanceOf(CreateMiddlewareException::class, $e);
$this->assertContains('PSR-4 autoloaders', $e->getMessage());
$this->assertStringContainsString('PSR-4 autoloaders', $e->getMessage());
}

public function testInvalidComposerJsonReturnsInstanceWithErrorMessage()
{
$error = 'Invalid or malformed JSON';
$e = CreateMiddlewareException::invalidComposerJson($error);
$this->assertInstanceOf(CreateMiddlewareException::class, $e);
$this->assertContains('Unable to parse composer.json: ', $e->getMessage());
$this->assertContains($error, $e->getMessage());
$this->assertStringContainsString('Unable to parse composer.json: ', $e->getMessage());
$this->assertStringContainsString($error, $e->getMessage());
}

public function testAutoloaderNotFoundReturnsInstanceUsingClassNameProvided()
{
$expected = __CLASS__;
$e = CreateMiddlewareException::autoloaderNotFound($expected);
$this->assertInstanceOf(CreateMiddlewareException::class, $e);
$this->assertContains('match ' . $expected, $e->getMessage());
$this->assertStringContainsString('match ' . $expected, $e->getMessage());
}

public function testUnableToCreatePathReturnsInstanceUsingPathAndClassProvided()
Expand All @@ -51,8 +51,8 @@ public function testUnableToCreatePathReturnsInstanceUsingPathAndClassProvided()
$class = __CLASS__;
$e = CreateMiddlewareException::unableToCreatePath($path, $class);
$this->assertInstanceOf(CreateMiddlewareException::class, $e);
$this->assertContains('directory ' . $path, $e->getMessage());
$this->assertContains('class ' . $class, $e->getMessage());
$this->assertStringContainsString('directory ' . $path, $e->getMessage());
$this->assertStringContainsString('class ' . $class, $e->getMessage());
}

public function testClassExistsReturnsInstanceUsingPathAndClassProvided()
Expand All @@ -61,7 +61,7 @@ public function testClassExistsReturnsInstanceUsingPathAndClassProvided()
$class = __CLASS__;
$e = CreateMiddlewareException::classExists($path, $class);
$this->assertInstanceOf(CreateMiddlewareException::class, $e);
$this->assertContains('directory ' . $path, $e->getMessage());
$this->assertContains('Class ' . $class, $e->getMessage());
$this->assertStringContainsString('directory ' . $path, $e->getMessage());
$this->assertStringContainsString('Class ' . $class, $e->getMessage());
}
}
4 changes: 2 additions & 2 deletions test/CreateMiddleware/CreateMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class CreateMiddlewareTest extends TestCase
/** @var string */
private $projectRoot;

public function setUp()
protected function setUp() : void
{
$this->dir = vfsStream::setup('project');
$this->projectRoot = vfsStream::url('project');
Expand Down Expand Up @@ -279,6 +279,6 @@ public function testTheClassSkeletonParameterOverridesTheConstant()
);

$classFileContents = file_get_contents($expectedPath);
$this->assertContains('class Foo\Bar\BazMiddleware', $classFileContents);
$this->assertStringContainsString('class Foo\Bar\BazMiddleware', $classFileContents);
}
}
2 changes: 1 addition & 1 deletion test/Factory/ClassNotFoundExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ public function testForClassNameGeneratesExpectedException()
{
$e = ClassNotFoundException::forClassName(__CLASS__);
$this->assertInstanceOf(ClassNotFoundException::class, $e);
$this->assertContains(sprintf('Class "%s"', __CLASS__), $e->getMessage());
$this->assertStringContainsString(sprintf('Class "%s"', __CLASS__), $e->getMessage());
}
}
2 changes: 1 addition & 1 deletion test/Factory/ConfigFileNotWritableExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ public function testForFileGeneratesExpectedException()
{
$e = ConfigFileNotWritableException::forFile(__FILE__);
$this->assertInstanceOf(ConfigFileNotWritableException::class, $e);
$this->assertContains(sprintf('file "%s"', __FILE__), $e->getMessage());
$this->assertStringContainsString(sprintf('file "%s"', __FILE__), $e->getMessage());
}
}
6 changes: 3 additions & 3 deletions test/Factory/ConfigInjectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ConfigInjectorTest extends TestCase
/** @var string */
private $projectRoot;

public function setUp()
protected function setUp() : void
{
$this->dir = vfsStream::setup('project');
$this->projectRoot = vfsStream::url('project');
Expand Down Expand Up @@ -58,7 +58,7 @@ public function testCreatesConfigFileIfItDidNotPreviouslyExist()
{
$this->injector->injectFactoryForClass(__CLASS__ . 'Factory', __CLASS__);
$config = include($this->projectRoot . '/' . ConfigInjector::CONFIG_FILE);
$this->assertInternalType('array', $config);
$this->assertIsArray($config);
$this->assertTrue(isset($config['dependencies']['factories']));
$this->assertCount(1, $config['dependencies']['factories']);
$this->assertTrue(isset($config['dependencies']['factories'][__CLASS__]));
Expand All @@ -82,7 +82,7 @@ public function testAddsNewEntryToConfigFile()

$this->injector->injectFactoryForClass(__CLASS__ . 'Factory', __CLASS__);
$config = include($this->projectRoot . '/' . ConfigInjector::CONFIG_FILE);
$this->assertInternalType('array', $config);
$this->assertIsArray($config);
$this->assertTrue(isset($config['dependencies']['factories']));

$factories = $config['dependencies']['factories'];
Expand Down
4 changes: 2 additions & 2 deletions test/Factory/CreateFactoryCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class CreateFactoryCommandTest extends TestCase
/** @var CreateFactoryCommand */
private $command;

protected function setUp()
protected function setUp() : void
{
$this->input = $this->prophesize(InputInterface::class);
$this->output = $this->prophesize(ConsoleOutputInterface::class);
Expand All @@ -56,7 +56,7 @@ private function reflectExecuteMethod()

public function testConfigureSetsExpectedDescription()
{
$this->assertContains('Create a factory', $this->command->getDescription());
$this->assertStringContainsString('Create a factory', $this->command->getDescription());
}

public function testConfigureSetsExpectedHelp()
Expand Down
4 changes: 2 additions & 2 deletions test/Factory/CreateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class CreateTest extends TestCase
/** @var string */
private $projectRoot;

public function setUp()
protected function setUp() : void
{
$this->factory = new Create();
$this->dir = vfsStream::setup('project');
Expand Down Expand Up @@ -89,7 +89,7 @@ public function testCanCreateFactoryFile()

$fileName = $factory->createForClass($className);

$this->assertContains('TestClassFactory.php', $fileName);
$this->assertStringContainsString('TestClassFactory.php', $fileName);

require $fileName;
$factoryName = $className . 'Factory';
Expand Down
4 changes: 2 additions & 2 deletions test/Factory/FactoryAlreadyExistsExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function testForClassUsingFileGeneratesExpectedException()
{
$e = FactoryAlreadyExistsException::forClassUsingFile(__CLASS__, __FILE__);
$this->assertInstanceOf(FactoryAlreadyExistsException::class, $e);
$this->assertContains(sprintf('class "%s"', __CLASS__), $e->getMessage());
$this->assertContains(sprintf('file "%s"', __FILE__), $e->getMessage());
$this->assertStringContainsString(sprintf('class "%s"', __CLASS__), $e->getMessage());
$this->assertStringContainsString(sprintf('file "%s"', __FILE__), $e->getMessage());
}
}
2 changes: 1 addition & 1 deletion test/Factory/FactoryClassGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class FactoryClassGeneratorTest extends TestCase
*/
private $generator;

public function setUp()
protected function setUp() : void
{
$this->generator = new FactoryClassGenerator();
}
Expand Down
2 changes: 1 addition & 1 deletion test/Factory/FactoryWriteExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ public function testWhenCreatingFileGeneratesExpectedException()
{
$e = FactoryWriteException::whenCreatingFile(__FILE__);
$this->assertInstanceOf(FactoryWriteException::class, $e);
$this->assertContains('file "' . __FILE__ . '"', $e->getMessage());
$this->assertStringContainsString('file "' . __FILE__ . '"', $e->getMessage());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class MigrateInteropMiddlewareCommandTest extends TestCase
/** @var MigrateInteropMiddlewareCommand */
private $command;

protected function setUp()
protected function setUp() : void
{
$this->input = $this->prophesize(InputInterface::class);
$this->output = $this->prophesize(ConsoleOutputInterface::class);
Expand All @@ -57,7 +57,10 @@ private function reflectExecuteMethod()

public function testConfigureSetsExpectedDescription()
{
$this->assertContains('Migrate http-interop middleware and delegators', $this->command->getDescription());
$this->assertStringContainsString(
'Migrate http-interop middleware and delegators',
$this->command->getDescription()
);
}

private function getConstantValue(string $const, string $class = MigrateInteropMiddlewareCommand::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ private function reflectExecuteMethod() : ReflectionMethod

public function testConfigureSetsExpectedDescription()
{
$this->assertContains('Migrate PSR-15 middleware to request handlers', $this->command->getDescription());
$this->assertStringContainsString(
'Migrate PSR-15 middleware to request handlers',
$this->command->getDescription()
);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion test/Module/CommandCommonOptionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class CommandCommonOptionsTest extends TestCase
/** @var InputInterface|ObjectProphecy */
private $input;

protected function setUp()
protected function setUp() : void
{
$this->input = $this->prophesize(InputInterface::class);
}
Expand Down
Loading

0 comments on commit 8ed56ec

Please sign in to comment.