mirror of
				https://github.com/kevinveenbirkenbach/infinito.git
				synced 2025-10-31 09:19:08 +00:00 
			
		
		
		
	Implemented tests for UserRepository and mapped data schema
This commit is contained in:
		| @@ -21,9 +21,9 @@ class AbstractEntityTest extends TestCase | ||||
|  | ||||
|     public function testConstructor(): void | ||||
|     { | ||||
|         $this->assertEquals(0, $this->entity->getVersion()); | ||||
|         $this->expectException(\TypeError::class); | ||||
|         $this->entity->getId(); | ||||
|         $this->entity->getVersion(); | ||||
|     } | ||||
|  | ||||
|     public function testVersion(): void | ||||
|   | ||||
| @@ -23,6 +23,7 @@ class RelationTest extends TestCase | ||||
|     { | ||||
|         $this->assertInstanceOf(Collection::class, $this->relation->getChilds()); | ||||
|         $this->assertInstanceOf(Collection::class, $this->relation->getParents()); | ||||
|         $this->assertEquals(0, $this->relation->getVersion()); | ||||
|         $this->expectException(\TypeError::class); | ||||
|         $this->relation->getSource(); | ||||
|     } | ||||
|   | ||||
| @@ -32,6 +32,7 @@ class UserTest extends TestCase | ||||
|     public function testConstructor(): void | ||||
|     { | ||||
|         $this->assertInstanceOf(UserInterface::class, new User()); | ||||
|         $this->assertEquals(0, $this->user->getVersion()); | ||||
|     } | ||||
|  | ||||
|     public function testUsername(): void | ||||
|   | ||||
| @@ -10,7 +10,6 @@ use App\Entity\UserInterface; | ||||
|  | ||||
| class UserRepositoryTest extends KernelTestCase | ||||
| { | ||||
|     const USER_ID = 123456789; | ||||
|     /** | ||||
|      * @var EntityManager | ||||
|      */ | ||||
| @@ -28,17 +27,27 @@ class UserRepositoryTest extends KernelTestCase | ||||
|         $this->userRepository = $this->entityManager->getRepository(User::class); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @todo Test double username | ||||
|      * @todo Test double email | ||||
|      */ | ||||
|     public function testCreation(): void | ||||
|     { | ||||
|         $user = new User(); | ||||
|         $user->setId(self::USER_ID); | ||||
|         $user->setUsername('Karl Marx'); | ||||
|         $user->setEmail('mew21@test.de'); | ||||
|         $user->setPassword('Friedrich ist kein Engel!:)'); | ||||
|         $this->entityManager->persist($user); | ||||
|         $this->entityManager->flush(); | ||||
|         $userId = $user->getId(); | ||||
|         /** | ||||
|          * @var UserInterface | ||||
|          */ | ||||
|         $loadedUser = $this->userRepository->find(self::USER_ID); | ||||
|         $this->assertEquals(self::USER_ID, $loadedUser->getId()); | ||||
|         $loadedUser = $this->userRepository->find($userId); | ||||
|         $this->assertEquals($userId, $loadedUser->getId()); | ||||
|         $this->entityManager->remove($loadedUser); | ||||
|         $this->entityManager->flush(); | ||||
|         $this->assertNull($this->userRepository->find($userId)); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|   | ||||
		Reference in New Issue
	
	Block a user