Пример #1
0
 public function testSendLinkShareMailException()
 {
     $this->setupMailerMock('TestUser shared »MyFile« with you', ['*****@*****.**']);
     $mailNotifications = new MailNotifications($this->user, $this->l10n, $this->mailer, $this->logger, $this->defaults);
     $this->assertSame(['*****@*****.**'], $mailNotifications->sendLinkShareMail('*****@*****.**', 'MyFile', 'https://owncloud.com/file/?foo=bar', 3600));
 }
 public function testSendLinkShareMailException()
 {
     $message = $this->getMockBuilder('\\OC\\Mail\\Message')->disableOriginalConstructor()->getMock();
     $message->expects($this->once())->method('setSubject')->with('TestUser shared »MyFile« with you');
     $message->expects($this->once())->method('setTo')->with(['*****@*****.**']);
     $message->expects($this->once())->method('setHtmlBody');
     $message->expects($this->once())->method('setPlainBody');
     $message->expects($this->once())->method('setFrom')->with([\OCP\Util::getDefaultEmailAddress('sharing-noreply') => 'TestUser via UnitTestCloud']);
     $this->mailer->expects($this->once())->method('createMessage')->will($this->returnValue($message));
     $this->mailer->expects($this->once())->method('send')->with($message)->will($this->throwException(new Exception('Some Exception Message')));
     $this->defaults->expects($this->once())->method('getName')->will($this->returnValue('UnitTestCloud'));
     $this->config->expects($this->at(0))->method('getUserValue')->with('TestUser', 'settings', 'email', null)->will($this->returnValue('*****@*****.**'));
     $mailNotifications = new MailNotifications('TestUser', $this->config, $this->l10n, $this->mailer, $this->logger, $this->defaults);
     $this->assertSame(['*****@*****.**'], $mailNotifications->sendLinkShareMail('*****@*****.**', 'MyFile', 'https://owncloud.com/file/?foo=bar', 3600));
 }