From 889a3c5ca0b06357efe30823e6628bf9470226d6 Mon Sep 17 00:00:00 2001 From: Chris Burgess Date: Wed, 23 Jun 2021 13:59:59 +1200 Subject: [PATCH 1/2] Update to phpunit/phpunit:~6.0 Currently attempting to `composer install` hangs while trying to resolve packages. PHPUnit seems to be the sticking point? --- composer.json | 10 ++++++---- .../Arachne/Tests/Context/ArachneContextTest.php | 12 ++++++------ .../Initializer/ArachneInitializerTest.php | 3 ++- .../Arachne/Tests/FileSystem/FileLocatorTest.php | 15 ++++++++++----- tests/Arachne/Tests/Http/Client/GuzzleTest.php | 3 ++- .../ServiceContainer/ArachneExtensionTest.php | 4 +++- .../Tests/Validation/Schema/JsonSchemaTest.php | 6 ++++-- .../Tests/Validation/Schema/XmlSchemaTest.php | 9 ++++----- 8 files changed, 37 insertions(+), 25 deletions(-) diff --git a/composer.json b/composer.json index dd529fe..148b709 100644 --- a/composer.json +++ b/composer.json @@ -19,11 +19,13 @@ "seromenho/xml-validator": "~v1.0" }, "require-dev": { - "phpunit/phpunit": "~4.4" + "phpunit/phpunit": "~6.0" }, "autoload": { - "psr-0": { - "Arachne\\": "src/" + "psr-4": { + "Arachne\\": "src/Arachne/", + "Arachne\\Mocks\\": "tests/Arachne/Mocks/", + "Arachne\\Tests\\": "tests/Arachne/Tests/" } } -} +} \ No newline at end of file diff --git a/tests/Arachne/Tests/Context/ArachneContextTest.php b/tests/Arachne/Tests/Context/ArachneContextTest.php index 8d2c5bf..fbc374f 100644 --- a/tests/Arachne/Tests/Context/ArachneContextTest.php +++ b/tests/Arachne/Tests/Context/ArachneContextTest.php @@ -15,13 +15,14 @@ use Arachne\Context\ArachneContext; use Arachne\Mocks\Factory; use Arachne\Mocks\Http\Client; +use PHPUnit\Framework\TestCase; /** * Class ArachneContextTest * @package Arachne\Tests\FileSystem * @author Wojtek Gancarczyk */ -class ArachneContextTest extends \PHPUnit_Framework_TestCase +class ArachneContextTest extends TestCase { /** * @var ArachneContext @@ -42,7 +43,8 @@ public function setUp() public function testFailIfHttpClientWasNotSet() { - $this->setExpectedException('RuntimeException', 'Http client was not set'); + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage('Http client was not set'); $context = new ArachneContext; $context->iSendTheRequest(); } @@ -84,10 +86,8 @@ public function testTheStatusCodeShouldBe() public function testFailTheStatusCodeShouldBeIfTheStatusCodeIsInvalid() { - $this->setExpectedException( - '\Arachne\Exception\InvalidStatusCode', - 'Resource returned status code 200, status code 400 expected.' - ); + $this->expectException(\Arachne\Exception\InvalidStatusCode::class); + $this->expectExceptionMessage('Resource returned status code 200, status code 400 expected.'); $this->context->iSendTheRequest(); $this->context->theStatusCodeShouldBe(400); } diff --git a/tests/Arachne/Tests/Context/Initializer/ArachneInitializerTest.php b/tests/Arachne/Tests/Context/Initializer/ArachneInitializerTest.php index c5691a0..a5b5c93 100644 --- a/tests/Arachne/Tests/Context/Initializer/ArachneInitializerTest.php +++ b/tests/Arachne/Tests/Context/Initializer/ArachneInitializerTest.php @@ -14,13 +14,14 @@ use Arachne\Auth\DummyProvider; use Arachne\Context\Initializer\ArachneInitializer; use Arachne\Mocks; +use PHPUnit\Framework\TestCase; /** * Class ArachneInitializerTest * @package Arachne\Tests\Context\Initilizer * @author Wojtek Gancarczyk */ -class ArachneInitializerTest extends \PHPUnit_Framework_TestCase +class ArachneInitializerTest extends TestCase { /** * @var ArachneInitializer diff --git a/tests/Arachne/Tests/FileSystem/FileLocatorTest.php b/tests/Arachne/Tests/FileSystem/FileLocatorTest.php index d156d00..65dc165 100644 --- a/tests/Arachne/Tests/FileSystem/FileLocatorTest.php +++ b/tests/Arachne/Tests/FileSystem/FileLocatorTest.php @@ -13,13 +13,14 @@ use Arachne\FileSystem\FileLocator; use Arachne\Mocks\Factory; +use PHPUnit\Framework\TestCase; /** * Class FileLocatorTest * @package Arachne\Tests\FileSystem * @author Wojtek Gancarczyk */ -class FileLocatorTest extends \PHPUnit_Framework_TestCase +class FileLocatorTest extends TestCase { /** * @var FileLocator @@ -33,7 +34,8 @@ public function setUp() public function testFailOnNotExistingConfigurationValue() { - $this->setExpectedException('RuntimeException', '`request_file_dir` missing in the configuration'); + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage('`request_file_dir` missing in the configuration'); $fileLocator = new FileLocator(array()); $fileLocator->locateRequestFile('not', 'existing'); } @@ -51,7 +53,8 @@ public function testLocateSchemaFile() public function testFailLocatingNotExistingSchemaFile() { - $this->setExpectedException('RuntimeException', 'Schema file not.existing cannot be found'); + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage('Schema file not.existing cannot be found'); $this->fileLocator->locateSchemaFile('not', 'existing'); } @@ -68,7 +71,8 @@ public function testLocateRequestFile() public function testFailLocatingNotExistingRequestFile() { - $this->setExpectedException('RuntimeException', 'Request file not.existing cannot be found'); + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage('Request file not.existing cannot be found'); $this->fileLocator->locateRequestFile('not', 'existing'); } @@ -85,7 +89,8 @@ public function testLocateResponseFile() public function testFailLocatingNotExistingResponseFile() { - $this->setExpectedException('RuntimeException', 'Response file not.existing cannot be found'); + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage('Response file not.existing cannot be found'); $this->fileLocator->locateResponseFile('not', 'existing'); } } diff --git a/tests/Arachne/Tests/Http/Client/GuzzleTest.php b/tests/Arachne/Tests/Http/Client/GuzzleTest.php index e5db2ce..e673a51 100644 --- a/tests/Arachne/Tests/Http/Client/GuzzleTest.php +++ b/tests/Arachne/Tests/Http/Client/GuzzleTest.php @@ -16,13 +16,14 @@ use GuzzleHttp\Handler\MockHandler; use GuzzleHttp\HandlerStack; use GuzzleHttp\Psr7; +use PHPUnit\Framework\TestCase; /** * Class GuzzleTest * @package Arachne\Tests\Http\Client * @author Wojtek Gancarczyk */ -class GuzzleTest extends \PHPUnit_Framework_TestCase +class GuzzleTest extends TestCase { public function testDoNotFailIfResponseCodeIs404() { diff --git a/tests/Arachne/Tests/ServiceContainer/ArachneExtensionTest.php b/tests/Arachne/Tests/ServiceContainer/ArachneExtensionTest.php index 34d1a00..c3b0626 100644 --- a/tests/Arachne/Tests/ServiceContainer/ArachneExtensionTest.php +++ b/tests/Arachne/Tests/ServiceContainer/ArachneExtensionTest.php @@ -12,6 +12,7 @@ namespace Arachne\Tests\ServiceContainer; use Arachne\ServiceContainer\ArachneExtension; +use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\ContainerBuilder; /** @@ -19,7 +20,7 @@ * @package Arachne\Tests\ServiceContainer * @author Wojtek Gancarczyk */ -class ArachneExtensionTest extends \PHPUnit_Framework_TestCase +class ArachneExtensionTest extends TestCase { public function testDoNotFailIfAuthProviderNotSetUp() { @@ -30,6 +31,7 @@ public function testDoNotFailIfAuthProviderNotSetUp() $containerBuilder = new ContainerBuilder; $extension = new ArachneExtension; $extension->load($containerBuilder, $config); + $containerBuilder->registerExtension($extension); $containerBuilder->compile(); $this->assertSame( 'Arachne\Context\Initializer\ArachneInitializer', diff --git a/tests/Arachne/Tests/Validation/Schema/JsonSchemaTest.php b/tests/Arachne/Tests/Validation/Schema/JsonSchemaTest.php index 82e39f7..fae788e 100644 --- a/tests/Arachne/Tests/Validation/Schema/JsonSchemaTest.php +++ b/tests/Arachne/Tests/Validation/Schema/JsonSchemaTest.php @@ -12,13 +12,14 @@ namespace Arachne\Tests\Validation\Schema; use Arachne\Validation\Schema\JsonSchema; +use PHPUnit\Framework\TestCase; /** * Class JsonSchemaTest * @package Arachne\Tests\Validation\Schema * @author Wojtek Gancarczyk */ -class JsonSchemaTest extends \PHPUnit_Framework_TestCase +class JsonSchemaTest extends TestCase { public function testDoesNotFailOnValidSchema() { @@ -31,7 +32,8 @@ public function testDoesNotFailOnValidSchema() public function testFailsOnInvalidSchema() { - $this->setExpectedException(\Arachne\Exception\InvalidJson::class, 'The property lastName is required'); + $this->expectException(\Arachne\Exception\InvalidJson::class); + $this->expectExceptionMessage('The property lastName is required'); $validator = new JsonSchema; $validator->validateAgainstSchema( file_get_contents(implode(DIRECTORY_SEPARATOR, [FIXTURES_DIR, 'responses', 'test-invalid.json'])), diff --git a/tests/Arachne/Tests/Validation/Schema/XmlSchemaTest.php b/tests/Arachne/Tests/Validation/Schema/XmlSchemaTest.php index 88c1822..67d07b5 100644 --- a/tests/Arachne/Tests/Validation/Schema/XmlSchemaTest.php +++ b/tests/Arachne/Tests/Validation/Schema/XmlSchemaTest.php @@ -12,13 +12,14 @@ namespace Arachne\Tests\Validation\Schema; use Arachne\Validation\Schema\XmlSchema; +use PHPUnit\Framework\TestCase; /** * Class XmlSchemaTest * @package Arachne\Tests\Validation\Schema * @author Wojtek Gancarczyk */ -class XmlSchemaTest extends \PHPUnit_Framework_TestCase +class XmlSchemaTest extends TestCase { public function testDoesNotFailOnValidSchema() { @@ -31,10 +32,8 @@ public function testDoesNotFailOnValidSchema() public function testFailsOnInvalidSchema() { - $this->setExpectedException( - \Arachne\Exception\InvalidXml::class, - "Element 'invalid': This element is not expected. Expected is ( child_string )." - ); + $this->expectException(\Arachne\Exception\InvalidXml::class); + $this->expectExceptionMessage("Element 'invalid': This element is not expected. Expected is ( child_string )."); $validator = new XmlSchema; $validator->validateAgainstSchema( file_get_contents(implode(DIRECTORY_SEPARATOR, [FIXTURES_DIR, 'responses', 'test-invalid.xml'])), From eca2361f7def2c96ff2d860e206e25cbf37a28e3 Mon Sep 17 00:00:00 2001 From: Chris Burgess Date: Thu, 24 Jun 2021 19:43:37 +1200 Subject: [PATCH 2/2] phpunit/phpunit:^8.5 || ^9.0 to match Behat 3.8 --- composer.json | 4 ++-- tests/Arachne/Tests/Context/ArachneContextTest.php | 2 +- .../Tests/Context/Initializer/ArachneInitializerTest.php | 2 +- tests/Arachne/Tests/FileSystem/FileLocatorTest.php | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 148b709..f0f85a1 100644 --- a/composer.json +++ b/composer.json @@ -13,13 +13,13 @@ ], "require": { "php": ">=5.4.0", - "behat/behat": "~3.3.0", + "behat/behat": "~3.3", "guzzlehttp/guzzle": "~6.0", "justinrainbow/json-schema": "~4.1|~5.0", "seromenho/xml-validator": "~v1.0" }, "require-dev": { - "phpunit/phpunit": "~6.0" + "phpunit/phpunit": "^8.5 || ^9.0" }, "autoload": { "psr-4": { diff --git a/tests/Arachne/Tests/Context/ArachneContextTest.php b/tests/Arachne/Tests/Context/ArachneContextTest.php index fbc374f..22dcf00 100644 --- a/tests/Arachne/Tests/Context/ArachneContextTest.php +++ b/tests/Arachne/Tests/Context/ArachneContextTest.php @@ -34,7 +34,7 @@ class ArachneContextTest extends TestCase */ private $client; - public function setUp() + public function setUp(): void { $this->client = Factory::createHttpClient(); $this->context = new ArachneContext; diff --git a/tests/Arachne/Tests/Context/Initializer/ArachneInitializerTest.php b/tests/Arachne/Tests/Context/Initializer/ArachneInitializerTest.php index a5b5c93..703a536 100644 --- a/tests/Arachne/Tests/Context/Initializer/ArachneInitializerTest.php +++ b/tests/Arachne/Tests/Context/Initializer/ArachneInitializerTest.php @@ -28,7 +28,7 @@ class ArachneInitializerTest extends TestCase */ private $initializer; - public function setUp() + public function setUp(): void { $this->initializer = new ArachneInitializer( Mocks\Factory::createValidationProvider(), diff --git a/tests/Arachne/Tests/FileSystem/FileLocatorTest.php b/tests/Arachne/Tests/FileSystem/FileLocatorTest.php index 65dc165..55d395b 100644 --- a/tests/Arachne/Tests/FileSystem/FileLocatorTest.php +++ b/tests/Arachne/Tests/FileSystem/FileLocatorTest.php @@ -27,7 +27,7 @@ class FileLocatorTest extends TestCase */ private $fileLocator; - public function setUp() + public function setUp(): void { $this->fileLocator = Factory::createFileLocator(); }