SystemListingTest.php in Zircon Profile 8
File
core/modules/system/src/Tests/Common/SystemListingTest.php
View source
<?php
namespace Drupal\system\Tests\Common;
use Drupal\Core\Extension\ExtensionDiscovery;
use Drupal\simpletest\KernelTestBase;
class SystemListingTest extends KernelTestBase {
function testDirectoryPrecedence() {
$expected_directories = array(
'drupal_system_listing_compatible_test' => array(
'core/profiles/testing/modules',
'core/modules/system/tests/modules',
),
);
foreach ($expected_directories as $module => $directories) {
foreach ($directories as $directory) {
$filename = "{$directory}/{$module}/{$module}.info.yml";
$this
->assertTrue(file_exists(\Drupal::root() . '/' . $filename), format_string('@filename exists.', array(
'@filename' => $filename,
)));
}
}
$listing = new ExtensionDiscovery(\Drupal::root());
$listing
->setProfileDirectories(array(
'core/profiles/testing',
));
$files = $listing
->scan('module');
foreach ($expected_directories as $module => $directories) {
$expected_directory = array_shift($directories);
$expected_uri = "{$expected_directory}/{$module}/{$module}.info.yml";
$this
->assertEqual($files[$module]
->getPathname(), $expected_uri, format_string('Module @actual was found at @expected.', array(
'@actual' => $files[$module]
->getPathname(),
'@expected' => $expected_uri,
)));
}
}
}