You are here

public function FeaturesAssignTest::testAssignSiteType in Features 8.3

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

@covers Drupal\features\Plugin\FeaturesAssignment\FeaturesAssignmentSiteType

File

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

Class

FeaturesAssignTest
The Feature Assign test.

Namespace

Drupal\Tests\features\Kernel

Code

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.'));
}