You are here

public function FeaturesBundleUiTest::testAssignmentConfigure in Features 8.4

Same name and namespace in other branches
  1. 8.3 modules/features_ui/tests/src/Functional/FeaturesBundleUiTest.php \Drupal\Tests\features_ui\Functional\FeaturesBundleUiTest::testAssignmentConfigure()

Tests configuring an assignment.

File

modules/features_ui/tests/src/Functional/FeaturesBundleUiTest.php, line 83

Class

FeaturesBundleUiTest
Tests configuring bundles.

Namespace

Drupal\Tests\features_ui\Functional

Code

public function testAssignmentConfigure() {

  // Check initial values.
  $settings = $this
    ->defaultBundle()
    ->getAssignmentSettings('exclude');
  $this
    ->assertTrue(isset($settings['types']['config']['features_bundle']), 'Excluding features_bundle');
  $this
    ->assertFalse(isset($settings['types']['config']['system_simple']), 'Not excluding system_simple');
  $this
    ->assertFalse(isset($settings['types']['config']['user_role']), 'Not excluding user_role');
  $this
    ->assertTrue($settings['curated'], 'Excluding curated items');
  $this
    ->assertTrue($settings['module']['namespace'], 'Excluding by namespace');

  // Check initial form.
  $this
    ->drupalGet('admin/config/development/features/bundle/_exclude/default');
  $this
    ->assertFieldChecked('edit-types-config-features-bundle', 'features_bundle is checked');
  $this
    ->assertNoFieldChecked('edit-types-config-system-simple', 'system_simple is not checked');
  $this
    ->assertNoFieldChecked('edit-types-config-user-role', 'user_role is not checked');
  $this
    ->assertFieldChecked('edit-curated', 'curated is checked');
  $this
    ->assertFieldChecked('edit-module-namespace', 'namespace is checked');

  // Configure the form.
  $this
    ->drupalPostForm(NULL, [
    'types[config][system_simple]' => TRUE,
    'types[config][user_role]' => FALSE,
    'curated' => TRUE,
    'module[namespace]' => FALSE,
  ], 'Save settings');

  // Check form results.
  $this
    ->drupalGet('admin/config/development/features/bundle/_exclude/default');
  $this
    ->assertFieldChecked('edit-types-config-features-bundle', 'Saved, features_bundle is checked');
  $this
    ->assertFieldChecked('edit-types-config-system-simple', 'Saved, system_simple is checked');
  $this
    ->assertNoFieldChecked('edit-types-config-user-role', 'Saved, user_role is not checked');
  $this
    ->assertFieldChecked('edit-curated', 'Saved, curated is checked');
  $this
    ->assertNoFieldChecked('edit-module-namespace', 'Saved, namespace is not checked');

  // Check final values.
  $settings = $this
    ->defaultBundle()
    ->getAssignmentSettings('exclude');
  $this
    ->assertTrue(isset($settings['types']['config']['features_bundle']), 'Saved, excluding features_bundle');
  $this
    ->assertTrue(isset($settings['types']['config']['system_simple']), 'Saved, excluding system_simple');
  $this
    ->assertFalse(isset($settings['types']['config']['user_role']), 'Saved, not excluding user_role');
  $this
    ->assertTrue($settings['curated'], 'Saved, excluding curated items');
  $this
    ->assertFalse($settings['module']['namespace'], 'Saved, not excluding by namespace');
}