diff --git a/src/Dto/Search/Query/DefaultQueryOperator.php b/src/Dto/Search/Query/QueryOperator.php similarity index 78% rename from src/Dto/Search/Query/DefaultQueryOperator.php rename to src/Dto/Search/Query/QueryOperator.php index 68dbc2b..bc478d6 100644 --- a/src/Dto/Search/Query/DefaultQueryOperator.php +++ b/src/Dto/Search/Query/QueryOperator.php @@ -5,7 +5,7 @@ /** * @codeCoverageIgnore */ -enum DefaultQueryOperator: string +enum QueryOperator: string { case AND = 'AND'; case OR = 'OR'; diff --git a/src/Dto/Search/Query/SelectQuery.php b/src/Dto/Search/Query/SelectQuery.php index c1e39c6..661f992 100644 --- a/src/Dto/Search/Query/SelectQuery.php +++ b/src/Dto/Search/Query/SelectQuery.php @@ -28,7 +28,7 @@ public function __construct( public readonly array $sort, public readonly array $filter, public readonly array $facets, - public readonly DefaultQueryOperator $defaultQueryOperator + public readonly QueryOperator $defaultQueryOperator ) { } } diff --git a/src/Dto/Search/Query/SelectQueryBuilder.php b/src/Dto/Search/Query/SelectQueryBuilder.php index 552168f..fd9c573 100644 --- a/src/Dto/Search/Query/SelectQueryBuilder.php +++ b/src/Dto/Search/Query/SelectQueryBuilder.php @@ -28,8 +28,8 @@ class SelectQueryBuilder */ private array $facets = []; - private DefaultQueryOperator $defaultQueryOperator = - DefaultQueryOperator::AND; + private QueryOperator $defaultQueryOperator = + QueryOperator::AND; public function __construct() { @@ -105,7 +105,7 @@ public function facet(Facet ...$facetList): SelectQueryBuilder } public function defaultQueryOperator( - DefaultQueryOperator $defaultQueryOperator + QueryOperator $defaultQueryOperator ): SelectQueryBuilder { $this->defaultQueryOperator = $defaultQueryOperator; return $this; diff --git a/src/Service/Search/SolrSelect.php b/src/Service/Search/SolrSelect.php index 0ad8a37..d936886 100644 --- a/src/Service/Search/SolrSelect.php +++ b/src/Service/Search/SolrSelect.php @@ -4,11 +4,11 @@ namespace Atoolo\Search\Service\Search; -use Atoolo\Search\Dto\Search\Query\DefaultQueryOperator; use Atoolo\Search\Dto\Search\Query\Facet\FacetField; use Atoolo\Search\Dto\Search\Query\Facet\FacetMultiQuery; use Atoolo\Search\Dto\Search\Query\Facet\FacetQuery; use Atoolo\Search\Dto\Search\Query\Filter\Filter; +use Atoolo\Search\Dto\Search\Query\QueryOperator; use Atoolo\Search\Dto\Search\Query\SelectQuery; use Atoolo\Search\Dto\Search\Query\Sort\Criteria; use Atoolo\Search\Dto\Search\Query\Sort\Date; @@ -148,9 +148,9 @@ static function ($term) use ($solrQuery) { private function addQueryDefaultOperatorToSolrQuery( SolrSelectQuery $solrQuery, - DefaultQueryOperator $operator + QueryOperator $operator ): void { - if ($operator === DefaultQueryOperator::OR) { + if ($operator === QueryOperator::OR) { $solrQuery->setQueryDefaultOperator( SolrSelectQuery::QUERY_OPERATOR_OR ); diff --git a/test/Dto/Search/Query/SelectQueryBuilderTest.php b/test/Dto/Search/Query/SelectQueryBuilderTest.php index 1e0eef2..e02c4ce 100644 --- a/test/Dto/Search/Query/SelectQueryBuilderTest.php +++ b/test/Dto/Search/Query/SelectQueryBuilderTest.php @@ -4,9 +4,9 @@ namespace Atoolo\Search\Test\Dto\Search\Query; -use Atoolo\Search\Dto\Search\Query\DefaultQueryOperator; use Atoolo\Search\Dto\Search\Query\Facet\Facet; use Atoolo\Search\Dto\Search\Query\Filter\Filter; +use Atoolo\Search\Dto\Search\Query\QueryOperator; use Atoolo\Search\Dto\Search\Query\SelectQueryBuilder; use Atoolo\Search\Dto\Search\Query\Sort\Criteria; use InvalidArgumentException; @@ -141,10 +141,10 @@ public function testSetTwoFacetSWithSameKey(): void public function testSetQueryDefaultOperator(): void { - $this->builder->defaultQueryOperator(DefaultQueryOperator::AND); + $this->builder->defaultQueryOperator(QueryOperator::AND); $query = $this->builder->build(); $this->assertEquals( - DefaultQueryOperator::AND, + QueryOperator::AND, $query->defaultQueryOperator, 'unexpected queryDefaultOperator' ); diff --git a/test/Service/Search/SolrSelectTest.php b/test/Service/Search/SolrSelectTest.php index e1e410e..f71d27a 100644 --- a/test/Service/Search/SolrSelectTest.php +++ b/test/Service/Search/SolrSelectTest.php @@ -5,12 +5,12 @@ namespace Atoolo\Search\Test\Service\Search; use Atoolo\Resource\Resource; -use Atoolo\Search\Dto\Search\Query\DefaultQueryOperator; use Atoolo\Search\Dto\Search\Query\Facet\Facet; use Atoolo\Search\Dto\Search\Query\Facet\FacetMultiQuery; use Atoolo\Search\Dto\Search\Query\Facet\FacetQuery; use Atoolo\Search\Dto\Search\Query\Facet\ObjectTypeFacet; use Atoolo\Search\Dto\Search\Query\Filter\Filter; +use Atoolo\Search\Dto\Search\Query\QueryOperator; use Atoolo\Search\Dto\Search\Query\SelectQuery; use Atoolo\Search\Dto\Search\Query\Sort\Criteria; use Atoolo\Search\Dto\Search\Query\Sort\Date; @@ -93,7 +93,7 @@ public function testSelectEmpty(): void ], [], [], - DefaultQueryOperator::OR + QueryOperator::OR ); $searchResult = $this->searcher->select($query); @@ -116,7 +116,7 @@ public function testSelectWithText(): void ], [], [], - DefaultQueryOperator::OR + QueryOperator::OR ); $searchResult = $this->searcher->select($query); @@ -144,7 +144,7 @@ public function testSelectWithSort(): void ], [], [], - DefaultQueryOperator::OR + QueryOperator::OR ); $searchResult = $this->searcher->select($query); @@ -168,7 +168,7 @@ public function testSelectWithInvalidSort(): void [$sort], [], [], - DefaultQueryOperator::OR + QueryOperator::OR ); $this->expectException(InvalidArgumentException::class); @@ -185,7 +185,7 @@ public function testSelectWithAndDefaultOperator(): void [], [], [], - DefaultQueryOperator::AND + QueryOperator::AND ); $searchResult = $this->searcher->select($query); @@ -211,7 +211,7 @@ public function testSelectWithFilter(): void [], [$filter], [], - DefaultQueryOperator::OR + QueryOperator::OR ); $searchResult = $this->searcher->select($query); @@ -244,7 +244,7 @@ public function testSelectWithFacets(): void [], [], $facets, - DefaultQueryOperator::OR + QueryOperator::OR ); $searchResult = $this->searcher->select($query); @@ -271,7 +271,7 @@ public function testSelectWithInvalidFacets(): void [], [], $facets, - DefaultQueryOperator::OR + QueryOperator::OR ); $this->expectException(InvalidArgumentException::class); @@ -310,7 +310,7 @@ public function testResultFacets(): void [], [], $facets, - DefaultQueryOperator::OR + QueryOperator::OR ); $searchResult = $this->searcher->select($query); @@ -353,7 +353,7 @@ public function testInvalidResultFacets(): void [], [], $facets, - DefaultQueryOperator::OR + QueryOperator::OR ); $this->expectException(InvalidArgumentException::class);