-
-
Notifications
You must be signed in to change notification settings - Fork 439
Expand file tree
/
Copy pathApplicationFileProcessorTest.php
More file actions
65 lines (48 loc) · 2.04 KB
/
Copy pathApplicationFileProcessorTest.php
File metadata and controls
65 lines (48 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
declare(strict_types=1);
namespace Rector\Tests\Application\ApplicationFileProcessor;
use Rector\Application\ApplicationFileProcessor;
use Rector\Caching\Detector\ChangedFilesDetector;
use Rector\DeadCode\Rector\ClassMethod\RemoveEmptyClassMethodRector;
use Rector\Testing\PHPUnit\AbstractLazyTestCase;
use Rector\ValueObject\Configuration;
final class ApplicationFileProcessorTest extends AbstractLazyTestCase
{
private ApplicationFileProcessor $applicationFileProcessor;
private ChangedFilesDetector $changedFilesDetector;
protected function setUp(): void
{
parent::setUp();
$this->applicationFileProcessor = $this->make(ApplicationFileProcessor::class);
$this->changedFilesDetector = $this->make(ChangedFilesDetector::class);
}
protected function tearDown(): void
{
$this->changedFilesDetector->clear();
}
public function testCleanFileIsCachedAsUnchanged(): void
{
$filePath = __DIR__ . '/Source/CleanFile.php';
$this->applicationFileProcessor->processFiles([$filePath], new Configuration(isDryRun: true));
$this->assertFalse($this->changedFilesDetector->hasFileChanged($filePath));
}
public function testOnlyRuleRunDoesNotCacheFileAsUnchanged(): void
{
$filePath = __DIR__ . '/Source/CleanFile.php';
$this->applicationFileProcessor->processFiles([$filePath], new Configuration(
isDryRun: true,
onlyRule: RemoveEmptyClassMethodRector::class
));
// a file clean under one rule is not necessarily clean under all rules
$this->assertTrue($this->changedFilesDetector->hasFileChanged($filePath));
}
public function testOnlySuffixRunDoesNotCacheFileAsUnchanged(): void
{
$filePath = __DIR__ . '/Source/CleanFile.php';
$this->applicationFileProcessor->processFiles([$filePath], new Configuration(
isDryRun: true,
onlySuffix: 'Controller.php'
));
$this->assertTrue($this->changedFilesDetector->hasFileChanged($filePath));
}
}