Skip to content

Commit

Permalink
fix: call to ::container
Browse files Browse the repository at this point in the history
  • Loading branch information
dunglas committed Jun 15, 2021
1 parent d510c3b commit e0d02ac
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
Expand Up @@ -725,7 +725,7 @@ protected function buildSearchFilter(ManagerRegistry $managerRegistry, ?array $p
});

$iriConverter = $iriConverterProphecy->reveal();
$propertyAccessor = self::$kernel->getContainer()->get('test.property_accessor');
$propertyAccessor = static::$kernel->getContainer()->get('test.property_accessor');

$identifierExtractorProphecy = $this->prophesize(IdentifiersExtractorInterface::class);
$identifierExtractorProphecy->getIdentifiersFromResourceClass(Argument::type('string'))->willReturn(['id']);
Expand Down
4 changes: 2 additions & 2 deletions tests/Bridge/Doctrine/Orm/Filter/SearchFilterTest.php
Expand Up @@ -343,7 +343,7 @@ public function testNotPassingIdentifiersExtractor()
$requestStack->push(Request::create('/api/dummies', 'GET', []));
$iriConverterProphecy = $this->prophesize(IriConverterInterface::class);
$iriConverter = $iriConverterProphecy->reveal();
$propertyAccessor = self::$kernel->getContainer()->get('test.property_accessor');
$propertyAccessor = static::$kernel->getContainer()->get('test.property_accessor');

return new SearchFilter($this->managerRegistry, $requestStack, $iriConverter, $propertyAccessor, null, null, null);
}
Expand Down Expand Up @@ -593,7 +593,7 @@ protected function buildSearchFilter(ManagerRegistry $managerRegistry, ?array $p
});

$iriConverter = $iriConverterProphecy->reveal();
$propertyAccessor = self::$kernel->getContainer()->get('test.property_accessor');
$propertyAccessor = static::$kernel->getContainer()->get('test.property_accessor');

$identifierExtractorProphecy = $this->prophesize(IdentifiersExtractorInterface::class);
$identifierExtractorProphecy->getIdentifiersFromResourceClass(Argument::type('string'))->willReturn(['id']);
Expand Down
7 changes: 4 additions & 3 deletions tests/Bridge/Symfony/Bundle/Test/ApiTestCaseTest.php
Expand Up @@ -143,7 +143,7 @@ public function testAssertMatchesResourceItemJsonSchemaOutput(): void
$this->recreateSchema();

/** @var EntityManagerInterface $manager */
$manager = self::$container->get('doctrine')->getManager();
$manager = (method_exists(static::class, 'getContainer') ? static::getContainer() : static::$container)->get('doctrine')->getManager();
$dummyDtoInputOutput = new DummyDtoInputOutput();
$dummyDtoInputOutput->str = 'lorem';
$dummyDtoInputOutput->num = 54;
Expand Down Expand Up @@ -187,7 +187,8 @@ public function testFindIriBy(): void
]);
$this->assertResponseIsSuccessful();

$resource = 'mongodb' === self::$container->getParameter('kernel.environment') ? DummyDocument::class : Dummy::class;
$container = method_exists(static::class, 'getContainer') ? static::getContainer() : static::$container;
$resource = 'mongodb' === $container->getParameter('kernel.environment') ? DummyDocument::class : Dummy::class;
$this->assertMatchesRegularExpression('~^/dummies/\d+~', self::findIriBy($resource, ['name' => 'Kevin']));
$this->assertNull(self::findIriBy($resource, ['name' => 'not-exist']));
}
Expand All @@ -197,7 +198,7 @@ private function recreateSchema(): void
self::bootKernel();

/** @var EntityManagerInterface $manager */
$manager = self::$container->get('doctrine')->getManager();
$manager = (method_exists(static::class, 'getContainer') ? static::getContainer() : static::$container)->get('doctrine')->getManager();
/** @var \Doctrine\ORM\Mapping\ClassMetadata[] $classes */
$classes = $manager->getMetadataFactory()->getAllMetadata();
$schemaTool = new SchemaTool($manager);
Expand Down
6 changes: 3 additions & 3 deletions tests/Bridge/Symfony/Bundle/Test/ClientTest.php
Expand Up @@ -28,7 +28,7 @@ protected function setUp(): void
/**
* @var EntityManagerInterface
*/
$manager = self::$container->get('doctrine')->getManager();
$manager = (method_exists(static::class, 'getContainer') ? static::getContainer() : static::$container)->get('doctrine')->getManager();
/** @var \Doctrine\ORM\Mapping\ClassMetadata[] $classes */
$classes = $manager->getMetadataFactory()->getAllMetadata();
$schemaTool = new SchemaTool($manager);
Expand All @@ -41,8 +41,8 @@ public function testRequest(): void
{
$client = self::createClient();
$client->getKernelBrowser();
$this->assertSame(self::$kernel->getContainer(), $client->getContainer());
$this->assertSame(self::$kernel, $client->getKernel());
$this->assertSame(method_exists(static::class, 'getContainer') ? static::getContainer() : static::$kernel->getContainer(), $client->getContainer());
$this->assertSame(static::$kernel, $client->getKernel());

$client->enableProfiler();
$response = $client->request('GET', '/');
Expand Down
2 changes: 1 addition & 1 deletion tests/Util/AnnotationFilterExtractorTraitTest.php
Expand Up @@ -31,7 +31,7 @@ class AnnotationFilterExtractorTraitTest extends KernelTestCase
protected function setUp(): void
{
self::bootKernel();
$this->extractor = new AnnotationFilterExtractor(self::$kernel->getContainer()->get('test.annotation_reader'));
$this->extractor = new AnnotationFilterExtractor(static::$kernel->getContainer()->get('test.annotation_reader'));
}

public function testReadAnnotations()
Expand Down

0 comments on commit e0d02ac

Please sign in to comment.