1313
1414namespace CodeIgniter \AutoReview ;
1515
16+ use InvalidArgumentException ;
1617use JsonException ;
1718use PHPUnit \Framework \TestCase ;
1819
@@ -40,7 +41,7 @@ protected function setUp(): void
4041
4142 public function testFrameworkRequireIsTheSameWithDevRequire (): void
4243 {
43- $ this ->checkFramework ('require ' );
44+ $ this ->checkSection ('require ' , ' framework ' );
4445 }
4546
4647 public function testFrameworkRequireDevIsTheSameWithDevRequireDev (): void
@@ -68,7 +69,7 @@ public function testFrameworkRequireDevIsTheSameWithDevRequireDev(): void
6869
6970 public function testFrameworkSuggestIsTheSameWithDevSuggest (): void
7071 {
71- $ this ->checkFramework ('suggest ' );
72+ $ this ->checkSection ('suggest ' , ' framework ' );
7273 }
7374
7475 public function testFrameworkConfigIsTheSameWithDevSuggest (): void
@@ -89,21 +90,25 @@ public function testStarterConfigIsTheSameWithDevSuggest(): void
8990 );
9091 }
9192
92- private function checkFramework (string $ section ): void
93+ private function checkSection (string $ section, string $ component ): void
9394 {
94- $ this ->assertSame (
95- $ this ->devComposer [$ section ],
96- $ this ->frameworkComposer [$ section ],
97- 'The framework \'s " ' . $ section . '" section is not updated with the main composer.json. '
98- );
99- }
95+ switch (strtolower ($ component )) {
96+ case 'framework ' :
97+ $ sectionContent = $ this ->frameworkComposer [$ section ] ?? null ;
98+ break ;
99+
100+ case 'starter ' :
101+ $ sectionContent = $ this ->starterComposer [$ section ] ?? null ;
102+ break ;
103+
104+ default :
105+ throw new InvalidArgumentException (sprintf ('Unknown component: %s. ' , $ component ));
106+ }
100107
101- private function checkStarter (string $ section ): void
102- {
103108 $ this ->assertSame (
104109 $ this ->devComposer [$ section ],
105- $ this -> starterComposer [ $ section ] ,
106- 'The starter \'s " ' . $ section . ' " section is not updated with the main composer.json. '
110+ $ sectionContent ,
111+ sprintf ( 'The %s \'s "%s " section is not updated with the main composer.json ' , strtolower ( $ component ), $ section )
107112 );
108113 }
109114
0 commit comments