Skip to content

Commit 8411725

Browse files
committed
#90 Add created answers to return
1 parent 5cb4d82 commit 8411725

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

api/src/DataFixtures/AppFixtures.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,17 @@ public function createQuestions(array $questions, Quiz $quiz): array
6767
/**
6868
* @param array{array{content: string, is_correct: boolean, display_order: integer}} $answers
6969
* @param Question $question
70+
* @return array<int, Answer> $createdAnswers
7071
*/
71-
public function createAnswers(array $answers, Question $question): void
72+
public function createAnswers(array $answers, Question $question): array
7273
{
74+
$createdAnswers = [];
7375
foreach ($answers as $answerData) {
74-
$this->createAnswer($answerData, $question);
76+
$answer = $this->createAnswer($answerData, $question);
77+
$createdAnswers[] = $answer;
7578
}
79+
80+
return $createdAnswers;
7681
}
7782

7883
/**

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,13 @@ public function testCreateAnswers()
8989
$question = new Question;
9090
$question->setContent('Test content');
9191

92-
$createAnswersFunction = $this->appFixtures->createAnswers($question1[0]['answers'], $question);
92+
$createdAnswers = $this->appFixtures->createAnswers($question1[0]['answers'], $question);
9393

94-
self::assertNull($createAnswersFunction);
94+
self::assertIsArray($createdAnswers);
95+
96+
foreach ($createdAnswers as $answer) {
97+
self::assertInstanceOf(Answer::class, $answer);
98+
}
9599
}
96100

97101
public function testGetDataSets()

0 commit comments

Comments
 (0)