diff --git a/packages/tester-bundle/.phpstorm.meta.php b/packages/tester-bundle/.phpstorm.meta.php deleted file mode 100644 index 10849c461..000000000 --- a/packages/tester-bundle/.phpstorm.meta.php +++ /dev/null @@ -1,8 +0,0 @@ - "@"]) -); diff --git a/packages/tester-bundle/DependencyInjection/ServiceTesterTrait.php b/packages/tester-bundle/DependencyInjection/ServiceTesterTrait.php deleted file mode 100644 index 47c236c2e..000000000 --- a/packages/tester-bundle/DependencyInjection/ServiceTesterTrait.php +++ /dev/null @@ -1,48 +0,0 @@ -boot(); - $container = self::$mainTestKernel->getContainer(); - self::$mainTestContainer = $container->get('test.service_container'); - } - - return self::$mainTestContainer; - } - - public static function getService(string $service): ?object - { - return static::getMainTestContainer()->get($service); - } - - /** - * @afterClass - */ - public static function shutdownMainTestContainer(): void - { - self::$mainTestKernel?->shutdown(); - - if (self::$mainTestContainer instanceof ResetInterface) { - self::$mainTestContainer->reset(); - } - - self::$mainTestKernel = self::$mainTestContainer = null; - } -} diff --git a/packages/tester-bundle/DrawTesterBundle.php b/packages/tester-bundle/DrawTesterBundle.php index e70fb8546..ff4b13b17 100644 --- a/packages/tester-bundle/DrawTesterBundle.php +++ b/packages/tester-bundle/DrawTesterBundle.php @@ -12,14 +12,6 @@ class DrawTesterBundle extends Bundle { - public static $ids = []; - - public static function addServicesToTest($ids): void - { - $ids = (array) $ids; - self::$ids += $ids; - } - public function build(ContainerBuilder $container): void { $container->addCompilerPass(new CompilerPass()); diff --git a/packages/tester-bundle/Tests/Messenger/TransportTesterTest.php b/packages/tester-bundle/Tests/Messenger/TransportTesterTest.php index 1309ead22..92f0c034c 100644 --- a/packages/tester-bundle/Tests/Messenger/TransportTesterTest.php +++ b/packages/tester-bundle/Tests/Messenger/TransportTesterTest.php @@ -14,13 +14,13 @@ class TransportTesterTest extends TestCase protected function setUp(): void { - $this->transportTester = $this->getService('messenger.transport.memory.draw.tester'); + $this->transportTester = static::getContainer()->get('messenger.transport.memory.draw.tester'); } public function testGetTransport(): void { static::assertSame( - $this->getService('messenger.transport.memory'), + static::getContainer()->get('messenger.transport.memory'), $this->transportTester->getTransport() ); } diff --git a/packages/tester-bundle/Tests/TestCase.php b/packages/tester-bundle/Tests/TestCase.php index c00ca9a08..9d52e33ff 100644 --- a/packages/tester-bundle/Tests/TestCase.php +++ b/packages/tester-bundle/Tests/TestCase.php @@ -2,7 +2,6 @@ namespace Draw\Bundle\TesterBundle\Tests; -use Draw\Bundle\TesterBundle\DependencyInjection\ServiceTesterTrait; use Draw\Bundle\TesterBundle\Http\BrowserFactoryInterface; use Draw\Bundle\TesterBundle\Http\HttpTesterTrait; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; @@ -11,7 +10,6 @@ class TestCase extends KernelTestCase implements BrowserFactoryInterface { use HttpTesterTrait; - use ServiceTesterTrait; // For symfony 4.x protected static $class = AppKernel::class; diff --git a/tests/Controller/Api/UsersControllerTest.php b/tests/Controller/Api/UsersControllerTest.php index 2ee9ac631..ed9040425 100644 --- a/tests/Controller/Api/UsersControllerTest.php +++ b/tests/Controller/Api/UsersControllerTest.php @@ -7,18 +7,20 @@ use Doctrine\ORM\EntityManagerInterface; use Draw\Bundle\UserBundle\Email\ForgotPasswordEmail; use Monolog\Level; +use PHPUnit\Framework\Attributes\AfterClass; +use PHPUnit\Framework\Attributes\BeforeClass; use Symfony\Component\HttpFoundation\Response; class UsersControllerTest extends TestCase { - /** - * @beforeClass - * - * @afterClass - */ + #[ + BeforeClass, + AfterClass, + ] public static function cleanUp(): void { - static::getService(EntityManagerInterface::class) + static::getContainer() + ->get(EntityManagerInterface::class) ->createQueryBuilder() ->delete(User::class, 'user') ->andWhere('user.email = :email') diff --git a/tests/TestCase.php b/tests/TestCase.php index a78a77570..43f23e34f 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -2,7 +2,6 @@ namespace App\Tests; -use Draw\Bundle\TesterBundle\DependencyInjection\ServiceTesterTrait; use Draw\Bundle\TesterBundle\Http\BrowserFactoryInterface; use Draw\Bundle\TesterBundle\Http\HttpTesterTrait; use Draw\Bundle\TesterBundle\Mailer\TemplatedMailerAssertionsTrait; @@ -21,7 +20,6 @@ class TestCase extends KernelTestCase implements BrowserFactoryInterface } use MessengerTesterTrait; use MetricTesterTrait; - use ServiceTesterTrait; use TemplatedMailerAssertionsTrait; public function createBrowser(): AbstractBrowser