/** * @test * @dataProvider messageTypeDataProvider */ public function sendAdminMessageSendsEmailToOrganisatorIfConfigured($messageType) { $organisator = new \DERHANSEN\SfEventMgt\Domain\Model\Organisator(); $event = new \DERHANSEN\SfEventMgt\Domain\Model\Event(); $event->setNotifyAdmin(FALSE); $event->setNotifyOrganisator(TRUE); $event->setOrganisator($organisator); $registration = new \DERHANSEN\SfEventMgt\Domain\Model\Registration(); $settings = array('notification' => array('senderEmail' => '*****@*****.**', 'adminEmail' => '*****@*****.**')); $emailService = $this->getMock('DERHANSEN\\SfEventMgt\\Service\\EmailService', array('sendEmailMessage'), array(), '', FALSE); $emailService->expects($this->once())->method('sendEmailMessage')->will($this->returnValue(TRUE)); $this->inject($this->subject, 'emailService', $emailService); // Inject configuration and configurationManager $configuration = array('plugin.' => array('tx_sfeventmgt.' => array('view.' => array('templateRootPath' => 'EXT:sf_event_mgt/Resources/Private/Templates/', 'layoutRootPath' => 'EXT:sf_event_mgt/Resources/Private/Layouts/')))); $configurationManager = $this->getMock('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager', array('getConfiguration'), array(), '', FALSE); $configurationManager->expects($this->once())->method('getConfiguration')->will($this->returnValue($configuration)); $this->inject($this->subject, 'configurationManager', $configurationManager); $emailView = $this->getMock('TYPO3\\CMS\\Fluid\\View\\StandaloneView', array(), array(), '', FALSE); $objectManager = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManager', array(), array(), '', FALSE); $objectManager->expects($this->once())->method('get')->will($this->returnValue($emailView)); $this->inject($this->subject, 'objectManager', $objectManager); $hashService = $this->getMock('TYPO3\\CMS\\Extbase\\Security\\Cryptography\\HashService'); $hashService->expects($this->once())->method('generateHmac')->will($this->returnValue('HMAC')); $hashService->expects($this->once())->method('appendHmac')->will($this->returnValue('HMAC')); $this->inject($this->subject, 'hashService', $hashService); $result = $this->subject->sendAdminMessage($event, $registration, $settings, $messageType); $this->assertTrue($result); }
/** * @test * @dataProvider messageTypeDataProvider */ public function sendAdminMessageSendsEmailToOrganisatorIfConfigured($messageType) { $organisator = new \DERHANSEN\SfEventMgt\Domain\Model\Organisator(); $event = new \DERHANSEN\SfEventMgt\Domain\Model\Event(); $event->setNotifyAdmin(false); $event->setNotifyOrganisator(true); $event->setOrganisator($organisator); $registration = new \DERHANSEN\SfEventMgt\Domain\Model\Registration(); $settings = ['notification' => ['senderEmail' => '*****@*****.**', 'adminEmail' => '*****@*****.**']]; $emailService = $this->getMock('DERHANSEN\\SfEventMgt\\Service\\EmailService', ['sendEmailMessage'], [], '', false); $emailService->expects($this->once())->method('sendEmailMessage')->will($this->returnValue(true)); $this->inject($this->subject, 'emailService', $emailService); $attachmentService = $this->getMock('DERHANSEN\\SfEventMgt\\Service\\Notification\\AttachmentService', ['getAttachments'], [], '', false); $attachmentService->expects($this->once())->method('getAttachments'); $this->inject($this->subject, 'attachmentService', $attachmentService); $emailView = $this->getMock('TYPO3\\CMS\\Fluid\\View\\StandaloneView', [], [], '', false); $objectManager = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManager', [], [], '', false); $objectManager->expects($this->once())->method('get')->will($this->returnValue($emailView)); $this->inject($this->subject, 'objectManager', $objectManager); $hashService = $this->getMock('TYPO3\\CMS\\Extbase\\Security\\Cryptography\\HashService'); $hashService->expects($this->once())->method('generateHmac')->will($this->returnValue('HMAC')); $hashService->expects($this->once())->method('appendHmac')->will($this->returnValue('HMAC')); $this->inject($this->subject, 'hashService', $hashService); $fluidStandaloneService = $this->getMock('DERHANSEN\\SfEventMgt\\Service\\FluidStandaloneService', [], [], '', false); $fluidStandaloneService->expects($this->any())->method('getTemplateFolders')->will($this->returnValue([])); $this->inject($this->subject, 'fluidStandaloneService', $fluidStandaloneService); $result = $this->subject->sendAdminMessage($event, $registration, $settings, $messageType); $this->assertTrue($result); }