diff --git a/eZ/Publish/API/Repository/Tests/SearchServiceTest.php b/eZ/Publish/API/Repository/Tests/SearchServiceTest.php index 514a9f4f2d9..a1c1f025e61 100644 --- a/eZ/Publish/API/Repository/Tests/SearchServiceTest.php +++ b/eZ/Publish/API/Repository/Tests/SearchServiceTest.php @@ -411,6 +411,69 @@ function ( $a, $b ) ), $fixtureDir . 'LanguageCodeAlwaysAvailable.php', ), + array( + new Query( + array( + 'criterion' => new Criterion\Depth( Criterion\Operator::EQ, 1 ), + 'sortClauses' => array( new SortClause\ContentId() ) + ) + ), + $fixtureDir . 'Depth.php', + ), + array( + new Query( + array( + 'criterion' => new Criterion\Depth( Criterion\Operator::IN, array( 1, 3 ) ), + 'sortClauses' => array( new SortClause\ContentId() ) + ) + ), + $fixtureDir . 'DepthIn.php', + ), + array( + new Query( + array( + 'criterion' => new Criterion\Depth( Criterion\Operator::GT, 2 ), + 'sortClauses' => array( new SortClause\ContentId() ) + ) + ), + $fixtureDir . 'DepthGt.php', + ), + array( + new Query( + array( + 'criterion' => new Criterion\Depth( Criterion\Operator::GTE, 2 ), + 'sortClauses' => array( new SortClause\ContentId() ) + ) + ), + $fixtureDir . 'DepthGte.php', + ), + array( + new Query( + array( + 'criterion' => new Criterion\Depth( Criterion\Operator::LT, 2 ), + 'sortClauses' => array( new SortClause\ContentId() ) + ) + ), + $fixtureDir . 'Depth.php', + ), + array( + new Query( + array( + 'criterion' => new Criterion\Depth( Criterion\Operator::LTE, 2 ), + 'sortClauses' => array( new SortClause\ContentId() ) + ) + ), + $fixtureDir . 'DepthLte.php', + ), + array( + new Query( + array( + 'criterion' => new Criterion\Depth( Criterion\Operator::BETWEEN, array( 1, 2 ) ), + 'sortClauses' => array( new SortClause\ContentId() ) + ) + ), + $fixtureDir . 'DepthLte.php', + ), ); } diff --git a/eZ/Publish/API/Repository/Tests/_fixtures/Legacy/Depth.php b/eZ/Publish/API/Repository/Tests/_fixtures/Legacy/Depth.php new file mode 100644 index 00000000000..5a76c1fe25b --- /dev/null +++ b/eZ/Publish/API/Repository/Tests/_fixtures/Legacy/Depth.php @@ -0,0 +1,69 @@ + array(), + 'searchHits' => array( + 0 => eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state( + array( + 'valueObject' => array( + 'id' => 4, + 'title' => 'Users', + ), + 'score' => NULL, + 'index' => NULL, + 'highlight' => NULL, + ) + ), + 1 => eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state( + array( + 'valueObject' => array( + 'id' => 41, + 'title' => 'Media', + ), + 'score' => NULL, + 'index' => NULL, + 'highlight' => NULL, + ) + ), + 2 => eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state( + array( + 'valueObject' => array( + 'id' => 45, + 'title' => 'Setup', + ), + 'score' => NULL, + 'index' => NULL, + 'highlight' => NULL, + ) + ), + 3 => eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state( + array( + 'valueObject' => array( + 'id' => 56, + 'title' => 'Design', + ), + 'score' => NULL, + 'index' => NULL, + 'highlight' => NULL, + ) + ), + 4 => eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state( + array( + 'valueObject' => array( + 'id' => 57, + 'title' => 'Home', + ), + 'score' => NULL, + 'index' => NULL, + 'highlight' => NULL, + ) + ), + ), + 'spellSuggestion' => NULL, + 'time' => 1, + 'timedOut' => NULL, + 'maxScore' => NULL, + 'totalCount' => 5, + ) +); diff --git a/eZ/Publish/API/Repository/Tests/_fixtures/Legacy/DepthGt.php b/eZ/Publish/API/Repository/Tests/_fixtures/Legacy/DepthGt.php new file mode 100644 index 00000000000..50a7be17d91 --- /dev/null +++ b/eZ/Publish/API/Repository/Tests/_fixtures/Legacy/DepthGt.php @@ -0,0 +1,36 @@ + array(), + 'searchHits' => array( + 0 => eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state( + array( + 'valueObject' => array( + 'id' => 10, + 'title' => 'Anonymous User', + ), + 'score' => NULL, + 'index' => NULL, + 'highlight' => NULL, + ) + ), + 1 => eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state( + array( + 'valueObject' => array( + 'id' => 14, + 'title' => 'Administrator User', + ), + 'score' => NULL, + 'index' => NULL, + 'highlight' => NULL, + ) + ), + ), + 'spellSuggestion' => NULL, + 'time' => 1, + 'timedOut' => NULL, + 'maxScore' => NULL, + 'totalCount' => 2, + ) +); diff --git a/eZ/Publish/API/Repository/Tests/_fixtures/Legacy/DepthGte.php b/eZ/Publish/API/Repository/Tests/_fixtures/Legacy/DepthGte.php new file mode 100644 index 00000000000..455c194cef6 --- /dev/null +++ b/eZ/Publish/API/Repository/Tests/_fixtures/Legacy/DepthGte.php @@ -0,0 +1,157 @@ + array(), + 'searchHits' => array( + 0 => eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state( + array( + 'valueObject' => array( + 'id' => 10, + 'title' => 'Anonymous User', + ), + 'score' => NULL, + 'index' => NULL, + 'highlight' => NULL, + ) + ), + 1 => eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state( + array( + 'valueObject' => array( + 'id' => 11, + 'title' => 'Members', + ), + 'score' => NULL, + 'index' => NULL, + 'highlight' => NULL, + ) + ), + 2 => eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state( + array( + 'valueObject' => array( + 'id' => 12, + 'title' => 'Administrator users', + ), + 'score' => NULL, + 'index' => NULL, + 'highlight' => NULL, + ) + ), + 3 => eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state( + array( + 'valueObject' => array( + 'id' => 13, + 'title' => 'Editors', + ), + 'score' => NULL, + 'index' => NULL, + 'highlight' => NULL, + ) + ), + 4 => eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state( + array( + 'valueObject' => array( + 'id' => 14, + 'title' => 'Administrator User', + ), + 'score' => NULL, + 'index' => NULL, + 'highlight' => NULL, + ) + ), + 5 => eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state( + array( + 'valueObject' => array( + 'id' => 42, + 'title' => 'Anonymous Users', + ), + 'score' => NULL, + 'index' => NULL, + 'highlight' => NULL, + ) + ), + 6 => eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state( + array( + 'valueObject' => array( + 'id' => 49, + 'title' => 'Images', + ), + 'score' => NULL, + 'index' => NULL, + 'highlight' => NULL, + ) + ), + 7 => eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state( + array( + 'valueObject' => array( + 'id' => 50, + 'title' => 'Files', + ), + 'score' => NULL, + 'index' => NULL, + 'highlight' => NULL, + ) + ), + 8 => eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state( + array( + 'valueObject' => array( + 'id' => 51, + 'title' => 'Multimedia', + ), + 'score' => NULL, + 'index' => NULL, + 'highlight' => NULL, + ) + ), + 9 => eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state( + array( + 'valueObject' => array( + 'id' => 52, + 'title' => 'Common INI settings', + ), + 'score' => NULL, + 'index' => NULL, + 'highlight' => NULL, + ) + ), + 10 => eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state( + array( + 'valueObject' => array( + 'id' => 54, + 'title' => 'eZ Publish Demo Design (without demo content)', + ), + 'score' => NULL, + 'index' => NULL, + 'highlight' => NULL, + ) + ), + 11 => eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state( + array( + 'valueObject' => array( + 'id' => 58, + 'title' => 'Contact Us', + ), + 'score' => NULL, + 'index' => NULL, + 'highlight' => NULL, + ) + ), + 12 => eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state( + array( + 'valueObject' => array( + 'id' => 59, + 'title' => 'Partners', + ), + 'score' => NULL, + 'index' => NULL, + 'highlight' => NULL, + ) + ), + ), + 'spellSuggestion' => NULL, + 'time' => 1, + 'timedOut' => NULL, + 'maxScore' => NULL, + 'totalCount' => 13, + ) +); diff --git a/eZ/Publish/API/Repository/Tests/_fixtures/Legacy/DepthIn.php b/eZ/Publish/API/Repository/Tests/_fixtures/Legacy/DepthIn.php new file mode 100644 index 00000000000..ae19a037060 --- /dev/null +++ b/eZ/Publish/API/Repository/Tests/_fixtures/Legacy/DepthIn.php @@ -0,0 +1,91 @@ + array(), + 'searchHits' => array( + 0 => eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state( + array( + 'valueObject' => array( + 'id' => 4, + 'title' => 'Users', + ), + 'score' => NULL, + 'index' => NULL, + 'highlight' => NULL, + ) + ), + 1 => eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state( + array( + 'valueObject' => array( + 'id' => 10, + 'title' => 'Anonymous User', + ), + 'score' => NULL, + 'index' => NULL, + 'highlight' => NULL, + ) + ), + 2 => eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state( + array( + 'valueObject' => array( + 'id' => 14, + 'title' => 'Administrator User', + ), + 'score' => NULL, + 'index' => NULL, + 'highlight' => NULL, + ) + ), + 3 => eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state( + array( + 'valueObject' => array( + 'id' => 41, + 'title' => 'Media', + ), + 'score' => NULL, + 'index' => NULL, + 'highlight' => NULL, + ) + ), + 4 => eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state( + array( + 'valueObject' => array( + 'id' => 45, + 'title' => 'Setup', + ), + 'score' => NULL, + 'index' => NULL, + 'highlight' => NULL, + ) + ), + 5 => eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state( + array( + 'valueObject' => array( + 'id' => 56, + 'title' => 'Design', + ), + 'score' => NULL, + 'index' => NULL, + 'highlight' => NULL, + ) + ), + 6 => eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state( + array( + 'valueObject' => array( + 'id' => 57, + 'title' => 'Home', + ), + 'score' => NULL, + 'index' => NULL, + 'highlight' => NULL, + ) + ), + ), + 'spellSuggestion' => NULL, + 'time' => 1, + 'timedOut' => NULL, + 'maxScore' => NULL, + 'totalCount' => 7, + ) +); diff --git a/eZ/Publish/API/Repository/Tests/_fixtures/Legacy/DepthLte.php b/eZ/Publish/API/Repository/Tests/_fixtures/Legacy/DepthLte.php new file mode 100644 index 00000000000..78e49d67f8b --- /dev/null +++ b/eZ/Publish/API/Repository/Tests/_fixtures/Legacy/DepthLte.php @@ -0,0 +1,190 @@ + array(), + 'searchHits' => array( + 0 => eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state( + array( + 'valueObject' => array( + 'id' => 4, + 'title' => 'Users', + ), + 'score' => NULL, + 'index' => NULL, + 'highlight' => NULL, + ) + ), + 1 => eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state( + array( + 'valueObject' => array( + 'id' => 11, + 'title' => 'Members', + ), + 'score' => NULL, + 'index' => NULL, + 'highlight' => NULL, + ) + ), + 2 => eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state( + array( + 'valueObject' => array( + 'id' => 12, + 'title' => 'Administrator users', + ), + 'score' => NULL, + 'index' => NULL, + 'highlight' => NULL, + ) + ), + 3 => eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state( + array( + 'valueObject' => array( + 'id' => 13, + 'title' => 'Editors', + ), + 'score' => NULL, + 'index' => NULL, + 'highlight' => NULL, + ) + ), + 4 => eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state( + array( + 'valueObject' => array( + 'id' => 41, + 'title' => 'Media', + ), + 'score' => NULL, + 'index' => NULL, + 'highlight' => NULL, + ) + ), + 5 => eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state( + array( + 'valueObject' => array( + 'id' => 42, + 'title' => 'Anonymous Users', + ), + 'score' => NULL, + 'index' => NULL, + 'highlight' => NULL, + ) + ), + 6 => eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state( + array( + 'valueObject' => array( + 'id' => 45, + 'title' => 'Setup', + ), + 'score' => NULL, + 'index' => NULL, + 'highlight' => NULL, + ) + ), + 7 => eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state( + array( + 'valueObject' => array( + 'id' => 49, + 'title' => 'Images', + ), + 'score' => NULL, + 'index' => NULL, + 'highlight' => NULL, + ) + ), + 8 => eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state( + array( + 'valueObject' => array( + 'id' => 50, + 'title' => 'Files', + ), + 'score' => NULL, + 'index' => NULL, + 'highlight' => NULL, + ) + ), + 9 => eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state( + array( + 'valueObject' => array( + 'id' => 51, + 'title' => 'Multimedia', + ), + 'score' => NULL, + 'index' => NULL, + 'highlight' => NULL, + ) + ), + 10 => eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state( + array( + 'valueObject' => array( + 'id' => 52, + 'title' => 'Common INI settings', + ), + 'score' => NULL, + 'index' => NULL, + 'highlight' => NULL, + ) + ), + 11 => eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state( + array( + 'valueObject' => array( + 'id' => 54, + 'title' => 'eZ Publish Demo Design (without demo content)', + ), + 'score' => NULL, + 'index' => NULL, + 'highlight' => NULL, + ) + ), + 12 => eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state( + array( + 'valueObject' => array( + 'id' => 56, + 'title' => 'Design', + ), + 'score' => NULL, + 'index' => NULL, + 'highlight' => NULL, + ) + ), + 13 => eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state( + array( + 'valueObject' => array( + 'id' => 57, + 'title' => 'Home', + ), + 'score' => NULL, + 'index' => NULL, + 'highlight' => NULL, + ) + ), + 14 => eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state( + array( + 'valueObject' => array( + 'id' => 58, + 'title' => 'Contact Us', + ), + 'score' => NULL, + 'index' => NULL, + 'highlight' => NULL, + ) + ), + 15 => eZ\Publish\API\Repository\Values\Content\Search\SearchHit::__set_state( + array( + 'valueObject' => array( + 'id' => 59, + 'title' => 'Partners', + ), + 'score' => NULL, + 'index' => NULL, + 'highlight' => NULL, + ) + ), + ), + 'spellSuggestion' => NULL, + 'time' => 1, + 'timedOut' => NULL, + 'maxScore' => NULL, + 'totalCount' => 16, + ) +); diff --git a/eZ/Publish/API/Repository/Values/Content/Query/Criterion/Depth.php b/eZ/Publish/API/Repository/Values/Content/Query/Criterion/Depth.php new file mode 100644 index 00000000000..1cde52a6140 --- /dev/null +++ b/eZ/Publish/API/Repository/Values/Content/Query/Criterion/Depth.php @@ -0,0 +1,78 @@ +operator}' for DateMetadata criterion handler." ); } } diff --git a/eZ/Publish/Core/Persistence/Legacy/Content/Search/Gateway/CriterionHandler/Depth.php b/eZ/Publish/Core/Persistence/Legacy/Content/Search/Gateway/CriterionHandler/Depth.php new file mode 100644 index 00000000000..b0164d2c016 --- /dev/null +++ b/eZ/Publish/Core/Persistence/Legacy/Content/Search/Gateway/CriterionHandler/Depth.php @@ -0,0 +1,93 @@ +getUniqueTableName(); + $column = $this->dbHandler->quoteColumn( 'depth', $table ); + + $query->leftJoin( + $query->alias( + $this->dbHandler->quoteTable( 'ezcontentobject_tree' ), + $this->dbHandler->quoteIdentifier( $table ) + ), + $query->expr->eq( + $this->dbHandler->quoteColumn( 'contentobject_id', $table ), + $this->dbHandler->quoteColumn( 'id', 'ezcontentobject' ) + ) + ); + + switch ( $criterion->operator ) + { + case Criterion\Operator::IN: + return $query->expr->in( + $column, + $criterion->value + ); + + case Criterion\Operator::BETWEEN: + return $query->expr->between( + $column, + $query->bindValue( $criterion->value[0] ), + $query->bindValue( $criterion->value[1] ) + ); + + case Criterion\Operator::EQ: + case Criterion\Operator::GT: + case Criterion\Operator::GTE: + case Criterion\Operator::LT: + case Criterion\Operator::LTE: + $operatorFunction = $this->comparatorMap[$criterion->operator]; + return $query->expr->$operatorFunction( + $column, + $query->bindValue( reset( $criterion->value ) ) + ); + + default: + throw new RuntimeException( "Unknown operator '{$criterion->operator}' for Depth criterion handler." ); + } + } +} + diff --git a/eZ/Publish/Core/Persistence/Legacy/Content/Search/Gateway/CriterionHandler/FieldValue/Handler.php b/eZ/Publish/Core/Persistence/Legacy/Content/Search/Gateway/CriterionHandler/FieldValue/Handler.php index a3223423ab1..9d03759866c 100644 --- a/eZ/Publish/Core/Persistence/Legacy/Content/Search/Gateway/CriterionHandler/FieldValue/Handler.php +++ b/eZ/Publish/Core/Persistence/Legacy/Content/Search/Gateway/CriterionHandler/FieldValue/Handler.php @@ -115,7 +115,7 @@ public function handle( ezcQuerySelect $query, Criterion $criterion, $column ) break; default: - throw new RuntimeException( 'Unknown operator.' ); + throw new RuntimeException( "Unknown operator '{$criterion->operator}' for Field criterion handler." ); } return $filter; diff --git a/eZ/Publish/Core/Persistence/Legacy/Content/Search/Gateway/CriterionHandler/RelationList.php b/eZ/Publish/Core/Persistence/Legacy/Content/Search/Gateway/CriterionHandler/RelationList.php index 0e5a1e6a5e1..010c9ddbc2c 100644 --- a/eZ/Publish/Core/Persistence/Legacy/Content/Search/Gateway/CriterionHandler/RelationList.php +++ b/eZ/Publish/Core/Persistence/Legacy/Content/Search/Gateway/CriterionHandler/RelationList.php @@ -141,7 +141,7 @@ public function handle( CriteriaConverter $converter, ezcQuerySelect $query, Cri ); default: - throw new RuntimeException( 'Unknown operator.' ); + throw new RuntimeException( "Unknown operator '{$criterion->operator}' for RelationList criterion handler." ); } } } diff --git a/eZ/Publish/Core/Persistence/Legacy/Handler.php b/eZ/Publish/Core/Persistence/Legacy/Handler.php index aa4671db4df..2cb53df6bc6 100644 --- a/eZ/Publish/Core/Persistence/Legacy/Handler.php +++ b/eZ/Publish/Core/Persistence/Legacy/Handler.php @@ -530,6 +530,7 @@ public function searchHandler() new CriterionHandler\Visibility( $db ), new CriterionHandler\UserMetadata( $db ), new CriterionHandler\RelationList( $db ), + new CriterionHandler\Depth( $db ), ) ), new Content\Search\Gateway\SortClauseConverter( diff --git a/eZ/Publish/Core/Persistence/Legacy/Tests/Content/SearchHandlerTest.php b/eZ/Publish/Core/Persistence/Legacy/Tests/Content/SearchHandlerTest.php index 4898eb4998b..a426490b346 100644 --- a/eZ/Publish/Core/Persistence/Legacy/Tests/Content/SearchHandlerTest.php +++ b/eZ/Publish/Core/Persistence/Legacy/Tests/Content/SearchHandlerTest.php @@ -224,6 +224,9 @@ protected function getContentSearchHandler( array $fullTextSearchConfiguration = new Content\Search\Gateway\CriterionHandler\RelationList( $this->getDatabaseHandler() ), + new Content\Search\Gateway\CriterionHandler\Depth( + $this->getDatabaseHandler() + ), ) ), new Content\Search\Gateway\SortClauseConverter( @@ -730,6 +733,141 @@ public function testContentSubtreeFilterEq() ); } + /** + * @return void + * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Search\Gateway\CriterionHandler\Depth + * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Search\Gateway\EzcDatabase + */ + public function testContentDepthFilterEq() + { + $this->assertSearchResults( + array( 4, 41, 45, 56, 65 ), + $this->getContentSearchHandler()->findContent( + new Query( + array( + 'criterion' => new Criterion\Depth( Criterion\Operator::EQ, 1 ), + 'limit' => 10, + ) + ) + ) + ); + } + + /** + * @return void + * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Search\Gateway\CriterionHandler\Depth + * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Search\Gateway\EzcDatabase + */ + public function testContentDepthFilterIn() + { + $this->assertSearchResults( + array( 4, 11, 12, 13, 41, 42, 45, 49, 50, 51, 52, 54, 56, 57, 65, 67, 75, 84, 94, 105, 151, 154, 165, 188, 225 ), + $this->getContentSearchHandler()->findContent( + new Query( + array( + 'criterion' => new Criterion\Depth( Criterion\Operator::IN, array( 1, 2 ) ), + ) + ) + ) + ); + } + + /** + * @return void + * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Search\Gateway\CriterionHandler\Depth + * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Search\Gateway\EzcDatabase + */ + public function testContentDepthFilterBetween() + { + $this->assertSearchResults( + array( 4, 41, 45, 56, 65 ), + $this->getContentSearchHandler()->findContent( + new Query( + array( + 'criterion' => new Criterion\Depth( Criterion\Operator::BETWEEN, array( 0, 1 ) ), + ) + ) + ) + ); + } + + /** + * @return void + * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Search\Gateway\CriterionHandler\Depth + * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Search\Gateway\EzcDatabase + */ + public function testContentDepthFilterGreaterThan() + { + $this->assertSearchResults( + array( 97, 100, 133, 134, 135, 137, 138, 140, 141, 142, 143, 146, 149, 172, 173, 175, 192, 194, 195, 196, 197, 198, 199, 200, 201, 203, 204, 205, 206, 207, 208, 209, 210, 212, 213 ), + $this->getContentSearchHandler()->findContent( + new Query( + array( + 'criterion' => new Criterion\Depth( Criterion\Operator::GT, 4 ), + ) + ) + ) + ); + } + + /** + * @return void + * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Search\Gateway\CriterionHandler\Depth + * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Search\Gateway\EzcDatabase + */ + public function testContentDepthFilterGreaterThanOrEqual() + { + $this->assertSearchResults( + array( 97, 100, 133, 134, 135, 137, 138, 140, 141, 142, 143, 146, 149, 172, 173, 175, 192, 194, 195, 196, 197, 198, 199, 200, 201, 203, 204, 205, 206, 207, 208, 209, 210, 212, 213 ), + $this->getContentSearchHandler()->findContent( + new Query( + array( + 'criterion' => new Criterion\Depth( Criterion\Operator::GTE, 5 ), + ) + ) + ) + ); + } + + /** + * @return void + * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Search\Gateway\CriterionHandler\Depth + * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Search\Gateway\EzcDatabase + */ + public function testContentDepthFilterLessThan() + { + $this->assertSearchResults( + array( 4, 41, 45, 56, 65 ), + $this->getContentSearchHandler()->findContent( + new Query( + array( + 'criterion' => new Criterion\Depth( Criterion\Operator::LT, 2 ), + 'limit' => 10, + ) + ) + ) + ); + } + + /** + * @return void + * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Search\Gateway\CriterionHandler\Depth + * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Search\Gateway\EzcDatabase + */ + public function testContentDepthFilterLessThanOrEqual() + { + $this->assertSearchResults( + array( 4, 11, 12, 13, 41, 42, 45, 49, 50, 51, 52, 54, 56, 57, 65, 67, 75, 84, 94, 105, 151, 154, 165, 188, 225 ), + $this->getContentSearchHandler()->findContent( + new Query( + array( + 'criterion' => new Criterion\Depth( Criterion\Operator::LTE, 2 ), + ) + ) + ) + ); + } + /** * @return void * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Search\Gateway\CriterionHandler\ContentTypeId