Skip to content

Commit 927dcfd

Browse files
committed
Added additional content remote ids check in SearchServiceBookmarkTest
1 parent 582d8d7 commit 927dcfd

File tree

1 file changed

+83
-7
lines changed

1 file changed

+83
-7
lines changed

tests/integration/Core/Repository/SearchServiceBookmarkTest.php

+83-7
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,38 @@
1212
use Ibexa\Contracts\Core\Repository\Values\Content\Location;
1313
use Ibexa\Contracts\Core\Repository\Values\Content\LocationQuery;
1414
use Ibexa\Contracts\Core\Repository\Values\Content\Query;
15+
use Ibexa\Contracts\Core\Repository\Values\Content\Search\SearchHit;
16+
use Ibexa\Contracts\Core\Repository\Values\Content\Search\SearchResult;
1517
use Ibexa\Tests\Integration\Core\RepositorySearchTestCase;
1618

1719
final class SearchServiceBookmarkTest extends RepositorySearchTestCase
1820
{
1921
private const FOLDER_CONTENT_TYPE_IDENTIFIER = 'folder';
2022
private const MEDIA_CONTENT_TYPE_ID = 43;
2123
private const ALL_BOOKMARKED_LOCATIONS = 6;
24+
private const ALL_BOOKMARKED_CONTENT_REMOTE_IDS = [
25+
'1bb4fe25487f05527efa8bfd394cecc7',
26+
'3c160cca19fb135f83bd02d911f04db2',
27+
'5f7f0bdb3381d6a461d8c29ff53d908f',
28+
'9b47a45624b023b1a76c73b74d704acf',
29+
'a6e35cbcb7cd6ae4b691f3eee30cd262',
30+
'f5c88a2209584891056f987fd965b0ba',
31+
];
32+
private const ALL_NO_BOOKMARKED_CONTENT_REMOTE_IDS = [
33+
'08799e609893f7aba22f10cb466d9cc8',
34+
'09082deb98662a104f325aaa8c4933d3',
35+
'14e4411b264a6194a33847843919451a',
36+
'15b256dbea2ae72418ff5facc999e8f9',
37+
'241d538ce310074e602f29f49e44e938',
38+
'27437f3547db19cf81a33c92578b2c89',
39+
'732a5acd01b51a6fe6eab448ad4138a9',
40+
'8a9c9c761004866fb458d89910f52bee',
41+
'8b8b22fe3c6061ed500fbd2b377b885f',
42+
'e7ff633c6b8e0fd3531e74c6e712bead',
43+
'f8cc7a4cf8a964a1a0ea6666f5da7d0d',
44+
'faaeb9be3bd98ed09f606fc16d144eca',
45+
];
46+
private const MEDIA_CONTENT_REMOTE_ID = 'a6e35cbcb7cd6ae4b691f3eee30cd262';
2247

2348
protected function setUp(): void
2449
{
@@ -33,14 +58,16 @@ protected function setUp(): void
3358
* @dataProvider provideDataForTestCriterion
3459
*
3560
* @param array<\Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion> $criteria
61+
* @param array<string> $remoteIds
3662
*/
3763
public function testCriterion(
3864
int $expectedCount,
39-
array $criteria
65+
array $criteria,
66+
array $remoteIds
4067
): void {
4168
$query = $this->createQuery($criteria);
4269

43-
$this->assertExpectedSearchHits($expectedCount, $query);
70+
$this->assertExpectedSearchHits($expectedCount, $remoteIds, $query);
4471
}
4572

4673
/**
@@ -56,6 +83,7 @@ public function provideDataForTestCriterion(): iterable
5683
[
5784
new Query\Criterion\Location\IsBookmarked(),
5885
],
86+
self::ALL_BOOKMARKED_CONTENT_REMOTE_IDS,
5987
];
6088

6189
yield 'All bookmarked locations limited to folder content type' => [
@@ -64,6 +92,7 @@ public function provideDataForTestCriterion(): iterable
6492
new Query\Criterion\ContentTypeIdentifier(self::FOLDER_CONTENT_TYPE_IDENTIFIER),
6593
new Query\Criterion\Location\IsBookmarked(),
6694
],
95+
[self::MEDIA_CONTENT_REMOTE_ID],
6796
];
6897

6998
yield 'All bookmarked locations limited to user group content type' => [
@@ -72,6 +101,12 @@ public function provideDataForTestCriterion(): iterable
72101
new Query\Criterion\ContentTypeIdentifier('user_group'),
73102
new Query\Criterion\Location\IsBookmarked(),
74103
],
104+
[
105+
'3c160cca19fb135f83bd02d911f04db2',
106+
'5f7f0bdb3381d6a461d8c29ff53d908f',
107+
'9b47a45624b023b1a76c73b74d704acf',
108+
'f5c88a2209584891056f987fd965b0ba',
109+
],
75110
];
76111

77112
yield 'All bookmarked locations limited to user content type' => [
@@ -80,13 +115,15 @@ public function provideDataForTestCriterion(): iterable
80115
new Query\Criterion\ContentTypeIdentifier('user'),
81116
new Query\Criterion\Location\IsBookmarked(),
82117
],
118+
['1bb4fe25487f05527efa8bfd394cecc7'],
83119
];
84120

85121
yield 'All no bookmarked locations' => [
86122
12,
87123
[
88124
new Query\Criterion\Location\IsBookmarked(false),
89125
],
126+
self::ALL_NO_BOOKMARKED_CONTENT_REMOTE_IDS,
90127
];
91128
}
92129

@@ -98,7 +135,11 @@ public function testCriterionDeleteBookmark(): void
98135
]
99136
);
100137

101-
$this->assertExpectedSearchHits(self::ALL_BOOKMARKED_LOCATIONS, $query);
138+
$this->assertExpectedSearchHits(
139+
self::ALL_BOOKMARKED_LOCATIONS,
140+
self::ALL_BOOKMARKED_CONTENT_REMOTE_IDS,
141+
$query
142+
);
102143

103144
$mediaLocation = $this->loadMediaFolderLocation();
104145

@@ -109,19 +150,54 @@ public function testCriterionDeleteBookmark(): void
109150

110151
$this->refreshSearch();
111152

112-
$this->assertExpectedSearchHits(5, $query);
153+
$this->assertExpectedSearchHits(
154+
5,
155+
[
156+
'1bb4fe25487f05527efa8bfd394cecc7',
157+
'3c160cca19fb135f83bd02d911f04db2',
158+
'5f7f0bdb3381d6a461d8c29ff53d908f',
159+
'9b47a45624b023b1a76c73b74d704acf',
160+
'f5c88a2209584891056f987fd965b0ba',
161+
],
162+
$query
163+
);
113164
}
114165

166+
/**
167+
* @param array<string> $expectedRemoteIds
168+
*/
115169
private function assertExpectedSearchHits(
116170
int $expectedCount,
171+
array $expectedRemoteIds,
117172
LocationQuery $query
118173
): void {
119174
$searchHits = self::getSearchService()->findLocations($query);
120175

121-
self::assertSame(
122-
$expectedCount,
123-
$searchHits->totalCount
176+
self::assertSame($expectedCount, $searchHits->totalCount);
177+
178+
$remoteIds = $this->extractRemoteIds($searchHits);
179+
180+
self::assertSame($expectedRemoteIds, $remoteIds);
181+
}
182+
183+
/**
184+
* @return array<string>
185+
*/
186+
private function extractRemoteIds(SearchResult $result): array
187+
{
188+
$remoteIds = array_map(
189+
static function (SearchHit $searchHit): string {
190+
/** @var \Ibexa\Contracts\Core\Repository\Values\Content\Location $location */
191+
$location = $searchHit->valueObject;
192+
193+
return $location->getContentInfo()->remoteId;
194+
},
195+
$result->searchHits
124196
);
197+
198+
sort($remoteIds);
199+
200+
return $remoteIds;
125201
}
126202

127203
/**

0 commit comments

Comments
 (0)