aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorValentin Popov <info@valentineus.link>2019-05-10 23:57:18 +0300
committerValentin Popov <info@valentineus.link>2019-05-10 23:57:18 +0300
commit747055f9d199ea53ae066f1844d24885052f0030 (patch)
tree165392e27335104db0c345a639cea2c7ed3cdf0b /tests
parented0ce52060690eff5459c037338d26796307ef79 (diff)
downloadlocal_webhooks-747055f9d199ea53ae066f1844d24885052f0030.tar.xz
local_webhooks-747055f9d199ea53ae066f1844d24885052f0030.zip
Added external function add service
Signed-off-by: Valentin Popov <info@valentineus.link>
Diffstat (limited to 'tests')
-rw-r--r--tests/external_test.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/external_test.php b/tests/external_test.php
index 517f370..c0e4cd7 100644
--- a/tests/external_test.php
+++ b/tests/external_test.php
@@ -65,6 +65,42 @@ final class local_webhooks_external_testcase extends externallib_advanced_testca
}
/**
+ * Testing external add service.
+ *
+ * @throws \ReflectionException
+ * @throws \coding_exception
+ * @throws \dml_exception
+ * @throws \invalid_parameter_exception
+ * @throws \invalid_response_exception
+ * @throws \restricted_context_exception
+ */
+ public function test_adding() {
+ $this->resetAfterTest();
+ self::setAdminUser();
+
+ $record = self::get_random_record();
+ $return = local_webhooks_external::add_service((array) $record);
+ $return = external_api::clean_returnvalue(local_webhooks_external::add_service_returns(), $return);
+
+ self::assertInternalType('integer', $return);
+ self::assertEquals(1, api::get_total_count());
+
+ $service = api::get_service($return);
+ 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::assertEquals($return, $service->id);
+
+ self::assertInternalType('array', $service->events);
+ self::assertCount(count($record->events), $service->events);
+ foreach ($service->events as $event) {
+ self::assertContains($event, $record->events);
+ }
+ }
+
+ /**
* Testing the external delete service.
*
* @throws \ReflectionException