35 lines
1015 B
PHP
35 lines
1015 B
PHP
<?php
|
|
|
|
namespace Slovocast\Tests\Domain\Repository;
|
|
|
|
use Slovocast\Domain\Repository\User\UserRepository;
|
|
use Slovocast\Infrastructure\Api\Database\DatabaseHandlerInterface;
|
|
use Slovocast\Infrastructure\User\BasicUserAuthorization;
|
|
use Slovocast\Tests\TestCase;
|
|
|
|
class UserRepositoryTest extends TestCase
|
|
{
|
|
public function testRegisteringAUser(): void
|
|
{
|
|
$user = $this->getUserFromArray();
|
|
$databaseHandler = $this->prophesize(DatabaseHandlerInterface::class);
|
|
|
|
$databaseHandler->insert()->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);
|
|
$this->assertEquals(100, $user->getId());
|
|
}
|
|
}
|