diff --git a/core/modules/system/lib/Drupal/system/Tests/Condition/ConditionFormTest.php b/core/modules/system/lib/Drupal/system/Tests/Condition/ConditionFormTest.php new file mode 100644 index 0000000..f28b3c4 --- /dev/null +++ b/core/modules/system/lib/Drupal/system/Tests/Condition/ConditionFormTest.php @@ -0,0 +1,35 @@ + 'Condition Form Tests', + 'description' => 'Tests that condtion plugins basic form handling is working.', + 'group' => 'Condition API', + ); + } + + /** + * Submit the system_config_form ensure the configuration has expected values. + */ + function testConfigForm() { + $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->drupalPost(NULL, array('bundles[page]' => 'page', 'bundles[article]' => 'article'), t('Submit')); + $this->assertText('The bundles are article and page', 'The form component appropriately saved the bundles.'); + } + +} diff --git a/core/modules/system/tests/modules/condition_test/condition_test.info b/core/modules/system/tests/modules/condition_test/condition_test.info new file mode 100644 index 0000000..753f032 --- /dev/null +++ b/core/modules/system/tests/modules/condition_test/condition_test.info @@ -0,0 +1,6 @@ +name = "Condition Test Support" +description = "Test general form component for condition plugins." +package = Testing +version = VERSION +core = 8.x +hidden = TRUE diff --git a/core/modules/system/tests/modules/condition_test/condition_test.module b/core/modules/system/tests/modules/condition_test/condition_test.module new file mode 100644 index 0000000..76fccd8 --- /dev/null +++ b/core/modules/system/tests/modules/condition_test/condition_test.module @@ -0,0 +1,18 @@ + array( + 'name' => t('Article'), + 'base' => 'article', + 'description' => t('An article content type'), + 'title_label' => t('Subject'), + ), + 'page' => array( + 'name' => t('Page'), + 'base' => 'page', + 'description' => t('A page content type'), + 'title_label' => t('Subject'), + ), + ); +} diff --git a/core/modules/system/tests/modules/condition_test/condition_test.routing.yml b/core/modules/system/tests/modules/condition_test/condition_test.routing.yml new file mode 100644 index 0000000..96fbdca --- /dev/null +++ b/core/modules/system/tests/modules/condition_test/condition_test.routing.yml @@ -0,0 +1,6 @@ +condition_test_1: + pattern: '/condition_test' + defaults: + _controller: '\Drupal\condition_test\FormController::getForm' + requirements: + _access: 'TRUE' diff --git a/core/modules/system/tests/modules/condition_test/lib/Drupal/condition_test/FormController.php b/core/modules/system/tests/modules/condition_test/lib/Drupal/condition_test/FormController.php new file mode 100644 index 0000000..2d63e19 --- /dev/null +++ b/core/modules/system/tests/modules/condition_test/lib/Drupal/condition_test/FormController.php @@ -0,0 +1,50 @@ +condition = $manager->createInstance('node_type'); + return drupal_get_form($this); + } + + public function buildForm(array $form, array &$form_state) { + $form = $this->condition->buildForm($form, $form_state); + $form['actions']['submit'] = array( + '#type' => 'submit', + '#value' => t('Submit'), + ); + return $form; + } + + public function validateForm(array &$form, array &$form_state) { + $this->condition->validateForm($form, $form_state); + } + + public function submitForm(array &$form, array &$form_state) { + $this->condition->submitForm($form, $form_state); + $config = $this->condition->getConfig(); + $bundles = implode(' and ', $config['bundles']); + //drupal_set_message('
' . var_export($this->condition->getConfig(), TRUE) . '
'); + drupal_set_message(t('The bundles are @bundles', array('@bundles' => $bundles))); + } +}