test set layout browsing
This commit is contained in:
parent
936855efab
commit
eb7ac7d261
8 changed files with 619 additions and 3 deletions
|
|
@ -3,6 +3,8 @@
|
|||
namespace Tests\Feature\Database;
|
||||
|
||||
use App\Auth\PasswordHasher;
|
||||
use App\Element\Element;
|
||||
use App\Element\ElementRepository;
|
||||
use App\Set\SetRepository;
|
||||
use App\Shared\ValueObject\EmailAddress;
|
||||
use App\User\UserRepository;
|
||||
|
|
@ -60,4 +62,60 @@ class DatabaseSeederTest extends TestCase
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function test_it_seeds_elements_for_every_set_idempotently(): void
|
||||
{
|
||||
$this->seed();
|
||||
$this->seed();
|
||||
|
||||
$sets = app(SetRepository::class)->all();
|
||||
$elementRepository = app(ElementRepository::class);
|
||||
$expectedElements = [
|
||||
'Bible' => [
|
||||
'Chapter 1:chapter:Creation',
|
||||
'Chapter 2:chapter:Creation',
|
||||
'Creation:portion:Genesis',
|
||||
'Exodus:book:root',
|
||||
'Genesis:book:root',
|
||||
'Noah:portion:Genesis',
|
||||
'Shemot:portion:Exodus',
|
||||
],
|
||||
'Course' => [
|
||||
'Applied Practice:module:root',
|
||||
'Core Concepts:lesson:Foundations',
|
||||
'Final Review:lesson:Applied Practice',
|
||||
'Foundations:module:root',
|
||||
'Guided Exercise:lesson:Applied Practice',
|
||||
'Welcome:lesson:Foundations',
|
||||
],
|
||||
'Fitness Program' => [
|
||||
'Build Phase:phase:root',
|
||||
'Foundation Phase:phase:root',
|
||||
'Full Body Circuit:workout:Build Phase',
|
||||
'Hip Flow:exercise:Mobility Day',
|
||||
'Mobility Day:workout:Foundation Phase',
|
||||
'Push-up:exercise:Strength Day',
|
||||
'Squat:exercise:Strength Day',
|
||||
'Strength Day:workout:Foundation Phase',
|
||||
],
|
||||
];
|
||||
|
||||
$this->assertDatabaseCount('elements', 21);
|
||||
|
||||
foreach ($sets as $set) {
|
||||
$signatures = array_map(function (Element $element): string {
|
||||
$parentName = $element->getParentElement()?->getName()
|
||||
?? 'root';
|
||||
|
||||
return "{$element->getName()}:{$element->getKind()}"
|
||||
. ":{$parentName}";
|
||||
}, $elementRepository->findBySet($set));
|
||||
sort($signatures);
|
||||
|
||||
$this->assertSame(
|
||||
$expectedElements[$set->getName()],
|
||||
$signatures,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue