File tree 2 files changed +72
-0
lines changed 2 files changed +72
-0
lines changed Original file line number Diff line number Diff line change 8
8
use MeiliSearch \Contracts \TaskStatus ;
9
9
use MeiliSearch \Contracts \TaskType ;
10
10
use PHPUnit \Framework \TestCase ;
11
+ use Tests \MockTask ;
11
12
12
13
final class TaskTest extends TestCase
13
14
{
@@ -88,4 +89,24 @@ public function testCreateEnqueuedTask(): void
88
89
self ::assertNull ($ task ->getDetails ());
89
90
self ::assertNull ($ task ->getError ());
90
91
}
92
+
93
+ public function testArraySetThrows (): void
94
+ {
95
+ $ task = MockTask::create (TaskType::IndexCreation);
96
+
97
+ $ this ->expectException (\LogicException::class);
98
+ $ this ->expectExceptionMessage ('Setting data on "MeiliSearch\Contracts\Task::type" is not supported. ' );
99
+
100
+ $ task ['type ' ] = TaskType::IndexDeletion;
101
+ }
102
+
103
+ public function testArrayUnsetThrows (): void
104
+ {
105
+ $ task = MockTask::create (TaskType::IndexCreation);
106
+
107
+ $ this ->expectException (\LogicException::class);
108
+ $ this ->expectExceptionMessage ('Unsetting data on "MeiliSearch\Contracts\Task::type" is not supported. ' );
109
+
110
+ unset($ task ['type ' ]);
111
+ }
91
112
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ namespace Tests \Settings ;
6
+
7
+ use Meilisearch \Endpoints \Indexes ;
8
+ use Tests \TestCase ;
9
+
10
+ final class PaginationTest extends TestCase
11
+ {
12
+ private Indexes $ index ;
13
+
14
+ public const DEFAULT_PAGINATION = [
15
+ 'maxTotalHits ' => 1000 ,
16
+ ];
17
+
18
+ protected function setUp (): void
19
+ {
20
+ parent ::setUp ();
21
+ $ this ->index = $ this ->createEmptyIndex ($ this ->safeIndexName ());
22
+ }
23
+
24
+ public function testGetDefaultPagination (): void
25
+ {
26
+ $ response = $ this ->index ->getPagination ();
27
+
28
+ self ::assertSame (self ::DEFAULT_PAGINATION , $ response );
29
+ }
30
+
31
+ public function testUpdatePagination (): void
32
+ {
33
+ $ promise = $ this ->index ->updatePagination (['maxTotalHits ' => 100 ]);
34
+
35
+ $ this ->index ->waitForTask ($ promise ['taskUid ' ]);
36
+
37
+ self ::assertSame (['maxTotalHits ' => 100 ], $ this ->index ->getPagination ());
38
+ }
39
+
40
+ public function testResetRankingRules (): void
41
+ {
42
+ $ promise = $ this ->index ->updatePagination (['maxTotalHits ' => 100 ]);
43
+
44
+ $ this ->index ->waitForTask ($ promise ['taskUid ' ]);
45
+
46
+ $ promise = $ this ->index ->resetPagination ();
47
+ $ this ->index ->waitForTask ($ promise ['taskUid ' ]);
48
+
49
+ self ::assertSame (self ::DEFAULT_PAGINATION , $ this ->index ->getPagination ());
50
+ }
51
+ }
You can’t perform that action at this time.
0 commit comments