point-tools/old/tests/Skobkin/PointToolsBundle/Event/UsersRenamedEventTest.php

30 lines
1 KiB
PHP

<?php
namespace Tests\Skobkin\PointToolsBundle\Event;
use src\PointToolsBundle\Entity\User;
use src\PointToolsBundle\Entity\UserRenameEvent;
use src\PointToolsBundle\Event\UsersRenamedEvent;
class UsersRenamedEventTest extends \PHPUnit_Framework_TestCase
{
public function testNameConstant()
{
$this->assertEquals('app.users.renamed', UsersRenamedEvent::NAME, 'Event name changed');
}
public function testGetRenames()
{
$user = new User(99999, new \DateTime(), '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');
}
}