39 lines
1,005 B
PHP
39 lines
1,005 B
PHP
<?php
|
|
|
|
namespace Tests\Feature\Database;
|
|
|
|
use App\Auth\PasswordHasher;
|
|
use App\Shared\ValueObject\EmailAddress;
|
|
use App\User\UserRepository;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Tests\TestCase;
|
|
|
|
class DatabaseSeederTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_it_seeds_the_development_user_idempotently(): void
|
|
{
|
|
$this->seed();
|
|
$this->seed();
|
|
|
|
$this->assertDatabaseHas('users', [
|
|
'email' => 'user@example.com',
|
|
]);
|
|
$this->assertDatabaseMissing('users', [
|
|
'email' => 'user@example.com',
|
|
'passwordHash' => 'password',
|
|
]);
|
|
$this->assertDatabaseCount('users', 1);
|
|
|
|
$user = app(UserRepository::class)->findByEmail(
|
|
new EmailAddress('user@example.com'),
|
|
);
|
|
|
|
$this->assertNotNull($user);
|
|
$this->assertTrue(app(PasswordHasher::class)->verify(
|
|
'password',
|
|
$user->getPasswordHash(),
|
|
));
|
|
}
|
|
}
|