class PackageManagerTest in Composer Manager 8
@coversDefaultClass \Drupal\composer_manager\PackageManager @group composer_manager
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\composer_manager\Unit\PackageManagerTest
Expanded class hierarchy of PackageManagerTest
File
- tests/
src/ Unit/ PackageManagerTest.php, line 13
Namespace
Drupal\Tests\composer_manager\UnitView source
class PackageManagerTest extends UnitTestCase {
/**
* @var \Drupal\composer_manager\PackageManager
*/
protected $manager;
/**
* Package fixtures.
*
* @var array
*/
protected $packages = [
'core' => [
'name' => 'drupal/core',
'type' => 'drupal-core',
],
'extension' => [
'commerce_kickstart' => [
'name' => 'drupal/commerce_kickstart',
'require' => [
'symfony/css-selector' => '2.6.*',
],
'extra' => [
'path' => 'profiles/commerce_kickstart/composer.json',
],
],
'test1' => [
'name' => 'drupal/test1',
'require' => [
'symfony/intl' => '2.6.*',
],
'extra' => [
'path' => 'modules/test1/composer.json',
],
],
'test2' => [
'name' => 'drupal/test2',
'require' => [
'symfony/config' => '2.6.*',
],
'extra' => [
'path' => 'sites/all/modules/test2/composer.json',
],
],
],
'installed' => [
[
'name' => 'symfony/dependency-injection',
'version' => 'v2.6.3',
'description' => 'Symfony DependencyInjection Component',
'homepage' => 'http://symfony.com',
],
[
'name' => 'symfony/event-dispatcher',
'version' => 'v2.6.3',
'description' => 'Symfony EventDispatcher Component',
'homepage' => 'http://symfony.com',
'require' => [
// symfony/event-dispatcher doesn't really have this requirement,
// we're lying for test purposes.
'symfony/yaml' => 'dev-master',
],
],
[
'name' => 'symfony/yaml',
'version' => 'dev-master',
'source' => [
'type' => 'git',
'url' => 'https://github.com/symfony/Yaml.git',
'reference' => '3346fc090a3eb6b53d408db2903b241af51dcb20',
],
],
],
];
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
$structure = [
'vendor' => [
'composer' => [
'installed.json' => json_encode($this->packages['installed']),
],
],
'core' => [
'composer.json' => json_encode($this->packages['core']),
],
'profiles' => [
'commerce_kickstart' => [
'commerce_kickstart.info.yml' => 'type: profile',
'commerce_kickstart.profile' => '<?php',
'composer.json' => json_encode($this->packages['extension']['commerce_kickstart']),
],
],
'modules' => [
'test1' => [
'composer.json' => json_encode($this->packages['extension']['test1']),
'test1.module' => '<?php',
'test1.info.yml' => 'type: module',
],
],
'sites' => [
'all' => [
'modules' => [
'test2' => [
'composer.json' => json_encode($this->packages['extension']['test2']),
'test2.module' => '<?php',
'test2.info.yml' => 'type: module',
],
],
],
],
];
vfsStream::setup('drupal', null, $structure);
$this->manager = new PackageManager('vfs://drupal');
}
/**
* @covers ::getCorePackage
*/
public function testCorePackage() {
$core_package = $this->manager
->getCorePackage();
$this
->assertEquals($this->packages['core'], $core_package);
}
/**
* @covers ::getExtensionPackages
*/
public function testExtensionPackages() {
$extension_packages = $this->manager
->getExtensionPackages();
$this
->assertEquals($this->packages['extension'], $extension_packages);
}
/**
* @covers ::getInstalledPackages
*/
public function testInstalledPackages() {
$installed_packages = $this->manager
->getInstalledPackages();
$this
->assertEquals($this->packages['installed'], $installed_packages);
}
/**
* @covers ::getRequiredPackages
* @covers ::processRequiredPackages
*/
public function testRequiredPackages() {
$expected_packages = [
'symfony/css-selector' => [
'constraint' => '2.6.*',
'description' => '',
'homepage' => '',
'require' => [],
'required_by' => [
'drupal/commerce_kickstart',
],
'version' => '',
],
'symfony/config' => [
'constraint' => '2.6.*',
'description' => '',
'homepage' => '',
'require' => [],
'required_by' => [
'drupal/test2',
],
'version' => '',
],
'symfony/intl' => [
'constraint' => '2.6.*',
'description' => '',
'homepage' => '',
'require' => [],
'required_by' => [
'drupal/test1',
],
'version' => '',
],
];
$required_packages = $this->manager
->getRequiredPackages();
$this
->assertEquals($expected_packages, $required_packages);
}
/**
* @covers ::needsComposerUpdate
*/
public function testNeedsComposerUpdate() {
$needs_update = $this->manager
->needsComposerUpdate();
$this
->assertEquals(TRUE, $needs_update);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PackageManagerTest:: |
protected | property | ||
PackageManagerTest:: |
protected | property | Package fixtures. | |
PackageManagerTest:: |
public | function |
Overrides UnitTestCase:: |
|
PackageManagerTest:: |
public | function | @covers ::getCorePackage | |
PackageManagerTest:: |
public | function | @covers ::getExtensionPackages | |
PackageManagerTest:: |
public | function | @covers ::getInstalledPackages | |
PackageManagerTest:: |
public | function | @covers ::needsComposerUpdate | |
PackageManagerTest:: |
public | function | @covers ::getRequiredPackages @covers ::processRequiredPackages | |
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. |