Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test and fixture for symlink package #77

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@
/tests/fixtures/custom-vendor/foo
/tests/fixtures/default/web
/tests/fixtures/default/vendor
/tests/fixtures/*/composer.lock
/tests/fixtures/**/composer.lock
/tests/fixtures/symlink-package/drupal/*
/tests/fixtures/symlink-package/package/vendor
11 changes: 8 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,18 @@
"scripts": {
"install-fixtures": [
"cd tests/fixtures/custom-vendor && composer install",
"cd tests/fixtures/default && composer install"
"cd tests/fixtures/default && composer install",
"cd tests/fixtures/symlink-package/drupal && composer install",
"cd tests/fixtures/symlink-package/package && composer install"
],
"uninstall-fixtures": [
"rm -rf tests/fixtures/*/composer.lock",
"rm -rf tests/fixtures/**/composer.lock",
"rm -rf tests/fixtures/custom-vendor/foo",
"rm -rf tests/fixtures/default/web",
"rm -rf tests/fixtures/default/vendor"
"rm -rf tests/fixtures/default/vendor",
"rm -rf tests/fixtures/symlink-package/drupal/web",
"rm -rf tests/fixtures/symlink-package/drupal/vendor",
"rm -rf tests/fixtures/symlink-package/package/vendor"
],
"reinstall-fixtures": [
"@uninstall-fixtures",
Expand Down
26 changes: 26 additions & 0 deletions tests/DrupalFinderComposerRuntimeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,30 @@ public function testCustomVendor() {
$this->assertSame($result['getDrupalRoot'], $basePath . '/foo/bar/drupal');
}

/**
* @runInSeparateProcess
*/
public function testSymlinkPackage() {
$drupalPath = realpath(__DIR__ . '/fixtures/symlink-package/drupal');
$this->assertDirectoryExists("$drupalPath/vendor", static::installFixtures);
$this->assertDirectoryExists("$drupalPath/web", static::installFixtures);

$packagePath = realpath(__DIR__ . '/fixtures/symlink-package/package');
$this->assertDirectoryExists("$packagePath/vendor", static::installFixtures);

$process = new Process(['composer', 'exec', 'symlink-package'], $drupalPath);
$process->run();

// executes after the command finishes
if (!$process->isSuccessful()) {
throw new ProcessFailedException($process);
}

$result = json_decode($process->getOutput(), TRUE);
var_dump($result);
// $this->assertSame($result['getComposerRoot'], $drupalPath);
// $this->assertSame($result['getVendorDir'], $drupalPath . '/vendor');
// $this->assertSame($result['getDrupalRoot'], $drupalPath . '/web');
}

}
44 changes: 44 additions & 0 deletions tests/fixtures/symlink-package/drupal/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"description": "A Drupal project that refers to the local package 'webflo/foo'.",
"type": "project",
"license": "GPL-2.0-or-later",
"repositories": {
"drupal": {
"type": "composer",
"url": "https://packages.drupal.org/8"
},
"drupal-finder": {
"type": "path",
"url": "../../../"
},
"symlink-package": {
"type": "path",
"url": "../package",
"options": {
"symlink": true
}
}
},
"require": {
"composer/installers": "^2.0",
"drupal/core": "^10",
"webflo/foo": "*"
},
"conflict": {
"drupal/drupal": "*"
},
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
"allow-plugins": {
"composer/installers": true
}
},
"extra": {
"installer-paths": {
"web/core": [
"type:drupal-core"
]
}
}
}
17 changes: 17 additions & 0 deletions tests/fixtures/symlink-package/package/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "webflo/foo",
"description": "The package that depends on Drupal Finder.",
"repositories": {
"drupal-finder": {
"type": "path",
"url": "../../../"
}
},
"require": {
"webflo/drupal-finder": "*"
},
"bin": [
"symlink-package"
],
"minimum-stability": "dev"
}
14 changes: 14 additions & 0 deletions tests/fixtures/symlink-package/package/symlink-package
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env php
<?php

require __DIR__ . '/vendor/autoload.php';

use DrupalFinder\DrupalFinderComposerRuntime;

$finder = new DrupalFinderComposerRuntime();

echo json_encode([
'getComposerRoot' => $finder->getComposerRoot(),
'getVendorDir' => $finder->getVendorDir(),
'getDrupalRoot' => $finder->getDrupalRoot(),
]);