class ExtensionDiscoveryTest in Composer Manager 8
@coversDefaultClass \Drupal\composer_manager\ExtensionDiscovery @group composer_manager
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\composer_manager\Unit\ExtensionDiscoveryTest
Expanded class hierarchy of ExtensionDiscoveryTest
File
- tests/
src/ Unit/ ExtensionDiscoveryTest.php, line 13
Namespace
Drupal\Tests\composer_manager\UnitView source
class ExtensionDiscoveryTest extends UnitTestCase {
/**
* @var \Drupal\composer_manager\ExtensionDiscovery
*/
protected $discovery;
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
// Simulate modules in multiple sites and multiple profiles.
$structure = [
'modules' => [
'test1' => $this
->generateModule('test1'),
],
'profiles' => [
'commons' => [
'commons.info.yml' => 'type: profile',
'commons.profile' => '<?php',
'modules' => [
'test2' => $this
->generateModule('test2'),
],
],
],
'sites' => [
'all' => [
'modules' => [
'test3' => $this
->generateModule('test3'),
],
],
'default' => [
'modules' => [
'test4' => $this
->generateModule('test4'),
],
],
'test.site.com' => [
'profiles' => [
'commerce_kickstart' => [
'commerce_kickstart.info.yml' => 'type: profile',
'commerce_kickstart.profile' => '<?php',
'modules' => [
'test5' => $this
->generateModule('test5'),
],
],
],
'modules' => [
'test6' => $this
->generateModule('test6'),
],
],
],
];
vfsStream::setup('drupal', null, $structure);
$this->discovery = new ExtensionDiscovery('vfs://drupal');
}
/**
* {@inheritdoc}
*/
public function tearDown() {
$this->discovery
->resetCache();
}
/**
* @covers ::scan
* @covers ::getSiteDirectories
*/
public function testScan() {
$expected_profiles = [
'commons',
'commerce_kickstart',
];
$profiles = $this->discovery
->scan('profile');
$this
->assertEquals($expected_profiles, array_keys($profiles));
$expected_extensions = [
'test5',
'test2',
'test3',
'test1',
'test4',
'test6',
];
$profile_directories = array_map(function ($profile) {
return $profile
->getPath();
}, $profiles);
$this->discovery
->setProfileDirectories($profile_directories);
$extensions = $this->discovery
->scan('module');
$this
->assertEquals($expected_extensions, array_keys($extensions));
}
/**
* Returns the file structure for a module.
*/
protected function generateModule($name) {
return [
$name . '.module' => '<?php',
$name . '.info.yml' => 'type: module',
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ExtensionDiscoveryTest:: |
protected | property | ||
ExtensionDiscoveryTest:: |
protected | function | Returns the file structure for a module. | |
ExtensionDiscoveryTest:: |
public | function |
Overrides UnitTestCase:: |
|
ExtensionDiscoveryTest:: |
public | function | ||
ExtensionDiscoveryTest:: |
public | function | @covers ::scan @covers ::getSiteDirectories | |
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | 1 |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. |