first commit

This commit is contained in:
2024-07-15 12:33:27 +02:00
commit ce50ae282b
22084 changed files with 2623791 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
[composer.json]
indent_size = 2

View File

@@ -0,0 +1,172 @@
<?php
namespace DrupalFinder\Tests;
use DrupalFinder\DrupalFinder;
use org\bovigo\vfs\vfsStream;
/**
* @deprecated in drupal-finder:1.3.0 and is removed from drupal-finder:2.0.0.
*/
class Drupal7FinderTest extends DrupalFinderTestBase
{
protected static $fileStructure = [
'includes' => [
'common.inc' => '',
],
'misc' => [
'drupal.js' => '',
],
'sites' => [
'all' => [
'modules' => []
]
]
];
/**
* @return array
*/
protected function getDrupalComposerStructure()
{
$fileStructure = [
'web' => static::$fileStructure,
'composer.json' => [
'require' => [
'drupal/drupal' => '*',
],
'extra' => [
'installer-paths' => [
'web/' => [
'type:drupal-core',
],
],
],
],
'vendor' => [],
];
return $fileStructure;
}
public function testDrupalComposerStructure()
{
$fileStructure = $this->getDrupalComposerStructure();
$this->assertComposerStructure($fileStructure);
}
public function testDrupalComposerStructureWithoutRequire()
{
$fileStructure = [
'web' => static::$fileStructure,
'composer.json' => [
'extra' => [
'installer-paths' => [
'web' => [
'drupal/drupal',
],
],
],
],
];
$this->assertComposerStructure($fileStructure);
}
public function testNoDrupalRootWithRealFilesystem()
{
$finder = new DrupalFinder();
$root = $this->tempdir(sys_get_temp_dir());
$this->assertFalse($finder->locateRoot($root));
$this->assertFalse($finder->getDrupalRoot());
$this->assertFalse($finder->getComposerRoot());
$this->assertFalse($finder->getVendorDir());
}
public function testDrupalComposerStructureWithRealFilesystem()
{
$finder = new DrupalFinder();
$root = $this->tempdir(sys_get_temp_dir());
$this->dumpToFileSystem($this->getDrupalComposerStructure(), $root);
$this->assertTrue($finder->locateRoot($root));
$this->assertSame($root . '/web', $finder->getDrupalRoot());
$this->assertSame($root, $finder->getComposerRoot());
$this->assertSame($root . '/vendor', $finder->getVendorDir());
// Test symlink implementation
$symlink = $this->tempdir(sys_get_temp_dir());
$this->symlink($root, $symlink . '/foo');
$this->assertTrue($finder->locateRoot($symlink . '/foo'));
$this->assertSame($root . '/web', $finder->getDrupalRoot());
$this->assertSame($root, $finder->getComposerRoot());
$this->assertSame($root . '/vendor', $finder->getVendorDir());
}
public function testDrupalWithLinkedModule()
{
$finder = new DrupalFinder();
$root = $this->tempdir(sys_get_temp_dir());
$this->dumpToFileSystem($this->getDrupalComposerStructure(), $root);
$module = $this->tempdir(sys_get_temp_dir());
$module_link = $root . '/web/sites/all/modules/foo';
$this->symlink($module, $module_link);
$this->assertTrue($finder->locateRoot($module_link));
$this->assertSame($root . '/web', realpath($finder->getDrupalRoot()));
$this->assertSame($root, realpath($finder->getComposerRoot()));
$this->assertSame($root . '/vendor', realpath($finder->getVendorDir()));
}
public function testDrupalWithCustomVendor()
{
$finder = new DrupalFinder();
$root = $this->tempdir(sys_get_temp_dir());
$fileStructure = $this->getDrupalComposerStructure();
$composerJson = $fileStructure['composer.json'];
$composerJson['config']['vendor-dir'] = 'vendor-foo';
$fileStructure['composer.json'] = $composerJson;
$fileStructure['vendor-foo'] = [];
$this->dumpToFileSystem($fileStructure, $root);
$this->assertTrue($finder->locateRoot($root));
$this->assertSame($root . '/web', realpath($finder->getDrupalRoot()));
$this->assertSame($root, realpath($finder->getComposerRoot()));
$this->assertSame($root . '/vendor-foo', realpath($finder->getVendorDir()));
}
/**
* @param $fileStructure
*/
protected function assertComposerStructure($fileStructure)
{
$finder = new DrupalFinder();
$fileStructure = $this->prepareFileStructure($fileStructure);
$root = vfsStream::setup('root', null, $fileStructure);
$this->assertTrue($finder->locateRoot($root->url() . '/web'));
$this->assertSame('vfs://root/web', $finder->getDrupalRoot());
$this->assertSame('vfs://root', $finder->getComposerRoot());
$this->assertSame('vfs://root/vendor', $finder->getVendorDir());
$this->assertTrue($finder->locateRoot($root->url() . '/web/misc'));
$this->assertSame('vfs://root/web', $finder->getDrupalRoot());
$this->assertSame('vfs://root', $finder->getComposerRoot());
$this->assertSame('vfs://root/vendor', $finder->getVendorDir());
$this->assertTrue($finder->locateRoot($root->url()));
$this->assertSame('vfs://root/web', $finder->getDrupalRoot());
$this->assertSame('vfs://root', $finder->getComposerRoot());
$this->assertSame('vfs://root/vendor', $finder->getVendorDir());
$root = vfsStream::setup(
'root',
null,
['nested_folder' => $fileStructure]
);
$this->assertFalse($finder->locateRoot($root->url()));
$this->assertFalse($finder->getDrupalRoot());
$this->assertFalse($finder->getComposerRoot());
$this->assertFalse($finder->getVendorDir());
}
}

View File

@@ -0,0 +1,346 @@
<?php
namespace DrupalFinder\Tests;
use org\bovigo\vfs\vfsStream;
use DrupalFinder\DrupalFinder;
/**
* @deprecated in drupal-finder:1.3.0 and is removed from drupal-finder:2.0.0.
*/
class Drupal8FinderTest extends DrupalFinderTestBase
{
protected static $fileStructure = [
'autoload.php' => '',
'composer.json' => [
'extra' => [
'installer-paths' => [
'core' => [
'type:drupal-core'
]
]
]
],
'core' => [
'includes' => [
'common.inc' => '',
],
'misc' => [
'drupal.js' => '',
],
'core.services.yml' => '',
],
'modules' => [],
'vendor' => [],
];
protected static $fileStructureDrupal_8_8_x = [
'autoload.php' => '',
'composer.json' => [
'name' => 'drupal/drupal',
'require' => [
'drupal/core' => 'self.version',
],
'extra' => [
'installer-paths' => [
'vendor/drupal/core' => [
'type:drupal-core',
],
],
],
],
'core' => [
'includes' => [
'common.inc' => '',
],
'misc' => [
'drupal.js' => '',
],
'core.services.yml' => '',
],
'modules' => [],
'vendor' => [],
];
/**
* @return array
*/
protected function getDrupalComposerStructure()
{
$fileStructure = [
'web' => static::$fileStructure,
'composer.json' => [
'require' => [
'drupal/core' => '*',
],
'extra' => [
'installer-paths' => [
'web/core' => [
'type:drupal-core',
],
],
],
],
'vendor' => [],
];
unset($fileStructure['web']['composer.json']);
unset($fileStructure['web']['vendor']);
return $fileStructure;
}
public function testDrupalDefaultStructure()
{
$finder = new DrupalFinder();
$root = vfsStream::setup('root', null, $this->prepareFileStructure(static::$fileStructure));
$this->assertTrue($finder->locateRoot($root->url()));
$this->assertSame('vfs://root', $finder->getDrupalRoot());
$this->assertSame('vfs://root', $finder->getComposerRoot());
$this->assertSame('vfs://root/vendor', $finder->getVendorDir());
$this->assertTrue($finder->locateRoot($root->url() . '/misc'));
$this->assertSame('vfs://root', $finder->getDrupalRoot());
$this->assertSame('vfs://root', $finder->getComposerRoot());
$this->assertSame('vfs://root/vendor', $finder->getVendorDir());
$root = vfsStream::setup(
'root',
null,
['project' => $this->prepareFileStructure(static::$fileStructure)]
);
$this->assertFalse(
$finder->locateRoot($root->url()),
'Not in the scope of the project'
);
$this->assertFalse($finder->getDrupalRoot());
$this->assertFalse($finder->getComposerRoot());
$this->assertFalse($finder->getVendorDir());
}
public function testDrupalDefaultStructure_8_8_x()
{
$finder = new DrupalFinder();
$root = vfsStream::setup('root', null, $this->prepareFileStructure(static::$fileStructureDrupal_8_8_x));
$this->assertTrue($finder->locateRoot($root->url()));
$this->assertSame('vfs://root', $finder->getDrupalRoot());
$this->assertSame('vfs://root', $finder->getComposerRoot());
$this->assertSame('vfs://root/vendor', $finder->getVendorDir());
$this->assertTrue($finder->locateRoot($root->url() . '/misc'));
$this->assertSame('vfs://root', $finder->getDrupalRoot());
$this->assertSame('vfs://root', $finder->getComposerRoot());
$this->assertSame('vfs://root/vendor', $finder->getVendorDir());
$root = vfsStream::setup(
'root',
null,
['project' => $this->prepareFileStructure(static::$fileStructure)]
);
$this->assertFalse(
$finder->locateRoot($root->url()),
'Not in the scope of the project'
);
$this->assertFalse($finder->getDrupalRoot());
$this->assertFalse($finder->getComposerRoot());
$this->assertFalse($finder->getVendorDir());
}
public function testDrupalComposerStructure()
{
$fileStructure = $this->getDrupalComposerStructure();
$this->assertComposerStructure($fileStructure);
}
public function testDrupalComposerStructureWithCustomRoot()
{
$finder = new DrupalFinder();
$fileStructure = [
'src' => static::$fileStructure,
'composer.json' => [
'require' => [
'drupal/core' => '*',
],
'extra' => [
'installer-paths' => [
'src/core' => [
'type:drupal-core',
],
],
],
],
'vendor' => [],
];
unset($fileStructure['src']['composer.json']);
unset($fileStructure['src']['vendor']);
$fileStructure = $this->prepareFileStructure($fileStructure);
$root = vfsStream::setup('root', null, $fileStructure);
$this->assertTrue($finder->locateRoot($root->url() . '/src'));
$this->assertSame('vfs://root/src', $finder->getDrupalRoot());
$this->assertSame('vfs://root', $finder->getComposerRoot());
$this->assertSame('vfs://root/vendor', $finder->getVendorDir());
$this->assertTrue($finder->locateRoot($root->url() . '/src/misc'));
$this->assertSame('vfs://root/src', $finder->getDrupalRoot());
$this->assertSame('vfs://root', $finder->getComposerRoot());
$this->assertSame('vfs://root/vendor', $finder->getVendorDir());
$this->assertTrue($finder->locateRoot($root->url()));
$this->assertSame('vfs://root/src', $finder->getDrupalRoot());
$this->assertSame('vfs://root', $finder->getComposerRoot());
$this->assertSame('vfs://root/vendor', $finder->getVendorDir());
$root = vfsStream::setup(
'root',
null,
['nested_folder' => $fileStructure]
);
$this->assertFalse($finder->locateRoot($root->url()));
$this->assertFalse($finder->getDrupalRoot());
$this->assertFalse($finder->getComposerRoot());
$this->assertFalse($finder->getVendorDir());
}
public function testDrupalComposerStructureWithoutRequire()
{
$fileStructure = [
'web' => static::$fileStructure,
'composer.json' => [
'extra' => [
'installer-paths' => [
'web/core' => [
'drupal/core',
],
],
],
],
];
unset($fileStructure['web']['composer.json']);
$this->assertComposerStructure($fileStructure);
}
public function testNoDrupalRootWithRealFilesystem()
{
$finder = new DrupalFinder();
$root = $this->tempdir(sys_get_temp_dir());
$this->assertFalse($finder->locateRoot($root));
$this->assertFalse($finder->getDrupalRoot());
$this->assertFalse($finder->getComposerRoot());
$this->assertFalse($finder->getVendorDir());
}
public function testDrupalDefaultStructureWithRealFilesystem()
{
$finder = new DrupalFinder();
$root = $this->tempdir(sys_get_temp_dir());
$this->dumpToFileSystem(static::$fileStructure, $root);
$this->assertTrue($finder->locateRoot($root));
$this->assertSame($root, $finder->getDrupalRoot());
$this->assertSame($root, $finder->getComposerRoot());
$this->assertSame($root . '/vendor', $finder->getVendorDir());
// Test symlink implementation
$symlink = $this->tempdir(sys_get_temp_dir());
$this->symlink($root, $symlink . '/foo');
$this->assertTrue($finder->locateRoot($symlink . '/foo'));
$this->assertSame($root, $finder->getDrupalRoot());
$this->assertSame($root, $finder->getComposerRoot());
$this->assertSame($root . '/vendor', $finder->getVendorDir());
}
public function testDrupalComposerStructureWithRealFilesystem()
{
$finder = new DrupalFinder();
$root = $this->tempdir(sys_get_temp_dir());
$this->dumpToFileSystem($this->getDrupalComposerStructure(), $root);
$this->assertTrue($finder->locateRoot($root));
$this->assertSame($root . '/web', $finder->getDrupalRoot());
$this->assertSame($root, $finder->getComposerRoot());
$this->assertSame($root . '/vendor', $finder->getVendorDir());
// Test symlink implementation
$symlink = $this->tempdir(sys_get_temp_dir());
$this->symlink($root, $symlink . '/foo');
$this->assertTrue($finder->locateRoot($symlink . '/foo'));
$this->assertSame($root . '/web', $finder->getDrupalRoot());
$this->assertSame($root, $finder->getComposerRoot());
$this->assertSame($root . '/vendor', $finder->getVendorDir());
}
public function testDrupalWithLinkedModule()
{
$finder = new DrupalFinder();
$root = $this->tempdir(sys_get_temp_dir());
$this->dumpToFileSystem(static::$fileStructure, $root);
$module = $this->tempdir(sys_get_temp_dir());
$module_link = $root . '/modules/foo';
$this->symlink($module, $module_link);
$this->assertTrue($finder->locateRoot($module_link));
$this->assertSame($root, realpath($finder->getDrupalRoot()));
$this->assertSame($root, realpath($finder->getComposerRoot()));
$this->assertSame($root . '/vendor', realpath($finder->getVendorDir()));
}
public function testDrupalWithCustomVendor()
{
$finder = new DrupalFinder();
$root = $this->tempdir(sys_get_temp_dir());
$fileStructure = static::$fileStructure;
$fileStructure['composer.json'] = [
'config' => [
'vendor-dir' => 'vendor-foo'
]
];
$fileStructure['vendor-foo'] = [];
$this->dumpToFileSystem($fileStructure, $root);
$this->assertTrue($finder->locateRoot($root));
$this->assertSame($root, realpath($finder->getDrupalRoot()));
$this->assertSame($root, realpath($finder->getComposerRoot()));
$this->assertSame($root . '/vendor-foo', realpath($finder->getVendorDir()));
}
/**
* @param $fileStructure
*/
protected function assertComposerStructure($fileStructure)
{
$finder = new DrupalFinder();
$fileStructure = $this->prepareFileStructure($fileStructure);
$root = vfsStream::setup('root', null, $fileStructure);
$this->assertTrue($finder->locateRoot($root->url() . '/web'));
$this->assertSame('vfs://root/web', $finder->getDrupalRoot());
$this->assertSame('vfs://root', $finder->getComposerRoot());
$this->assertSame('vfs://root/vendor', $finder->getVendorDir());
$this->assertTrue($finder->locateRoot($root->url() . '/web/misc'));
$this->assertSame('vfs://root/web', $finder->getDrupalRoot());
$this->assertSame('vfs://root', $finder->getComposerRoot());
$this->assertSame('vfs://root/vendor', $finder->getVendorDir());
$this->assertTrue($finder->locateRoot($root->url()));
$this->assertSame('vfs://root/web', $finder->getDrupalRoot());
$this->assertSame('vfs://root', $finder->getComposerRoot());
$this->assertSame('vfs://root/vendor', $finder->getVendorDir());
$root = vfsStream::setup(
'root',
null,
['nested_folder' => $fileStructure]
);
$this->assertFalse($finder->locateRoot($root->url()));
$this->assertFalse($finder->getDrupalRoot());
$this->assertFalse($finder->getComposerRoot());
$this->assertFalse($finder->getVendorDir());
}
}

View File

@@ -0,0 +1,63 @@
<?php
namespace DrupalFinder\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Process\Exception\ProcessFailedException;
use Symfony\Component\Process\Process;
class DrupalFinderComposerRuntimeTest extends TestCase {
protected const installFixtures = 'Execute "composer install-fixtures" first.';
/**
* @runInSeparateProcess
*/
public function testDefault() {
$basePath = realpath(__DIR__ . '/fixtures/default');
$this->assertDirectoryExists($basePath . '/vendor', static::installFixtures);
$this->assertDirectoryExists($basePath . '/web', static::installFixtures);
$result = json_decode(require $basePath . '/drupal-finder.php', TRUE);
$this->assertSame($result['getComposerRoot'], $basePath);
$this->assertSame($result['getVendorDir'], $basePath . '/vendor');
$this->assertSame($result['getDrupalRoot'], $basePath . '/web');
}
/**
* @runInSeparateProcess
*/
public function testDefaultComposerScript() {
$basePath = realpath(__DIR__ . '/fixtures/default');
$this->assertDirectoryExists($basePath . '/vendor', static::installFixtures);
$this->assertDirectoryExists($basePath . '/web', static::installFixtures);
$process = new Process(['composer', 'run-script', 'dump-drupal-finder'], $basePath);
$process->run();
// executes after the command finishes
if (!$process->isSuccessful()) {
throw new ProcessFailedException($process);
}
$result = json_decode($process->getOutput(), TRUE);
$this->assertSame($result['getComposerRoot'], $basePath);
$this->assertSame($result['getVendorDir'], $basePath . '/vendor');
$this->assertSame($result['getDrupalRoot'], $basePath . '/web');
}
/**
* @runInSeparateProcess
*/
public function testCustomVendor() {
$basePath = realpath(__DIR__ . '/fixtures/custom-vendor');
$this->assertDirectoryExists($basePath . '/foo/bar', static::installFixtures);
$this->assertDirectoryExists($basePath . '/foo/bar/drupal', static::installFixtures);
$result = json_decode(require $basePath . '/drupal-finder.php', TRUE);
$this->assertSame($result['getComposerRoot'], $basePath);
$this->assertSame($result['getVendorDir'], $basePath . '/foo/bar');
$this->assertSame($result['getDrupalRoot'], $basePath . '/foo/bar/drupal');
}
}

View File

@@ -0,0 +1,187 @@
<?php
namespace DrupalFinder\Tests;
use DrupalFinder\DrupalFinder;
use Exception;
use PHPUnit\Framework\SkippedTestError;
use PHPUnit\Framework\TestCase;
/**
* @deprecated in drupal-finder:1.3.0 and is removed from drupal-finder:2.0.0.
*/
abstract class DrupalFinderTestBase extends TestCase
{
/**
* @var string
*/
protected $envNameDrupal;
/**
* @var string
*/
protected $envNameComposer;
/**
* @var string
*/
protected $envNameVendor;
protected function setUp(): void
{
parent::setUp();
$this->envNameDrupal = DrupalFinder::ENV_DRUPAL_ROOT;
$this->envNameComposer = DrupalFinder::ENV_COMPOSER_ROOT;
$this->envNameVendor = DrupalFinder::ENV_VENDOR_DIR;
}
protected function tearDown(): void
{
parent::tearDown();
// Unset variables to ensure their values don't carry over into other
// tests that are going to run.
putenv('DRUPAL_FINDER_DRUPAL_ROOT');
putenv('DRUPAL_FINDER_COMPOSER_ROOT');
putenv('DRUPAL_FINDER_VENDOR_DIR');
}
public function testOnlyDrupalEnvironmentVariable() {
$finder = new DrupalFinder();
$fileStructure = [
'web' => [],
];
$root = $this->tempdir(sys_get_temp_dir());
$this->dumpToFileSystem($fileStructure, $root);
$drupal_root = $root . '/web';
putenv("{$this->envNameDrupal}=$drupal_root");
// DrupalFinder::locateRoot should be true if the Drupal root is known.
$this->assertTrue($finder->locateRoot($root));
$this->assertSame($finder->getDrupalRoot(), $drupal_root);
}
public function testOnlyVendorEnvironmentVariable() {
$finder = new DrupalFinder();
$fileStructure = [
'vendor' => [],
];
$root = $this->tempdir(sys_get_temp_dir());
$this->dumpToFileSystem($fileStructure, $root);
$vendor_dir = $root . '/vendor';
putenv("{$this->envNameVendor}=$vendor_dir");
// DrupalFinder::locateRoot should be false since Drupal root is unknown.
$this->assertFalse($finder->locateRoot($root));
$this->assertSame($finder->getVendorDir(), $vendor_dir);
}
public function testOnlyComposerEnvironmentVariable() {
$finder = new DrupalFinder();
$fileStructure = [];
$root = $this->tempdir(sys_get_temp_dir());
$this->dumpToFileSystem($fileStructure, $root);
$composer_dir = $root;
putenv("{$this->envNameComposer}=$composer_dir");
// DrupalFinder::locateRoot should be false since Drupal root is unknown.
$this->assertFalse($finder->locateRoot($root));
$this->assertSame($finder->getComposerRoot(), $composer_dir);
}
protected function dumpToFileSystem($fileStructure, $root)
{
$fileStructure = $this->prepareFileStructure($fileStructure);
foreach ($fileStructure as $name => $content) {
if (is_array($content)) {
mkdir($root . '/' . $name);
$this->dumpToFileSystem($content, $root . '/' . $name);
} else {
file_put_contents($root . '/' . $name, $content);
}
}
}
protected function prepareFileStructure($fileStructure)
{
foreach ($fileStructure as $name => $content) {
if (($name === 'composer.json' || $name === 'composer.lock') && is_array($content)) {
$fileStructure[$name] = json_encode($content, JSON_UNESCAPED_SLASHES);
} elseif (is_array($content)) {
$fileStructure[$name] = $this->prepareFileStructure($content);
}
}
return $fileStructure;
}
protected function tempdir($dir, $prefix = '', $mode = 0700)
{
if (substr($dir, -1) != '/') {
$dir .= '/';
}
do {
$path = $dir . $prefix . mt_rand(0, 9999999);
} while (!mkdir($path, $mode));
register_shutdown_function(
[static::class, 'tempdir_remove'],
$path
);
return realpath($path);
}
public static function tempdir_remove($path)
{
if (is_link($path)) {
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
rmdir($path);
} else {
unlink($path);
}
return;
}
foreach (scandir($path) as $child) {
if (in_array($child, ['.', '..'])) {
continue;
}
$child = "$path/$child";
is_dir($child) ? static::tempdir_remove($child) : unlink($child);
}
rmdir($path);
}
/**
* @param $target
* @param $link
*
* @throws SkippedTestError
*/
protected function symlink($target, $link)
{
try {
return symlink($target, $link);
} catch (Exception $e) {
if (defined('PHP_WINDOWS_VERSION_BUILD')
&& strstr($e->getMessage(), WIN_ERROR_PRIVILEGE_NOT_HELD)
) {
$this->markTestSkipped(<<<'MESSAGE'
No privilege to create symlinks. Run test as Administrator (elevated process).
MESSAGE
);
}
throw $e;
}
}
}
define('WIN_ERROR_PRIVILEGE_NOT_HELD', '1314');

View File

@@ -0,0 +1,17 @@
{
"repositories": {
"drupal-finder": {
"type": "path",
"url": "../../../"
}
},
"require": {
"webflo/drupal-finder": "*",
"drupal/core": "^10"
},
"config": {
"vendor-dir": "foo/bar"
},
"minimum-stability": "dev",
"prefer-stable": true
}

View File

@@ -0,0 +1,14 @@
<?php
use DrupalFinder\DrupalFinderComposerRuntime;
require __DIR__ . '/foo/bar/autoload.php';
$finder = new DrupalFinderComposerRuntime();
return json_encode([
'getComposerRoot' => $finder->getComposerRoot(),
'getVendorDir' => $finder->getVendorDir(),
'getDrupalRoot' => $finder->getDrupalRoot(),
]
);

View File

@@ -0,0 +1,19 @@
<?php
namespace DrupalFinder\Tests\Fixtures\Default;
use Composer\Script\Event;
use DrupalFinder\DrupalFinderComposerRuntime;
class TestAsComposerScript {
public static function dumpDrupalFinder(Event $event) {
$finder = new DrupalFinderComposerRuntime();
$event->getIO()->writeRaw(json_encode([
'getComposerRoot' => $finder->getComposerRoot(),
'getVendorDir' => $finder->getVendorDir(),
'getDrupalRoot' => $finder->getDrupalRoot(),
]));
}
}

View File

@@ -0,0 +1,35 @@
{
"repositories": {
"drupal-finder": {
"type": "path",
"url": "../../../"
}
},
"require": {
"composer/installers": "^2.2",
"drupal/core": "^10",
"webflo/drupal-finder": "*"
},
"config": {
"allow-plugins": {
"composer/installers": true
}
},
"extra": {
"installer-paths": {
"web/core": [
"type:drupal-core"
]
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"autoload": {
"classmap": [
"TestAsComposerScript.php"
]
},
"scripts": {
"dump-drupal-finder": "\\DrupalFinder\\Tests\\Fixtures\\Default\\TestAsComposerScript::dumpDrupalFinder"
}
}

View File

@@ -0,0 +1,14 @@
<?php
use DrupalFinder\DrupalFinderComposerRuntime;
require __DIR__ . '/vendor/autoload.php';
$finder = new DrupalFinderComposerRuntime();
return json_encode([
'getComposerRoot' => $finder->getComposerRoot(),
'getVendorDir' => $finder->getVendorDir(),
'getDrupalRoot' => $finder->getDrupalRoot(),
]
);