From 3de3f83f7a55d11e63f026a70adc2eb266175ca9 Mon Sep 17 00:00:00 2001 From: thomascorthals Date: Tue, 28 Nov 2023 17:43:57 +0100 Subject: [PATCH] Integration tests for WT_PHPS --- composer.json | 1 + src/Component/ResponseParser/FacetSet.php | 6 +- src/Component/ResponseParser/MoreLikeThis.php | 2 +- src/Component/ResponseParser/Spellcheck.php | 6 +- src/Component/ResponseParser/Stats.php | 4 +- src/Component/ResponseParser/Terms.php | 2 +- .../Analysis/ResponseParser/Field.php | 2 +- src/QueryType/MoreLikeThis/ResponseParser.php | 2 +- src/QueryType/Spellcheck/ResponseParser.php | 2 +- src/QueryType/Terms/ResponseParser.php | 2 +- .../AbstractTechproductsTestCase.php | 210 ++++++++++++++---- 11 files changed, 182 insertions(+), 57 deletions(-) diff --git a/composer.json b/composer.json index 6b5ba7d4c..9b4d3f68f 100755 --- a/composer.json +++ b/composer.json @@ -32,6 +32,7 @@ "phpstan/phpstan-deprecation-rules": "^1.0", "phpstan/phpstan-phpunit": "^1.0", "phpunit/phpunit": "^9.6", + "rawr/phpunit-data-provider": "^3.3", "roave/security-advisories": "dev-master", "symfony/event-dispatcher": "^5.0 || ^6.0" }, diff --git a/src/Component/ResponseParser/FacetSet.php b/src/Component/ResponseParser/FacetSet.php index df9e612a6..234858a77 100644 --- a/src/Component/ResponseParser/FacetSet.php +++ b/src/Component/ResponseParser/FacetSet.php @@ -245,7 +245,7 @@ protected function facetField(AbstractQuery $query, FacetInterface $facet, array return null; } - if ($query->getResponseWriter() === $query::WT_JSON) { + if ($query::WT_JSON === $query->getResponseWriter()) { $data['facet_counts']['facet_fields'][$key] = $this->convertToKeyValueArray( $data['facet_counts']['facet_fields'][$key] ); @@ -344,7 +344,7 @@ protected function facetRange(AbstractQuery $query, FacetInterface $facet, array $end = $data['end'] ?? null; $gap = $data['gap'] ?? null; - if ($query->getResponseWriter() === $query::WT_JSON) { + if ($query::WT_JSON === $query->getResponseWriter()) { $data['counts'] = $this->convertToKeyValueArray($data['counts']); } @@ -416,7 +416,7 @@ protected function pivotStats(AbstractQuery $query, PivotItem $pivotItem): void $stats->removeResult($key); foreach ($result as $field => $values) { - if ($query->getResponseWriter() === $query::WT_JSON) { + if ($query::WT_JSON === $query->getResponseWriter()) { $values = $this->normalizeParsedJsonStats($values); } diff --git a/src/Component/ResponseParser/MoreLikeThis.php b/src/Component/ResponseParser/MoreLikeThis.php index 05a3bff11..a1163970a 100644 --- a/src/Component/ResponseParser/MoreLikeThis.php +++ b/src/Component/ResponseParser/MoreLikeThis.php @@ -49,7 +49,7 @@ public function parse(?ComponentAwareQueryInterface $query, ?AbstractComponent $ // There seems to be a bug in Solr that json.nl=flat is ignored in a distributed search on Solr // Cloud. In that case the "map" format is returned which doesn't need to be converted. But we don't // use it in general because it has limitations for some components. - if (isset($searchResults[0]) && $query && $query->getResponseWriter() === $query::WT_JSON) { + if (isset($searchResults[0]) && $query && $query::WT_JSON === $query->getResponseWriter()) { // We have a "flat" json result. $searchResults = $this->convertToKeyValueArray($searchResults); } diff --git a/src/Component/ResponseParser/Spellcheck.php b/src/Component/ResponseParser/Spellcheck.php index 3fb364ae1..0cd112548 100644 --- a/src/Component/ResponseParser/Spellcheck.php +++ b/src/Component/ResponseParser/Spellcheck.php @@ -43,7 +43,7 @@ public function parse(?ComponentAwareQueryInterface $query, ?AbstractComponent $ \count($data['spellcheck']['suggestions']) > 0 ) { $spellcheckResults = $data['spellcheck']['suggestions']; - if ($query && $query->getResponseWriter() === $query::WT_JSON) { + if ($query && $query::WT_JSON === $query->getResponseWriter()) { $spellcheckResults = $this->convertToKeyValueArray($spellcheckResults); } @@ -111,7 +111,7 @@ protected function parseCollation(?AbstractQuery $queryObject, $values): array $collations[] = new Collation($value, null, []); } } else { - if ($queryObject && $queryObject->getResponseWriter() === $queryObject::WT_JSON) { + if ($queryObject && $queryObject::WT_JSON === $queryObject->getResponseWriter()) { if (\is_array(current($values))) { foreach ($values as $key => $value) { if (\array_key_exists('collationQuery', $value)) { @@ -150,7 +150,7 @@ protected function parseCollation(?AbstractQuery $queryObject, $values): array $corrections = []; if (null !== $correctionResult) { - if ($queryObject && $queryObject->getResponseWriter() === $queryObject::WT_JSON) { + if ($queryObject && $queryObject::WT_JSON === $queryObject->getResponseWriter()) { $correctionResult = $this->convertToKeyValueArray($correctionResult); } diff --git a/src/Component/ResponseParser/Stats.php b/src/Component/ResponseParser/Stats.php index 5d103faa1..3be6d9670 100644 --- a/src/Component/ResponseParser/Stats.php +++ b/src/Component/ResponseParser/Stats.php @@ -50,7 +50,7 @@ public function parse(?ComponentAwareQueryInterface $query, ?AbstractComponent $ if (isset($stats['facets'])) { foreach ($stats['facets'] as $facetField => $values) { foreach ($values as $value => $valueStats) { - if ($query->getResponseWriter() === $query::WT_JSON) { + if ($query::WT_JSON === $query->getResponseWriter()) { $valueStats = $this->normalizeParsedJsonStats($valueStats); } @@ -59,7 +59,7 @@ public function parse(?ComponentAwareQueryInterface $query, ?AbstractComponent $ } } - if ($query->getResponseWriter() === $query::WT_JSON) { + if ($query::WT_JSON === $query->getResponseWriter()) { $stats = $this->normalizeParsedJsonStats($stats); } diff --git a/src/Component/ResponseParser/Terms.php b/src/Component/ResponseParser/Terms.php index 653f6630a..d9bf74eab 100644 --- a/src/Component/ResponseParser/Terms.php +++ b/src/Component/ResponseParser/Terms.php @@ -41,7 +41,7 @@ public function parse(?ComponentAwareQueryInterface $query, ?AbstractComponent $ // There seems to be a bug in Solr that json.nl=flat is ignored in a distributed search on Solr // Cloud. In that case the "map" format is returned which doesn't need to be converted. But we don't // use it in general because it has limitations for some components. - if (isset($termData[0]) && $query && $query->getResponseWriter() === $query::WT_JSON) { + if (isset($termData[0]) && $query && $query::WT_JSON === $query->getResponseWriter()) { // We have a "flat" json result. $termData = $this->convertToKeyValueArray($termData); } diff --git a/src/QueryType/Analysis/ResponseParser/Field.php b/src/QueryType/Analysis/ResponseParser/Field.php index b60f975e0..be32737c3 100644 --- a/src/QueryType/Analysis/ResponseParser/Field.php +++ b/src/QueryType/Analysis/ResponseParser/Field.php @@ -77,7 +77,7 @@ protected function parseTypes(ResultInterface $result, array $data): array foreach ($data as $fieldKey => $fieldData) { $types = []; foreach ($fieldData as $typeKey => $typeData) { - if ($query->getResponseWriter() === $query::WT_JSON) { + if ($query::WT_JSON === $query->getResponseWriter()) { // fix for extra level for key fields if (1 === \count($typeData)) { $typeData = current($typeData); diff --git a/src/QueryType/MoreLikeThis/ResponseParser.php b/src/QueryType/MoreLikeThis/ResponseParser.php index 162ed64aa..3e25f43a5 100644 --- a/src/QueryType/MoreLikeThis/ResponseParser.php +++ b/src/QueryType/MoreLikeThis/ResponseParser.php @@ -34,7 +34,7 @@ public function parse(ResultInterface $result): array if (isset($data['interestingTerms']) && 'none' !== $query->getInterestingTerms()) { $terms = $data['interestingTerms']; if ('details' === $query->getInterestingTerms()) { - if ($query->getResponseWriter() === $query::WT_JSON) { + if ($query::WT_JSON === $query->getResponseWriter()) { $terms = $this->convertToKeyValueArray($terms); } } diff --git a/src/QueryType/Spellcheck/ResponseParser.php b/src/QueryType/Spellcheck/ResponseParser.php index 115debcea..5e8f95458 100644 --- a/src/QueryType/Spellcheck/ResponseParser.php +++ b/src/QueryType/Spellcheck/ResponseParser.php @@ -38,7 +38,7 @@ public function parse(ResultInterface $result): array $suggestResults = $data['spellcheck']['suggestions']; $termClass = $query->getOption('termclass'); - if ($query->getResponseWriter() === $query::WT_JSON) { + if ($query::WT_JSON === $query->getResponseWriter()) { $suggestResults = $this->convertToKeyValueArray($suggestResults); } diff --git a/src/QueryType/Terms/ResponseParser.php b/src/QueryType/Terms/ResponseParser.php index 6602d4b14..24e386b44 100644 --- a/src/QueryType/Terms/ResponseParser.php +++ b/src/QueryType/Terms/ResponseParser.php @@ -42,7 +42,7 @@ public function parse(ResultInterface $result): array // There seems to be a bug in Solr that json.nl=flat is ignored in a distributed search on Solr // Cloud. In that case the "map" format is returned which doesn't need to be converted. But we don't // use it in general because it has limitations for some components. - if (isset($terms[0]) && $query->getResponseWriter() === $query::WT_JSON) { + if (isset($terms[0]) && $query::WT_JSON === $query->getResponseWriter()) { // We have a "flat" json result. $terms = $this->convertToKeyValueArray($terms); } diff --git a/tests/Integration/AbstractTechproductsTestCase.php b/tests/Integration/AbstractTechproductsTestCase.php index 2fb3143fd..0b7e67f1e 100644 --- a/tests/Integration/AbstractTechproductsTestCase.php +++ b/tests/Integration/AbstractTechproductsTestCase.php @@ -64,6 +64,7 @@ use Solarium\Tests\Integration\Query\CustomSelfQuery; use Solarium\Tests\Integration\Query\CustomStaticQuery; use Symfony\Contracts\EventDispatcher\Event; +use TRegx\PhpUnit\DataProviders\DataProvider; abstract class AbstractTechproductsTestCase extends TestCase { @@ -206,9 +207,21 @@ public static function setUpBeforeClass(): void } } + /** + * This data provider can be used to test functional equivalence in parsing results + * from the same queries with different response writers. + */ + public function responseWriterProvider(): array + { + return [ + [AbstractQuery::WT_JSON], + [AbstractQuery::WT_PHPS], + ]; + } + /** * This data provider should be used by all UpdateQuery tests that don't test request - * format specific Commands to ensure functional equivalance between the formats. + * format specific Commands to ensure functional equivalence between the formats. */ public function updateRequestFormatProvider(): array { @@ -218,9 +231,25 @@ public function updateRequestFormatProvider(): array ]; } - public function testPing() + /** + * This data provider crosees {@see updateRequestFormatProvider()} with + * {@see responseWriterProvider()}. + */ + public function crossRequestFormatResponseWriterProvider(): DataProvider + { + return DataProvider::cross( + $this->updateRequestFormatProvider(), + $this->responseWriterProvider(), + ); + } + + /** + * @dataProvider responseWriterProvider + */ + public function testPing(string $responseWriter) { $ping = self::$client->createPing(); + $ping->setResponseWriter($responseWriter); $result = self::$client->ping($ping); $this->assertSame(0, $result->getStatus()); $this->assertSame('OK', $result->getPingStatus()); @@ -232,9 +261,13 @@ public function testPing() } } - public function testSelect(): SelectResult + /** + * @dataProvider responseWriterProvider + */ + public function testSelect(string $responseWriter) { $select = self::$client->createSelect(); + $select->setResponseWriter($responseWriter); $select->setSorts(['id' => SelectQuery::SORT_ASC]); $result = self::$client->select($select); $this->assertSame(32, $result->getNumFound()); @@ -257,17 +290,14 @@ public function testSelect(): SelectResult 'GB18030TEST', 'GBP', ], $ids); - - return $result; } - /** - * @depends testSelect - * - * @param SelectResult $result - */ - public function testJsonSerializeSelectResult(SelectResult $result) + public function testJsonSerializeSelectResult() { + $select = self::$client->createSelect(); + $select->setResponseWriter(AbstractQuery::WT_JSON); + $result = self::$client->select($select); + $expectedJson = $result->getResponse()->getBody(); // this only calls SelectResult::jsonSerialize() which gets the document data from the parsed response @@ -282,9 +312,9 @@ public function testJsonSerializeSelectResult(SelectResult $result) /** * @see https://solr.apache.org/guide/the-standard-query-parser.html#escaping-special-characters * - * @dataProvider updateRequestFormatProvider + * @dataProvider crossRequestFormatResponseWriterProvider */ - public function testEscapes(string $requestFormat) + public function testEscapes(string $requestFormat, string $responseWriter) { $escapeChars = [' ', '+', '-', '&&', '||', '!', '(', ')', '{', '}', '[', ']', '^', '"', '~', '*', '?', ':', '/', '\\']; $cat = [implode('', $escapeChars)]; @@ -295,6 +325,7 @@ public function testEscapes(string $requestFormat) $update = self::$client->createUpdate(); $update->setRequestFormat($requestFormat); + $update->setResponseWriter($responseWriter); $doc = $update->createDocument(); $doc->setField('id', 'solarium-test-escapes'); $doc->setField('name', 'Solarium Test Escapes'); @@ -305,6 +336,7 @@ public function testEscapes(string $requestFormat) // check if stored correctly in index $select = self::$client->createSelect(); + $select->setResponseWriter($responseWriter); $select->setQuery('id:%T1%', ['solarium-test-escapes']); $result = self::$client->select($select); $this->assertCount(1, $result); @@ -336,13 +368,14 @@ public function testEscapes(string $requestFormat) /** * @see https://github.com/solariumphp/solarium/issues/1104 * - * @dataProvider updateRequestFormatProvider + * @dataProvider crossRequestFormatResponseWriterProvider */ - public function testPhraseQuery(string $requestFormat) + public function testPhraseQuery(string $requestFormat, string $responseWriter) { $phrase = "^The 17\" O'Conner && O`Series \n OR a || 1%2 1~2 1*2 \r\n book? \r \twhat \\ text: }{ )( ][ - + // \n\r ok? end$"; $update = self::$client->createUpdate(); + $update->setResponseWriter($responseWriter); $update->setRequestFormat($requestFormat); $doc = $update->createDocument(); $doc->setField('id', 'solarium-test-phrase'); @@ -364,6 +397,7 @@ public function testPhraseQuery(string $requestFormat) // check if stored correctly in index $select = self::$client->createSelect(); + $select->setResponseWriter($responseWriter); $select->setQuery('id:solarium-test-phrase'); $result = self::$client->select($select); $this->assertSame([$phrase], $result->getIterator()->current()->getFields()['cat']); @@ -393,9 +427,9 @@ public function testPhraseQuery(string $requestFormat) * @see https://github.com/solariumphp/solarium/issues/974 * @see https://solr.apache.org/guide/local-parameters-in-queries.html#basic-syntax-of-local-parameters * - * @dataProvider updateRequestFormatProvider + * @dataProvider crossRequestFormatResponseWriterProvider */ - public function testLocalParamValueEscapes(string $requestFormat) + public function testLocalParamValueEscapes(string $requestFormat, string $responseWriter) { $categories = [ 'solarium-test-localparamvalue-escapes', @@ -410,6 +444,7 @@ public function testLocalParamValueEscapes(string $requestFormat) ]; $update = self::$client->createUpdate(); + $update->setResponseWriter($responseWriter); $update->setRequestFormat($requestFormat); $doc = $update->createDocument(); $doc->setField('id', 'solarium-test-localparamvalue-escapes'); @@ -420,6 +455,7 @@ public function testLocalParamValueEscapes(string $requestFormat) self::$client->update($update); $select = self::$client->createSelect(); + $select->setResponseWriter($responseWriter); $select->setRows(0); $facetSet = $select->getFacetSet(); @@ -459,9 +495,13 @@ public function testLocalParamValueEscapes(string $requestFormat) $this->assertCount(0, $result); } - public function testRangeQueries() + /** + * @dataProvider responseWriterProvider + */ + public function testRangeQueries(string $responseWriter) { $select = self::$client->createSelect(); + $select->setResponseWriter($responseWriter); $select->setQuery( $select->getHelper()->rangeQuery('price', null, 80) @@ -693,10 +733,13 @@ public function testFacetHighlightSpellcheckComponent() /** * @see https://solr.apache.org/guide/solr/latest/query-guide/faceting.html#combining-stats-component-with-pivots + * + * @dataProvider responseWriterProvider */ - public function testFacetPivotsWithStatsComponent() + public function testFacetPivotsWithStatsComponent(string $responseWriter) { $select = self::$client->createSelect(); + $select->setResponseWriter($responseWriter); $facetSet = $select->getFacetSet(); $facet = $facetSet->createFacetPivot('piv1'); @@ -725,19 +768,18 @@ public function testFacetPivotsWithStatsComponent() } /** - * @testWith ["METHOD_UNIFIED"] - * ["METHOD_ORIGINAL"] - * ["METHOD_FASTVECTOR"] + * @dataProvider crossHighlightingMethodResponseWriterProvider */ - public function testHighlightingComponentMethods(string $method) + public function testHighlightingComponentMethods(string $method, string $responseWriter) { $select = self::$client->createSelect(); + $select->setResponseWriter($responseWriter); // The self-defined "componentdemo" request handler has a highlighting component. $select->setHandler('componentdemo'); $select->setQuery('id:F8V7067-APL-KIT'); $highlighting = $select->getHighlighting(); - $highlighting->setMethod(\constant(Highlighting::class.'::'.$method)); + $highlighting->setMethod($method); $highlighting->setFields('name, features'); $highlighting->getField('features')->setSimplePrefix('')->setSimplePostfix(''); $highlighting->setQuery('(power cord) OR (power adapter)'); @@ -774,6 +816,20 @@ public function testHighlightingComponentMethods(string $method) ); } + public function crossHighlightingMethodResponseWriterProvider(): DataProvider + { + $highlightingMethods = [ + [Highlighting::METHOD_UNIFIED], + [Highlighting::METHOD_ORIGINAL], + [Highlighting::METHOD_FASTVECTOR], + ]; + + return DataProvider::cross( + $highlightingMethods, + $this->responseWriterProvider(), + ); + } + /** * @see https://github.com/solariumphp/solarium/issues/184 */ @@ -838,13 +894,16 @@ public function testSpellCheckComponentWithSameWordMisspelledMultipleTimes() * * @see https://cwiki.apache.org/confluence/display/solr/SolrCloud%20/#SolrCloud-KnownLimitations * + * @dataProvider responseWriterProvider + * * @group skip_for_solr_cloud */ - public function testGroupingComponent() + public function testGroupingComponent(string $responseWriter) { self::$client->registerQueryType('grouping', GroupingTestQuery::class); /** @var GroupingTestQuery $select */ $select = self::$client->createQuery('grouping'); + $select->setResponseWriter($responseWriter); $select->setQuery('solr memory'); $select->setFields('id'); $select->addSort('manu_exact', SelectQuery::SORT_ASC); @@ -964,16 +1023,19 @@ public function testGroupingComponent() * Skipped for SolrCloud because maxScore is included in distributed search results even if score is not requested (SOLR-6612). * This makes the test fail on SolrCloud for queries that don't fetch a score and thus aren't affected by SOLR-13839. * - * @group skip_for_solr_cloud - * * @see https://issues.apache.org/jira/browse/SOLR-13839 * @see https://issues.apache.org/jira/browse/SOLR-6612 + * + * @dataProvider responseWriterProvider + * + * @group skip_for_solr_cloud */ - public function testGroupingComponentFixForSolr13839() + public function testGroupingComponentFixForSolr13839(string $responseWriter) { self::$client->registerQueryType('grouping', GroupingTestQuery::class); /** @var GroupingTestQuery $select */ $select = self::$client->createQuery('grouping'); + $select->setResponseWriter($responseWriter); // without score in the fl parameter, result groups don't have a maxScore $select->setFields('id'); $grouping = $select->getGrouping(); @@ -1016,9 +1078,13 @@ public function testGroupingComponentFixForSolr13839() $this->assertNull($queryGroup->getMaximumScore()); } - public function testMoreLikeThisComponent() + /** + * @dataProvider responseWriterProvider + */ + public function testMoreLikeThisComponent(string $responseWriter) { $select = self::$client->createSelect(); + $select->setResponseWriter($responseWriter); $select->setQuery('apache'); $select->setSorts(['id' => SelectQuery::SORT_ASC]); @@ -1090,11 +1156,14 @@ public function testMoreLikeThisComponent() * @see https://issues.apache.org/jira/browse/SOLR-4414 * @see https://issues.apache.org/jira/browse/SOLR-5480 * + * @dataProvider responseWriterProvider + * * @group skip_for_solr_cloud */ - public function testMoreLikeThisQuery() + public function testMoreLikeThisQuery(string $responseWriter) { $query = self::$client->createMoreLikethis(); + $query->setResponseWriter($responseWriter); // the document we query to get similar documents for $query->setQuery('id:SP2514N'); @@ -1145,11 +1214,14 @@ public function testMoreLikeThisQuery() * @see https://issues.apache.org/jira/browse/SOLR-4414 * @see https://issues.apache.org/jira/browse/SOLR-5480 * + * @dataProvider responseWriterProvider + * * @group skip_for_solr_cloud */ - public function testMoreLikeThisStream() + public function testMoreLikeThisStream(string $responseWriter) { $query = self::$client->createMoreLikethis(); + $query->setResponseWriter($responseWriter); // the supplied text we want similar documents for $text = <<getInterestingTerms(); } - public function testQueryElevation() + /** + * @dataProvider responseWriterProvider + */ + public function testQueryElevation(string $responseWriter) { $select = self::$client->createSelect(); + $select->setResponseWriter($responseWriter); // In the techproducts example, the request handler "select" doesn't contain a query elevation component. // But the "elevate" request handler does. $select->setHandler('elevate'); @@ -1233,9 +1309,13 @@ public function testQueryElevation() $this->assertFalse($document->{'[elevated]'}); } - public function testSpatial() + /** + * @dataProvider responseWriterProvider + */ + public function testSpatial(string $responseWriter) { $select = self::$client->createSelect(); + $select->setResponseWriter($responseWriter); $select->setQuery( $select->getHelper()->geofilt('store', 40, -100, 100000) @@ -1290,9 +1370,13 @@ public function testSpellcheck() ], $words); } - public function testSuggester() + /** + * @dataProvider responseWriterProvider + */ + public function testSuggester(string $responseWriter) { $suggester = self::$client->createSuggester(); + $suggester->setResponseWriter($responseWriter); // The techproducts example doesn't provide a default suggester, but 'mySuggester'. $suggester->setDictionary('mySuggester'); $suggester->setQuery('electronics'); @@ -1314,9 +1398,13 @@ public function testSuggester() $this->assertContains('electronics and stuff2', $phrases); } - public function testTerms() + /** + * @dataProvider responseWriterProvider + */ + public function testTerms(string $responseWriter) { $terms = self::$client->createTerms(); + $terms->setResponseWriter($responseWriter); $terms->setFields('name'); // Setting distrib to true in a non cloud setup causes exceptions. @@ -1340,10 +1428,14 @@ public function testTerms() ], $result->getTerms('name')); } - public function testTermsComponent() + /** + * @dataProvider responseWriterProvider + */ + public function testTermsComponent(string $responseWriter) { self::$client->registerQueryType('test', TermsTestQuery::class); $select = self::$client->createQuery('test'); + $select->setResponseWriter($responseWriter); // Setting distrib to true in a non cloud setup causes exceptions. if ($this instanceof AbstractCloudTestCase) { @@ -1403,11 +1495,12 @@ public function testTermsComponent() } /** - * @dataProvider updateRequestFormatProvider + * @dataProvider crossRequestFormatResponseWriterProvider */ - public function testUpdate(string $requestFormat) + public function testUpdate(string $requestFormat, string $responseWriter) { $select = self::$client->createSelect(); + $select->setResponseWriter($responseWriter); $select->setQuery('cat:solarium-test'); $select->addSort('id', $select::SORT_ASC); $select->setFields('id,name,price,content'); @@ -1415,6 +1508,7 @@ public function testUpdate(string $requestFormat) // add, but don't commit $update = self::$client->createUpdate(); $update->setRequestFormat($requestFormat); + $update->setResponseWriter($responseWriter); $doc1 = $update->createDocument(); $doc1->setField('id', 'solarium-test-1'); $doc1->setField('name', 'Solarium Test 1'); @@ -1435,6 +1529,7 @@ public function testUpdate(string $requestFormat) // commit $update = self::$client->createUpdate(); $update->setRequestFormat($requestFormat); + $update->setResponseWriter($responseWriter); $update->addCommit(true, true); self::$client->update($update); $result = self::$client->select($select); @@ -1459,6 +1554,7 @@ public function testUpdate(string $requestFormat) // delete by id and commit $update = self::$client->createUpdate(); $update->setRequestFormat($requestFormat); + $update->setResponseWriter($responseWriter); $update->addDeleteById('solarium-test-1'); $update->addCommit(true, true); self::$client->update($update); @@ -1473,6 +1569,7 @@ public function testUpdate(string $requestFormat) // delete by query and commit $update = self::$client->createUpdate(); $update->setRequestFormat($requestFormat); + $update->setResponseWriter($responseWriter); $update->addDeleteQuery('cat:solarium-test'); $update->addCommit(true, true); self::$client->update($update); @@ -1482,6 +1579,7 @@ public function testUpdate(string $requestFormat) // optimize $update = self::$client->createUpdate(); $update->setRequestFormat($requestFormat); + $update->setResponseWriter($responseWriter); $update->addOptimize(true, false); $response = self::$client->update($update); $this->assertSame(0, $response->getStatus()); @@ -1491,6 +1589,7 @@ public function testUpdate(string $requestFormat) // add, rollback, commit $update = self::$client->createUpdate(); $update->setRequestFormat($requestFormat); + $update->setResponseWriter($responseWriter); $doc1 = $update->createDocument(); $doc1->setField('id', 'solarium-test-1'); $doc1->setField('name', 'Solarium Test 1'); @@ -1508,9 +1607,13 @@ public function testUpdate(string $requestFormat) } } - public function testUpdateRawXml() + /** + * @dataProvider responseWriterProvider + */ + public function testUpdateRawXml(string $responseWriter) { $select = self::$client->createSelect(); + $select->setResponseWriter($responseWriter); $select->setQuery('cat:solarium-test'); $select->addSort('id', $select::SORT_ASC); $select->setFields('id,name,price,content'); @@ -1518,6 +1621,7 @@ public function testUpdateRawXml() // raw add and raw commit $update = self::$client->createUpdate(); $update->setRequestFormat(UpdateQuery::REQUEST_FORMAT_XML); + $update->setResponseWriter($responseWriter); $update->addRawXmlCommand('solarium-test-1Solarium Test 1solarium-test3.14'); $update->addRawXmlCommand(''); self::$client->update($update); @@ -1532,6 +1636,7 @@ public function testUpdateRawXml() // grouped mixed raw commands $update = self::$client->createUpdate(); $update->setRequestFormat(UpdateQuery::REQUEST_FORMAT_XML); + $update->setResponseWriter($responseWriter); $update->addRawXmlCommand('solarium-test-2Solarium Test 2solarium-test42'); $update->addRawXmlCommand('solarium-test-1'); self::$client->update($update); @@ -1546,6 +1651,7 @@ public function testUpdateRawXml() // raw delete and regular commit $update = self::$client->createUpdate(); $update->setRequestFormat(UpdateQuery::REQUEST_FORMAT_XML); + $update->setResponseWriter($responseWriter); $update->addRawXmlCommand('cat:solarium-test'); $update->addCommit(true, true); self::$client->update($update); @@ -1555,6 +1661,7 @@ public function testUpdateRawXml() // add from UTF-8 encoded files without and with Byte Order Mark and XML declaration $update = self::$client->createUpdate(); $update->setRequestFormat(UpdateQuery::REQUEST_FORMAT_XML); + $update->setResponseWriter($responseWriter); foreach (glob(__DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'testxml[1234]-add*.xml') as $file) { $update->addRawXmlFile($file); } @@ -1564,6 +1671,7 @@ public function testUpdateRawXml() // add from non-UTF-8 encoded file $update = self::$client->createUpdate(); $update->setRequestFormat(UpdateQuery::REQUEST_FORMAT_XML); + $update->setResponseWriter($responseWriter); $update->setInputEncoding('ISO-8859-1'); $update->addRawXmlFile(__DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'testxml5-add-iso-8859-1.xml'); $update->addCommit(true, true); @@ -1605,6 +1713,7 @@ public function testUpdateRawXml() // delete from file with grouped delete commands $update = self::$client->createUpdate(); $update->setRequestFormat(UpdateQuery::REQUEST_FORMAT_XML); + $update->setResponseWriter($responseWriter); $update->addRawXmlFile(__DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'testxml6-delete.xml'); $update->addCommit(true, true); self::$client->update($update); @@ -2948,9 +3057,13 @@ public function testUpdateWithoutControlCharacterFiltering() self::$client->update($update); } - public function testReRankQuery() + /** + * @dataProvider responseWriterProvider + */ + public function testReRankQuery(string $responseWriter) { $select = self::$client->createSelect(); + $select->setResponseWriter($responseWriter); $select->setQuery('inStock:true'); $select->setRows(2); $result = self::$client->select($select); @@ -3637,12 +3750,15 @@ public function testLoadbalancerFailover() } /** + * @dataProvider responseWriterProvider + * * @group skip_for_solr_cloud */ - public function testMinimumScoreFilterWithGrouping() + public function testMinimumScoreFilterWithGrouping(string $responseWriter) { $filter = self::$client->getPlugin('minimumscorefilter'); $query = self::$client->createQuery($filter::QUERY_TYPE); + $query->setResponseWriter($responseWriter); $query->setQuery('*:*'); $groupComponent = $query->getGrouping(); @@ -3796,9 +3912,13 @@ public function testParallelExecution() self::$client->removeEndpoint('invalid'); } - public function testPrefetchIterator() + /** + * @dataProvider responseWriterProvider + */ + public function testPrefetchIterator(string $responseWriter) { $select = self::$client->createSelect(); + $select->setResponseWriter($responseWriter); $select->addSort('id', SelectQuery::SORT_ASC); /** @var PrefetchIterator $prefetch */ $prefetch = self::$client->getPlugin('prefetchiterator'); @@ -3818,9 +3938,13 @@ public function testPrefetchIterator() self::$client->removePlugin('prefetchiterator'); } - public function testPrefetchIteratorWithCursorMark() + /** + * @dataProvider responseWriterProvider + */ + public function testPrefetchIteratorWithCursorMark(string $responseWriter) { $select = self::$client->createSelect(); + $select->setResponseWriter($responseWriter); $select->setCursorMark('*'); $select->addSort('id', SelectQuery::SORT_ASC); /** @var PrefetchIterator $prefetch */