Skip to content

Commit 82a2f29

Browse files
committed
more fixtures
1 parent e3d0328 commit 82a2f29

File tree

2 files changed

+46
-16
lines changed

2 files changed

+46
-16
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"suggest": {
3+
"illuminate/container": "to use container"
4+
},
5+
"require-dev": {
6+
"illuminate/container": "^9.0"
7+
}
8+
}

tests/ComposerProcessor/RaiseToInstalledComposerProcessor/RaiseToInstalledComposerProcessorTest.php

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Rector\Jack\Tests\ComposerProcessor\RaiseToInstalledComposerProcessor;
66

77
use Nette\Utils\FileSystem;
8+
use PHPUnit\Framework\Attributes\DataProvider;
89
use Rector\Jack\ComposerProcessor\RaiseToInstalledComposerProcessor;
910
use Rector\Jack\Tests\AbstractTestCase;
1011
use Rector\Jack\ValueObject\ChangedPackageVersion;
@@ -49,9 +50,43 @@ public function testSkipDev(): void
4950
$this->assertEmpty($changedPackageVersionsResult->getChangedPackageVersions());
5051
}
5152

52-
public function testSkipSuggestChange(): void
53+
public static function provideSkipSuggestChangeFiles(): iterable
5354
{
54-
$composerJsonContents = FileSystem::read(__DIR__ . '/Fixture/skip-suggest.json');
55+
yield [
56+
__DIR__ . '/Fixture/skip-suggest.json',
57+
<<<'JSON'
58+
{
59+
"require-dev": {
60+
"illuminate/container": "^12.19"
61+
},
62+
"suggest": {
63+
"illuminate/container": "to use container"
64+
}
65+
}
66+
67+
JSON
68+
];
69+
70+
yield [
71+
__DIR__ . '/Fixture/skip-suggest-early-definition.json',
72+
<<<'JSON'
73+
{
74+
"suggest": {
75+
"illuminate/container": "to use container"
76+
},
77+
"require-dev": {
78+
"illuminate/container": "^12.19"
79+
}
80+
}
81+
82+
JSON
83+
];
84+
}
85+
86+
#[DataProvider('provideSkipSuggestChangeFiles')]
87+
public function testSkipSuggestChange(string $file, string $changedFileContent): void
88+
{
89+
$composerJsonContents = FileSystem::read($file);
5590

5691
$changedPackageVersionsResult = $this->raiseToInstalledComposerProcessor->process($composerJsonContents);
5792

@@ -61,20 +96,7 @@ public function testSkipSuggestChange(): void
6196
$this->assertSame('^9.0', $changedPackageVersion->getOldVersion());
6297
$this->assertSame('^12.19', $changedPackageVersion->getNewVersion());
6398

64-
$this->assertSame(<<<'JSON'
65-
{
66-
"require-dev": {
67-
"illuminate/container": "^12.19"
68-
},
69-
"suggest": {
70-
"illuminate/container": "to use container"
71-
}
72-
}
73-
74-
JSON
75-
,
76-
$changedPackageVersionsResult->getComposerJsonContents()
77-
);
99+
$this->assertSame($changedFileContent, $changedPackageVersionsResult->getComposerJsonContents());
78100
}
79101

80102
public function testSinglePiped(): void

0 commit comments

Comments
 (0)