Skip to content

Commit 4d295b0

Browse files
Solr 9.6 → 9.7 for integration tests
1 parent daf9df3 commit 4d295b0

File tree

3 files changed

+48
-28
lines changed

3 files changed

+48
-28
lines changed

.github/workflows/run-tests.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ jobs:
5151
ref: branch_8_11
5252
path: lucene-solr
5353

54-
- name: Checkout solr 9.6
54+
- name: Checkout solr 9.7
5555
if: matrix.solr == 9
5656
uses: actions/checkout@v4
5757
with:
5858
repository: apache/solr
59-
ref: branch_9_6
59+
ref: branch_9_7
6060
path: lucene-solr
6161

6262
- name: Start Solr ${{ matrix.solr }} in ${{ matrix.mode }} mode

tests/Integration/AbstractTechproductsTestCase.php

+44-24
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Solarium\Core\Client\Request;
2121
use Solarium\Core\Client\Response;
2222
use Solarium\Core\Event\Events;
23+
use Solarium\Core\Query\AbstractDocument;
2324
use Solarium\Core\Query\AbstractQuery;
2425
use Solarium\Core\Query\Helper;
2526
use Solarium\Core\Query\RequestBuilderInterface;
@@ -95,6 +96,25 @@ abstract class AbstractTechproductsTestCase extends TestCase
9596
*/
9697
protected static $isSolrOnWindows;
9798

99+
/**
100+
* Asserts that a document contains exactly the expected fields.
101+
*
102+
* {@internal We used to compare the actual array of fields directly to the
103+
* expected array with {@see assertSame()} but that stopped working
104+
* with Solr 9.7.0 because the order in which fields are returned
105+
* has changed for some queries. There was never a guarantee that
106+
* Solr maintains field order (SOLR-1190), we had just been lucky
107+
* that it had always happened to work out before.}
108+
*/
109+
public static function assertDocumentHasFields(array $expectedFields, AbstractDocument $actualDocument, string $message = ''): void
110+
{
111+
$actualFields = $actualDocument->getFields();
112+
ksort($actualFields);
113+
ksort($expectedFields);
114+
115+
static::assertSame($expectedFields, $actualFields, $message);
116+
}
117+
98118
abstract protected static function createTechproducts(): void;
99119

100120
public static function setUpBeforeClass(): void
@@ -187,16 +207,16 @@ public static function setUpBeforeClass(): void
187207
$select->setQuery('êâîôû');
188208
$result = self::$client->select($select);
189209
static::assertCount(1, $result);
190-
static::assertSame([
210+
static::assertDocumentHasFields([
191211
'id' => 'UTF8TEST',
192-
], $result->getIterator()->current()->getFields());
212+
], $result->getIterator()->current());
193213

194214
$select->setQuery('这是一个功能');
195215
$result = self::$client->select($select);
196216
static::assertCount(1, $result);
197-
static::assertSame([
217+
static::assertDocumentHasFields([
198218
'id' => 'GB18030TEST',
199-
], $result->getIterator()->current()->getFields());
219+
], $result->getIterator()->current());
200220
} catch (\Exception $e) {
201221
self::tearDownAfterClass();
202222
static::markTestSkipped('Solr techproducts sample data not indexed properly.');
@@ -551,15 +571,15 @@ public function testRangeQueries(string $responseWriter)
551571
$result = self::$client->select($select);
552572
$this->assertSame(2, $result->getNumFound());
553573
$iterator = $result->getIterator();
554-
$this->assertSame([
574+
$this->assertDocumentHasFields([
555575
'id' => 'MA147LL/A',
556576
'manufacturedate_dt' => '2005-10-12T08:00:00Z',
557-
], $iterator->current()->getFields());
577+
], $iterator->current());
558578
$iterator->next();
559-
$this->assertSame([
579+
$this->assertDocumentHasFields([
560580
'id' => 'F8V7067-APL-KIT',
561581
'manufacturedate_dt' => '2005-08-01T16:30:25Z',
562-
], $iterator->current()->getFields());
582+
], $iterator->current());
563583

564584
// VS1GB400C3 costs 74.99, SP2514N costs 92.0, 0579B002 costs 179.99
565585
$select->setFields('id,price');
@@ -570,63 +590,63 @@ public function testRangeQueries(string $responseWriter)
570590
$result = self::$client->select($select);
571591
$this->assertSame(3, $result->getNumFound());
572592
$iterator = $result->getIterator();
573-
$this->assertSame([
593+
$this->assertDocumentHasFields([
574594
'id' => 'VS1GB400C3',
575595
'price' => 74.99,
576-
], $iterator->current()->getFields());
596+
], $iterator->current());
577597
$iterator->next();
578-
$this->assertSame([
598+
$this->assertDocumentHasFields([
579599
'id' => 'SP2514N',
580600
'price' => 92.0,
581-
], $iterator->current()->getFields());
601+
], $iterator->current());
582602
$iterator->next();
583-
$this->assertSame([
603+
$this->assertDocumentHasFields([
584604
'id' => '0579B002',
585605
'price' => 179.99,
586-
], $iterator->current()->getFields());
606+
], $iterator->current());
587607

588608
$select->setQuery(
589609
$select->getHelper()->rangeQuery('price', 74.99, 179.99, [true, false])
590610
);
591611
$result = self::$client->select($select);
592612
$this->assertSame(2, $result->getNumFound());
593613
$iterator = $result->getIterator();
594-
$this->assertSame([
614+
$this->assertDocumentHasFields([
595615
'id' => 'VS1GB400C3',
596616
'price' => 74.99,
597-
], $iterator->current()->getFields());
617+
], $iterator->current());
598618
$iterator->next();
599-
$this->assertSame([
619+
$this->assertDocumentHasFields([
600620
'id' => 'SP2514N',
601621
'price' => 92.0,
602-
], $iterator->current()->getFields());
622+
], $iterator->current());
603623

604624
$select->setQuery(
605625
$select->getHelper()->rangeQuery('price', 74.99, 179.99, [false, true])
606626
);
607627
$result = self::$client->select($select);
608628
$this->assertSame(2, $result->getNumFound());
609629
$iterator = $result->getIterator();
610-
$this->assertSame([
630+
$this->assertDocumentHasFields([
611631
'id' => 'SP2514N',
612632
'price' => 92.0,
613-
], $iterator->current()->getFields());
633+
], $iterator->current());
614634
$iterator->next();
615-
$this->assertSame([
635+
$this->assertDocumentHasFields([
616636
'id' => '0579B002',
617637
'price' => 179.99,
618-
], $iterator->current()->getFields());
638+
], $iterator->current());
619639

620640
$select->setQuery(
621641
$select->getHelper()->rangeQuery('price', 74.99, 179.99, [false, false])
622642
);
623643
$result = self::$client->select($select);
624644
$this->assertSame(1, $result->getNumFound());
625645
$iterator = $result->getIterator();
626-
$this->assertSame([
646+
$this->assertDocumentHasFields([
627647
'id' => 'SP2514N',
628648
'price' => 92.0,
629-
], $iterator->current()->getFields());
649+
], $iterator->current());
630650
}
631651

632652
public function testFacetHighlightSpellcheckComponent()

tests/Integration/Fixtures/schema9.patch

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ index 190214aebad..7a76a28276a 100644
66
<!-- points to the root document of a block of nested documents. Required for nested
77
document support, may be removed otherwise
88
-->
9-
- <field name="_root_" type="string" indexed="true" stored="false" docValues="false" />
10-
+ <field name="_root_" type="string" indexed="true" stored="true" docValues="false" />
9+
- <field name="_root_" type="string" indexed="true" stored="false" />
10+
+ <field name="_root_" type="string" indexed="true" stored="true" />
1111
+ <fieldType name="_nest_path_" class="solr.NestPathField" />
1212
+ <field name="_nest_path_" type="_nest_path_" />
1313

0 commit comments

Comments
 (0)