Skip to content

Commit 9fc4c11

Browse files
authored
Merge pull request #160 from catalyst/MOODLE_404_STABLE-issue151
Issue #151: Resolved unit tests for Moodle 5.1 and 4.5+
2 parents 39f8805 + f1c0a2f commit 9fc4c11

3 files changed

Lines changed: 8 additions & 7 deletions

File tree

tests/esrequest_test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ public function tearDown(): void {
9393
* The GuzzleHttp exception is no longer be throwed
9494
*/
9595
public function test_get_unreachable_host(): void {
96-
$this->expectException(\GuzzleHttp\Exception\ConnectException::class);
9796
$url = 'http://unreachable:9020';
9897
$client = new \search_elastic\esrequest();
9998
$response = $client->get($url);
99+
$this->assertEquals(503, $response->getStatusCode());
100100
}
101101

102102
/**

tests/local/chunking/fixed_size_test.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ public static function chunk_overlap_provider(): array {
107107
* @dataProvider chunk_overlap_provider
108108
* @param int $maxsize
109109
* @param int $overlap
110-
* @param int $exceptednumchunks
110+
* @param int $expectednumchunks
111111
*/
112-
public function test_chunk_with_overlap(int $maxsize, int $overlap, int $exceptednumchunks): void {
112+
public function test_chunk_with_overlap(int $maxsize, int $overlap, int $expectednumchunks): void {
113113
$rec = new stdClass();
114114
$rec->content = <<<EOF
115115
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
@@ -128,11 +128,12 @@ public function test_chunk_with_overlap(int $maxsize, int $overlap, int $excepte
128128
$options = [
129129
'maxsize' => $maxsize,
130130
'overlap' => $overlap,
131+
'expectednumchunks' => $expectednumchunks,
131132
];
132133

133134
$chunkingstrategy = new fixed_size();
134135
$chunks = $chunkingstrategy->chunk($docdata['content'], $options);
135-
$this->assertCount($exceptednumchunks, $chunks);
136+
$this->assertCount($expectednumchunks, $chunks);
136137

137138
// Last chunk should include end of text.
138139
$lastchunk = $chunks[count($chunks) - 1]['text'];

tests/server_ready_check_test.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ public static function server_ready_provider(): array {
6666
* Tests check result.
6767
*
6868
* @param string $hostname
69-
* @param string $expectedstatus
69+
* @param string $status
7070
* @dataProvider server_ready_provider
7171
*/
72-
public function test_check(string $hostname, string $expectedstatus): void {
72+
public function test_check(string $hostname, string $status): void {
7373
$this->resetAfterTest();
7474
set_config('hostname', $hostname, 'search_elastic');
7575

@@ -86,7 +86,7 @@ public function test_check(string $hostname, string $expectedstatus): void {
8686

8787
$check = new server_ready_check($stack);
8888
$result = $check->get_result();
89-
$this->assertEquals($expectedstatus, $result->get_status());
89+
$this->assertEquals($status, $result->get_status());
9090
}
9191

9292
/**

0 commit comments

Comments
 (0)