From 9ce0d31e43d74b2dac7c9cbc67f62bd2c6daee35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Poirier=20Th=C3=A9or=C3=AAt?= Date: Sun, 11 Aug 2024 18:01:48 -0400 Subject: [PATCH] [Tester\TesterBundle] Refactor PHPUnit extension and improve documentation --- .../KernelShutdownExtension.php | 2 +- .../SetUpAutowire/AutowireClient.php | 1 + .../SetUpAutowire/AutowireParameter.php | 1 + .../SetUpAutowire/AutowireService.php | 1 + .../SetUpAutowire/AutowiredInterface.php | 7 - packages/tester-bundle/README.md | 125 ++++++++++- packages/tester-bundle/extension.neon | 6 +- .../AutowireReadWritePropertiesExtension.php | 2 +- .../CarbonResetExtension.php | 2 +- .../SetUpAutowire/AutowireInterface.php | 2 +- .../Extension/SetUpAutowire/AutowireMock.php | 2 +- .../SetUpAutowire/AutowireMockProperty.php | 2 +- .../AutowiredCompletionAwareInterface.php | 2 +- .../SetUpAutowire/AutowiredInterface.php | 7 + .../SetUpAutowire/SetUpAutowireExtension.php | 2 +- packages/tester/README.md | 199 ++++++++++++++++++ packages/tester/README.rst | 148 ------------- packages/tester/phpunit.xml.dist | 2 +- phpunit.xml.dist | 6 +- tests/Command/NullCommandTest.php | 2 +- .../GenerateDocumentationCommandTest.php | 2 +- .../Api/TestDocumentControllerTest.php | 2 +- tests/Controller/OpenApiControllerTest.php | 2 +- tests/Controller/PingActionTest.php | 2 +- .../Security/TwoFactorAuthorizationTest.php | 2 +- .../UserRequestInterceptedSubscriberTest.php | 2 +- .../PostExecutionQueueCronJobListenerTest.php | 2 +- tests/Entity/UserTest.php | 2 +- .../PropertyReferenceEncodingListenerTest.php | 2 +- .../ResponseApiExceptionListenerTest.php | 2 +- ...bjectDeleteBatchEventEventListenerTest.php | 2 +- tests/SonataImportBundle/ImporterTest.php | 2 +- .../Action/RetryFailedMessageActionTest.php | 2 +- .../User/Action/UnlockUserActionTest.php | 2 +- .../SetUpAutowireExtensionTest.php | 6 +- .../ValueIsNotUsedValidatorTest.php | 2 +- 36 files changed, 367 insertions(+), 190 deletions(-) rename packages/tester-bundle/PHPUnit/Extension/{ => KernelShutdown}/KernelShutdownExtension.php (96%) delete mode 100644 packages/tester-bundle/PHPUnit/Extension/SetUpAutowire/AutowiredInterface.php rename packages/{tester-bundle => tester}/PHPStan/Rules/Properties/AutowireReadWritePropertiesExtension.php (94%) rename packages/tester/PHPUnit/Extension/{ => CarbonReset}/CarbonResetExtension.php (94%) rename packages/{tester-bundle => tester}/PHPUnit/Extension/SetUpAutowire/AutowireInterface.php (75%) rename packages/{tester-bundle => tester}/PHPUnit/Extension/SetUpAutowire/AutowireMock.php (95%) rename packages/{tester-bundle => tester}/PHPUnit/Extension/SetUpAutowire/AutowireMockProperty.php (93%) rename packages/{tester-bundle => tester}/PHPUnit/Extension/SetUpAutowire/AutowiredCompletionAwareInterface.php (64%) create mode 100644 packages/tester/PHPUnit/Extension/SetUpAutowire/AutowiredInterface.php rename packages/{tester-bundle => tester}/PHPUnit/Extension/SetUpAutowire/SetUpAutowireExtension.php (98%) create mode 100644 packages/tester/README.md delete mode 100644 packages/tester/README.rst diff --git a/packages/tester-bundle/PHPUnit/Extension/KernelShutdownExtension.php b/packages/tester-bundle/PHPUnit/Extension/KernelShutdown/KernelShutdownExtension.php similarity index 96% rename from packages/tester-bundle/PHPUnit/Extension/KernelShutdownExtension.php rename to packages/tester-bundle/PHPUnit/Extension/KernelShutdown/KernelShutdownExtension.php index 564e81fa0..d920d4e8e 100644 --- a/packages/tester-bundle/PHPUnit/Extension/KernelShutdownExtension.php +++ b/packages/tester-bundle/PHPUnit/Extension/KernelShutdown/KernelShutdownExtension.php @@ -1,6 +1,6 @@ get('my_service')->doSomething(); + } +} +``` + +Since symfony shutdown the kernel in the tearDown method, this will boot a new kernel cause a kernel to be up. + +Adding the KernelShutdownExtension will make sure the kernel is shutdown after the test. + +```xml + + + + + + +``` + +### SetUpAutowire addon + +The [draw/tester](https://github.com/mpoiriert/tester) component provide a way to autowire property in your test. + +This bundle provide some custom Autowire attribute that can use in the context of a Symfony test cases. + +Make sure to register is in your phpunit configuration file. as explained in the `draw/tester` documentation. + +```xml + + + + + +``` + +Here is an example of attribute you can use in your test case: + +```php +namespace App\Tests; + +use App\AServiceInterface; +use App\MyService; +use Draw\Bundle\TesterBundle\Messenger\TransportTester; +use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowireParameter; +use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowireService; +use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowireTransportTester; +use Draw\Component\Tester\PHPUnit\Extension\SetUpAutowire\AutowiredInterface; +use Draw\Component\Tester\PHPUnit\Extension\SetUpAutowire\AutowireMock; +use PHPUnit\Framework\MockObject\MockObject; +use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; + +class MyTest extends KernelTestCase implements AutowiredInterface +{ + // From d + #[AutowireMock] + private AServiceInterface&MockObject $aService + + // Will hook MyService from the test container. Your test need to extend KernelTestCase. + // + // The AutowireMockProperty will replace the aService property of $myService. + // By defaults, it will use the same property name in the current test case but you can specify a different one using the second parameter. + #[AutowireService] + #[AutowireMockProperty('aService')] + private MyService $myService; + + // Will hook the parameter from the container using ParameterBagInterface::resolveValue + #[AutowireParameter('%my_parameter%')] + private string $parameter; + + // Will hook the transport tester from the container. + #[AutowireTransportTester('async')] + private TransportTester $transportTester; +} +``` + +If you extend from a `WebTestCase` you can also use the `AutowireClient` attribute to get a client. + +By using the `AutowireClient` in conjunction with the `AutowireService` you are use that the client is +created before the other service preventing the exception: + +`Booting the kernel before calling "Symfony\Bundle\FrameworkBundle\Test\WebTestCase::createClient" is not supported, the kernel should only be booted once` + +```php +namespace App\Tests; + +use App\MyService;use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowireClient;use Draw\Component\Tester\PHPUnit\Extension\SetUpAutowire\AutowiredInterface;use Symfony\Bundle\FrameworkBundle\KernelBrowser;use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; + +class MyTest extends WebTestCase implements AutowiredInterface +{ + #[AutowireClient] + private KernelBrowser $client; + + public function testSomething(): void + { + $this->client->request('GET', '/my-route'); + + static::assertResponseIsSuccessful(); + } +} +``` + +This is the same client as the one you get from the `WebTestCase`, you can use it the same way. + +Note that the `AutowireClient` attribute have an `options` and `server` parameters like you would do when calling the `createClient` method. diff --git a/packages/tester-bundle/extension.neon b/packages/tester-bundle/extension.neon index 74a17fffe..85ac976cd 100644 --- a/packages/tester-bundle/extension.neon +++ b/packages/tester-bundle/extension.neon @@ -1,7 +1,7 @@ services: - draw.tester_bundle.autowire_client_read_write_properties_extension: - class: Draw\Bundle\TesterBundle\PHPStan\Rules\Properties\AutowireReadWritePropertiesExtension + draw.component.tester.autowire_client_read_write_properties_extension: + class: Draw\Component\Tester\PHPStan\Rules\Properties\AutowireReadWritePropertiesExtension arguments: - - 'Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowireInterface' + - 'Draw\Component\Tester\PHPUnit\Extension\SetUpAutowire\AutowireInterface' tags: - phpstan.properties.readWriteExtension diff --git a/packages/tester-bundle/PHPStan/Rules/Properties/AutowireReadWritePropertiesExtension.php b/packages/tester/PHPStan/Rules/Properties/AutowireReadWritePropertiesExtension.php similarity index 94% rename from packages/tester-bundle/PHPStan/Rules/Properties/AutowireReadWritePropertiesExtension.php rename to packages/tester/PHPStan/Rules/Properties/AutowireReadWritePropertiesExtension.php index 054e57893..46ef9f595 100644 --- a/packages/tester-bundle/PHPStan/Rules/Properties/AutowireReadWritePropertiesExtension.php +++ b/packages/tester/PHPStan/Rules/Properties/AutowireReadWritePropertiesExtension.php @@ -1,6 +1,6 @@ 'value1', + 'key2' => (object)['toto' => 'value'] + ]; + + $dateTester = new DataTester($data); + $dateTester + ->assertIsArray('array') + ->assertCount(2) + ->path('[key1]')->assertSame('value1'); + + $dateTester->path('[key2].toto')->assertSame('value'); + } +} +``` + +## PHPUnit Extension + +This package also provide a PHPUnit extension to make it easier to write test. + +### CarbonReset + +If you are using Carbon in your project, you might want to reset the Carbon class between each test to make sure you have a consistent state. + +Register the extension in your phpunit configuration file. + +```xml + + + + + +``` + +This will reset your carbon class between each test and test suite like it would in `TestCass::tearDown` and `TestCass::tearDownAfterClass`. + +### SetUpAutowire + +A bit like the Service auto wiring would work via a service container, this extension allow you to autowire properties +base on attribute that implement `AutowireInterface`. + +Make sure to register is in your phpunit configuration file. + +```xml + + + + + +``` + +Once this is done, your test need to implement the `AutowiredInterface` interface so the extension will hook it. + +```php +namespace App\Tests; + +use Draw\Component\Tester\PHPUnit\Extension\SetUpAutowire\AutowiredInterface;use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; + +class MyTest extends KernelTestCase implements AutowiredInterface +{ +} +``` + +Having the extension by itself doesn't do much, you need to put some attribute on the property you need to autowire. + +> Note that the autowired system doesn't work on static properties. + +```php +namespace App\Tests; + +use App\MyInterface; +use App\MyObject; +use App\MySecondObject; +use Draw\Component\Tester\PHPUnit\Extension\SetUpAutowire\AutowiredInterface; +use Draw\Component\Tester\PHPUnit\Extension\SetUpAutowire\AutowireMock; +use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\TestCase; + +class MyTest extends TestCase implements AutowiredInterface +{ + // Will create a mock object of MyInterface and assigned it to property. + // This can be used in conjunction with the AutowireMockProperty (see below). + #[AutowireMock] + private MyInterface&MockObject $aService + + // The AutowireMockProperty will replace the aService property of $myObject. + #[AutowireMockProperty('aService')] + private MyObject $myObject; + + // By defaults, it will use the same property name in the current test case, but you can specify a different one using the second parameter. + #[AutowireMockProperty('aService', 'anotherProperty')] + private MySecondObject $mySecondObject; + + public function setUp(): void + { + $this->myObject = new MyObject(); + $this->mySecondObject = new MySecondObject(); + } +} +``` + +> This might seem a bit useless, but in a framework context using service it will more sense. +> The `AutowireService` from [draw/tester-bundle](https://github.com/mpoiriert/tester-bundle) is a good example of this in Symfony. + +Since the auto wiring is done in the `setUp` hook of phpunit extension you cannot use them in the setup method of you test. +If you need to access those property in your `setUp` method, you can use the `AutowiredCompletionAwareInterface` instead. + +```php +namespace App\Tests; + +use App\MyService;use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowireService;use Draw\Component\Tester\PHPUnit\Extension\SetUpAutowire\AutowiredCompletionAwareInterface;use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; + +class MyTest extends KernelTestCase implements AutowiredCompletionAwareInterface +{ + #[AutowireMock] + private MyInterface&MockObject $aService + + public function postAutowire(): void + { + $this->aService + ->expects(static::any()) + ->method('someMethod') + ->willReturn('someValue'); + } +} +``` + +#### Creating you own Autowire attribute + +You can create your own attribute to autowire your own property. + +You just need to create an attribute that implement the `AutowireInterface` interface. + +```php +namespace App\Test\PHPUnit\SetUpAutowire; + +use Draw\Component\Tester\PHPUnit\Extension\SetUpAutowire\AutowireInterface;use PHPUnit\Framework\TestCase; + +#[\Attribute(\Attribute::TARGET_PROPERTY)] +class AutowireRandomInt implements AutowireInterface +{ + // This is the priority of the autowire. The higher the number the sooner it will be called. + // This can be important if you need to autowire a property before another one. + public static function getPriority(): int + { + return 0; + } + + public function __construct( + private int $min = \PHP_INT_MIN, + private int $max = \PHP_INT_MAX + ) {} + + public function autowire(TestCase $testCase, \ReflectionProperty $reflectionProperty): void + { + $reflectionProperty->setValue( + $testCase, + random_int($this->min, $this->max) + ); + } +} +``` + +Now you can simply use it in your test case: + +```php + +namespace App\Tests; + +use App\Test\PHPUnit\SetUpAutowire\AutowireRandomInt; + +class MyTest extends KernelTestCase +{ + #[AutowireRandomInt(1, 10)] + private int $randomInt; +} +``` diff --git a/packages/tester/README.rst b/packages/tester/README.rst deleted file mode 100644 index cbcabbf49..000000000 --- a/packages/tester/README.rst +++ /dev/null @@ -1,148 +0,0 @@ -Php Data Tester -=============== - -**Need to be updated** - -This library is a wrapper around **PHPUnit Assert** class to be able to use a fluent interface on the data you want to test. - -The library can be install via `Composer/Packagist `_. - -Here is a quick example of how to use it in a **PHPUnit TestCase**: - -.. code-block:: php - - 'value1', - 'key2' => (object)['toto' => 'value'] - ]; - - $tester = new Tester($data); - $tester->assertInternalType('array') - ->assertCount(2) - ->path('[key1]')->assertSame('value1'); - $tester->path('[key2].toto')->assertSame('value'); - } - -There is a lot more features available, just `Read the Docs `_! - -Php Http Tester -=============== - -This library is meant to be a testing framework for http call. It is framework agnostic. -By default it does a curl call to the specified url but you can use/create a adapter for the framework you are using. - -The library can be install via `Composer/Packagist `_. - -In that example we are trying to have a browser flow so the usage of phpunit annotation **@depends** -and **@test** make it more readable. - -Here is a quick example of how to use it in a **PHPUnit TestCase**: - -.. code-block:: php - - get('http://your.domain.com/api/me') - ->assertStatus(403); - } - - /** - * @test - * @depends notAuthorizeProfileAccess - */ - public function login() - { - $testResponse = static::$client->post( - 'http://your.domain.com/api/tokens', - json_encode([ - 'username' => 'my-username', - 'password' => 'my-password' - ]) - ); - - $content = $testResponse - ->assertSuccessful() - ->assertCookie('session') // We are not debating the usage of cookie here ;) - ->getResponseBodyContents(); - - // Continue with the test of you content - $this->assertJson($content); - } - - /** - * @test - * @depends login - */ - public function getMyProfile() - { - // The same client is during all test. Cookies are sent automatically between request - $testResponse = static::$client->get('http://your.domain.com/api/me') - - $content = $testResponse - ->assertSuccessful() - ->getResponseBodyContents(); - - // Continue with the test of you content - $this->assertJson($content); - } - } - -If you need to use it in another context and can still relay on PHPUnit Assertion you can simply create your the client -manually and use it: - -.. code-block:: php - - post( - 'http://your.domain.com/api/tokens', - json_encode([ - 'username' => 'my-username', - 'password' => 'my-password' - ]) - ); - -By default the client will use the **Draw\HttpTester\CurlRequestExecutioner** but you can make your own by implementing -the **Draw\HttpTester\RequestExecutionerInterface**. - -## Currently Supported Request Executioner - -=========== ========================================================== ================ -Executioner Class Package -=========== ========================================================== ================ -Curl Draw\HttpTester\CurlRequestExecutioner draw/http-tester -Laravel 4.2 Draw\HttpTester\Bridge\Laravel4\Laravel4RequestExecutioner draw/http-tester - - - -** Not available yet ** -There is a lot more features available, just `Read the Docs `_! \ No newline at end of file diff --git a/packages/tester/phpunit.xml.dist b/packages/tester/phpunit.xml.dist index c23e36d05..8f9f9f262 100644 --- a/packages/tester/phpunit.xml.dist +++ b/packages/tester/phpunit.xml.dist @@ -1,6 +1,6 @@ + xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"> ./Tests diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 8f722e060..eae99d8ec 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -42,8 +42,8 @@ - - - + + + diff --git a/tests/Command/NullCommandTest.php b/tests/Command/NullCommandTest.php index 4f19869c2..5588e6654 100644 --- a/tests/Command/NullCommandTest.php +++ b/tests/Command/NullCommandTest.php @@ -4,10 +4,10 @@ use App\Command\NullCommand; use App\Tests\TestCase; -use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowiredInterface; use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowireService; use Draw\Component\Tester\Application\CommandDataTester; use Draw\Component\Tester\Application\CommandTestTrait; +use Draw\Component\Tester\PHPUnit\Extension\SetUpAutowire\AutowiredInterface; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputOption; diff --git a/tests/Console/Command/GenerateDocumentationCommandTest.php b/tests/Console/Command/GenerateDocumentationCommandTest.php index f01d73b60..4dbc15bdb 100644 --- a/tests/Console/Command/GenerateDocumentationCommandTest.php +++ b/tests/Console/Command/GenerateDocumentationCommandTest.php @@ -4,10 +4,10 @@ use App\Tests\FilteredCommandTestTrait; use App\Tests\TestCase; -use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowiredInterface; use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowireService; use Draw\Component\Console\Command\GenerateDocumentationCommand; use Draw\Component\Tester\Application\CommandDataTester; +use Draw\Component\Tester\PHPUnit\Extension\SetUpAutowire\AutowiredInterface; use PHPUnit\Framework\Attributes\CoversClass; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; diff --git a/tests/Controller/Api/TestDocumentControllerTest.php b/tests/Controller/Api/TestDocumentControllerTest.php index 3b6a22180..48f04374d 100644 --- a/tests/Controller/Api/TestDocumentControllerTest.php +++ b/tests/Controller/Api/TestDocumentControllerTest.php @@ -5,8 +5,8 @@ use App\Message\NewTestDocumentMessage; use Draw\Bundle\TesterBundle\Messenger\MessengerTesterTrait; use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowireClient; -use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowiredInterface; use Draw\Bundle\TesterBundle\WebTestCase; +use Draw\Component\Tester\PHPUnit\Extension\SetUpAutowire\AutowiredInterface; use Symfony\Bundle\FrameworkBundle\KernelBrowser; class TestDocumentControllerTest extends WebTestCase implements AutowiredInterface diff --git a/tests/Controller/OpenApiControllerTest.php b/tests/Controller/OpenApiControllerTest.php index 872c7cf06..87eeadea0 100644 --- a/tests/Controller/OpenApiControllerTest.php +++ b/tests/Controller/OpenApiControllerTest.php @@ -3,8 +3,8 @@ namespace App\Tests\Controller; use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowireClient; -use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowiredInterface; use Draw\Bundle\TesterBundle\WebTestCase; +use Draw\Component\Tester\PHPUnit\Extension\SetUpAutowire\AutowiredInterface; use Symfony\Bundle\FrameworkBundle\KernelBrowser; class OpenApiControllerTest extends WebTestCase implements AutowiredInterface diff --git a/tests/Controller/PingActionTest.php b/tests/Controller/PingActionTest.php index d4be7a096..da6dcfe04 100644 --- a/tests/Controller/PingActionTest.php +++ b/tests/Controller/PingActionTest.php @@ -3,8 +3,8 @@ namespace App\Tests\Controller; use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowireClient; -use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowiredInterface; use Draw\Bundle\TesterBundle\WebTestCase; +use Draw\Component\Tester\PHPUnit\Extension\SetUpAutowire\AutowiredInterface; use Symfony\Bundle\FrameworkBundle\KernelBrowser; use Symfony\Component\HttpFoundation\Response; diff --git a/tests/Controller/Security/TwoFactorAuthorizationTest.php b/tests/Controller/Security/TwoFactorAuthorizationTest.php index 485f38ffa..e8269bc6f 100644 --- a/tests/Controller/Security/TwoFactorAuthorizationTest.php +++ b/tests/Controller/Security/TwoFactorAuthorizationTest.php @@ -5,9 +5,9 @@ use App\Entity\User; use Doctrine\ORM\EntityManagerInterface; use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowireClient; -use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowiredInterface; use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowireService; use Draw\Bundle\TesterBundle\WebTestCase; +use Draw\Component\Tester\PHPUnit\Extension\SetUpAutowire\AutowiredInterface; use PHPUnit\Framework\Attributes\AfterClass; use PHPUnit\Framework\Attributes\BeforeClass; use PHPUnit\Framework\Attributes\Depends; diff --git a/tests/Controller/Security/UserRequestInterceptedSubscriberTest.php b/tests/Controller/Security/UserRequestInterceptedSubscriberTest.php index 601687fae..a8e9e1eda 100644 --- a/tests/Controller/Security/UserRequestInterceptedSubscriberTest.php +++ b/tests/Controller/Security/UserRequestInterceptedSubscriberTest.php @@ -4,8 +4,8 @@ use App\Tests\AuthenticatorTestTrait; use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowireClient; -use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowiredInterface; use Draw\Bundle\TesterBundle\WebTestCase; +use Draw\Component\Tester\PHPUnit\Extension\SetUpAutowire\AutowiredInterface; use Symfony\Bundle\FrameworkBundle\KernelBrowser; use Symfony\Component\HttpFoundation\Response; diff --git a/tests/CronJob/EventListener/PostExecutionQueueCronJobListenerTest.php b/tests/CronJob/EventListener/PostExecutionQueueCronJobListenerTest.php index f3d534e5e..f94a1dc8e 100644 --- a/tests/CronJob/EventListener/PostExecutionQueueCronJobListenerTest.php +++ b/tests/CronJob/EventListener/PostExecutionQueueCronJobListenerTest.php @@ -4,11 +4,11 @@ use App\Command\NullCommand; use Draw\Bundle\TesterBundle\Messenger\TransportTester; -use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowiredCompletionAwareInterface; use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowireService; use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowireTransportTester; use Draw\Component\Core\FilterExpression\Expression\Expression; use Draw\Component\CronJob\Message\ExecuteCronJobMessage; +use Draw\Component\Tester\PHPUnit\Extension\SetUpAutowire\AutowiredCompletionAwareInterface; use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Component\Console\Command\Command; diff --git a/tests/Entity/UserTest.php b/tests/Entity/UserTest.php index f1b2ee91f..eaf54a339 100644 --- a/tests/Entity/UserTest.php +++ b/tests/Entity/UserTest.php @@ -6,13 +6,13 @@ use App\Tests\TestCase; use Doctrine\ORM\EntityManagerInterface; use Draw\Bundle\TesterBundle\Messenger\TransportTester; -use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowiredInterface; use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowireService; use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowireTransportTester; use Draw\Bundle\UserBundle\Entity\UserLock; use Draw\Bundle\UserBundle\Message\NewUserLockMessage; use Draw\Bundle\UserBundle\Message\UserLockDelayedActivationMessage; use Draw\Component\Messenger\Searchable\Stamp\SearchableTagStamp; +use Draw\Component\Tester\PHPUnit\Extension\SetUpAutowire\AutowiredInterface; use PHPUnit\Framework\Attributes\After; use Symfony\Component\Messenger\MessageBusInterface; use Symfony\Component\Messenger\Stamp\ReceivedStamp; diff --git a/tests/Messenger/DoctrineEnvelopeEntityReference/EventListener/PropertyReferenceEncodingListenerTest.php b/tests/Messenger/DoctrineEnvelopeEntityReference/EventListener/PropertyReferenceEncodingListenerTest.php index a0824e980..1931c9600 100644 --- a/tests/Messenger/DoctrineEnvelopeEntityReference/EventListener/PropertyReferenceEncodingListenerTest.php +++ b/tests/Messenger/DoctrineEnvelopeEntityReference/EventListener/PropertyReferenceEncodingListenerTest.php @@ -7,11 +7,11 @@ use App\Message\NewTestDocumentMessage; use App\Message\NewUserMessage; use Doctrine\ORM\EntityManagerInterface; -use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowiredInterface; use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowireService; use Draw\Component\Core\Reflection\ReflectionAccessor; use Draw\Component\Messenger\SerializerEventDispatcher\Event\PostEncodeEvent; use Draw\Component\Messenger\SerializerEventDispatcher\Event\PreEncodeEvent; +use Draw\Component\Tester\PHPUnit\Extension\SetUpAutowire\AutowiredInterface; use Draw\Contracts\Messenger\EnvelopeFinderInterface; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; diff --git a/tests/OpenApi/EventListener/ResponseApiExceptionListenerTest.php b/tests/OpenApi/EventListener/ResponseApiExceptionListenerTest.php index ad6dd196d..fe5507aaa 100644 --- a/tests/OpenApi/EventListener/ResponseApiExceptionListenerTest.php +++ b/tests/OpenApi/EventListener/ResponseApiExceptionListenerTest.php @@ -3,10 +3,10 @@ namespace App\Tests\OpenApi\EventListener; use Draw\Bundle\TesterBundle\EventDispatcher\EventListenerTestTrait; -use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowiredInterface; use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowireService; use Draw\Component\OpenApi\Event\PreDumpRootSchemaEvent; use Draw\Component\OpenApi\EventListener\ResponseApiExceptionListener; +use Draw\Component\Tester\PHPUnit\Extension\SetUpAutowire\AutowiredInterface; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; class ResponseApiExceptionListenerTest extends KernelTestCase implements AutowiredInterface diff --git a/tests/SonataExtraBundle/EventListener/PreObjectDeleteBatchEventEventListenerTest.php b/tests/SonataExtraBundle/EventListener/PreObjectDeleteBatchEventEventListenerTest.php index 1ec46e2b6..7f72cab4b 100644 --- a/tests/SonataExtraBundle/EventListener/PreObjectDeleteBatchEventEventListenerTest.php +++ b/tests/SonataExtraBundle/EventListener/PreObjectDeleteBatchEventEventListenerTest.php @@ -6,8 +6,8 @@ use App\Security\Voter\CannotSelfVoter; use Doctrine\ORM\EntityManagerInterface; use Draw\Bundle\SonataExtraBundle\EventListener\PreObjectDeleteBatchEventEventListener; -use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowiredInterface; use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowireService; +use Draw\Component\Tester\PHPUnit\Extension\SetUpAutowire\AutowiredInterface; use Sonata\DoctrineORMAdminBundle\Event\PreObjectDeleteBatchEvent; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Component\Security\Core\Authentication\Token\AbstractToken; diff --git a/tests/SonataImportBundle/ImporterTest.php b/tests/SonataImportBundle/ImporterTest.php index 9178e2299..23e2e7a80 100644 --- a/tests/SonataImportBundle/ImporterTest.php +++ b/tests/SonataImportBundle/ImporterTest.php @@ -7,8 +7,8 @@ use Draw\Bundle\SonataImportBundle\Entity\Import; use Draw\Bundle\SonataImportBundle\Import\Importer; use Draw\Bundle\TesterBundle\PHPUnit\Extension\DeleteTemporaryEntity\BaseTemporaryEntityCleaner; -use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowiredInterface; use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowireService; +use Draw\Component\Tester\PHPUnit\Extension\SetUpAutowire\AutowiredInterface; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; class ImporterTest extends KernelTestCase implements AutowiredInterface diff --git a/tests/SonataIntegrationBundle/Messenger/Action/RetryFailedMessageActionTest.php b/tests/SonataIntegrationBundle/Messenger/Action/RetryFailedMessageActionTest.php index d8da5508e..5ce81d89e 100644 --- a/tests/SonataIntegrationBundle/Messenger/Action/RetryFailedMessageActionTest.php +++ b/tests/SonataIntegrationBundle/Messenger/Action/RetryFailedMessageActionTest.php @@ -8,9 +8,9 @@ use App\Message\FailedMessage; use App\Tests\SonataIntegrationBundle\WebTestCaseTrait; use Draw\Bundle\TesterBundle\Messenger\MessengerTesterTrait; -use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowiredInterface; use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowireService; use Draw\Component\Messenger\Message\RetryFailedMessageMessage; +use Draw\Component\Tester\PHPUnit\Extension\SetUpAutowire\AutowiredInterface; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Component\Messenger\MessageBusInterface; use Symfony\Component\Messenger\Stamp\TransportNamesStamp; diff --git a/tests/SonataIntegrationBundle/User/Action/UnlockUserActionTest.php b/tests/SonataIntegrationBundle/User/Action/UnlockUserActionTest.php index 41f34ab65..cd82efc44 100644 --- a/tests/SonataIntegrationBundle/User/Action/UnlockUserActionTest.php +++ b/tests/SonataIntegrationBundle/User/Action/UnlockUserActionTest.php @@ -3,8 +3,8 @@ namespace App\Tests\SonataIntegrationBundle\User\Action; use App\Tests\SonataIntegrationBundle\WebTestCaseTrait; -use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowiredInterface; use Draw\Bundle\UserBundle\Entity\UserLock; +use Draw\Component\Tester\PHPUnit\Extension\SetUpAutowire\AutowiredInterface; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; class UnlockUserActionTest extends WebTestCase implements AutowiredInterface diff --git a/tests/TesterBundle/PHPUnit/Extension/SetUpAutoWire/SetUpAutowireExtensionTest.php b/tests/TesterBundle/PHPUnit/Extension/SetUpAutoWire/SetUpAutowireExtensionTest.php index 57a748d43..5f6806724 100644 --- a/tests/TesterBundle/PHPUnit/Extension/SetUpAutoWire/SetUpAutowireExtensionTest.php +++ b/tests/TesterBundle/PHPUnit/Extension/SetUpAutoWire/SetUpAutowireExtensionTest.php @@ -6,12 +6,12 @@ use Doctrine\Persistence\ManagerRegistry; use Draw\Bundle\TesterBundle\Messenger\TransportTester; use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowireClient; -use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowiredInterface; -use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowireMock; -use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowireMockProperty; use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowireParameter; use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowireService; use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowireTransportTester; +use Draw\Component\Tester\PHPUnit\Extension\SetUpAutowire\AutowiredInterface; +use Draw\Component\Tester\PHPUnit\Extension\SetUpAutowire\AutowireMock; +use Draw\Component\Tester\PHPUnit\Extension\SetUpAutowire\AutowireMockProperty; use PHPUnit\Framework\MockObject\MockObject; use Symfony\Bundle\FrameworkBundle\KernelBrowser; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; diff --git a/tests/Validator/Constraints/ValueIsNotUsedValidatorTest.php b/tests/Validator/Constraints/ValueIsNotUsedValidatorTest.php index 3dfe28455..bf62f8f10 100644 --- a/tests/Validator/Constraints/ValueIsNotUsedValidatorTest.php +++ b/tests/Validator/Constraints/ValueIsNotUsedValidatorTest.php @@ -4,8 +4,8 @@ use App\Entity\Tag; use App\Entity\User; -use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowiredInterface; use Draw\Bundle\TesterBundle\PHPUnit\Extension\SetUpAutowire\AutowireService; +use Draw\Component\Tester\PHPUnit\Extension\SetUpAutowire\AutowiredInterface; use Draw\Component\Validator\Constraints\ValueIsNotUsed; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Component\Validator\Validator\ValidatorInterface;