Skip to content
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
1 change: 1 addition & 0 deletions src/DrupalFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ protected function findAndValidateRoots($path)
}
$this->drupalRoot = rtrim($path . '/' . $install_path, '/');
$this->vendorDir = $this->composerRoot . '/vendor';
break;
}
}
}
Expand Down
48 changes: 48 additions & 0 deletions tests/Drupal8FinderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,33 @@ protected function getDrupalComposerStructure()
return $fileStructure;
}

protected function getDrupalComposerStructureWithDuplicateInstallerPaths()
{
$fileStructure = [
'web' => static::$fileStructure,
'composer.json' => [
'require' => [
'drupal/core' => '*',
],
'extra' => [
'installer-paths' => [
'web/core' => [
'type:drupal-core',
],
'core' => [
'type:drupal-core',
],
],
],
],
'vendor' => [],
];
unset($fileStructure['web']['composer.json']);
unset($fileStructure['web']['vendor']);

return $fileStructure;
}

public function testDrupalDefaultStructure()
{
$finder = new DrupalFinder();
Expand Down Expand Up @@ -271,6 +298,27 @@ public function testDrupalComposerStructureWithRealFilesystem()
$this->assertSame($root . '/vendor', $finder->getVendorDir());
}

public function testDrupalComposerStructureWithDuplicateInstallerPaths()
{
$finder = new DrupalFinder();
$root = $this->tempdir(sys_get_temp_dir());
$this->dumpToFileSystem($this->getDrupalComposerStructureWithDuplicateInstallerPaths(), $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();
Expand Down