Files
Phraseanet/tests/Alchemy/Tests/Phrasea/Notification/ReceiverTest.php
Romain Neutron 09c74afab6 Merge branch '3.8'
Conflicts:
	lib/Alchemy/Phrasea/Controller/Prod/Export.php
	lib/Alchemy/Phrasea/Core/Version.php
	lib/Alchemy/Phrasea/Helper/Prod.php
	lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngine.php
	lib/Alchemy/Phrasea/SearchEngine/SphinxSearch/SphinxSearchEngine.php
	lib/classes/User/Adapter.php
	lib/classes/caption/Field/Value.php
	lib/classes/collection.php
	lib/classes/module/report/filter.php
	lib/classes/task/period/ftp.php
	templates/web/common/dialog_export.html.twig
	templates/web/report/ajax_dashboard_content_child.html.twig
	tests/Alchemy/Tests/Phrasea/Controller/Admin/UsersTest.php
2013-12-18 12:12:58 +01:00

96 lines
2.5 KiB
PHP

<?php
namespace Alchemy\Tests\Phrasea\Notification;
use Alchemy\Phrasea\Notification\Receiver;
use Alchemy\Phrasea\Exception\InvalidArgumentException;
class ReceiverTest extends \PhraseanetTestCase
{
/**
* @var Receiver
*/
protected $object;
private $name;
private $email;
public function setUp()
{
$this->name = 'name-' . mt_rand();
$this->email = sprintf('name-%s@domain-%s.com', mt_rand(), mt_rand());
$this->object = new Receiver($this->name, $this->email);
}
/**
* @covers Alchemy\Phrasea\Notification\Receiver::getName
*/
public function testGetName()
{
$this->assertEquals($this->name, $this->object->getName());
}
/**
* @covers Alchemy\Phrasea\Notification\Receiver::getEmail
*/
public function testGetEmail()
{
$this->assertEquals($this->email, $this->object->getEmail());
}
/**
* @covers Alchemy\Phrasea\Notification\Receiver::fromUser
*/
public function testFromUser()
{
$user = $this->getMockBuilder('\User_Adapter')
->disableOriginalConstructor()
->getMock();
$user->expects($this->any())
->method('get_display_name')
->will($this->returnValue($this->name));
$user->expects($this->any())
->method('get_email')
->will($this->returnValue($this->email));
$object = Receiver::fromUser($user);
$this->assertEquals($this->email, $object->getEmail());
$this->assertEquals($this->name, $object->getName());
}
/**
* @covers Alchemy\Phrasea\Notification\Receiver::fromUser
*/
public function testFromUserFailed()
{
$user = $this->getMockBuilder('\User_Adapter')
->disableOriginalConstructor()
->getMock();
$user->expects($this->any())
->method('get_display_name')
->will($this->returnValue($this->name));
$user->expects($this->any())
->method('get_email')
->will($this->returnValue('wrong user'));
try {
Receiver::fromUser($user);
$this->fail('Should have raised an exception');
} catch (InvalidArgumentException $e) {
}
}
/**
* @expectedException \Alchemy\Phrasea\Exception\InvalidArgumentException
* @expectedExceptionMessage Invalid e-mail address (romain neutron email)
*/
public function testWrongEmail()
{
new Receiver('romain neutron', 'romain neutron email');
}
}