Skip to content

Commit f6ff7cf

Browse files
committed
Create test for symlink package
See #74
1 parent 7304506 commit f6ff7cf

File tree

6 files changed

+112
-4
lines changed

6 files changed

+112
-4
lines changed

Diff for: .gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@
44
/tests/fixtures/custom-vendor/foo
55
/tests/fixtures/default/web
66
/tests/fixtures/default/vendor
7-
/tests/fixtures/*/composer.lock
7+
/tests/fixtures/**/composer.lock
8+
/tests/fixtures/symlink-package/drupal/*
9+
/tests/fixtures/symlink-package/package/vendor

Diff for: composer.json

+8-3
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,18 @@
3636
"scripts": {
3737
"install-fixtures": [
3838
"cd tests/fixtures/custom-vendor && composer install",
39-
"cd tests/fixtures/default && composer install"
39+
"cd tests/fixtures/default && composer install",
40+
"cd tests/fixtures/symlink-package/drupal && composer install",
41+
"cd tests/fixtures/symlink-package/package && composer install"
4042
],
4143
"uninstall-fixtures": [
42-
"rm -rf tests/fixtures/*/composer.lock",
44+
"rm -rf tests/fixtures/**/composer.lock",
4345
"rm -rf tests/fixtures/custom-vendor/foo",
4446
"rm -rf tests/fixtures/default/web",
45-
"rm -rf tests/fixtures/default/vendor"
47+
"rm -rf tests/fixtures/default/vendor",
48+
"rm -rf tests/fixtures/symlink-package/drupal/web",
49+
"rm -rf tests/fixtures/symlink-package/drupal/vendor",
50+
"rm -rf tests/fixtures/symlink-package/package/vendor"
4651
],
4752
"reinstall-fixtures": [
4853
"@uninstall-fixtures",

Diff for: tests/DrupalFinderComposerRuntimeTest.php

+26
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,30 @@ public function testCustomVendor() {
6060
$this->assertSame($result['getDrupalRoot'], $basePath . '/foo/bar/drupal');
6161
}
6262

63+
/**
64+
* @runInSeparateProcess
65+
*/
66+
public function testSymlinkPackage() {
67+
$drupalPath = realpath(__DIR__ . '/fixtures/symlink-package/drupal');
68+
$this->assertDirectoryExists("$drupalPath/vendor", static::installFixtures);
69+
$this->assertDirectoryExists("$drupalPath/web", static::installFixtures);
70+
71+
$packagePath = realpath(__DIR__ . '/fixtures/symlink-package/package');
72+
$this->assertDirectoryExists("$packagePath/vendor", static::installFixtures);
73+
74+
$process = new Process(['composer', 'exec', 'symlink-package'], $drupalPath);
75+
$process->run();
76+
77+
// executes after the command finishes
78+
if (!$process->isSuccessful()) {
79+
throw new ProcessFailedException($process);
80+
}
81+
82+
$result = json_decode($process->getOutput(), TRUE);
83+
var_dump($result);
84+
// $this->assertSame($result['getComposerRoot'], $drupalPath);
85+
// $this->assertSame($result['getVendorDir'], $drupalPath . '/vendor');
86+
// $this->assertSame($result['getDrupalRoot'], $drupalPath . '/web');
87+
}
88+
6389
}

Diff for: tests/fixtures/symlink-package/drupal/composer.json

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"description": "A Drupal project that refers to the local package 'webflo/foo'.",
3+
"type": "project",
4+
"license": "GPL-2.0-or-later",
5+
"repositories": {
6+
"drupal": {
7+
"type": "composer",
8+
"url": "https://packages.drupal.org/8"
9+
},
10+
"drupal-finder": {
11+
"type": "path",
12+
"url": "../../../"
13+
},
14+
"symlink-package": {
15+
"type": "path",
16+
"url": "../package",
17+
"options": {
18+
"symlink": true
19+
}
20+
}
21+
},
22+
"require": {
23+
"composer/installers": "^2.0",
24+
"drupal/core": "^10",
25+
"webflo/foo": "*"
26+
},
27+
"conflict": {
28+
"drupal/drupal": "*"
29+
},
30+
"minimum-stability": "dev",
31+
"prefer-stable": true,
32+
"config": {
33+
"allow-plugins": {
34+
"composer/installers": true
35+
}
36+
},
37+
"extra": {
38+
"installer-paths": {
39+
"web/core": [
40+
"type:drupal-core"
41+
]
42+
}
43+
}
44+
}

Diff for: tests/fixtures/symlink-package/package/composer.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "webflo/foo",
3+
"description": "The package that depends on Drupal Finder.",
4+
"repositories": {
5+
"drupal-finder": {
6+
"type": "path",
7+
"url": "../../../"
8+
}
9+
},
10+
"require": {
11+
"webflo/drupal-finder": "*"
12+
},
13+
"bin": [
14+
"symlink-package"
15+
],
16+
"minimum-stability": "dev"
17+
}
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
require __DIR__ . '/vendor/autoload.php';
5+
6+
use DrupalFinder\DrupalFinderComposerRuntime;
7+
8+
$finder = new DrupalFinderComposerRuntime();
9+
10+
echo json_encode([
11+
'getComposerRoot' => $finder->getComposerRoot(),
12+
'getVendorDir' => $finder->getVendorDir(),
13+
'getDrupalRoot' => $finder->getDrupalRoot(),
14+
]);

0 commit comments

Comments
 (0)