42945b250a805f6a4f05f490dfe93c91c1cf4df1
[yaffs-website] / web / core / modules / system / src / Tests / Condition / ConditionFormTest.php
1 <?php
2
3 namespace Drupal\system\Tests\Condition;
4
5 use Drupal\node\Entity\Node;
6 use Drupal\simpletest\WebTestBase;
7
8 /**
9  * Tests that condition plugins basic form handling is working.
10  *
11  * Checks condition forms and submission and gives a very cursory check to make
12  * sure the configuration that was submitted actually causes the condition to
13  * validate correctly.
14  *
15  * @group Condition
16  */
17 class ConditionFormTest extends WebTestBase {
18
19   public static $modules = ['node', 'condition_test'];
20
21   /**
22    * Submit the condition_node_type_test_form to test condition forms.
23    */
24   public function testConfigForm() {
25     $this->drupalCreateContentType(['type' => 'page', 'name' => 'Page']);
26     $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
27
28     $article = Node::create([
29       'type' => 'article',
30       'title' => $this->randomMachineName(),
31     ]);
32     $article->save();
33
34     $this->drupalGet('condition_test');
35     $this->assertField('bundles[article]', 'There is an article bundle selector.');
36     $this->assertField('bundles[page]', 'There is a page bundle selector.');
37     $this->drupalPostForm(NULL, ['bundles[page]' => 'page', 'bundles[article]' => 'article'], t('Submit'));
38     // @see \Drupal\condition_test\FormController::submitForm()
39     $this->assertText('Bundle: page');
40     $this->assertText('Bundle: article');
41     $this->assertText('Executed successfully.', 'The form configured condition executed properly.');
42   }
43
44 }