Elgg\Notifications\NotificationsServiceTestCase::testCanUseEnqueueHookToPreventSubscriptionNotificationEventFromQueueing PHP Метод

testCanUseEnqueueHookToPreventSubscriptionNotificationEventFromQueueing() публичный Метод

    public function testCanUseEnqueueHookToPreventSubscriptionNotificationEventFromQueueing()
    {
        $object = $this->getTestObject();
        $call_count = 0;
        $recipient = $this->mocks()->getUser(['language' => 'en']);
        $mock = $this->getMock(SubscriptionsService::class, ['getSubscriptions'], [], '', false);
        $mock->expects($this->exactly(0))->method('getSubscriptions')->will($this->returnValue([$recipient->guid => ['test_method', 'bad_method']]));
        $this->subscriptions = $mock;
        $this->hooks->registerHandler('enqueue', 'notification', function ($hook, $type, $return, $params) use(&$call_count, $object) {
            $call_count++;
            $this->assertEquals($object, $params['object']);
            $this->assertEquals('test_event', $params['action']);
            return false;
        });
        $this->setupServices();
        $this->notifications->registerMethod('test_method');
        $this->session->setLoggedInUser($this->actor);
        $this->notifications->registerEvent($object->getType(), $object->getSubtype(), ['test_event']);
        $this->assertEquals(0, $this->queue->size());
        $this->notifications->enqueueEvent('test_event', $object->getType(), $object);
        $this->assertEquals(1, $call_count);
        $this->assertEquals(0, $this->queue->size());
        $this->session->removeLoggedInUser();
        $this->assertEquals(0, $this->notifications->processQueue($this->time + 10));
    }