@@ -23,6 +23,11 @@ final class FileHashComputerTest extends AbstractLazyTestCase
2323 */
2424 private array $ originalFileExtensions = [];
2525
26+ /**
27+ * @var mixed[]
28+ */
29+ private array $ originalRuleConfigurations = [];
30+
2631 protected function setUp (): void
2732 {
2833 parent ::setUp ();
@@ -32,12 +37,14 @@ protected function setUp(): void
3237 // the parameter bag is a global static shared across the whole test process, restore it after
3338 $ this ->originalRules = SimpleParameterProvider ::provideArrayParameter (Option::REGISTERED_RECTOR_RULES );
3439 $ this ->originalFileExtensions = SimpleParameterProvider ::provideArrayParameter (Option::FILE_EXTENSIONS );
40+ $ this ->originalRuleConfigurations = SimpleParameterProvider ::provideArrayParameter (Option::RULE_CONFIGURATIONS );
3541 }
3642
3743 protected function tearDown (): void
3844 {
3945 SimpleParameterProvider ::setParameter (Option::REGISTERED_RECTOR_RULES , $ this ->originalRules );
4046 SimpleParameterProvider ::setParameter (Option::FILE_EXTENSIONS , $ this ->originalFileExtensions );
47+ SimpleParameterProvider ::setParameter (Option::RULE_CONFIGURATIONS , $ this ->originalRuleConfigurations );
4148 }
4249
4350 public function testOutputAffectingParameterChangesHash (): void
@@ -66,4 +73,22 @@ public function testRuleChangeIsExcludedFromHash(): void
6673
6774 $ this ->assertSame ($ hashBefore , $ hashAfter );
6875 }
76+
77+ public function testConfiguredRuleValueChangeChangesHash (): void
78+ {
79+ $ configFilePath = __DIR__ . '/Fixture/rector.php ' ;
80+
81+ SimpleParameterProvider ::setParameter (Option::RULE_CONFIGURATIONS , [
82+ 'Rector \\SomeRule ' => ['old value ' ],
83+ ]);
84+ $ hashBefore = $ this ->fileHashComputer ->compute ($ configFilePath );
85+
86+ // same rule, changed configuration value must invalidate the cache
87+ SimpleParameterProvider ::setParameter (Option::RULE_CONFIGURATIONS , [
88+ 'Rector \\SomeRule ' => ['new value ' ],
89+ ]);
90+ $ hashAfter = $ this ->fileHashComputer ->compute ($ configFilePath );
91+
92+ $ this ->assertNotSame ($ hashBefore , $ hashAfter );
93+ }
6994}
0 commit comments