Skip to content

Commit aa02342

Browse files
authored
Fix #32: Use dev-dependencies for the root package and don't use for others (#33)
1 parent 862e1ff commit aa02342

4 files changed

Lines changed: 103 additions & 2 deletions

File tree

src/PackagesListBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ private function calculatePackageDepths(
9797
++$depth;
9898

9999
$dependencies = $includingDev
100-
? array_keys($package->getRequires())
101-
: [...array_keys($package->getRequires()), ...array_keys($package->getDevRequires())];
100+
? [...array_keys($package->getRequires()), ...array_keys($package->getDevRequires())]
101+
: array_keys($package->getRequires());
102102

103103
foreach ($dependencies as $dependency) {
104104
if (array_key_exists($dependency, $allPackages)) {
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Yiisoft\Config\Tests\Integration;
6+
7+
final class PackagesListBuilderWithDevTest extends ComposerTest
8+
{
9+
protected function getStartComposerConfig(): array
10+
{
11+
return [
12+
'name' => 'yiisoft/testpackage',
13+
'type' => 'library',
14+
'minimum-stability' => 'dev',
15+
'require' => [
16+
'yiisoft/config' => '*',
17+
'test/d-dev-c' => '*',
18+
],
19+
'require-dev' => [
20+
'test/a' => '*',
21+
],
22+
'repositories' => [
23+
[
24+
'type' => 'path',
25+
'url' => '../../',
26+
],
27+
[
28+
'type' => 'path',
29+
'url' => '../Packages/test/a',
30+
'options' => [
31+
'symlink' => false,
32+
],
33+
],
34+
[
35+
'type' => 'path',
36+
'url' => '../Packages/test/c',
37+
'options' => [
38+
'symlink' => false,
39+
],
40+
],
41+
[
42+
'type' => 'path',
43+
'url' => '../Packages/test/d-dev-c',
44+
'options' => [
45+
'symlink' => false,
46+
],
47+
],
48+
],
49+
];
50+
}
51+
52+
public function testBase(): void
53+
{
54+
$this->assertMergePlan([
55+
'params' => [
56+
'test/a' => [
57+
'config/params.php',
58+
],
59+
],
60+
'web' => [
61+
'test/d-dev-c' => [
62+
'config/web.php',
63+
],
64+
'test/a' => [
65+
'config/web.php',
66+
],
67+
],
68+
]);
69+
}
70+
71+
private function assertMergePlan(array $mergePlan): void
72+
{
73+
$this->assertSame($mergePlan, require $this->workingDirectory . '/config/packages/merge_plan.php');
74+
}
75+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "test/d-dev-c",
3+
"version": "1.0.0",
4+
"autoload": {
5+
"psr-4": {
6+
"Test\\Yii\\View\\": "src"
7+
}
8+
},
9+
"require-dev": {
10+
"test/c": "*"
11+
},
12+
"extra": {
13+
"config-plugin": {
14+
"web": "config/web.php"
15+
}
16+
}
17+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/** @var array $params */
6+
7+
return [
8+
stdClass::class => stdClass::class,
9+
];

0 commit comments

Comments
 (0)