fix: DockerSecretsResolver - don't normalize absolute paths like /var/www/html/...
Some checks failed
Deploy Application / deploy (push) Has been cancelled
Some checks failed
Deploy Application / deploy (push) Has been cancelled
This commit is contained in:
66
tests/Framework/Database/Seed/SeedRepositoryTest.php
Normal file
66
tests/Framework/Database/Seed/SeedRepositoryTest.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use App\Framework\Database\ConnectionInterface;
|
||||
use App\Framework\Database\Seed\SeedRepository;
|
||||
use App\Framework\Database\ValueObjects\SqlQuery;
|
||||
use App\Framework\DateTime\SystemClock;
|
||||
|
||||
describe('SeedRepository', function () {
|
||||
beforeEach(function () {
|
||||
$this->connection = Mockery::mock(ConnectionInterface::class);
|
||||
$this->clock = new SystemClock();
|
||||
$this->repository = new SeedRepository($this->connection, $this->clock);
|
||||
});
|
||||
|
||||
it('checks if seeder has run', function () {
|
||||
$result = Mockery::mock();
|
||||
$result->shouldReceive('fetch')
|
||||
->once()
|
||||
->andReturn(['count' => 1]);
|
||||
|
||||
$this->connection->shouldReceive('query')
|
||||
->once()
|
||||
->with(Mockery::on(function (SqlQuery $query) {
|
||||
return str_contains($query->sql, 'SELECT COUNT(*)');
|
||||
}))
|
||||
->andReturn($result);
|
||||
|
||||
expect($this->repository->hasRun('TestSeeder'))->toBeTrue();
|
||||
});
|
||||
|
||||
it('returns false when seeder has not run', function () {
|
||||
$result = Mockery::mock();
|
||||
$result->shouldReceive('fetch')
|
||||
->once()
|
||||
->andReturn(['count' => 0]);
|
||||
|
||||
$this->connection->shouldReceive('query')
|
||||
->once()
|
||||
->andReturn($result);
|
||||
|
||||
expect($this->repository->hasRun('TestSeeder'))->toBeFalse();
|
||||
});
|
||||
|
||||
it('marks seeder as run', function () {
|
||||
$this->connection->shouldReceive('execute')
|
||||
->once()
|
||||
->with(Mockery::on(function (SqlQuery $query) {
|
||||
return str_contains($query->sql, 'INSERT INTO seeds');
|
||||
}));
|
||||
|
||||
$this->repository->markAsRun('TestSeeder', 'Test description');
|
||||
});
|
||||
|
||||
it('clears all seeds', function () {
|
||||
$this->connection->shouldReceive('execute')
|
||||
->once()
|
||||
->with(Mockery::on(function (SqlQuery $query) {
|
||||
return str_contains($query->sql, 'DELETE FROM seeds');
|
||||
}));
|
||||
|
||||
$this->repository->clearAll();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user