Skip to content

Commit 56ac9ec

Browse files
committed
Add tests for missing coverage report
1 parent 31b5036 commit 56ac9ec

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

tests/Contracts/TaskTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use MeiliSearch\Contracts\TaskStatus;
99
use MeiliSearch\Contracts\TaskType;
1010
use PHPUnit\Framework\TestCase;
11+
use Tests\MockTask;
1112

1213
final class TaskTest extends TestCase
1314
{
@@ -88,4 +89,24 @@ public function testCreateEnqueuedTask(): void
8889
self::assertNull($task->getDetails());
8990
self::assertNull($task->getError());
9091
}
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+
}
91112
}

tests/Settings/PaginationTest.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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+
}

0 commit comments

Comments
 (0)