From 538090970141433445a468c7fa79738f2ccd29ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petar=20=C5=A0panja?= Date: Tue, 17 Feb 2015 11:41:39 +0100 Subject: [PATCH] EZP-23941: move searchable field map to storage --- Repository/Tests/SearchServiceTest.php | 114 +++++++++++-------------- 1 file changed, 52 insertions(+), 62 deletions(-) diff --git a/Repository/Tests/SearchServiceTest.php b/Repository/Tests/SearchServiceTest.php index 8700dfceb..357ff4da9 100644 --- a/Repository/Tests/SearchServiceTest.php +++ b/Repository/Tests/SearchServiceTest.php @@ -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() { @@ -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() { @@ -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() { @@ -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 */ @@ -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(); @@ -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. *