Skip to content

Commit 5cb4d82

Browse files
committed
#90 Add created questions to return
1 parent 38f91d2 commit 5cb4d82

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

api/src/DataFixtures/AppFixtures.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,21 @@ public function createQuizzes(): array
4747
/**
4848
* @param array{array{content:string, quiz: string, answers: array{array{content: string, is_correct: boolean, display_order: integer}} }} $questions
4949
* @param Quiz $quiz
50+
* @return array<int, Question> $createdQuestions
5051
*/
51-
public function createQuestions(array $questions, Quiz $quiz): void
52+
public function createQuestions(array $questions, Quiz $quiz): array
5253
{
54+
$createdQuestions = [];
5355
foreach ($questions as $questionData) {
5456
$question = $this->createQuestion($questionData, $quiz);
5557
$answers = $questionData['answers'];
5658

5759
$this->createAnswers($answers, $question);
60+
61+
$createdQuestions[] = $question;
5862
}
63+
64+
return $createdQuestions;
5965
}
6066

6167
/**

api/tests/unit/config/fixtures/data_fixtures/AppFixturesTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,13 @@ public function testCreateQuestions()
7474
$quiz->setTitle('Test title');
7575
$quiz->setSlug('test-slug');
7676

77-
$createQuestionsFunction = $this->appFixtures->createQuestions($html['questions'], $quiz);
77+
$createdQuestions = $this->appFixtures->createQuestions($html['questions'], $quiz);
7878

79-
self::assertNull($createQuestionsFunction);
79+
self::assertIsArray($createdQuestions);
80+
81+
foreach ($createdQuestions as $question) {
82+
self::assertInstanceOf(Question::class, $question);
83+
}
8084
}
8185

8286
public function testCreateAnswers()

0 commit comments

Comments
 (0)