diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/api_test.php | 13 | ||||
-rw-r--r-- | tests/task_test.php | 21 |
2 files changed, 20 insertions, 14 deletions
diff --git a/tests/api_test.php b/tests/api_test.php index 998db9e..941fdbd 100644 --- a/tests/api_test.php +++ b/tests/api_test.php @@ -230,17 +230,6 @@ final class local_webhooks_api_testcase extends advanced_testcase { foreach ($services as $service) { self::assertContains($service->id, $ids); - self::assertEquals($record->header, $service->header); - self::assertEquals($record->name, $service->name); - self::assertEquals($record->point, $service->point); - self::assertEquals($record->status, $service->status); - self::assertEquals($record->token, $service->token); - - self::assertInternalType('array', $service->events); - self::assertCount(count($record->events), $service->events); - foreach ($service->events as $event) { - self::assertContains($event, $record->events); - } } } @@ -272,7 +261,7 @@ final class local_webhooks_api_testcase extends advanced_testcase { } self::assertCount(1, api::get_services([ - 'name' => 'Example name #' . random_int(1, $total), + 'name' => 'Example name #' . random_int(5, $total), ])); $limit = intdiv($total, 2); diff --git a/tests/task_test.php b/tests/task_test.php index 1fe9bc2..7779261 100644 --- a/tests/task_test.php +++ b/tests/task_test.php @@ -36,6 +36,9 @@ final class local_webhooks_task_testcase extends advanced_testcase { * Testing add a task to the queue. */ public function test_add_task() { + global $DB; + + $DB->delete_records('task_adhoc'); $this->resetAfterTest(); manager::queue_adhoc_task(new notify()); @@ -53,6 +56,9 @@ final class local_webhooks_task_testcase extends advanced_testcase { * @throws \dml_exception */ public function test_execute_disabled() { + global $DB; + + $DB->delete_records('task_adhoc'); curl::mock_response('{}'); $this->resetAfterTest(); @@ -80,6 +86,9 @@ final class local_webhooks_task_testcase extends advanced_testcase { * @throws \dml_exception */ public function test_execute_enabled() { + global $DB; + + $DB->delete_records('task_adhoc'); curl::mock_response('{}'); $this->resetAfterTest(); @@ -116,10 +125,14 @@ final class local_webhooks_task_testcase extends advanced_testcase { * @throws \dml_exception */ public function test_observer_multiple() { - $generator = self::getDataGenerator(); + global $DB; + + $DB->delete_records('task_adhoc'); curl::mock_response('{}'); $this->resetAfterTest(); + $generator = self::getDataGenerator(); + $record = new record(); $record->events = ['\core\event\course_created']; $record->header = 'application/json'; @@ -159,10 +172,14 @@ final class local_webhooks_task_testcase extends advanced_testcase { * @throws \dml_exception */ public function test_observer_single() { - $generator = self::getDataGenerator(); + global $DB; + + $DB->delete_records('task_adhoc'); curl::mock_response('{}'); $this->resetAfterTest(); + $generator = self::getDataGenerator(); + $record = new record(); $record->events = ['\core\event\course_created']; $record->header = 'application/json'; |