/** * @group InstantNotificationsService */ public function testCanNotifyUserViaCustomMethods() { $object = $this->getTestObject(); $from = $this->mocks()->getUser(); $to1 = $this->mocks()->getUser(); create_metadata($to1->guid, 'notification:method:test_method', true, '', $to1->guid, ACCESS_PUBLIC); $to2 = $this->mocks()->getUser(); create_metadata($to2->guid, 'notification:method:test_method', true, '', $to2->guid, ACCESS_PUBLIC); $subject = 'Test message'; $body = 'Lorem ipsum'; $this->hooks->registerHandler('send', 'notification:test_method', [Values::class, 'getFalse']); $this->hooks->registerHandler('send', 'notification:test_method2', [Values::class, 'getTrue']); $this->setupServices(); $this->notifications->registerMethod('test_method'); $this->notifications->registerMethod('test_method2'); $expected = [$to1->guid => ['test_method2' => true], $to2->guid => ['test_method2' => true]]; $this->assertEquals($expected, notify_user([$to1->guid, $to2->guid, 0], $from->guid, $subject, $body, [], 'test_method2')); }