Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / system / tests / src / Functional / Condition / ConditionFormTest.php
diff --git a/web/core/modules/system/tests/src/Functional/Condition/ConditionFormTest.php b/web/core/modules/system/tests/src/Functional/Condition/ConditionFormTest.php
new file mode 100644 (file)
index 0000000..adefc43
--- /dev/null
@@ -0,0 +1,44 @@
+<?php
+
+namespace Drupal\Tests\system\Functional\Condition;
+
+use Drupal\node\Entity\Node;
+use Drupal\Tests\BrowserTestBase;
+
+/**
+ * Tests that condition plugins basic form handling is working.
+ *
+ * Checks condition forms and submission and gives a very cursory check to make
+ * sure the configuration that was submitted actually causes the condition to
+ * validate correctly.
+ *
+ * @group Condition
+ */
+class ConditionFormTest extends BrowserTestBase {
+
+  public static $modules = ['node', 'condition_test'];
+
+  /**
+   * Submit the condition_node_type_test_form to test condition forms.
+   */
+  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.');
+  }
+
+}