2019-01-04 20:41:37 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Unit\Domain\UserManagement;
|
|
|
|
|
|
|
|
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
2019-02-17 14:33:19 +01:00
|
|
|
use Infinito\Entity\User;
|
|
|
|
use Infinito\Domain\UserManagement\UserSourceDirector;
|
|
|
|
use Infinito\Repository\Source\SourceRepository;
|
|
|
|
use Infinito\Entity\Source\AbstractSource;
|
2019-05-30 16:10:09 +02:00
|
|
|
use Infinito\Domain\Fixture\FixtureSource\GuestUserFixtureSource;
|
2019-01-04 20:41:37 +01:00
|
|
|
|
2019-01-13 14:08:21 +01:00
|
|
|
/**
|
|
|
|
* @author kevinfrantz
|
|
|
|
*/
|
|
|
|
class UserSourceDirectorTest extends KernelTestCase
|
2019-01-04 20:41:37 +01:00
|
|
|
{
|
|
|
|
/**
|
2019-01-13 14:08:21 +01:00
|
|
|
* @var SourceRepository
|
2019-01-04 20:41:37 +01:00
|
|
|
*/
|
2019-01-13 14:08:21 +01:00
|
|
|
private $sourceRepository;
|
2019-01-04 20:41:37 +01:00
|
|
|
|
|
|
|
public function setUp(): void
|
|
|
|
{
|
|
|
|
self::bootKernel();
|
2019-01-13 14:08:21 +01:00
|
|
|
$this->sourceRepository = self::$container->get('doctrine.orm.default_entity_manager')->getRepository(AbstractSource::class);
|
2019-01-04 20:41:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testGuestUser(): void
|
|
|
|
{
|
|
|
|
$origineUser = null;
|
2019-01-13 14:08:21 +01:00
|
|
|
$userIdentityManager = new UserSourceDirector($this->sourceRepository, $origineUser);
|
2019-01-04 20:41:37 +01:00
|
|
|
$expectedUser = $userIdentityManager->getUser();
|
2019-03-29 23:21:52 +01:00
|
|
|
$this->assertEquals(GuestUserFixtureSource::getSlug(), $expectedUser->getSource()->getSlug());
|
2019-01-04 20:41:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testUser(): void
|
|
|
|
{
|
2019-01-13 14:08:21 +01:00
|
|
|
$origineUser = $this->createMock(User::class);
|
|
|
|
$userIdentityManager = new UserSourceDirector($this->sourceRepository, $origineUser);
|
2019-01-04 20:41:37 +01:00
|
|
|
$expectedUser = $userIdentityManager->getUser();
|
|
|
|
$this->assertEquals($origineUser, $expectedUser);
|
|
|
|
}
|
|
|
|
}
|