public function grade(CodingExecutionResult $result) { $result->assertInputContains('index.php', 'foreach'); $result->assertElementContains('h3', 'Kitty'); $result->assertElementContains('h3', 'Tiger'); $result->assertElementContains('h3', 'Jay'); $buttonCount = substr_count($result->getOutput(), '<button>'); if ($buttonCount == 0) { throw new GradingException('Don\'t forget to add a `<button>Schedule me</button>` inside the `foreach` for each walker!'); } if ($buttonCount == 1) { throw new GradingException('I only see 1 `<button>` - make sure to include this *inside* the `foreach` loop so that 3 are printed'); } if ($buttonCount != 3) { throw new GradingException('There should be 3 `<button>` element exactly'); } }