/** * @param FileTool $tool * @param string $input * @param array $errorLines * @throws \Exception */ public static function assertReview(FileTool $tool, $input, array $errorLines) { $path = tempnam(sys_get_temp_dir(), 'review-test'); file_put_contents($path, $input); $report = new Report(); try { $file = new File($path, File::STATUS_UNKNOWN); self::assertNotEmpty($file->getContent()->get()); $tool->process($file, $report); $output = $file->getContent()->get(); self::assertEquals($input, $output, 'Review should not change source code. Tool:' . $tool->getName()); } catch (\Exception $e) { throw $e; } finally { /** @noinspection PhpUsageOfSilenceOperatorInspection */ @unlink($path); } $reportErrorLines = []; foreach ($report as $message) { $reportErrorLines[] = $message->getLine(); } self::assertEquals($reportErrorLines, $errorLines, 'Invalid error lines. Tool: ' . $tool->getName()); }
/** * @param FileTool $fileTool * @return $this */ public function removeTool(FileTool $fileTool) { $name = $fileTool->getName(); unset($this->tools[$name]); return $this; }