class PackageTest in Features 8.4
Same name and namespace in other branches
- 8.3 tests/src/Unit/PackageTest.php \Drupal\Tests\features\Unit\PackageTest
@coversDefaultClass \Drupal\features\Package @group features
Hierarchy
- class \Drupal\Tests\features\Unit\PackageTest extends \PHPUnit\Framework\TestCase
Expanded class hierarchy of PackageTest
File
- tests/
src/ Unit/ PackageTest.php, line 12
Namespace
Drupal\Tests\features\UnitView source
class PackageTest extends TestCase {
/**
* @covers ::setDependencies
*/
public function testSetDependencies() {
$package = new Package('test_feature', []);
$this
->assertEquals([], $package
->getDependencies());
$package
->setDependencies([
'some_module',
'my_module',
'my_module',
'test_feature',
]);
// Test that duplicates are removed, results sorted, and the package cannot
/// require itself.
$expected = [
'my_module',
'some_module',
];
$this
->assertEquals($expected, $package
->getDependencies());
}
/**
* @covers ::appendDependency
*/
public function testAppendDependency() {
$package = new Package('test_feature', []);
$this
->assertEquals([], $package
->getDependencies());
$dependencies = [
'some_module',
'my_module',
'my_module',
'test_feature',
];
foreach ($dependencies as $dependency) {
$package
->appendDependency($dependency);
}
// Test that duplicates are removed, results sorted, and the package cannot
/// require itself.
$expected = [
'my_module',
'some_module',
];
$this
->assertEquals($expected, $package
->getDependencies());
}
/**
* @covers ::setFeaturesInfo
*/
public function testSetFeaturesInfo() {
$package = new Package('test_feature', []);
$this
->assertEquals([], $package
->getFeaturesInfo());
$package
->setFeaturesInfo([
'bundle' => 'test_bundle',
]);
$this
->assertEquals([
'bundle' => 'test_bundle',
], $package
->getFeaturesInfo());
$this
->assertEquals('test_bundle', $package
->getBundle());
}
/**
* {@inheritDoc}
*/
public function testGetConfig() {
$package = new Package('test_feature', [
'config' => [
'test_config_a',
'test_config_b',
],
]);
$this
->assertEquals([
'test_config_a',
'test_config_b',
], $package
->getConfig());
return $package;
}
/**
* The test append config.
*
* @depends testGetConfig
* @covers ::appendConfig
*/
public function testAppendConfig(Package $package) {
$package
->appendConfig('test_config_a');
$package
->appendConfig('test_config_c');
$this
->assertEquals([
'test_config_a',
'test_config_b',
'test_config_c',
], array_values($package
->getConfig()));
return $package;
}
/**
* The test remove config.
*
* @depends testAppendConfig
* @covers ::removeConfig
*/
public function testRemoveConfig(Package $package) {
$package
->removeConfig('test_config_a');
$this
->assertEquals([
'test_config_b',
'test_config_c',
], array_values($package
->getConfig()));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PackageTest:: |
public | function | The test append config. | |
PackageTest:: |
public | function | @covers ::appendDependency | |
PackageTest:: |
public | function | ||
PackageTest:: |
public | function | The test remove config. | |
PackageTest:: |
public | function | @covers ::setDependencies | |
PackageTest:: |
public | function | @covers ::setFeaturesInfo |