You are here

public function FeaturesAssignTest::testAssignBase in Features 8.4

Same name and namespace in other branches
  1. 8.3 tests/src/Kernel/FeaturesAssignTest.php \Drupal\Tests\features\Kernel\FeaturesAssignTest::testAssignBase()

@covers Drupal\features\Plugin\FeaturesAssignment\FeaturesAssignmentBaseType

File

tests/src/Kernel/FeaturesAssignTest.php, line 191

Class

FeaturesAssignTest
The Feature Assign test.

Namespace

Drupal\Tests\features\Kernel

Code

public function testAssignBase() {
  $method_id = 'base';

  // 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->assigner
    ->applyAssignmentMethod($method_id);
  $packages = $this->featuresManager
    ->getPackages();
  $expected_package_names = [
    'article',
    'user',
  ];
  $this
    ->assertEquals($expected_package_names, array_keys($packages), 'Expected packages not created.');

  // Dependents like field.field.node.article.body should not be assigned.
  $expected_config_items = [
    'node.type.article',
  ];
  $this
    ->assertEquals($expected_config_items, $packages['article']
    ->getConfig(), 'Expected configuration items not present in article package.');
}