Skip to content

Commit

Permalink
Merge pull request #717 from chimeraphp/renovate/phpunit-phpunit-10.x
Browse files Browse the repository at this point in the history
Update dependency phpunit/phpunit to v10
  • Loading branch information
lcobucci authored Mar 19, 2023
2 parents a6501e1 + 796487e commit 901ff09
Show file tree
Hide file tree
Showing 10 changed files with 294 additions and 390 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
/phpcs.xml
/.phpcs.cache
/infection.log
/.phpunit.result.cache
/.phpunit.cache
/build
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.1",
"phpstan/phpstan-strict-rules": "^1.4",
"phpunit/phpunit": "^9.5"
"phpunit/phpunit": "^10.0.16"
},
"conflict": {
"lcobucci/di-builder": "7.2.0"
Expand Down
508 changes: 225 additions & 283 deletions composer.lock

Large diffs are not rendered by default.

10 changes: 4 additions & 6 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,16 @@
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
verbose="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
beStrictAboutChangesToGlobalState="true"
beStrictAboutCoversAnnotation="true"
beStrictAboutResourceUsageDuringSmallTests="true"
forceCoversAnnotation="true"
failOnRisky="true"
failOnWarning="true"
executionOrder="random"
cacheDirectory=".phpunit.cache"
requireCoverageMetadata="true"
beStrictAboutCoverageMetadata="true"
>
<coverage processUncoveredFiles="true">
<coverage>
<include>
<directory>src</directory>
</include>
Expand Down
45 changes: 22 additions & 23 deletions tests/Functional/ApplicationRegistrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace Chimera\DependencyInjection\Tests\Functional;

use Chimera\DependencyInjection as Services;
use Chimera\DependencyInjection\Tests\Functional\App\CreateThing;
use Chimera\DependencyInjection\Tests\Functional\App\CreateThingHandler;
use Chimera\DependencyInjection\Tests\Functional\App\FetchThing;
Expand Down Expand Up @@ -32,6 +33,7 @@
use Mezzio\Router\Middleware\MethodNotAllowedMiddleware;
use Mezzio\Router\Route;
use Mezzio\Router\RouteCollector;
use PHPUnit\Framework\Attributes as PHPUnit;
use Psr\Http\Server\MiddlewareInterface;
use ReflectionProperty;
use SplQueue;
Expand All @@ -41,23 +43,21 @@
use function assert;
use function iterator_to_array;

/**
* @covers \Chimera\DependencyInjection\Mapping\ExpandTags
* @covers \Chimera\DependencyInjection\Mapping\Package
* @covers \Chimera\DependencyInjection\MessageCreator\JmsSerializer\Package
* @covers \Chimera\DependencyInjection\Routing\ErrorHandling\Package
* @covers \Chimera\DependencyInjection\Routing\ErrorHandling\RegisterDefaultComponents
* @covers \Chimera\DependencyInjection\Routing\Mezzio\Package
* @covers \Chimera\DependencyInjection\Routing\Mezzio\RegisterServices
* @covers \Chimera\DependencyInjection\ServiceBus\Tactician\Package
* @covers \Chimera\DependencyInjection\ServiceBus\Tactician\RegisterServices
* @covers \Chimera\DependencyInjection\RegisterApplication
* @covers \Chimera\DependencyInjection\RegisterDefaultComponents
* @covers \Chimera\DependencyInjection\ValidateApplicationComponents
*/
#[PHPUnit\CoversClass(Services\Mapping\ExpandTags::class)]
#[PHPUnit\CoversClass(Services\Mapping\Package::class)]
#[PHPUnit\CoversClass(Services\MessageCreator\JmsSerializer\Package::class)]
#[PHPUnit\CoversClass(Services\Routing\ErrorHandling\Package::class)]
#[PHPUnit\CoversClass(Services\Routing\ErrorHandling\RegisterDefaultComponents::class)]
#[PHPUnit\CoversClass(Services\Routing\Mezzio\Package::class)]
#[PHPUnit\CoversClass(Services\Routing\Mezzio\RegisterServices::class)]
#[PHPUnit\CoversClass(Services\ServiceBus\Tactician\Package::class)]
#[PHPUnit\CoversClass(Services\ServiceBus\Tactician\RegisterServices::class)]
#[PHPUnit\CoversClass(Services\RegisterApplication::class)]
#[PHPUnit\CoversClass(Services\RegisterDefaultComponents::class)]
#[PHPUnit\CoversClass(Services\ValidateApplicationComponents::class)]
final class ApplicationRegistrationTest extends ApplicationTestCase
{
/** @test */
#[PHPUnit\Test]
public function applicationMustBeCorrectlyRegistered(): void
{
$container = $this->createContainer();
Expand All @@ -66,7 +66,7 @@ public function applicationMustBeCorrectlyRegistered(): void
self::assertInstanceOf(Application::class, $container->get('sample-app.http'));
}

/** @test */
#[PHPUnit\Test]
public function routesMustBeProperlyDefined(): void
{
$container = $this->createContainer();
Expand Down Expand Up @@ -106,7 +106,7 @@ private static function assertRouteRegistered(
self::assertSame($expectedName, $match[0]->getName());
}

/** @test */
#[PHPUnit\Test]
public function httpMiddlewaresMustBeProperlyDefined(): void
{
$container = $this->createContainer();
Expand Down Expand Up @@ -135,7 +135,6 @@ public function httpMiddlewaresMustBeProperlyDefined(): void
}

$property = new ReflectionProperty(MiddlewarePipe::class, 'pipeline');
$property->setAccessible(true);

$result = $container->get('sample-app.http.middleware_pipeline');
assert($result instanceof MiddlewarePipe);
Expand All @@ -148,7 +147,7 @@ public function httpMiddlewaresMustBeProperlyDefined(): void
self::assertSame(iterator_to_array($expectedPipeline), iterator_to_array($resultingPipeline));
}

/** @test */
#[PHPUnit\Test]
public function serviceBusesMustExist(): void
{
$container = $this->createContainer();
Expand All @@ -157,7 +156,7 @@ public function serviceBusesMustExist(): void
self::assertInstanceOf(ServiceBus::class, $container->get('sample-app.query_bus'));
}

/** @test */
#[PHPUnit\Test]
public function commandBusHandlersMustBeProperlyDefined(): void
{
$container = $this->createContainer();
Expand All @@ -169,7 +168,7 @@ public function commandBusHandlersMustBeProperlyDefined(): void
self::assertInstanceOf(RemoveThingHandler::class, $locator->getHandlerForCommand(RemoveThing::class));
}

/** @test */
#[PHPUnit\Test]
public function commandBusMiddlewareMustBeProperlyDefined(): void
{
$container = $this->createContainer();
Expand All @@ -187,7 +186,7 @@ public function commandBusMiddlewareMustBeProperlyDefined(): void
self::assertEquals(new CommandBus($middlewareList), $bus); // @phpstan-ignore-line
}

/** @test */
#[PHPUnit\Test]
public function queryBusHandlersMustBeProperlyDefined(): void
{
$container = $this->createContainer();
Expand All @@ -199,7 +198,7 @@ public function queryBusHandlersMustBeProperlyDefined(): void
self::assertInstanceOf(ListThingsHandler::class, $locator->getHandlerForCommand(ListThings::class));
}

/** @test */
#[PHPUnit\Test]
public function queryBusMiddlewareMustBeProperlyDefined(): void
{
$container = $this->createContainer();
Expand Down
36 changes: 17 additions & 19 deletions tests/Functional/ApplicationRunTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@

namespace Chimera\DependencyInjection\Tests\Functional;

use Chimera\DependencyInjection as Services;
use Chimera\Routing\Application;
use Laminas\Diactoros\ServerRequestFactory;
use Laminas\Diactoros\StreamFactory;
use PHPUnit\Framework\Attributes as PHPUnit;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Ramsey\Uuid\Uuid;
Expand All @@ -16,31 +18,27 @@

use const JSON_THROW_ON_ERROR;

/**
* @covers \Chimera\DependencyInjection\Mapping\ExpandTags
* @covers \Chimera\DependencyInjection\Mapping\Package
* @covers \Chimera\DependencyInjection\MessageCreator\JmsSerializer\Package
* @covers \Chimera\DependencyInjection\Routing\ErrorHandling\Package
* @covers \Chimera\DependencyInjection\Routing\ErrorHandling\RegisterDefaultComponents
* @covers \Chimera\DependencyInjection\Routing\Mezzio\Package
* @covers \Chimera\DependencyInjection\Routing\Mezzio\RegisterServices
* @covers \Chimera\DependencyInjection\ServiceBus\Tactician\Package
* @covers \Chimera\DependencyInjection\ServiceBus\Tactician\RegisterServices
* @covers \Chimera\DependencyInjection\RegisterApplication
* @covers \Chimera\DependencyInjection\RegisterDefaultComponents
* @covers \Chimera\DependencyInjection\ValidateApplicationComponents
*/
#[PHPUnit\CoversClass(Services\Mapping\ExpandTags::class)]
#[PHPUnit\CoversClass(Services\Mapping\Package::class)]
#[PHPUnit\CoversClass(Services\MessageCreator\JmsSerializer\Package::class)]
#[PHPUnit\CoversClass(Services\Routing\ErrorHandling\Package::class)]
#[PHPUnit\CoversClass(Services\Routing\ErrorHandling\RegisterDefaultComponents::class)]
#[PHPUnit\CoversClass(Services\Routing\Mezzio\Package::class)]
#[PHPUnit\CoversClass(Services\Routing\Mezzio\RegisterServices::class)]
#[PHPUnit\CoversClass(Services\ServiceBus\Tactician\Package::class)]
#[PHPUnit\CoversClass(Services\ServiceBus\Tactician\RegisterServices::class)]
#[PHPUnit\CoversClass(Services\RegisterApplication::class)]
#[PHPUnit\CoversClass(Services\RegisterDefaultComponents::class)]
#[PHPUnit\CoversClass(Services\ValidateApplicationComponents::class)]
final class ApplicationRunTest extends ApplicationTestCase
{
private const UUID_PATTERN = '[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[1-5]{1}[0-9A-Fa-f]{3}-'
. '[ABab89]{1}[0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}';

private const ITEM_ENDPOINT = '/^\/things\/' . self::UUID_PATTERN . '$/';

/**
* @test
* @dataProvider possibleRequests
*/
#[PHPUnit\Test]
#[PHPUnit\DataProvider('possibleRequests')]
public function correctResponseShouldBeProvided(ServerRequestInterface $request, callable $verifyResponse): void
{
$container = $this->createContainer();
Expand All @@ -52,7 +50,7 @@ public function correctResponseShouldBeProvided(ServerRequestInterface $request,
}

/** @return iterable<string, array{0: ServerRequestInterface, 1: callable}> */
public function possibleRequests(): iterable
public static function possibleRequests(): iterable
{
$factory = new ServerRequestFactory();
$streamFactory = new StreamFactory();
Expand Down
7 changes: 3 additions & 4 deletions tests/Functional/ApplicationTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Mezzio\Router\Middleware\DispatchMiddleware;
use Mezzio\Router\Middleware\ImplicitOptionsMiddleware;
use Mezzio\Router\Middleware\MethodNotAllowedMiddleware;
use PHPUnit\Framework\Attributes as PHPUnit;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
Expand Down Expand Up @@ -59,10 +60,8 @@ abstract class ApplicationTestCase extends TestCase
'sample-app.query_bus.decorated_bus.handler.locator',
];

/**
* @beforeClass
* @afterClass
*/
#[PHPUnit\BeforeClass]
#[PHPUnit\AfterClass]
final public static function cleanUpContainer(): void
{
exec('rm -rf ' . __DIR__ . '/App/dump');
Expand Down
39 changes: 13 additions & 26 deletions tests/Unit/RegisterApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,26 @@

use Chimera\DependencyInjection as Services;
use Chimera\DependencyInjection\RegisterApplication;
use PHPUnit\Framework\Attributes as PHPUnit;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\Compiler\PassConfig;

use function dirname;
use function iterator_to_array;

/**
* @covers \Chimera\DependencyInjection\Mapping\Package
* @covers \Chimera\DependencyInjection\MessageCreator\JmsSerializer\Package
* @covers \Chimera\DependencyInjection\Routing\ErrorHandling\Package
* @covers \Chimera\DependencyInjection\Routing\ErrorHandling\RegisterDefaultComponents
* @covers \Chimera\DependencyInjection\Routing\Mezzio\Package
* @covers \Chimera\DependencyInjection\Routing\Mezzio\RegisterServices
* @covers \Chimera\DependencyInjection\ServiceBus\Tactician\Package
* @covers \Chimera\DependencyInjection\ServiceBus\Tactician\RegisterServices
* @covers \Chimera\DependencyInjection\ValidateApplicationComponents
* @coversDefaultClass \Chimera\DependencyInjection\RegisterApplication
*/
#[PHPUnit\CoversClass(Services\Mapping\Package::class)]
#[PHPUnit\CoversClass(Services\MessageCreator\JmsSerializer\Package::class)]
#[PHPUnit\CoversClass(Services\Routing\ErrorHandling\Package::class)]
#[PHPUnit\CoversClass(Services\Routing\ErrorHandling\RegisterDefaultComponents::class)]
#[PHPUnit\CoversClass(Services\Routing\Mezzio\Package::class)]
#[PHPUnit\CoversClass(Services\Routing\Mezzio\RegisterServices::class)]
#[PHPUnit\CoversClass(Services\ServiceBus\Tactician\Package::class)]
#[PHPUnit\CoversClass(Services\ServiceBus\Tactician\RegisterServices::class)]
#[PHPUnit\CoversClass(Services\ValidateApplicationComponents::class)]
#[PHPUnit\CoversClass(RegisterApplication::class)]
final class RegisterApplicationTest extends TestCase
{
/**
* @test
*
* @covers ::__construct()
* @covers ::getFiles()
* @covers ::filterPackages()
*/
#[PHPUnit\Test]
public function getFilesShouldYieldFilesFromAllRelatedAndInstalledPackages(): void
{
$package = new RegisterApplication('testing');
Expand All @@ -46,13 +39,7 @@ public function getFilesShouldYieldFilesFromAllRelatedAndInstalledPackages(): vo
self::assertContains(dirname(__DIR__, 2) . '/config/serialization-jms.xml', $files);
}

/**
* @test
*
* @covers ::__construct()
* @covers ::getCompilerPasses()
* @covers ::filterPackages()
*/
#[PHPUnit\Test]
public function getCompilerPassesShouldYieldPassesFromAllRelatedAndInstalledPackages(): void
{
$package = new RegisterApplication('testing');
Expand Down
11 changes: 3 additions & 8 deletions tests/Unit/Routing/Mezzio/RegisterServicesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,15 @@
use Chimera\DependencyInjection\Routing\Mezzio\RegisterServices;
use Chimera\DependencyInjection\Tags;
use InvalidArgumentException;
use PHPUnit\Framework\Attributes as PHPUnit;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;

/** @coversDefaultClass \Chimera\DependencyInjection\Routing\Mezzio\RegisterServices */
#[PHPUnit\CoversClass(RegisterServices::class)]
final class RegisterServicesTest extends TestCase
{
/**
* @test
*
* @covers ::__construct
* @covers ::process
* @covers ::extractRoutes
*/
#[PHPUnit\Test]
public function exceptionShouldBeRaisedWhenTryingToRegisterDuplicatedRoutes(): void
{
$service1 = new Definition();
Expand Down
24 changes: 5 additions & 19 deletions tests/Unit/ValidateApplicationComponentsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,16 @@

use Chimera\DependencyInjection\ValidateApplicationComponents;
use Chimera\Routing\Application;
use PHPUnit\Framework\Attributes as PHPUnit;
use PHPUnit\Framework\TestCase;
use RuntimeException;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;

/** @coversDefaultClass \Chimera\DependencyInjection\ValidateApplicationComponents */
#[PHPUnit\CoversClass(ValidateApplicationComponents::class)]
final class ValidateApplicationComponentsTest extends TestCase
{
/**
* @test
*
* @covers ::__construct
* @covers ::process
*/
#[PHPUnit\Test]
public function exceptionShouldBeRaisedWhenDefinitionIsNotPublic(): void
{
$builder = new ContainerBuilder();
Expand All @@ -32,12 +28,7 @@ public function exceptionShouldBeRaisedWhenDefinitionIsNotPublic(): void
$pass->process($builder);
}

/**
* @test
*
* @covers ::__construct
* @covers ::process
*/
#[PHPUnit\Test]
public function exceptionShouldBeRaisedWhenLegacyAliasIsNotPublic(): void
{
$builder = new ContainerBuilder();
Expand All @@ -51,12 +42,7 @@ public function exceptionShouldBeRaisedWhenLegacyAliasIsNotPublic(): void
$pass->process($builder);
}

/**
* @test
*
* @covers ::__construct
* @covers ::process
*/
#[PHPUnit\Test]
public function noExceptionShouldBeRaisedWhenExpectedServicesArePublic(): void
{
$builder = new ContainerBuilder();
Expand Down

0 comments on commit 901ff09

Please sign in to comment.