public function FeaturesAssignTest::testAssignOptionalType in Features 8.3
Same name and namespace in other branches
- 8.4 tests/src/Kernel/FeaturesAssignTest.php \Drupal\Tests\features\Kernel\FeaturesAssignTest::testAssignOptionalType()
@covers Drupal\features\Plugin\FeaturesAssignment\FeaturesAssignmentOptionalType
File
- tests/
src/ Kernel/ FeaturesAssignTest.php, line 671
Class
- FeaturesAssignTest
- The Feature Assign test.
Namespace
Drupal\Tests\features\KernelCode
public function testAssignOptionalType() {
$method_id = 'optional';
// Enable the method.
$this
->enableAssignmentMethod($method_id);
$settings = [
'types' => [
'config' => [
'image_style',
],
],
];
$this->bundle
->setAssignmentSettings($method_id, $settings);
// Add some configuration.
$this
->addConfigurationItem('node.type.article', [], [
'type' => 'node_type',
]);
$this
->addConfigurationItem('image.style.test', [], [
'type' => 'image_style',
]);
$this->featuresManager
->initPackage(self::PACKAGE_NAME, 'My test package');
$this->assigner
->applyAssignmentMethod($method_id);
$packages = $this->featuresManager
->getPackages();
$this
->assertNotEmpty($packages[self::PACKAGE_NAME], 'Expected package not created.');
$config = $this->featuresManager
->getConfigCollection();
$this
->assertNotEmpty($config['node.type.article'], 'Expected config not created.');
$this
->assertNotEmpty($config['image.style.test'], 'Expected config not created.');
$this
->assertNull($config['node.type.article']
->getSubdirectory(), 'Expected package subdirectory not set to default.');
$this
->assertEquals($config['image.style.test']
->getSubdirectory(), InstallStorage::CONFIG_OPTIONAL_DIRECTORY, 'Expected package subdirectory not set to optional.');
}