Skip to content

Commit

Permalink
Replace overwritten container method
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-schranz committed Jul 17, 2024
1 parent a16a482 commit de9bfb1
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 13 deletions.
7 changes: 3 additions & 4 deletions Test/AbstractElasticsearchTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

use ONGR\ElasticsearchBundle\Service\Manager;
use ONGR\ElasticsearchBundle\Tests\WebTestCase;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
Expand Down Expand Up @@ -170,7 +169,7 @@ protected function doTearDown()
*
* @return ContainerInterface
*/
protected static function getContainer(): Container
protected static function getKernelContainer(): ContainerInterface
{
if (null === self::$container) {
self::bootKernel();
Expand Down Expand Up @@ -198,9 +197,9 @@ protected function getManager($name = 'default')
$this->ignoreVersions($this->managers[$name]);

return $this->managers[$name];
} elseif ($this->getContainer()->has($serviceName)) {
} elseif ($this->getKernelContainer()->has($serviceName)) {
/** @var Manager $manager */
$manager = $this->getContainer()->get($serviceName);
$manager = $this->getKernelContainer()->get($serviceName);
$this->managers[$name] = $manager;
} else {
throw new \LogicException(sprintf("Manager '%s' does not exist", $name));
Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/Command/CreateIndexCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public function testIndexMappingDump()
private function getCommandTester()
{
$indexCreateCommand = new IndexCreateCommand(
$this->getContainer()->get('es.client.index_suffix_finder'),
$this->getKernelContainer()->get('es.client.index_suffix_finder'),
['es.manager.default' => $this->getManager()]
);

Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/Command/IndexExportCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public function testIndexExport($options, $expectedResults)
private function getCommandTester()
{
$indexExportCommand = new IndexExportCommand(
$this->getContainer()->get('es.export'),
$this->getKernelContainer()->get('es.export'),
['es.manager.default' => $this->getManager()]
);

Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/Command/IndexImportCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public function testIndexImportWithGzipOption($bulkSize, $realSize, $filename)
private function getImportCommand()
{
return new IndexImportCommand(
$this->getContainer()->get('es.import'),
$this->getKernelContainer()->get('es.import'),
['es.manager.default' => $this->getManager()]
);
}
Expand Down
6 changes: 3 additions & 3 deletions Tests/Functional/Mapping/DocumentFinderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class DocumentFinderTest extends WebTestCase
*/
public function testGetBundleDocumentClasses()
{
$finder = new DocumentFinder($this->getContainer()->getParameter('kernel.bundles'));
$finder = new DocumentFinder($this->getClientContainer()->getParameter('kernel.bundles'));
$this->assertGreaterThan(0, count($finder->getBundleDocumentClasses('TestBundle')));
$this->assertEquals(0, count($finder->getBundleDocumentClasses('FrameworkBundle')));
}
Expand All @@ -36,7 +36,7 @@ public function testGetBundleClassException()
$this->expectException(\LogicException::class);
$this->expectExceptionMessage('Bundle \'NotExistingBundle\' does not exist.');

$finder = new DocumentFinder($this->getContainer()->getParameter('kernel.bundles'));
$finder = new DocumentFinder($this->getClientContainer()->getParameter('kernel.bundles'));
$finder->getBundleClass('NotExistingBundle');
}

Expand All @@ -45,7 +45,7 @@ public function testGetBundleClassException()
*
* @return ContainerInterface
*/
protected static function getContainer(): Container
protected static function getClientContainer(): ContainerInterface
{
return static::createClient()->getContainer();
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/Profiler/ElasticsearchProfilerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public function checkQueryParameters(&$query)
*/
private function getCollector()
{
$collector = $this->getContainer()->get('es.profiler');
$collector = $this->getKernelContainer()->get('es.profiler');
$collector->collect(new Request(), new Response());

return $collector;
Expand Down
9 changes: 8 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,12 @@
"replace": {
"ongr/elasticsearch-bundle": "self.version"
},
"minimum-stability": "dev"
"minimum-stability": "dev",
"extra": {
"symfony": {
"recipe-contrib": false,
"allow-contrib": false,
"require": "7.1.*"
}
}
}
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

<php>
<server name="KERNEL_DIR" value="Tests/app/" />
<server name="APP_ENV" value="test" force="true"/>
<env name="APP_ENV" value="test" force="true"/>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak"/>
</php>

Expand Down

0 comments on commit de9bfb1

Please sign in to comment.