From d01a5f2dbd18442a19d33e6374e2c33595f06785 Mon Sep 17 00:00:00 2001 From: Kevin Frantz Date: Sun, 13 Jan 2019 14:08:21 +0100 Subject: [PATCH] Optimized test for UserSourceDirector --- ...gerTest.php => UserSourceDirectorTest.php} | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) rename application/symfony/tests/Unit/Domain/UserManagement/{UserIdentityManagerTest.php => UserSourceDirectorTest.php} (50%) diff --git a/application/symfony/tests/Unit/Domain/UserManagement/UserIdentityManagerTest.php b/application/symfony/tests/Unit/Domain/UserManagement/UserSourceDirectorTest.php similarity index 50% rename from application/symfony/tests/Unit/Domain/UserManagement/UserIdentityManagerTest.php rename to application/symfony/tests/Unit/Domain/UserManagement/UserSourceDirectorTest.php index 7df6504..f712308 100644 --- a/application/symfony/tests/Unit/Domain/UserManagement/UserIdentityManagerTest.php +++ b/application/symfony/tests/Unit/Domain/UserManagement/UserSourceDirectorTest.php @@ -2,37 +2,41 @@ namespace Tests\Unit\Domain\UserManagement; -use App\Domain\UserManagement\UserIdentityManager; -use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use App\DBAL\Types\SystemSlugType; use App\Entity\User; +use App\Domain\UserManagement\UserSourceDirector; +use App\Repository\Source\SourceRepository; +use App\Entity\Source\AbstractSource; -class UserIdentityManagerTest extends KernelTestCase +/** + * @author kevinfrantz + */ +class UserSourceDirectorTest extends KernelTestCase { /** - * @var EntityManagerInterface + * @var SourceRepository */ - private $entityManager; + private $sourceRepository; public function setUp(): void { self::bootKernel(); - $this->entityManager = self::$container->get('doctrine.orm.default_entity_manager'); + $this->sourceRepository = self::$container->get('doctrine.orm.default_entity_manager')->getRepository(AbstractSource::class); } public function testGuestUser(): void { $origineUser = null; - $userIdentityManager = new UserIdentityManager($this->entityManager, $origineUser); + $userIdentityManager = new UserSourceDirector($this->sourceRepository, $origineUser); $expectedUser = $userIdentityManager->getUser(); $this->assertEquals(SystemSlugType::GUEST_USER, $expectedUser->getSource()->getSlug()); } public function testUser(): void { - $origineUser = new User(); - $userIdentityManager = new UserIdentityManager($this->entityManager, $origineUser); + $origineUser = $this->createMock(User::class); + $userIdentityManager = new UserSourceDirector($this->sourceRepository, $origineUser); $expectedUser = $userIdentityManager->getUser(); $this->assertEquals($origineUser, $expectedUser); }