Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Updates to Behat ~3.3, PHPUnit ^8.5 || ^9.0 #16

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
12 changes: 7 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@
],
"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": "~4.4"
"phpunit/phpunit": "^8.5 || ^9.0"
},
"autoload": {
"psr-0": {
"Arachne\\": "src/"
"psr-4": {
"Arachne\\": "src/Arachne/",
"Arachne\\Mocks\\": "tests/Arachne/Mocks/",
"Arachne\\Tests\\": "tests/Arachne/Tests/"
}
}
}
}
14 changes: 7 additions & 7 deletions tests/Arachne/Tests/Context/ArachneContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
*/
class ArachneContextTest extends \PHPUnit_Framework_TestCase
class ArachneContextTest extends TestCase
{
/**
* @var ArachneContext
Expand All @@ -33,7 +34,7 @@ class ArachneContextTest extends \PHPUnit_Framework_TestCase
*/
private $client;

public function setUp()
public function setUp(): void
{
$this->client = Factory::createHttpClient();
$this->context = new ArachneContext;
Expand All @@ -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();
}
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,21 @@
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 <[email protected]>
*/
class ArachneInitializerTest extends \PHPUnit_Framework_TestCase
class ArachneInitializerTest extends TestCase
{
/**
* @var ArachneInitializer
*/
private $initializer;

public function setUp()
public function setUp(): void
{
$this->initializer = new ArachneInitializer(
Mocks\Factory::createValidationProvider(),
Expand Down
17 changes: 11 additions & 6 deletions tests/Arachne/Tests/FileSystem/FileLocatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,29 @@

use Arachne\FileSystem\FileLocator;
use Arachne\Mocks\Factory;
use PHPUnit\Framework\TestCase;

/**
* Class FileLocatorTest
* @package Arachne\Tests\FileSystem
* @author Wojtek Gancarczyk <[email protected]>
*/
class FileLocatorTest extends \PHPUnit_Framework_TestCase
class FileLocatorTest extends TestCase
{
/**
* @var FileLocator
*/
private $fileLocator;

public function setUp()
public function setUp(): void
{
$this->fileLocator = Factory::createFileLocator();
}

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');
}
Expand All @@ -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');
}

Expand All @@ -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');
}

Expand All @@ -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');
}
}
3 changes: 2 additions & 1 deletion tests/Arachne/Tests/Http/Client/GuzzleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
*/
class GuzzleTest extends \PHPUnit_Framework_TestCase
class GuzzleTest extends TestCase
{
public function testDoNotFailIfResponseCodeIs404()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
namespace Arachne\Tests\ServiceContainer;

use Arachne\ServiceContainer\ArachneExtension;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;

/**
* Class ArachneExtensionTest
* @package Arachne\Tests\ServiceContainer
* @author Wojtek Gancarczyk <[email protected]>
*/
class ArachneExtensionTest extends \PHPUnit_Framework_TestCase
class ArachneExtensionTest extends TestCase
{
public function testDoNotFailIfAuthProviderNotSetUp()
{
Expand All @@ -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',
Expand Down
6 changes: 4 additions & 2 deletions tests/Arachne/Tests/Validation/Schema/JsonSchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
*/
class JsonSchemaTest extends \PHPUnit_Framework_TestCase
class JsonSchemaTest extends TestCase
{
public function testDoesNotFailOnValidSchema()
{
Expand All @@ -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'])),
Expand Down
9 changes: 4 additions & 5 deletions tests/Arachne/Tests/Validation/Schema/XmlSchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
*/
class XmlSchemaTest extends \PHPUnit_Framework_TestCase
class XmlSchemaTest extends TestCase
{
public function testDoesNotFailOnValidSchema()
{
Expand All @@ -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'])),
Expand Down