Skip to content

Commit bff74bf

Browse files
committed
[TASK] Use fixture files
1 parent f923073 commit bff74bf

File tree

86 files changed

+121
-79
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+121
-79
lines changed

packages/fractor-composer-json/rules-tests/AddPackageToRequireComposerJsonFractor/AddPackageToRequireComposerJsonFractorTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ final class AddPackageToRequireComposerJsonFractorTest extends AbstractFractorTe
1515
public function test(string $filePath): void
1616
{
1717
$this->doTestFile($filePath);
18-
$this->assertThatRuleIsApplied($filePath, AddPackageToRequireComposerJsonFractor::class);
18+
$this->assertThatRuleIsApplied(AddPackageToRequireComposerJsonFractor::class);
1919
}
2020

2121
public static function provideData(): Iterator
2222
{
23-
return self::yieldFilesFromDirectory(__DIR__ . '/Fixtures', '*.json');
23+
return self::yieldFilesFromDirectory(__DIR__ . '/Fixtures', '*.json.fixture');
2424
}
2525

2626
public function provideConfigFilePath(): ?string

packages/fractor-composer-json/rules-tests/AddPackageToRequireDevComposerJsonFractor/AddPackageToRequireDevComposerJsonFractorTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ final class AddPackageToRequireDevComposerJsonFractorTest extends AbstractFracto
1515
public function test(string $filePath): void
1616
{
1717
$this->doTestFile($filePath);
18-
$this->assertThatRuleIsApplied($filePath, AddPackageToRequireDevComposerJsonFractor::class);
18+
$this->assertThatRuleIsApplied(AddPackageToRequireDevComposerJsonFractor::class);
1919
}
2020

2121
public static function provideData(): Iterator
2222
{
23-
return self::yieldFilesFromDirectory(__DIR__ . '/Fixtures', '*.json');
23+
return self::yieldFilesFromDirectory(__DIR__ . '/Fixtures', '*.json.fixture');
2424
}
2525

2626
public function provideConfigFilePath(): ?string

packages/fractor-composer-json/rules-tests/ChangePackageVersionComposerJsonFractor/ChangePackageVersionComposerJsonFractorTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ final class ChangePackageVersionComposerJsonFractorTest extends AbstractFractorT
1515
public function test(string $filePath): void
1616
{
1717
$this->doTestFile($filePath);
18-
$this->assertThatRuleIsApplied($filePath, ChangePackageVersionComposerJsonFractor::class);
18+
$this->assertThatRuleIsApplied(ChangePackageVersionComposerJsonFractor::class);
1919
}
2020

2121
public static function provideData(): Iterator
2222
{
23-
return self::yieldFilesFromDirectory(__DIR__ . '/Fixtures', '*.json');
23+
return self::yieldFilesFromDirectory(__DIR__ . '/Fixtures', '*.json.fixture');
2424
}
2525

2626
public function provideConfigFilePath(): ?string

packages/fractor-composer-json/rules-tests/RemovePackageComposerJsonFractor/RemovePackageComposerJsonFractorTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ final class RemovePackageComposerJsonFractorTest extends AbstractFractorTestCase
1515
public function test(string $filePath): void
1616
{
1717
$this->doTestFile($filePath);
18-
$this->assertThatRuleIsApplied($filePath, RemovePackageComposerJsonFractor::class);
18+
$this->assertThatRuleIsApplied(RemovePackageComposerJsonFractor::class);
1919
}
2020

2121
public static function provideData(): Iterator
2222
{
23-
return self::yieldFilesFromDirectory(__DIR__ . '/Fixtures', '*.json');
23+
return self::yieldFilesFromDirectory(__DIR__ . '/Fixtures', '*.json.fixture');
2424
}
2525

2626
public function provideConfigFilePath(): ?string

packages/fractor-composer-json/rules-tests/RenamePackageComposerJsonFractor/RenamePackageComposerJsonFractorTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ final class RenamePackageComposerJsonFractorTest extends AbstractFractorTestCase
1515
public function test(string $filePath): void
1616
{
1717
$this->doTestFile($filePath);
18-
$this->assertThatRuleIsApplied($filePath, RenamePackageComposerJsonFractor::class);
18+
$this->assertThatRuleIsApplied(RenamePackageComposerJsonFractor::class);
1919
}
2020

2121
public static function provideData(): Iterator
2222
{
23-
return self::yieldFilesFromDirectory(__DIR__ . '/Fixtures', '*.json');
23+
return self::yieldFilesFromDirectory(__DIR__ . '/Fixtures', '*.json.fixture');
2424
}
2525

2626
public function provideConfigFilePath(): ?string

packages/fractor-composer-json/rules-tests/ReplacePackageAndVersionComposerJsonFractor/ReplacePackageAndVersionComposerJsonFractorTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ final class ReplacePackageAndVersionComposerJsonFractorTest extends AbstractFrac
1515
public function test(string $filePath): void
1616
{
1717
$this->doTestFile($filePath);
18-
$this->assertThatRuleIsApplied($filePath, ReplacePackageAndVersionComposerJsonFractor::class);
18+
$this->assertThatRuleIsApplied(ReplacePackageAndVersionComposerJsonFractor::class);
1919
}
2020

2121
public static function provideData(): Iterator
2222
{
23-
return self::yieldFilesFromDirectory(__DIR__ . '/Fixtures', '*.json');
23+
return self::yieldFilesFromDirectory(__DIR__ . '/Fixtures', '*.json.fixture');
2424
}
2525

2626
public function provideConfigFilePath(): ?string

packages/fractor-fluid/tests/FluidFileProcessor/FluidFileProcessorTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ final class FluidFileProcessorTest extends AbstractFractorTestCase
1515
public function test(string $filePath): void
1616
{
1717
$this->doTestFile($filePath);
18-
$this->assertThatRuleIsApplied($filePath, DummyFluidFractorRule::class);
18+
$this->assertThatRuleIsApplied(DummyFluidFractorRule::class);
1919
}
2020

2121
public static function provideData(): Iterator
2222
{
23-
return self::yieldFilesFromDirectory(__DIR__ . '/Fixtures', '*.html');
23+
return self::yieldFilesFromDirectory(__DIR__ . '/Fixtures', '*.html.fixture');
2424
}
2525

2626
public function provideConfigFilePath(): ?string

packages/fractor-rule-generator/src/Finder/TemplateFinder.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ private function addRuleAndTestCase(string $fixtureFileExtension): array
4242
return [
4343
__DIR__ . '/../../templates/rules/TYPO3__MajorPrefixed__/__Type__/__Name__.php',
4444
__DIR__ . '/../../templates/rules-tests/TYPO3__MajorPrefixed__/__Type__/__Test_Directory__/__Name__Test.php.inc',
45-
__DIR__ . '/../../templates/rules-tests/TYPO3__MajorPrefixed__/__Type__/__Test_Directory__/Fixtures/fixture.' . $fixtureFileExtension,
45+
__DIR__ . '/../../templates/rules-tests/TYPO3__MajorPrefixed__/__Type__/__Test_Directory__/Fixtures/fixture.' . $fixtureFileExtension . '.fixture',
4646
__DIR__ . '/../../templates/rules-tests/TYPO3__MajorPrefixed__/__Type__/__Test_Directory__/config/fractor.php.inc',
4747
];
4848
}

packages/fractor-rule-generator/tests/Functional/Console/Command/GenerateRuleCommandTest.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function testCreateRuleForFlexFormWithoutChangelog(): void
9898
self::assertFileExists($basePathConfig . '/typo3-9999.php');
9999
self::assertFileExists($basePathRules . '/TYPO3v9999/FlexForm/MigrateFlexFormFractor.php');
100100
self::assertFileExists($basePathRuleTests . '/TYPO3v9999/FlexForm/MigrateFlexFormFractor/config/fractor.php');
101-
self::assertFileExists($basePathRuleTests . '/TYPO3v9999/FlexForm/MigrateFlexFormFractor/Fixtures/fixture.xml');
101+
self::assertFileExists($basePathRuleTests . '/TYPO3v9999/FlexForm/MigrateFlexFormFractor/Fixtures/fixture.xml.fixture');
102102
self::assertFileExists(
103103
$basePathRuleTests . '/TYPO3v9999/FlexForm/MigrateFlexFormFractor/MigrateFlexFormFractorTest.php.inc'
104104
);
@@ -141,7 +141,7 @@ public function testCreateRuleForFlexFormWithChangelog(): void
141141
self::assertFileExists($basePathConfig . '/typo3-9999.php');
142142
self::assertFileExists($basePathRules . '/TYPO3v9999/FlexForm/MigrateFlexFormFractor.php');
143143
self::assertFileExists($basePathRuleTests . '/TYPO3v9999/FlexForm/MigrateFlexFormFractor/config/fractor.php');
144-
self::assertFileExists($basePathRuleTests . '/TYPO3v9999/FlexForm/MigrateFlexFormFractor/Fixtures/fixture.xml');
144+
self::assertFileExists($basePathRuleTests . '/TYPO3v9999/FlexForm/MigrateFlexFormFractor/Fixtures/fixture.xml.fixture');
145145
self::assertFileExists(
146146
$basePathRuleTests . '/TYPO3v9999/FlexForm/MigrateFlexFormFractor/MigrateFlexFormFractorTest.php.inc'
147147
);
@@ -176,7 +176,7 @@ public function testCreateRuleForFluidWithoutChangelog(): void
176176
self::assertFileExists($basePathConfig . '/typo3-9999.php');
177177
self::assertFileExists($basePathRules . '/TYPO3v9999/Fluid/MigrateFluidFractor.php');
178178
self::assertFileExists($basePathRuleTests . '/TYPO3v9999/Fluid/MigrateFluidFractor/config/fractor.php');
179-
self::assertFileExists($basePathRuleTests . '/TYPO3v9999/Fluid/MigrateFluidFractor/Fixtures/fixture.html');
179+
self::assertFileExists($basePathRuleTests . '/TYPO3v9999/Fluid/MigrateFluidFractor/Fixtures/fixture.html.fixture');
180180
self::assertFileExists(
181181
$basePathRuleTests . '/TYPO3v9999/Fluid/MigrateFluidFractor/MigrateFluidFractorTest.php.inc'
182182
);
@@ -216,7 +216,7 @@ public function testCreateRuleForFluidWithChangelog(): void
216216
self::assertFileExists($basePathConfig . '/typo3-9999.php');
217217
self::assertFileExists($basePathRules . '/TYPO3v9999/Fluid/MigrateFluidFractor.php');
218218
self::assertFileExists($basePathRuleTests . '/TYPO3v9999/Fluid/MigrateFluidFractor/config/fractor.php');
219-
self::assertFileExists($basePathRuleTests . '/TYPO3v9999/Fluid/MigrateFluidFractor/Fixtures/fixture.html');
219+
self::assertFileExists($basePathRuleTests . '/TYPO3v9999/Fluid/MigrateFluidFractor/Fixtures/fixture.html.fixture');
220220
self::assertFileExists(
221221
$basePathRuleTests . '/TYPO3v9999/Fluid/MigrateFluidFractor/MigrateFluidFractorTest.php.inc'
222222
);
@@ -253,7 +253,7 @@ public function testCreateRuleForTypoScriptWithoutChangelog(): void
253253
$basePathRuleTests . '/TYPO3v9999/TypoScript/MigrateTypoScriptFractor/config/fractor.php'
254254
);
255255
self::assertFileExists(
256-
$basePathRuleTests . '/TYPO3v9999/TypoScript/MigrateTypoScriptFractor/Fixtures/fixture.typoscript'
256+
$basePathRuleTests . '/TYPO3v9999/TypoScript/MigrateTypoScriptFractor/Fixtures/fixture.typoscript.fixture'
257257
);
258258
self::assertFileExists(
259259
$basePathRuleTests . '/TYPO3v9999/TypoScript/MigrateTypoScriptFractor/MigrateTypoScriptFractorTest.php.inc'
@@ -300,7 +300,7 @@ public function testCreateRuleForTypoScriptWithChangelog(): void
300300
$basePathRuleTests . '/TYPO3v9999/TypoScript/MigrateTypoScriptFractor/config/fractor.php'
301301
);
302302
self::assertFileExists(
303-
$basePathRuleTests . '/TYPO3v9999/TypoScript/MigrateTypoScriptFractor/Fixtures/fixture.typoscript'
303+
$basePathRuleTests . '/TYPO3v9999/TypoScript/MigrateTypoScriptFractor/Fixtures/fixture.typoscript.fixture'
304304
);
305305
self::assertFileExists(
306306
$basePathRuleTests . '/TYPO3v9999/TypoScript/MigrateTypoScriptFractor/MigrateTypoScriptFractorTest.php.inc'
@@ -335,7 +335,7 @@ public function testCreateRuleForYamlWithoutChangelog(): void
335335
self::assertFileExists($basePathConfig . '/typo3-9999.php');
336336
self::assertFileExists($basePathRules . '/TYPO3v9999/Yaml/MigrateYamlFractor.php');
337337
self::assertFileExists($basePathRuleTests . '/TYPO3v9999/Yaml/MigrateYamlFractor/config/fractor.php');
338-
self::assertFileExists($basePathRuleTests . '/TYPO3v9999/Yaml/MigrateYamlFractor/Fixtures/fixture.yaml');
338+
self::assertFileExists($basePathRuleTests . '/TYPO3v9999/Yaml/MigrateYamlFractor/Fixtures/fixture.yaml.fixture');
339339
self::assertFileExists(
340340
$basePathRuleTests . '/TYPO3v9999/Yaml/MigrateYamlFractor/MigrateYamlFractorTest.php.inc'
341341
);
@@ -375,7 +375,7 @@ public function testCreateRuleForYamlWithChangelog(): void
375375
self::assertFileExists($basePathConfig . '/typo3-9999.php');
376376
self::assertFileExists($basePathRules . '/TYPO3v9999/Yaml/MigrateYamlFractor.php');
377377
self::assertFileExists($basePathRuleTests . '/TYPO3v9999/Yaml/MigrateYamlFractor/config/fractor.php');
378-
self::assertFileExists($basePathRuleTests . '/TYPO3v9999/Yaml/MigrateYamlFractor/Fixtures/fixture.yaml');
378+
self::assertFileExists($basePathRuleTests . '/TYPO3v9999/Yaml/MigrateYamlFractor/Fixtures/fixture.yaml.fixture');
379379
self::assertFileExists(
380380
$basePathRuleTests . '/TYPO3v9999/Yaml/MigrateYamlFractor/MigrateYamlFractorTest.php.inc'
381381
);
@@ -410,7 +410,7 @@ public function testCreateRuleForComposerWithoutChangelog(): void
410410
self::assertFileExists($basePathRules . '/TYPO3v9999/Composer/MigrateComposerFractor.php');
411411
self::assertFileExists($basePathRuleTests . '/TYPO3v9999/Composer/MigrateComposerFractor/config/fractor.php');
412412
self::assertFileExists(
413-
$basePathRuleTests . '/TYPO3v9999/Composer/MigrateComposerFractor/Fixtures/fixture.json'
413+
$basePathRuleTests . '/TYPO3v9999/Composer/MigrateComposerFractor/Fixtures/fixture.json.fixture'
414414
);
415415
self::assertFileExists(
416416
$basePathRuleTests . '/TYPO3v9999/Composer/MigrateComposerFractor/MigrateComposerFractorTest.php.inc'
@@ -455,7 +455,7 @@ public function testCreateRuleForComposerWithChangelog(): void
455455
self::assertFileExists($basePathRules . '/TYPO3v9999/Composer/MigrateComposerFractor.php');
456456
self::assertFileExists($basePathRuleTests . '/TYPO3v9999/Composer/MigrateComposerFractor/config/fractor.php');
457457
self::assertFileExists(
458-
$basePathRuleTests . '/TYPO3v9999/Composer/MigrateComposerFractor/Fixtures/fixture.json'
458+
$basePathRuleTests . '/TYPO3v9999/Composer/MigrateComposerFractor/Fixtures/fixture.json.fixture'
459459
);
460460
self::assertFileExists(
461461
$basePathRuleTests . '/TYPO3v9999/Composer/MigrateComposerFractor/MigrateComposerFractorTest.php.inc'

packages/fractor-typoscript/tests/TypoScriptFileProcessor/TypoScriptFileProcessorTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ class TypoScriptFileProcessorTest extends AbstractFractorTestCase
1414
public function test(string $filePath): void
1515
{
1616
$this->doTestFile($filePath);
17-
$this->assertThatRuleIsApplied($filePath, DummyTypoScriptFractorRule::class);
17+
$this->assertThatRuleIsApplied(DummyTypoScriptFractorRule::class);
1818
}
1919

2020
public static function provideData(): \Iterator
2121
{
22-
return self::yieldFilesFromDirectory(__DIR__ . '/Fixtures', '*.typoscript');
22+
return self::yieldFilesFromDirectory(__DIR__ . '/Fixtures', '*.typoscript.fixture');
2323
}
2424

2525
public function provideConfigFilePath(): ?string

packages/fractor-yaml/tests/YamlFileProcessor/YamlFileProcessorTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ final class YamlFileProcessorTest extends AbstractFractorTestCase
1515
public function test(string $filePath): void
1616
{
1717
$this->doTestFile($filePath);
18-
$this->assertThatRuleIsApplied($filePath, DummyYamlFractorRule::class);
18+
$this->assertThatRuleIsApplied(DummyYamlFractorRule::class);
1919
}
2020

2121
public static function provideData(): Iterator
2222
{
23-
return self::yieldFilesFromDirectory(__DIR__ . '/Fixtures', '*.yaml');
23+
return self::yieldFilesFromDirectory(__DIR__ . '/Fixtures', '*.yaml.fixture');
2424
}
2525

2626
public function provideConfigFilePath(): ?string

packages/fractor/src/Testing/PHPUnit/AbstractFractorTestCase.php

+30-22
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
use a9f\Fractor\Testing\Contract\FractorTestInterface;
1717
use a9f\Fractor\Testing\Fixture\FixtureFileFinder;
1818
use a9f\Fractor\Testing\Fixture\FixtureSplitter;
19+
use a9f\Fractor\Testing\PHPUnit\ValueObject\FractorTestResult;
1920
use Nette\Utils\FileSystem;
21+
use Nette\Utils\Strings;
2022
use PHPUnit\Framework\TestCase;
2123
use Psr\Container\ContainerInterface;
2224

@@ -30,8 +32,6 @@ abstract class AbstractFractorTestCase extends TestCase implements FractorTestIn
3032

3133
private FractorRunner $fractorRunner;
3234

33-
private ?string $copiedFile = null;
34-
3535
protected function setUp(): void
3636
{
3737
$this->bootContainer();
@@ -42,10 +42,8 @@ protected function setUp(): void
4242
protected function tearDown(): void
4343
{
4444
// clear temporary file
45-
if (is_string($this->inputFilePath) && is_string($this->copiedFile)) {
45+
if (\is_string($this->inputFilePath)) {
4646
FileSystem::delete($this->inputFilePath);
47-
// restore copied file
48-
FileSystem::rename($this->copiedFile, $this->inputFilePath);
4947
}
5048

5149
unset($this->currentContainer);
@@ -93,9 +91,6 @@ protected static function yieldFilesFromDirectory(string $directory, string $suf
9391

9492
protected function doTestFile(string $fixtureFilePath): void
9593
{
96-
$this->copiedFile = $fixtureFilePath . '.tmp';
97-
98-
FileSystem::copy($fixtureFilePath, $this->copiedFile);
9994
// prepare input file contents and expected file output contents
10095
$fixtureFileContents = FileSystem::read($fixtureFilePath);
10196

@@ -113,9 +108,8 @@ protected function doTestFile(string $fixtureFilePath): void
113108
$inputFilePath = $this->createInputFilePath($fixtureFilePath);
114109
// to remove later in tearDown()
115110
$this->inputFilePath = $inputFilePath;
116-
117-
if ($fixtureFilePath === $this->copiedFile) {
118-
throw new ShouldNotHappenException('Fixture file and copied file cannot be the same: ' . $fixtureFilePath);
111+
if ($fixtureFilePath === $inputFilePath) {
112+
throw new ShouldNotHappenException('Fixture file and input file cannot be the same: ' . $fixtureFilePath);
119113
}
120114

121115
// write temp file
@@ -127,9 +121,9 @@ protected function doTestFile(string $fixtureFilePath): void
127121
/**
128122
* @param class-string<FractorRule> $rule
129123
*/
130-
protected function assertThatRuleIsApplied(string $filePath, string $rule): void
124+
protected function assertThatRuleIsApplied(string $rule): void
131125
{
132-
$file = $this->fileCollector->getFileByPath($filePath);
126+
$file = $this->fileCollector->getFileByPath($this->inputFilePath);
133127
self::assertInstanceOf(File::class, $file);
134128
self::assertEquals([AppliedRule::fromClassString($rule)], $file->getAppliedRules());
135129
}
@@ -148,32 +142,46 @@ private function doTestFileMatchesExpectedContent(
148142
string $fixtureFilePath
149143
): void {
150144
// the file is now changed (if any rule matches)
151-
$changedContents = $this->processFilePath($originalFilePath);
145+
$fractorTestResult = $this->processFilePath($originalFilePath);
146+
$changedContents = $fractorTestResult->getChangedContents();
152147

153148
$fixtureFilename = basename($fixtureFilePath);
154149
$failureMessage = sprintf('Failed on fixture file "%s"', $fixtureFilename);
150+
// give more context about used rules in case of set testing
151+
if (\count($fractorTestResult->getAppliedFractorRules()) > 1) {
152+
$failureMessage .= \PHP_EOL . \PHP_EOL;
153+
$failureMessage .= 'Applied Rector rules:' . \PHP_EOL;
154+
foreach ($fractorTestResult->getAppliedFractorRules() as $appliedFractorRule) {
155+
$failureMessage .= ' * ' . $appliedFractorRule . \PHP_EOL;
156+
}
157+
}
155158

156159
self::assertSame(trim($expectedFileContents), trim($changedContents), $failureMessage);
157160
}
158161

159-
private function processFilePath(string $filePath): string
162+
private function processFilePath(string $filePath): FractorTestResult
160163
{
161164
$configurationFactory = $this->getService(ConfigurationFactory::class);
162165
$configuration = $configurationFactory->createForTests([$filePath]);
163166

164-
$this->fractorRunner->run(new NullOutput(), $configuration);
167+
$processResult = $this->fractorRunner->run(new NullOutput(), $configuration);
165168

166169
// return changed file contents
167-
return FileSystem::read($filePath);
170+
$changedFileContents = FileSystem::read($filePath);
171+
172+
return new FractorTestResult($changedFileContents, $processResult);
168173
}
169174

170175
private function createInputFilePath(string $fixtureFilePath): string
171176
{
172-
$inputFileDirectory = dirname($fixtureFilePath);
173-
174-
$trimmedFixtureFilePath = $fixtureFilePath;
175-
176-
$fixtureBasename = pathinfo($trimmedFixtureFilePath, PATHINFO_BASENAME);
177+
$inputFileDirectory = \dirname($fixtureFilePath);
178+
// remove ".fixture" suffix
179+
if (\substr_compare($fixtureFilePath, '.fixture', -\strlen('.fixture')) === 0) {
180+
$trimmedFixtureFilePath = Strings::substring($fixtureFilePath, 0, -8);
181+
} else {
182+
$trimmedFixtureFilePath = $fixtureFilePath;
183+
}
184+
$fixtureBasename = \pathinfo($trimmedFixtureFilePath, \PATHINFO_BASENAME);
177185
return $inputFileDirectory . '/' . $fixtureBasename;
178186
}
179187
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace a9f\Fractor\Testing\PHPUnit\ValueObject;
6+
7+
use a9f\Fractor\ValueObject\ProcessResult;
8+
9+
final readonly class FractorTestResult
10+
{
11+
public function __construct(
12+
private string $changedContents,
13+
private ProcessResult $processResult
14+
) {
15+
}
16+
17+
public function getChangedContents() : string
18+
{
19+
return $this->changedContents;
20+
}
21+
22+
/**
23+
* @return array<class-string<string>>
24+
*/
25+
public function getAppliedFractorRules() : array
26+
{
27+
$appliedRules = [];
28+
foreach ($this->processResult->getFileDiffs() as $fileDiff) {
29+
$appliedRules = \array_merge($appliedRules, $fileDiff->getAppliedRules());
30+
}
31+
\sort($appliedRules);
32+
return \array_unique($appliedRules);
33+
}
34+
}

0 commit comments

Comments
 (0)