Skip to content

Commit

Permalink
[tests] Improve resetable interface call (#4834)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Aug 23, 2023
1 parent 37be2c2 commit c73bc29
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
1 change: 0 additions & 1 deletion packages-tests/Skipper/Skipper/SkipperRectorRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ protected function setUp(): void
self::$rectorConfig = null;
}


protected function tearDown(): void
{
// cleanup configuration
Expand Down
12 changes: 8 additions & 4 deletions packages/Testing/PHPUnit/AbstractRectorTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Rector\Core\Configuration\ConfigurationFactory;
use Rector\Core\Configuration\Option;
use Rector\Core\Configuration\Parameter\SimpleParameterProvider;
use Rector\Core\Configuration\RenamedClassesDataCollector;
use Rector\Core\Contract\DependencyInjection\ResetableInterface;
use Rector\Core\Contract\Rector\RectorInterface;
use Rector\Core\Exception\ShouldNotHappenException;
use Rector\Core\PhpParser\NodeTraverser\RectorNodeTraverser;
Expand Down Expand Up @@ -70,9 +70,13 @@ protected function setUp(): void
$cacheKey = sha1($configFile . static::class);

if (! isset(self::$cacheByRuleAndConfig[$cacheKey])) {
// reset class rename
$renamedClassesDataCollector = $rectorConfig->make(RenamedClassesDataCollector::class);
$renamedClassesDataCollector->reset();
// reset
/** @var RewindableGenerator<int, ResetableInterface> $resetables */
$resetables = $rectorConfig->tagged(ResetableInterface::class);
foreach ($resetables as $resetable) {
/** @var ResetableInterface $resetable */
$resetable->reset();
}

$this->forgetRectorsRules();

Expand Down

0 comments on commit c73bc29

Please sign in to comment.