コード例 #1
0
 /**
  * Tests if fromEventProperty returns expected attachments for objectStorage property
  * @test
  */
 public function getAttachmentsReturnsAttachmentsFromEventPropertyWithObjectStorage()
 {
     $registration = new \DERHANSEN\SfEventMgt\Domain\Model\Registration();
     $event = new \DERHANSEN\SfEventMgt\Domain\Model\Event();
     $mockFile1 = $this->getMock('TYPO3\\CMS\\Core\\Resource\\File', ['getForLocalProcessing'], [], '', false);
     $mockFile1->expects($this->any())->method('getForLocalProcessing')->will($this->returnValue('/path/to/somefile.pdf'));
     $mockFileRef1 = $this->getMock('TYPO3\\CMS\\Extbase\\Domain\\Model\\FileReference', ['getOriginalResource'], [], '', false);
     $mockFileRef1->expects($this->any())->method('getOriginalResource')->will($this->returnValue($mockFile1));
     $mockFile2 = $this->getMock('TYPO3\\CMS\\Core\\Resource\\File', ['getForLocalProcessing'], [], '', false);
     $mockFile2->expects($this->any())->method('getForLocalProcessing')->will($this->returnValue('/path/to/anotherfile.pdf'));
     $mockFileRef2 = $this->getMock('TYPO3\\CMS\\Extbase\\Domain\\Model\\FileReference', ['getOriginalResource'], [], '', false);
     $mockFileRef2->expects($this->any())->method('getOriginalResource')->will($this->returnValue($mockFile2));
     $event->addFiles($mockFileRef1);
     $event->addFiles($mockFileRef2);
     $registration->setEvent($event);
     $settings = ['notification' => ['registrationNew' => ['attachments' => ['user' => ['fromEventProperty' => ['files']]]]]];
     $expected = ['/path/to/somefile.pdf', '/path/to/anotherfile.pdf'];
     $attachments = $this->subject->getAttachments($settings, $registration, MessageType::REGISTRATION_NEW, MessageRecipient::USER);
     $this->assertEquals($expected, $attachments);
 }
コード例 #2
0
 /**
  * @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);
 }
コード例 #3
0
 /**
  * @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);
 }