mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
89 lines
2.3 KiB
PHP
89 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace Alchemy\Tests\Phrasea\Notification\Mail;
|
|
|
|
use Alchemy\Phrasea\Exception\LogicException;
|
|
use Alchemy\Phrasea\Notification\Mail\MailInfoOrderCancelled;
|
|
|
|
/**
|
|
* @group functional
|
|
* @group legacy
|
|
* @covers Alchemy\Phrasea\Notification\Mail\MailInfoOrderCancelled
|
|
*/
|
|
class MailInfoOrderCancelledTest extends MailTestCase
|
|
{
|
|
public function testSetQuantity()
|
|
{
|
|
$this->assertEquals('%user% a refuse %quantity% elements de votre commande', $this->getMail()->getMessage());
|
|
}
|
|
|
|
public function testSetDeliverer()
|
|
{
|
|
$this->assertEquals('%user% a refuse %quantity% elements de votre commande', $this->getMail()->getMessage());
|
|
}
|
|
|
|
public function testShouldThrowALogicExceptionIfNoQuantityProvided()
|
|
{
|
|
$mail = MailInfoOrderCancelled::create(
|
|
$this->getApplication(),
|
|
$this->getReceiverMock(),
|
|
$this->getEmitterMock(),
|
|
$this->getMessage()
|
|
);
|
|
|
|
$user = $this->createUserMock();
|
|
|
|
$user->expects($this->any())
|
|
->method('getDisplayName')
|
|
->will($this->returnValue('JeanPhil'));
|
|
|
|
$mail->setDeliverer($user);
|
|
|
|
try {
|
|
$mail->getMessage();
|
|
$this->fail('Should have raised an exception');
|
|
} catch (LogicException $e) {
|
|
|
|
}
|
|
}
|
|
public function testShouldThrowALogicExceptionIfNoDelivererProvided()
|
|
{
|
|
$mail = MailInfoOrderCancelled::create(
|
|
$this->getApplication(),
|
|
$this->getReceiverMock(),
|
|
$this->getEmitterMock(),
|
|
$this->getMessage()
|
|
);
|
|
|
|
$mail->setQuantity(42);
|
|
|
|
try {
|
|
$mail->getMessage();
|
|
$this->fail('Should have raised an exception');
|
|
} catch (LogicException $e) {
|
|
|
|
}
|
|
}
|
|
|
|
public function getMail()
|
|
{
|
|
$mail = MailInfoOrderCancelled::create(
|
|
$this->getApplication(),
|
|
$this->getReceiverMock(),
|
|
$this->getEmitterMock(),
|
|
$this->getMessage()
|
|
);
|
|
|
|
$user = $this->createUserMock();
|
|
|
|
$user->expects($this->any())
|
|
->method('getDisplayName')
|
|
->will($this->returnValue('JeanPhil'));
|
|
|
|
$mail->setDeliverer($user);
|
|
$mail->setQuantity(42);
|
|
|
|
return $mail;
|
|
}
|
|
}
|