Skip to content

Commit

Permalink
Integration tests for WT_PHPS
Browse files Browse the repository at this point in the history
  • Loading branch information
thomascorthals committed Nov 29, 2023
1 parent 77c1ddb commit 3de3f83
Show file tree
Hide file tree
Showing 11 changed files with 182 additions and 57 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
6 changes: 3 additions & 3 deletions src/Component/ResponseParser/FacetSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]
);
Expand Down Expand Up @@ -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']);
}

Expand Down Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Component/ResponseParser/MoreLikeThis.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Component/ResponseParser/Spellcheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Component/ResponseParser/Stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Component/ResponseParser/Terms.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/QueryType/Analysis/ResponseParser/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/QueryType/MoreLikeThis/ResponseParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/QueryType/Spellcheck/ResponseParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/QueryType/Terms/ResponseParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Loading

0 comments on commit 3de3f83

Please sign in to comment.