mardi 26 janvier 2016

Laravel 5 / PHPUnit: Assertion behaves differently in loop

5000 kudos to the person who can tell me why this is happening;

I can test each of my quizzes individually, and they all will pass, using this method:

public $quiz_ids = [
      6,
    ];

If I allow my loop to run for more than a single ID, the test will fail

public $quiz_ids = [
      1, 2, 3, 4, 5, 6,
    ];

The foreach loop:

foreach($this->quiz_ids as $quiz_id) {
  $quiz = App\Quiz::find($quiz_id);
  $input = $quiz->getCorrectInput();

  echo "Quiz: ".$quiz->id;

  $this->post('api/quiz/'.$this->quiz_id, $input)
        ->seeJson([
         "passed" => true
         ]);
}

Is this a known issue in PHPUnit?

Aucun commentaire:

Enregistrer un commentaire