Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EZP-30835: Added support for Solr 7.7 #2775

Merged
merged 4 commits into from
Oct 4, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
154 changes: 144 additions & 10 deletions eZ/Publish/API/Repository/Tests/SearchServiceFulltextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function testPrepareContent()
*
* @see testPrepareContent
*/
public function providerForTestFulltextSearch()
public function providerForTestFulltextSearchSolr6(): array
{
return [
[
Expand Down Expand Up @@ -173,16 +173,126 @@ public function providerForTestFulltextSearch()
}

/**
* Test for the findContent() method.
* Return pairs of arguments:
* - search string for testing
* - an array of corresponding Content keys as defined in testPrepareContent() method,
* ordered and grouped by relevancy.
*
* @param $searchString
* @see testPrepareContent
*/
public function providerForTestFulltextSearchSolr7(): array
{
return [
[
'fox',
[3, [6, 8, 10], [11, 13, 14], 15],
],
[
'quick fox',
$quickOrFox = [6, [11, 13], 15, [1, 3], [5, 7, 8, 10], [12, 14]],
],
[
'quick OR fox',
$quickOrFox,
],
[
'quick AND () OR AND fox',
$quickOrFox,
],
[
'+quick +fox',
$quickAndFox = [6, [11, 13], 15],
],
[
'quick AND fox',
$quickAndFox,
],
[
'brown +fox -news',
[8, 11, 3, 6],
],
[
'quick +fox -news',
[6, 11, 3, 8],
],
[
'quick brown +fox -news',
$notNewsFox = [11, [6, 8], 3],
],
[
'((quick AND fox) OR (brown AND fox) OR fox) AND NOT news',
$notNewsFox,
],
[
'"quick brown"',
[5, [11, 12], 15],
],
[
'"quick brown" AND fox',
[11, 15],
],
[
'quick OR brown AND fox AND NOT news',
[11, 8],
],
[
'(quick OR brown) AND fox AND NOT news',
[11, [6, 8]],
],
[
'"fox brown"',
[],
],
[
'qui*',
[[1, 5, 6, 7, 11, 12, 13, 15]],
],
[
'+qui* +fox',
[6, [11, 13], 15],
],
];
}

/**
* Test for the findContent() method on Solr 6.
*
* @param string $searchString
* @param array $expectedKeys
* @param array $idMap
*
* @depends testPrepareContent
* @dataProvider providerForTestFulltextSearchSolr6
*/
public function testFulltextContentSearchSolr6(string $searchString, array $expectedKeys, array $idMap): void
{
if (($solrVersion = getenv('SOLR_VERSION')) >= 7) {
$this->markTestSkipped('This test is only relevant for Solr 6');
}

$this->doTestFulltextContentSearch($searchString, $expectedKeys, $idMap);
}

/**
* Test for the findContent() method on Solr >= 7.
*
* @param string $searchString
* @param array $expectedKeys
* @param array $idMap
*
* @depends testPrepareContent
* @dataProvider providerForTestFulltextSearch
* @dataProvider providerForTestFulltextSearchSolr7
*/
public function testFulltextContentSearch($searchString, array $expectedKeys, array $idMap)
public function testFulltextContentSearchSolr7(string $searchString, array $expectedKeys, array $idMap): void
{
if (($solrVersion = getenv('SOLR_VERSION')) < 7) {
$this->markTestSkipped('This test is only relevant for Solr >= 7');
}

$this->doTestFulltextContentSearch($searchString, $expectedKeys, $idMap);
}

private function doTestFulltextContentSearch(string $searchString, array $expectedKeys, array $idMap): void
{
$repository = $this->getRepository(false);
$searchService = $repository->getSearchService();
Expand All @@ -194,21 +304,45 @@ public function testFulltextContentSearch($searchString, array $expectedKeys, ar
}

/**
* Test for the findLocations() method.
* Test for the findLocations() method on Solr 6.
*
* @param $searchString
* @param array $expectedKeys
* @param array $idMap
*
* @depends testPrepareContent
* @dataProvider providerForTestFulltextSearch
* @dataProvider providerForTestFulltextSearchSolr6
*/
public function testFulltextLocationSearch($searchString, array $expectedKeys, array $idMap)
public function testFulltextLocationSearchSolr6($searchString, array $expectedKeys, array $idMap): void
{
if (($solrVersion = getenv('SOLR_VERSION')) && $solrVersion < 6) {
$this->markTestSkipped('Solr 4 detected, skipping as scoring won\'t match');
if (($solrVersion = getenv('SOLR_VERSION')) && ($solrVersion < 6 || $solrVersion >= 7)) {
alongosz marked this conversation as resolved.
Show resolved Hide resolved
$this->markTestSkipped('This test is only relevant for Solr 6');
}

$this->doTestFulltextLocationSearch($searchString, $expectedKeys, $idMap);
}

/**
* Test for the findLocations() method on Solr >= 7.
*
* @param $searchString
* @param array $expectedKeys
* @param array $idMap
*
* @depends testPrepareContent
* @dataProvider providerForTestFulltextSearchSolr7
*/
public function testFulltextLocationSearchSolr7($searchString, array $expectedKeys, array $idMap): void
{
if (($solrVersion = getenv('SOLR_VERSION')) < 7) {
$this->markTestSkipped('This test is only relevant for Solr >= 7');
}

$this->doTestFulltextLocationSearch($searchString, $expectedKeys, $idMap);
}

private function doTestFulltextLocationSearch($searchString, array $expectedKeys, array $idMap): void
{
$repository = $this->getRepository(false);
$searchService = $repository->getSearchService();

Expand Down
Loading