lernschiff/tests/Feature/Frontend/TaskQuestionBankTest.php

32 lines
1.2 KiB
PHP

<?php
it('task-questions.php config exists', function () {
expect(file_exists(base_path('config/task-questions.php')))->toBeTrue();
});
it('config has buckets for all 5 subject colors', function () {
$bank = config('task-questions');
foreach (['primary', 'rose', 'violet', 'green', 'amber'] as $color) {
expect(array_key_exists($color, $bank))->toBeTrue("Question bank missing color '{$color}'");
expect($bank[$color])->toBeArray()->not->toBeEmpty();
}
});
it('each question has required keys (question, options, correct)', function () {
$bank = config('task-questions');
foreach ($bank as $color => $questions) {
foreach ($questions as $i => $q) {
expect($q)->toHaveKeys(['question', 'options', 'correct']);
expect($q['options'])->toHaveCount(4);
expect($q['correct'])->toBeInt()->toBeGreaterThanOrEqual(0)->toBeLessThan(4);
}
}
});
it('Math (primary) questions differ from German (rose)', function () {
$bank = config('task-questions');
$mathFirst = $bank['primary'][0]['question'];
$germanFirst = $bank['rose'][0]['question'];
expect($mathFirst)->not->toBe($germanFirst);
});