Skip to content

Commit 58dc6cd

Browse files
committed
Add test for config
1 parent 3ef4d42 commit 58dc6cd

1 file changed

Lines changed: 29 additions & 2 deletions

File tree

tests/system/AutoReview/ComposerJsonTest.php

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,20 @@ public function testFrameworkSuggestIsTheSameWithDevSuggest(): void
7373

7474
public function testFrameworkConfigIsTheSameWithDevSuggest(): void
7575
{
76-
$this->checkFramework('config');
76+
$this->checkConfig(
77+
$this->devComposer['config'],
78+
$this->frameworkComposer['config'],
79+
'framework'
80+
);
7781
}
7882

7983
public function testStarterConfigIsTheSameWithDevSuggest(): void
8084
{
81-
$this->checkStarter('config');
85+
$this->checkConfig(
86+
$this->devComposer['config'],
87+
$this->starterComposer['config'],
88+
'starter'
89+
);
8290
}
8391

8492
private function checkFramework(string $section): void
@@ -99,6 +107,25 @@ private function checkStarter(string $section): void
99107
);
100108
}
101109

110+
private function checkConfig(array $fromMain, array $fromComponent, string $component): void
111+
{
112+
foreach ($fromMain as $key => $expectedValue) {
113+
if (! isset($fromComponent[$key])) {
114+
$this->addToAssertionCount(1);
115+
116+
continue;
117+
}
118+
119+
$actualValue = $fromComponent[$key];
120+
121+
$this->assertSame($expectedValue, $actualValue, sprintf(
122+
'%s\'s value for config property "%s" is not same with the main composer.json\'s config.',
123+
ucfirst($component),
124+
$key
125+
));
126+
}
127+
}
128+
102129
private function getComposerJson(string $path): array
103130
{
104131
try {

0 commit comments

Comments
 (0)