Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
nunomaduro committed Sep 5, 2024
1 parent 9340cce commit bc11eaa
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/Plugins/Mutate.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Pest\Mutate\Plugins;

use NunoMaduro\Collision\Highlighter;
use Pest\Contracts\Bootstrapper;
use Pest\Contracts\Plugins\AddsOutput;
use Pest\Contracts\Plugins\Bootable;
Expand Down Expand Up @@ -132,7 +133,7 @@ public function handleArguments(array $arguments): array
}

$arguments = Container::getInstance()->get(ConfigurationRepository::class) // @phpstan-ignore-line
->cliConfiguration->fromArguments($arguments);
->cliConfiguration->fromArguments($arguments);

$mutationTestRunner->setOriginalArguments($arguments);

Expand All @@ -152,25 +153,28 @@ public function addOutput(int $exitCode): int
return $exitCode;
}

/** @var ConfigurationRepository $configuration */
$configuration = Container::getInstance()->get(ConfigurationRepository::class)->mergedConfiguration();
/** @var ConfigurationRepository $configurationRepository */
$configurationRepository = Container::getInstance()->get(ConfigurationRepository::class);
$configuration = $configurationRepository->mergedConfiguration();

if (! Only::isEnabled() && ! $configuration->everything) {
throw new InvalidOption(<<<'ERROR'
Mutation testing requires the usage of the `covers()` function. Here is an example:

```
<?php
$this->output->writeln([' <bg=red> ERROR </> Mutation testing requires the usage of the `covers()` function. Here is an example:', '']);

$highlighter = new Highlighter;
$content = $highlighter->highlight(<<<'PHP'
covers(TodoController::class); // mutations will be generated only for this class
it('list todos', function () {
// your test here...
});
```
PHP, 1);

Optionally, you can use the `--everything` flag for generating mutations for "covered" classes, but this is not recommended as it will slow down the mutation testing process.
ERROR);
$this->output->writeln($content);

$this->output->writeln(['', ' <bg=cyan> INFO </> Optionally, you can use the `--everything` flag for generating mutations for "covered" classes, but this is not recommended as it will slow down the mutation testing process.', '']);

return 1;
}

return $mutationTestRunner->run();
Expand Down

0 comments on commit bc11eaa

Please sign in to comment.