From d252c06543d5c64c99e0c3b4fb79259d47175277 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Wed, 1 Dec 2021 20:17:22 -0800 Subject: [PATCH] ConformanceTest - Demonstrate entity APIs with non-conformant deletion --- tests/phpunit/api/v4/Entity/ConformanceTest.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/phpunit/api/v4/Entity/ConformanceTest.php b/tests/phpunit/api/v4/Entity/ConformanceTest.php index 0b22857262..68d419b669 100644 --- a/tests/phpunit/api/v4/Entity/ConformanceTest.php +++ b/tests/phpunit/api/v4/Entity/ConformanceTest.php @@ -432,7 +432,16 @@ class ConformanceTest extends UnitTestCase implements HookInterface { $deleteAction->setUseTrash(FALSE); } + $log = []; + $listen = function($e) use (&$log) { + $log[] = $e->entity . '.' . $e->action; + }; + \Civi::dispatcher()->addListener('hook_civicrm_post', $listen); $deleteResult = $deleteAction->execute(); + \Civi::dispatcher()->removeListener('hook_civicrm_post', $listen); + + // We should have emitted an event. + $this->assertTrue(in_array("$entity.delete", $log), "$entity should emit hook_civicrm_post() for deletions"); // should get back an array of deleted id $this->assertEquals([['id' => $id]], (array) $deleteResult); -- 2.25.1