Exemplo n.º 1
0
 /**
  * @covers Drupal\features\Plugin\FeaturesAssignment\FeaturesAssignmentSiteType
  */
 public function testAssignSiteType()
 {
     $method_id = 'site';
     // Enable the method.
     $this->enableAssignmentMethod($method_id);
     // Test the default options for the site assignment method.
     // Add a piece of configuration of a site type.
     $this->addConfigurationItem('filter.format.plain_text', [], ['shortName' => 'plain_text', 'label' => 'Plain text', 'type' => 'filter_format']);
     // Add a piece of configuration of a non-site type.
     $this->addConfigurationItem('field.field.node.article.body', [], ['shortName' => 'node.article.body', 'label' => 'Body', 'type' => 'field_config', 'dependents' => []]);
     $this->assigner->applyAssignmentMethod($method_id);
     $packages = $this->featuresManager->getPackages();
     $expected_package_names = ['site'];
     $this->assertEquals($expected_package_names, array_keys($packages), 'Expected packages not created.');
     $this->assertTrue(in_array('filter.format.plain_text', $packages['site']->getConfig(), 'Expected configuration item not present in site package.'));
     $this->assertFalse(in_array('field.field.node.article.body', $packages['site']->getConfig(), 'Unexpected configuration item present in site package.'));
 }
Exemplo n.º 2
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.');
 }
Exemplo n.º 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.');
 }