From 0f85fc26ff52d5ec21f1ac4db43a29992bf8324c Mon Sep 17 00:00:00 2001 From: nathangray Date: Sat, 21 Oct 2017 11:24:46 +0200 Subject: [PATCH] Put mocked notification class into notifications app --- notifications/tests/MockedNotifications.php | 45 +++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 notifications/tests/MockedNotifications.php diff --git a/notifications/tests/MockedNotifications.php b/notifications/tests/MockedNotifications.php new file mode 100644 index 0000000000..dcd71661ad --- /dev/null +++ b/notifications/tests/MockedNotifications.php @@ -0,0 +1,45 @@ + + * $callback = function() use ($expected) { + * $test->assertContains($expected,$this->message_plain); + * }; + * MockedNotifications::set_callback($callback); + * $this->bo->tracking = new \_tracking($this->bo, MockedNotifications::class); + * + * + * Everything will run as normal except notifications won't be sent, and you can + * put assertions into the callback for what you expect of the notification(s). + */ +class MockedNotifications extends \notifications +{ + static $send_callback; + public static function set_callback(\Closure $send) + { + static::$send_callback = $send; + } + public function send() + { + return static::$send_callback->call($this); + } +} \ No newline at end of file