Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/QuickInstall/Sandbox/BoardService.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,13 @@ public function seed(string $name, string $preset, int $seed, string $action): v
throw new InvalidArgumentException('SQLite boards do not support fixture seeding. Use --reset to remove partial seed data, or use mariadb, mysql, or postgres for seeded boards.');
}

$this->createBoardRunner()->seed($name, $preset, $seed, $action);
$runner = $this->createBoardRunner();
if ($runner->status($name) !== 'running')
{
throw new RuntimeException('Board must be running before seeding. Start it first.');
}

$runner->seed($name, $preset, $seed, $action);
}

protected function createBoardRunner(): BoardRunner
Expand Down
15 changes: 15 additions & 0 deletions tests/Unit/BoardServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public function testStartStopDestroyAndSeedDelegateToRunner(): void
$project = $this->projectWithSource('3.3.14');
$project->appendBoard(['name' => 'demo', 'db' => 'mariadb']);
$runner = new ServiceTestBoardRunner($project);
$runner->statuses['demo'] = 'running';
$service = new TestBoardService($project, $runner);

self::assertSame('demo', $service->start('demo')['name']);
Expand All @@ -105,6 +106,19 @@ public function testStartStopDestroyAndSeedDelegateToRunner(): void
self::assertSame(['demo'], $runner->destroyed);
}

public function testSeedRequiresRunningBoard(): void
{
$project = $this->projectWithSource('3.3.14');
$project->appendBoard(['name' => 'demo', 'db' => 'mariadb']);
$runner = new ServiceTestBoardRunner($project);
$runner->statuses['demo'] = 'stopped';

$this->expectException(\RuntimeException::class);
$this->expectExceptionMessage('Board must be running before seeding. Start it first.');

(new TestBoardService($project, $runner))->seed('demo', 'tiny', 1, 'seed');
}

/**
* @dataProvider sqliteSeedActionProvider
*/
Expand All @@ -113,6 +127,7 @@ public function testSqliteSeedActionRules(string $action, bool $allowed): void
$project = $this->projectWithSource('3.3.14');
$project->appendBoard(['name' => 'demo', 'db' => 'sqlite']);
$runner = new ServiceTestBoardRunner($project);
$runner->statuses['demo'] = 'running';

if (!$allowed)
{
Expand Down