예제 #1
0
 /**
  * @covers Drupal\features\Plugin\FeaturesAssignment\FeaturesAssignmentDependency
  */
 public function testAssignDependency()
 {
     $method_id = 'dependency';
     // Enable the method.
     $this->enableAssignmentMethod($method_id);
     // Test the default options for the base assignment method.
     // Test node type assignments.
     // Declare the node_type entity 'article'.
     $this->addConfigurationItem('node.type.article', [], ['shortName' => 'article', 'label' => 'Article', 'type' => 'node_type', 'dependents' => ['field.field.node.article.body']]);
     // Add a piece of dependent configuration.
     $this->addConfigurationItem('field.field.node.article.body', [], ['shortName' => 'node.article.body', 'label' => 'Body', 'type' => 'field_config', 'dependents' => []]);
     $this->featuresManager->initPackage(self::PACKAGE_NAME, 'My test package');
     $this->featuresManager->assignConfigPackage(self::PACKAGE_NAME, ['node.type.article']);
     $this->assigner->applyAssignmentMethod($method_id);
     $packages = $this->featuresManager->getPackages();
     $expected_package_names = [self::PACKAGE_NAME];
     $this->assertEquals($expected_package_names, array_keys($packages), 'Expected packages not created.');
     $expected_config_items = ['node.type.article', 'field.field.node.article.body'];
     $this->assertEquals($expected_config_items, $packages[self::PACKAGE_NAME]->getConfig(), 'Expected configuration items not present in article package.');
 }
예제 #2
0
 /**
  * @covers Drupal\features\Plugin\FeaturesAssignment\FeaturesAssignmentOptionalType
  */
 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.');
 }
예제 #3
0
 /**
  * @covers Drupal\features\Plugin\FeaturesAssignment\FeaturesAssignmentForwardDependency
  */
 public function testAssignForwardDependency()
 {
     $method_id = 'forward_dependency';
     // Enable the method.
     $this->enableAssignmentMethod($method_id);
     // Add some configuration.
     // Two parent items.
     $this->addConfigurationItem('parent1', [], ['type' => 'node_type', 'dependents' => ['grandparent']]);
     $this->addConfigurationItem('parent2', [], ['type' => 'node_type', 'dependents' => []]);
     // Something that belongs to just one parent.
     $this->addConfigurationItem('child1', [], ['type' => 'node_type', 'dependents' => ['parent1']]);
     // Something that belongs to both parents.
     $this->addConfigurationItem('child2', [], ['type' => 'node_type', 'dependents' => ['parent1', 'parent2']]);
     // Something that indirectly belongs to parent1.
     $this->addConfigurationItem('grandchild', [], ['type' => 'node_type', 'dependents' => ['child1']]);
     // A dependent, not a dependency.
     $this->addConfigurationItem('grandparent', [], ['type' => 'node_type', 'dependents' => []]);
     // Something completely unrelated.
     $this->addConfigurationItem('stranger', [], ['type' => 'node_type', 'dependents' => []]);
     $this->featuresManager->initPackage(self::PACKAGE_NAME, 'My test package');
     $this->featuresManager->assignConfigPackage(self::PACKAGE_NAME, ['parent1']);
     $other_package_name = 'other_package';
     $this->featuresManager->initPackage($other_package_name, 'Other package');
     $this->featuresManager->assignConfigPackage($other_package_name, ['parent2']);
     $this->assigner->applyAssignmentMethod($method_id);
     $packages = $this->featuresManager->getPackages();
     $expected_package_names = [self::PACKAGE_NAME, $other_package_name];
     sort($expected_package_names);
     $actual_package_names = array_keys($packages);
     sort($actual_package_names);
     $this->assertEquals($expected_package_names, $actual_package_names, 'Expected packages not created.');
     $expected_config_items = ['parent1', 'child1', 'grandchild'];
     sort($expected_config_items);
     $actual_config_items = $packages[self::PACKAGE_NAME]->getConfig();
     sort($actual_config_items);
     $this->assertEquals($expected_config_items, $actual_config_items, 'Expected configuration items not present in article package.');
 }