48 lines
2.1 KiB
PHP
48 lines
2.1 KiB
PHP
<?php
|
|
|
|
it('task-questions.php config exists', function () {
|
|
expect(file_exists(base_path('config/task-questions.php')))->toBeTrue();
|
|
});
|
|
|
|
it('config is keyed by task slug (semantic, not by color)', function () {
|
|
$bank = config('task-questions');
|
|
// Should NOT have keys 'primary', 'rose', etc. directly
|
|
foreach (['primary', 'rose', 'violet', 'green', 'amber'] as $color) {
|
|
expect(array_key_exists($color, $bank))->toBeFalse("Bank should be slug-keyed, not color-keyed; found '{$color}'");
|
|
}
|
|
// Should have task slugs
|
|
expect(array_key_exists('math-multiplikation-bis-100', $bank))->toBeTrue();
|
|
expect(array_key_exists('deutsch-wortarten-nomen-verben', $bank))->toBeTrue();
|
|
});
|
|
|
|
it('each question has required keys (question, options, correct, lerni_hint, lerni_steps)', function () {
|
|
$bank = config('task-questions');
|
|
foreach ($bank as $slug => $questions) {
|
|
foreach ($questions as $i => $q) {
|
|
expect($q)->toHaveKeys(['question', 'options', 'correct', 'lerni_hint', 'lerni_steps']);
|
|
expect($q['options'])->toHaveCount(4);
|
|
expect($q['correct'])->toBeInt()->toBeGreaterThanOrEqual(0)->toBeLessThan(4);
|
|
expect($q['lerni_steps'])->toBeArray()->not->toBeEmpty();
|
|
}
|
|
}
|
|
});
|
|
|
|
it('each task slug in config/tasks.php has a matching question bank', function () {
|
|
foreach (config('tasks', []) as $t) {
|
|
$bank = config("task-questions.{$t['slug']}");
|
|
expect($bank)->toBeArray()->not->toBeEmpty("Task slug '{$t['slug']}' has no question bank");
|
|
}
|
|
});
|
|
|
|
it('different task slugs return different questions', function () {
|
|
$math = config('task-questions.math-multiplikation-bis-100');
|
|
$german = config('task-questions.deutsch-wortarten-nomen-verben');
|
|
expect($math[0]['question'])->not->toBe($german[0]['question']);
|
|
});
|
|
|
|
it('math-geometrie and math-multiplikation share color but have different questions', function () {
|
|
$mult = config('task-questions.math-multiplikation-bis-100');
|
|
$geom = config('task-questions.math-geometrie-flaechen');
|
|
expect($mult[0]['question'])->not->toBe($geom[0]['question']);
|
|
});
|