/** * Test if ignoreNotifications is respected * * @test */ public function findNotificationRegistrationsRespectsIgnoreNotificationsForEventUid3() { $event = $this->getMock('DERHANSEN\\SfEventMgt\\Domain\\Model\\Event', array(), array(), '', FALSE); $event->expects($this->once())->method('getUid')->will($this->returnValue(3)); $registrations = $this->registrationRepository->findNotificationRegistrations($event, NULL); $this->assertEquals(1, $registrations->count()); }
/** * Sends a custom notification defined by the given customNotification key * to all confirmed users of the event * * @param \DERHANSEN\SfEventMgt\Domain\Model\Event $event Event * @param string $customNotification CustomNotification * @param array $settings Settings * * @return int Number of notifications sent */ public function sendCustomNotification($event, $customNotification, $settings) { if (is_null($event) || $customNotification == '' || $settings == '' || !is_array($settings)) { return 0; } $count = 0; $constraints = $settings['notification']['customNotifications'][$customNotification]['constraints']; $registrations = $this->registrationRepository->findNotificationRegistrations($event, $constraints); foreach ($registrations as $registration) { /** @var \DERHANSEN\SfEventMgt\Domain\Model\Registration $registration */ if ($registration->isConfirmed() && !$registration->isIgnoreNotifications()) { $result = $this->sendUserMessage($event, $registration, $settings, MessageType::CUSTOM_NOTIFICATION, $customNotification); if ($result) { $count += 1; } } } return $count; }