point-tools/tests/Skobkin/PointToolsBundle/Event/UserRenamedEventTest.php

30 lines
1 KiB
PHP
Raw Normal View History

2017-01-09 20:39:24 +00:00
<?php
namespace Tests\Skobkin\PointToolsBundle\Event;
use Skobkin\Bundle\PointToolsBundle\Entity\User;
use Skobkin\Bundle\PointToolsBundle\Entity\UserRenameEvent;
use Skobkin\Bundle\PointToolsBundle\Event\UsersRenamedEvent;
class UserRenamedEventTest extends \PHPUnit_Framework_TestCase
{
public function testNameConstant()
{
$this->assertEquals('app.users.renamed', UsersRenamedEvent::NAME, 'Event name changed');
}
public function testGetRenames()
{
$user = new User(99999, 'testuser', 'Test User 1');
$renameRecords = [
new UserRenameEvent($user, 'testuser_old1'),
new UserRenameEvent($user, 'testuser_old2'),
new UserRenameEvent($user, 'testuser_old3'),
];
$renameEvent = new UsersRenamedEvent($renameRecords);
$this->assertCount(3, $renameEvent->getRenames(), 'Not exactly 3 renames returned');
$this->assertEquals('testuser_old1', $renameEvent->getRenames()[0]->getOldLogin(), 'Invalid old login returned');
}
}