Files
Phraseanet/tests/Alchemy/Tests/Phrasea/Notification/Mail/MailInfoValidationRequestTest.php
Nicolas Le Goff c10c78f740 Fix unit tests
2014-02-19 17:29:26 +01:00

95 lines
2.4 KiB
PHP

<?php
namespace Alchemy\Tests\Phrasea\Notification\Mail;
use Alchemy\Phrasea\Notification\Mail\MailInfoValidationRequest;
use Alchemy\Phrasea\Exception\LogicException;
/**
* @covers Alchemy\Phrasea\Notification\Mail\MailInfoValidationRequest
*/
class MailInfoValidationRequestTest extends MailWithLinkTestCase
{
public function testSetTitle()
{
$this->assertEquals('Validation request from %user% for \'%title%\'', $this->getMail()->getSubject());
}
public function testShouldThrowALogicExceptionIfNoUserProvided()
{
$mail = MailInfoValidationRequest::create(
$this->getApp(),
$this->getReceiverMock(),
$this->getEmitterMock(),
$this->getMessage(),
$this->getUrl(),
$this->getExpiration()
);
$mail->setTitle('Hello world');
try {
$mail->getSubject();
$this->fail('Should have raised an exception');
} catch (LogicException $e) {
}
}
public function testShouldThrowALogicExceptionIfNoTitleProvided()
{
$mail = MailInfoValidationRequest::create(
$this->getApp(),
$this->getReceiverMock(),
$this->getEmitterMock(),
$this->getMessage(),
$this->getUrl(),
$this->getExpiration()
);
$user = $this->createUserMock();
$user->expects($this->any())
->method('getDisplayName')
->will($this->returnValue('JeanPhil'));
$mail->setUser($user);
try {
$mail->getSubject();
$this->fail('Should have raised an exception');
} catch (LogicException $e) {
}
}
public function testSetUser()
{
$this->assertEquals('Validation request from %user% for \'%title%\'', $this->getMail()->getSubject());
}
public function getMail()
{
$mail = MailInfoValidationRequest::create(
$this->getApp(),
$this->getReceiverMock(),
$this->getEmitterMock(),
$this->getMessage(),
$this->getUrl(),
$this->getExpiration()
);
$user = $this->createUserMock();
$user->expects($this->any())
->method('getDisplayName')
->will($this->returnValue('JeanPhil'));
$mail->setUser($user);
$mail->setTitle('Hello world');
return $mail;
}
}