Skip to content

Commit

Permalink
Fixed Solr integration tests (#92)
Browse files Browse the repository at this point in the history
* [Behat] Changed when test services are loaded
* [Unit tests] Fixed Solr setup factory namespace
* Fixed SolrSetup usage and detection
* Excluded Filtering tests
  • Loading branch information
mnocon authored Mar 21, 2022
1 parent fb3a702 commit 7203579
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 15 deletions.
8 changes: 4 additions & 4 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -381,22 +381,22 @@ parameters:
path: tests/integration/Core/Repository/FieldType/UserIntegrationTest.php

-
message: "#^Class Ibexa\\\\Solr\\\\LegacySetupFactory not found\\.$#"
message: "#^Class Ibexa\\\\Tests\\\\Solr\\\\SetupFactory\\\\LegacySetupFactory not found\\.$#"
count: 1
path: tests/integration/Core/Repository/Regression/EZP20018LanguageTest.php

-
message: "#^Class Ibexa\\\\Solr\\\\LegacySetupFactory not found\\.$#"
message: "#^Class Ibexa\\\\Tests\\\\Solr\\\\SetupFactory\\\\LegacySetupFactory not found\\.$#"
count: 1
path: tests/integration/Core/Repository/SearchServiceLocationTest.php

-
message: "#^Class Ibexa\\\\Solr\\\\LegacySetupFactory not found\\.$#"
message: "#^Class Ibexa\\\\Tests\\\\Solr\\\\SetupFactory\\\\LegacySetupFactory not found\\.$#"
count: 5
path: tests/integration/Core/Repository/SearchServiceTest.php

-
message: "#^Class Ibexa\\\\Solr\\\\LegacySetupFactory not found\\.$#"
message: "#^Class Ibexa\\\\Tests\\\\Solr\\\\SetupFactory\\\\LegacySetupFactory not found\\.$#"
count: 3
path: tests/integration/Core/Repository/SearchServiceTranslationLanguageFallbackTest.php

Expand Down
3 changes: 2 additions & 1 deletion phpunit-integration-legacy-solr.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
failOnWarning="true"
>
<php>
<env name="setupFactory" value="Ibexa\Solr\LegacySetupFactory" />
<env name="setupFactory" value="Ibexa\Tests\Solr\SetupFactory\LegacySetupFactory" />
<env name="backendVersion" value="5" />
<env name="fixtureDir" value="Solr" />
<env name="solrServer" value="http://localhost:8983/" />
Expand All @@ -24,6 +24,7 @@
<!-- Search service is used all over the place, so we must run entire integration test suite -->
<testsuite name="integration_repository">
<directory>tests/integration/Core</directory>
<exclude>tests/integration/Core/Repository/Filtering</exclude>
</testsuite>
</testsuites>
<filter>
Expand Down
9 changes: 7 additions & 2 deletions src/bundle/Core/DependencyInjection/IbexaCoreExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ public function load(array $configs, ContainerBuilder $container)

$configuration = $this->getConfiguration($configs, $container);

$environment = $container->getParameter('kernel.environment');
if (in_array($environment, ['behat', 'test'])) {
if ($this->shouldLoadTestBehatServices($container)) {
$loader->load('feature_contexts.yml');
}

Expand Down Expand Up @@ -1016,6 +1015,12 @@ private function configurePlatformShSetup(ContainerBuilder $container): void
$container->setParameter('liip_imagine_driver', 'imagick');
}
}

private function shouldLoadTestBehatServices(ContainerBuilder $container): bool
{
return $container->hasParameter('ibexa.behat.browser.enabled')
&& $container->getParameter('ibexa.behat.browser.enabled');
}
}

class_alias(IbexaCoreExtension::class, 'eZ\Bundle\EzPublishCoreBundle\DependencyInjection\EzPublishCoreExtension');
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
use Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException;
use Ibexa\Contracts\Core\Repository\Values\Content\Query;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\LanguageCode;
use Ibexa\Solr\LegacySetupFactory;
use Ibexa\Tests\Integration\Core\Repository\BaseTest;
use Ibexa\Tests\Solr\SetupFactory\LegacySetupFactory;

/**
* Test case for language issues in EZP-20018.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
use Ibexa\Contracts\Core\Repository\Values\Content\Search\SearchResult;
use Ibexa\Contracts\Core\Test\Repository\SetupFactory\Legacy;
use Ibexa\Core\Repository\Values\Content\Location;
use Ibexa\Solr\LegacySetupFactory as LegacySolrSetupFactory;
use Ibexa\Tests\Core\Repository\Common;
use Ibexa\Tests\Solr\SetupFactory\LegacySetupFactory as LegacySolrSetupFactory;

/**
* Test case for Location operations in the SearchService.
Expand Down
15 changes: 10 additions & 5 deletions tests/integration/Core/Repository/SearchServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
use Ibexa\Contracts\Core\Repository\Values\Content\Search\SearchHit;
use Ibexa\Contracts\Core\Repository\Values\Content\Search\SearchResult;
use Ibexa\Contracts\Core\Test\Repository\SetupFactory\Legacy;
use Ibexa\Solr\LegacySetupFactory as LegacySolrSetupFactory;
use Ibexa\Tests\Core\Repository\Common;
use Ibexa\Tests\Solr\SetupFactory\LegacySetupFactory as LegacySolrSetupFactory;

/**
* Test case for operations in the SearchService.
Expand Down Expand Up @@ -1241,7 +1241,7 @@ public function testFindNoPerformCount()

$searchHit = $searchService->findContent($query);

if ($this->getSetupFactory() instanceof Legacy) {
if ($this->isRunningOnLegacySetup()) {
$this->assertNull(
$searchHit->totalCount
);
Expand All @@ -1257,7 +1257,7 @@ public function testFindNoPerformCountException()
{
$this->expectException(\RuntimeException::class);

if (!$this->getSetupFactory() instanceof Legacy) {
if (!$this->isRunningOnLegacySetup()) {
$this->markTestSkipped('Only applicable to Legacy/DB based search');
}

Expand Down Expand Up @@ -1287,7 +1287,7 @@ public function testFindLocationsNoPerformCount()

$searchHit = $searchService->findLocations($query);

if ($this->getSetupFactory() instanceof Legacy) {
if ($this->isRunningOnLegacySetup()) {
$this->assertNull(
$searchHit->totalCount
);
Expand All @@ -1303,7 +1303,7 @@ public function testFindLocationsNoPerformCountException()
{
$this->expectException(\RuntimeException::class);

if (!$this->getSetupFactory() instanceof Legacy) {
if (!$this->isRunningOnLegacySetup()) {
$this->markTestSkipped('Only applicable to Legacy/DB based search');
}

Expand Down Expand Up @@ -5250,6 +5250,11 @@ public function providerForTestSortingByNumericFieldsWithValuesOfDifferentLength
[15, 5],
];
}

private function isRunningOnLegacySetup(): bool
{
return get_class($this->getSetupFactory()) === Legacy::class;
}
}

class_alias(SearchServiceTest::class, 'eZ\Publish\API\Repository\Tests\SearchServiceTest');
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\SortClause;
use Ibexa\Contracts\Core\Repository\Values\Content\Search\SearchHit;
use Ibexa\Solr\LegacySetupFactory as LegacySolrSetupFactory;
use Ibexa\Tests\Solr\SetupFactory\LegacySetupFactory as LegacySolrSetupFactory;
use RuntimeException;

/**
Expand Down

0 comments on commit 7203579

Please # to comment.