/** * Validate code examples in $file * * @param \SplFileObject $file * @param string $formatIdentifier * @return void */ public function assertFile(\SplFileObject $file, $formatIdentifier = '') { $format = $this->formatFactory->createFormat($formatIdentifier ?: $file->getExtension()); $result = $this->testCase->getTestResultObject(); foreach ($this->tester->test($file, $format) as $example => $returnObj) { $this->testCase->addToAssertionCount(1); if ($returnObj->isFailure()) { $result->addFailure($this->testCase, new \PHPUnit_Framework_AssertionFailedError("Example {$example}: {$returnObj->getMessage()}"), 0.0); } } }