55namespace Rector \Jack \Tests \ComposerProcessor \RaiseToInstalledComposerProcessor ;
66
77use Nette \Utils \FileSystem ;
8+ use PHPUnit \Framework \Attributes \DataProvider ;
89use Rector \Jack \ComposerProcessor \RaiseToInstalledComposerProcessor ;
910use Rector \Jack \Tests \AbstractTestCase ;
1011use 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