Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,22 @@ lendable_phpunit:
pardoned:
- Foo\Bar\MyTest
```

## Rector

A [Rector](https://getrector.com/) rule is provided to automate adopting strict mocking across a test suite.

`Lendable\PHPUnitExtensions\Rector\EnforceDisableReturnValueGenerationForTestDoublesRector` adds PHPUnit's `#[DisableReturnValueGenerationForTestDoubles]` attribute to test classes that do not already have it. Abstract classes are skipped, since the attribute only has an effect when placed on the concrete test class.

Register the rule in your Rector configuration:

```php
use Lendable\PHPUnitExtensions\Rector\EnforceDisableReturnValueGenerationForTestDoublesRector;
use Rector\Config\RectorConfig;

return RectorConfig::configure()
// ...
->withRules([EnforceDisableReturnValueGenerationForTestDoublesRector::class]);
```

With the closure-style configuration, register it via `$rectorConfig->rule(EnforceDisableReturnValueGenerationForTestDoublesRector::class)`.
Loading