public function FeaturesManagerTest::testPrepareFiles in Features 8.3
Same name and namespace in other branches
- 8.4 tests/src/Unit/FeaturesManagerTest.php \Drupal\Tests\features\Unit\FeaturesManagerTest::testPrepareFiles()
@covers ::prepareFiles @covers ::addInfoFile
File
- tests/
src/ Unit/ FeaturesManagerTest.php, line 896
Class
- FeaturesManagerTest
- @coversDefaultClass Drupal\features\FeaturesManager @group features
Namespace
Drupal\Tests\features\UnitCode
public function testPrepareFiles() {
$packages = [];
$packages['test_feature'] = new Package('test_feature', [
'config' => [
'test_config',
],
'name' => 'Test feature',
]);
$packages['test_feature2'] = new Package('test_feature2', [
'config' => [
'test_config2',
],
'name' => 'Test feature 2',
'type' => 'profile',
'excluded' => [
'my_config',
],
'required' => [
'test_config2',
],
]);
$config_collection = [];
$config_collection['test_config'] = new ConfigurationItem('test_config', [
'foo' => 'bar',
]);
$config_collection['test_config2'] = new ConfigurationItem('test_config2', [
'foo' => 'bar',
]);
$this->featuresManager
->setConfigCollection($config_collection);
$this->featuresManager
->prepareFiles($packages);
// Test test_feature package.
$files = $packages['test_feature']
->getFiles();
$this
->assertCount(3, $files);
$this
->assertEquals('test_feature.info.yml', $files['info']['filename']);
$this
->assertEquals(Yaml::encode([
'name' => 'Test feature',
'type' => 'module',
'core_version_requirement' => '^8.9 || ^9',
]), $files['info']['string']);
$this
->assertEquals(Yaml::encode(TRUE), $files['features']['string']);
$this
->assertEquals('test_config.yml', $files['test_config']['filename']);
$this
->assertEquals(Yaml::encode([
'foo' => 'bar',
]), $files['test_config']['string']);
$this
->assertEquals('test_feature.features.yml', $files['features']['filename']);
$this
->assertEquals(Yaml::encode(TRUE), $files['features']['string']);
// Test test_feature2 package.
$files = $packages['test_feature2']
->getFiles();
$this
->assertEquals(Yaml::encode([
'excluded' => [
'my_config',
],
'required' => [
'test_config2',
],
]), $files['features']['string']);
}