getOption(self::COVERAGE_OPTION)) { $this->coverage = true; $originals[] = '--coverage-php'; $originals[] = \Pest\Support\Coverage::getPath(); if (! \Pest\Support\Coverage::isAvailable()) { if (\Pest\Support\Coverage::usingXdebug()) { $this->output->writeln([ '', " ERROR Unable to get coverage using Xdebug. Did you set Xdebug's coverage mode?", '', ]); } else { $this->output->writeln([ '', ' ERROR No code coverage driver is available.', '', ]); } exit(1); } } if ($input->getOption(self::MIN_OPTION) !== null) { /** @var int|float $minOption */ $minOption = $input->getOption(self::MIN_OPTION); $this->coverageMin = (float) $minOption; } return $originals; } /** * {@inheritdoc} */ public function addOutput(int $exitCode): int { if ($exitCode === 0 && $this->coverage) { if (! \Pest\Support\Coverage::isAvailable()) { $this->output->writeln( "\n ERROR No code coverage driver is available.", ); exit(1); } $coverage = \Pest\Support\Coverage::report($this->output); $exitCode = (int) ($coverage < $this->coverageMin); if ($exitCode === 1) { $this->output->writeln(sprintf( "\n FAIL Code coverage below expected: %s %%. Minimum: %s %%.", number_format($coverage, 1), number_format($this->coverageMin, 1) )); } $this->output->writeln(['']); } return $exitCode; } }