Skip to content

Commit 42fd9a3

Browse files
committed
update tests
1 parent 7f12504 commit 42fd9a3

2 files changed

Lines changed: 4 additions & 65 deletions

File tree

composer.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,14 @@
2121
"silverstripe/framework": "^6",
2222
"silverstripe/reports": "^6",
2323
"silverstripe/silverstripe-forager": "dev-feature/v2-silverstripe-6",
24-
"silverstripe/silverstripe-search-client-php": "dev-main",
24+
"silverstripe/silverstripe-search-client-php": "^0.0.1-alpha",
2525
"guzzlehttp/guzzle": "^7.9"
2626
},
2727
"require-dev": {
2828
"silverstripe/recipe-cms": "^6",
2929
"phpunit/phpunit": "^11.3",
3030
"slevomat/coding-standard": "~8.18.0"
3131
},
32-
"repositories": [
33-
{
34-
"type": "vcs",
35-
"url": "https://github.com/silverstripeltd/silverstripe-search-client-php.git"
36-
}
37-
],
3832
"minimum-stability": "dev",
3933
"prefer-stable": true,
4034
"autoload": {

tests/Service/BifrostServiceTest.php

Lines changed: 3 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -938,70 +938,15 @@ public function testRemoveAllDocuments(): void
938938
'deleted' => true,
939939
],
940940
]);
941-
// Third response, listing out the documents that are available after our delete request. We'll return some
942-
// more items to be deleted (testing that the loop functions)
943-
$bodyThree = json_encode([
944-
'meta' => [
945-
'page' => [
946-
'current' => 1,
947-
// Two pages of results, 3 here, and then we'll have 2 more later
948-
'total_pages' => 2,
949-
// Total of 4 documents, 3 of which are presented now
950-
'total_results' => 5,
951-
'size' => 3,
952-
],
953-
],
954-
'results' => [
955-
[
956-
'id' => 'doc1',
957-
'record_id' => '1',
958-
],
959-
[
960-
'id' => 'doc2',
961-
'record_id' => '2',
962-
],
963-
[
964-
'id' => 'doc3',
965-
'record_id' => '3',
966-
],
967-
],
968-
]);
969-
// Fourth response is from the second delete request
970-
$bodyFour = json_encode([
971-
[
972-
'id' => 'doc4',
973-
'deleted' => true,
974-
],
975-
[
976-
'id' => 'doc5',
977-
'deleted' => true,
978-
],
979-
]);
980-
// Fifth (and final) response is for when we request available documents after our second delete request. We'll
981-
// return no results here, indicating that everything has been deleted
982-
$bodyFive = json_encode([
983-
'meta' => [
984-
'page' => [
985-
'current' => 1,
986-
'total_pages' => 1,
987-
'total_results' => 0,
988-
'size' => 100,
989-
],
990-
],
991-
'results' => [],
992-
]);
993941

994942
// Append our mocks
995943
$this->mock->append(new Response(200, $headers, $bodyOne));
996944
$this->mock->append(new Response(200, $headers, $bodyTwo));
997-
$this->mock->append(new Response(200, $headers, $bodyThree));
998-
$this->mock->append(new Response(200, $headers, $bodyFour));
999-
$this->mock->append(new Response(200, $headers, $bodyFive));
1000945

1001-
$numRemoved = $this->searchService->removeAllDocuments('content');
946+
$numRemoved = $this->searchService->clearIndexDocuments('content', 5);
1002947

1003-
// A total of 5 documents were requested to be removed, but only 4 returned deleted = true
1004-
$this->assertEqualsCanonicalizing(4, $numRemoved);
948+
// A total of 3 documents were requested to be removed, but only 2 returned deleted = true
949+
$this->assertEqualsCanonicalizing(2, $numRemoved);
1005950
// And make sure nothing is left in our Response Stack. This would indicate that every Request we expect to make
1006951
// has been made
1007952
$this->assertEquals(0, $this->mock->count());

0 commit comments

Comments
 (0)