From e5bd4e58415582ac8123c61130f53abe6f551d6e Mon Sep 17 00:00:00 2001 From: Dave Smith-Hayes Date: Mon, 18 Nov 2024 03:12:56 +0000 Subject: [PATCH] Get a user from the database --- .../Domain/Repository/UserRepositoryTest.php | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/app/tests/Domain/Repository/UserRepositoryTest.php b/app/tests/Domain/Repository/UserRepositoryTest.php index 381d5e2..36044d6 100644 --- a/app/tests/Domain/Repository/UserRepositoryTest.php +++ b/app/tests/Domain/Repository/UserRepositoryTest.php @@ -50,4 +50,33 @@ class UserRepositoryTest extends TestCase (new \DateTime())->format("dmY") ); } + + public function getGettingUsers(): void + { + $hasher = new BasicUserAuthorization(); + $password = "password"; + $hashedPassword = $hasher->hash($password); + + $databaseHandler = $this->prophesize(DatabaseHandlerInterface::class); + $databaseHandler + ->query(Argument::type('string'), Argument::type('array')) + ->willReturn([ + [ + 'id' => 1, + 'name' => 'Dave Test', + 'email' => 'dave.test@email', + 'password' => $hashedPassword, + 'created_at' => '2024-11-17T00:00:00', + 'updated_at' => '2024-11-17T00:00:00' + ] + ]); + + $userRepository = new UserRepository( + $databaseHandler->reveal(), + $hasher + ); + + $user = $user->get(1); + $this->assertEquals("Dave Test", $user->getName()); + } }