getUserFromArray(); $databaseHandler = $this->prophesize(DatabaseHandlerInterface::class); $databaseHandler->insert( Argument::type('string'), Argument::type('array') )->willReturn(true); $databaseHandler->getConnection()->willReturn(new class { public function lastInsertId(): int { return 100; } }); $userRepository = new UserRepository( $databaseHandler->reveal(), new BasicUserAuthorization() ); $results = $userRepository->create($user); $this->assertTrue($results); /** * We are testing if the User entity has been mutated by the `create` * method in the UserRepository. */ $this->assertEquals(100, $user->getId()); } }