Added exact test get record by an event
Signed-off-by: Valentin Popov <info@valentineus.link>
This commit is contained in:
parent
46711c9942
commit
ae2f31261d
@ -234,8 +234,6 @@ final class local_webhooks_api_testcase extends advanced_testcase {
|
|||||||
/**
|
/**
|
||||||
* Testing get to the list services by event name.
|
* Testing get to the list services by event name.
|
||||||
*
|
*
|
||||||
* @todo It's no testing all conditional.
|
|
||||||
*
|
|
||||||
* @group local_webhooks
|
* @group local_webhooks
|
||||||
*
|
*
|
||||||
* @throws \dml_exception
|
* @throws \dml_exception
|
||||||
@ -246,18 +244,20 @@ final class local_webhooks_api_testcase extends advanced_testcase {
|
|||||||
$this->resetAfterTest();
|
$this->resetAfterTest();
|
||||||
|
|
||||||
$eventname = generate_uuid();
|
$eventname = generate_uuid();
|
||||||
|
$limit = random_int(1, 5);
|
||||||
$total = random_int(5, 20);
|
$total = random_int(5, 20);
|
||||||
|
|
||||||
$ids = [];
|
$ids = [];
|
||||||
|
|
||||||
for ($i = 0; $i < $total; $i++) {
|
for ($i = 0; $i < $total; $i++) {
|
||||||
$record = self::get_random_record();
|
$record = self::get_random_record();
|
||||||
$record->events[] = $eventname;
|
$record->events[] = $i < $limit ? $eventname : '';
|
||||||
$ids[] = api::add_service($record);
|
$ids[] = api::add_service($record);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self::assertEquals(count($ids), api::get_total_count());
|
||||||
$services = api::get_services_by_event($eventname);
|
$services = api::get_services_by_event($eventname);
|
||||||
self::assertCount(count($ids), $services);
|
self::assertCount($limit, $services);
|
||||||
|
|
||||||
foreach ($services as $service) {
|
foreach ($services as $service) {
|
||||||
self::assertContains($service->id, $ids);
|
self::assertContains($service->id, $ids);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user