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

30 lines
1 KiB
PHP
Raw Permalink 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;
2017-01-09 20:51:31 +00:00
class UsersRenamedEventTest extends \PHPUnit_Framework_TestCase
2017-01-09 20:39:24 +00:00
{
public function testNameConstant()
{
$this->assertEquals('app.users.renamed', UsersRenamedEvent::NAME, 'Event name changed');
}
public function testGetRenames()
{
2017-01-17 21:58:53 +00:00
$user = new User(99999, new \DateTime(), 'testuser', 'Test User 1');
2017-01-09 20:39:24 +00:00
$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');
}
}