function ConditionFormTest::testConfigForm

Same name and namespace in other branches
  1. 9 core/modules/system/tests/src/Functional/Condition/ConditionFormTest.php \Drupal\Tests\system\Functional\Condition\ConditionFormTest::testConfigForm()
  2. 10 core/modules/system/tests/src/Functional/Condition/ConditionFormTest.php \Drupal\Tests\system\Functional\Condition\ConditionFormTest::testConfigForm()
  3. 11.x core/modules/system/tests/src/Functional/Condition/ConditionFormTest.php \Drupal\Tests\system\Functional\Condition\ConditionFormTest::testConfigForm()

Submit the condition_node_type_test_form to test condition forms.

File

core/modules/system/tests/src/Functional/Condition/ConditionFormTest.php, line 29

Class

ConditionFormTest
Tests that condition plugins basic form handling is working.

Namespace

Drupal\Tests\system\Functional\Condition

Code

public function testConfigForm() {
  $this->drupalCreateContentType([
    'type' => 'page',
    'name' => 'Page',
  ]);
  $this->drupalCreateContentType([
    'type' => 'article',
    'name' => 'Article',
  ]);
  $article = Node::create([
    'type' => 'article',
    'title' => $this->randomMachineName(),
  ]);
  $article->save();
  $this->drupalGet('condition_test');
  $this->assertField('bundles[article]', 'There is an article bundle selector.');
  $this->assertField('bundles[page]', 'There is a page bundle selector.');
  $this->drupalPostForm(NULL, [
    'bundles[page]' => 'page',
    'bundles[article]' => 'article',
  ], t('Submit'));
  // @see \Drupal\condition_test\FormController::submitForm()
  $this->assertText('Bundle: page');
  $this->assertText('Bundle: article');
  $this->assertText('Executed successfully.', 'The form configured condition executed properly.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.