Skip to content

Commit

Permalink
EZP-23941: move searchable field map to storage
Browse files Browse the repository at this point in the history
  • Loading branch information
pspanja committed Feb 27, 2015
1 parent fa640cd commit 5380909
Showing 1 changed file with 52 additions and 62 deletions.
114 changes: 52 additions & 62 deletions Repository/Tests/SearchServiceTest.php
Expand Up @@ -1046,6 +1046,7 @@ public function testFieldCollectionContainsNoMatch()

/**
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
* @expectedExceptionMessage Argument '$criterion->target' is invalid: No searchable fields found for the given criterion target 'some_hopefully_unknown_field'
*/
public function testInvalidFieldIdentifierRange()
{
Expand All @@ -1068,6 +1069,7 @@ public function testInvalidFieldIdentifierRange()

/**
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
* @expectedExceptionMessage Argument '$criterion->target' is invalid: No searchable fields found for the given criterion target 'some_hopefully_unknown_field'
*/
public function testInvalidFieldIdentifierIn()
{
Expand All @@ -1090,6 +1092,7 @@ public function testInvalidFieldIdentifierIn()

/**
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
* @expectedExceptionMessage Argument '$criterion->target' is invalid: No searchable fields found for the given criterion target 'tag_cloud_url'
*/
public function testFindContentWithNonSearchableField()
{
Expand All @@ -1110,6 +1113,55 @@ public function testFindContentWithNonSearchableField()
);
}

/**
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
* @expectedExceptionMessage Argument '$sortClause->targetData' is invalid: No searchable fields found for the given sort clause target 'title' on 'template_look'
*/
public function testSortFieldWithNonSearchableField()
{
$setupFactory = $this->getSetupFactory();
if ( $setupFactory instanceof LegacySolr )
{
$this->markTestSkipped( "Field SortClause is not yet implemented for Solr storage" );
}

$repository = $this->getRepository();
$searchService = $repository->getSearchService();

$searchService->findContent(
new Query(
array(
'sortClauses' => array( new SortClause\Field( "template_look", "title" ) ),
)
)
);
}

/**
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
* @expectedExceptionMessage Argument '$sortClause->targetData' is invalid: No searchable fields found for the given sort clause target 'title' on 'template_look'
*/
public function testSortMapLocationDistanceWithNonSearchableField()
{
$repository = $this->getRepository();
$searchService = $repository->getSearchService();

$searchService->findContent(
new Query(
array(
'sortClauses' => array(
new SortClause\MapLocationDistance(
"template_look",
"title",
1,
2
),
),
)
)
);
}

/**
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
*/
Expand Down Expand Up @@ -1291,28 +1343,6 @@ function ( $a, $b )
);
}

public function getSortedContentSearchesLegacy()
{
$fixtureDir = $this->getFixtureDir();

return array(
// template_look/title es ezsetting fieldtype, not indexed in Solr or Elasticsearch
// @todo check - ezsetting should not be searchable
array(
array(
'filter' => new Criterion\SectionId( array( 5 ) ),
'offset' => 0,
'limit' => null,
'sortClauses' => array(
new SortClause\Field( "template_look", "title", Query::SORT_ASC ),
new SortClause\ContentId(),
)
),
$fixtureDir . 'SortTemplateTitle.php',
),
);
}

public function getSortedContentSearchesDeprecated()
{
$fixtureDir = $this->getFixtureDir();
Expand Down Expand Up @@ -2113,46 +2143,6 @@ function ( SearchHit $searchHit )
);
}

/**
* Test for the findContent() method.
*
* @todo Only for Legacy Storage Search, tests are missing for Solr and Elasticsearch
*
* @dataProvider getSortedContentSearchesLegacy
* @see \eZ\Publish\API\Repository\SearchService::findContent()
*/
public function testFindAndSortContentLegacy( $queryData, $fixture, $closure = null )
{
$setupFactory = $this->getSetupFactory();
if ( $setupFactory instanceof LegacySolr || $setupFactory instanceof LegacyElasticsearch )
{
$this->markTestSkipped( "ezsetting is not indexable on Solr and Elasticsearch storage" );
}

$query = new Query( $queryData );
$this->assertQueryFixture( $query, $fixture, $closure );
}

/**
* Test for the findLocations() method.
*
* @todo Only for Legacy Storage Search, tests are missing for Solr and Elasticsearch
*
* @dataProvider getSortedContentSearchesLegacy
* @see \eZ\Publish\API\Repository\SearchService::findLocations()
*/
public function testFindAndSortContentLocationsLegacy( $queryData, $fixture, $closure = null )
{
$setupFactory = $this->getSetupFactory();
if ( $setupFactory instanceof LegacySolr || $setupFactory instanceof LegacyElasticsearch )
{
$this->markTestSkipped( "ezsetting is not indexable on Solr and Elasticsearch storage" );
}

$query = new LocationQuery( $queryData );
$this->assertQueryFixture( $query, $fixture, $closure );
}

/**
* Test for the findContent() method.
*
Expand Down

0 comments on commit 5380909

Please sign in to comment.