-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
119 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Ibexa\Tests\Integration\Solr; | ||
|
||
use Ibexa\Bundle\Solr\IbexaSolrBundle; | ||
use Ibexa\Contracts\Core\Search\Handler; | ||
use Ibexa\Contracts\Test\Core\IbexaTestKernel as BaseIbexaTestKernel; | ||
use Ibexa\Solr\Handler as SolrHandler; | ||
use Symfony\Component\Config\Loader\LoaderInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
|
||
final class IbexaTestKernel extends BaseIbexaTestKernel | ||
{ | ||
public function registerBundles(): iterable | ||
{ | ||
yield from parent::registerBundles(); | ||
|
||
yield new IbexaSolrBundle(); | ||
} | ||
|
||
protected static function getExposedServicesById(): iterable | ||
{ | ||
yield from parent::getExposedServicesById(); | ||
|
||
yield SolrHandler::class => Handler::class; | ||
} | ||
|
||
public function registerContainerConfiguration(LoaderInterface $loader): void | ||
{ | ||
parent::registerContainerConfiguration($loader); | ||
|
||
$loader->load(static function (ContainerBuilder $container): void { | ||
(new SolrTestContainerBuilder())->loadSolrSettings($container); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Ibexa\Tests\Integration\Solr; | ||
|
||
use Ibexa\Tests\Integration\Core\Repository\SearchServiceTranslationLanguageFallbackTest; | ||
use RuntimeException; | ||
use Symfony\Component\Config\FileLocator; | ||
use Symfony\Component\Config\Resource\FileResource; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final class SolrTestContainerBuilder | ||
{ | ||
public const CONFIGURATION_FILES_MAP = [ | ||
SearchServiceTranslationLanguageFallbackTest::SETUP_DEDICATED => 'multicore_dedicated.yml', | ||
SearchServiceTranslationLanguageFallbackTest::SETUP_SHARED => 'multicore_shared.yml', | ||
SearchServiceTranslationLanguageFallbackTest::SETUP_SINGLE => 'single_core.yml', | ||
SearchServiceTranslationLanguageFallbackTest::SETUP_CLOUD => 'cloud.yml', | ||
]; | ||
|
||
public function loadSolrSettings(ContainerBuilder $containerBuilder): void | ||
{ | ||
$containerBuilder->setParameter('test.ibexa.solr.host', getenv('SOLR_HOST') ?: 'localhost'); | ||
|
||
$settingsPath = dirname(__DIR__, 2) . '/src/lib/Resources/config/container/'; | ||
$testSettingsPath = dirname(__DIR__) . '/lib/Resources/config/'; | ||
|
||
$solrLoader = new YamlFileLoader($containerBuilder, new FileLocator($settingsPath)); | ||
$solrLoader->load('solr.yml'); | ||
|
||
$testConfigurationFile = $this->getTestConfigurationFile(); | ||
$solrTestLoader = new YamlFileLoader($containerBuilder, new FileLocator($testSettingsPath)); | ||
$solrTestLoader->load($testConfigurationFile); | ||
|
||
$containerBuilder->addResource(new FileResource($testSettingsPath . $testConfigurationFile)); | ||
} | ||
|
||
public function getTestConfigurationFile(): string | ||
{ | ||
$isSolrCloud = getenv('SOLR_CLOUD') === 'yes'; | ||
$coresSetup = $isSolrCloud | ||
? SearchServiceTranslationLanguageFallbackTest::SETUP_CLOUD | ||
: getenv('CORES_SETUP'); | ||
|
||
if (!isset(self::CONFIGURATION_FILES_MAP[$coresSetup])) { | ||
throw new RuntimeException("Backend cores setup '{$coresSetup}' is not handled"); | ||
} | ||
|
||
return self::CONFIGURATION_FILES_MAP[$coresSetup]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters