- <?php
- * @file
- * Test ajax example module.
- */
-
- * Functional tests for AJAX Example module.
- *
- * @ingroup ajax_example
- */
- class AjaxExampleTestCase extends BackdropWebTestCase {
-
-
- * Enable module.
- */
- public function setUp() {
- parent::setUp('ajax_example');
- }
-
-
- * Check the non-JavaScript version of the "Dynamic Sections" example.
- */
- public function testDynamicSectionsNoJs() {
-
- $path = 'examples/ajax_example/dynamic_sections_no_js';
-
- $wrong = t('Wrong answer. Try again. (Hint: The right answer is "George Washington".)');
- $right = t('You got the right answer: George Washington');
-
- $params = array(
- t('Multiple Choice') => array(
- 'value' => t('Abraham Lincoln'),
- 'answer' => t('Abraham Lincoln'),
- 'response' => $wrong,
- ),
- t('True/False') => array(
- 'value' => t('George Washington'),
- 'answer' => t('George Washington'),
- 'response' => $right,
- ),
- t('Fill-in-the-blanks') => array(
- 'value' => NULL,
- 'answer' => t('George Washington'),
- 'response' => $right,
- ),
- );
- foreach ($params as $style => $q_and_a) {
-
- $edit = array('question_type_select' => $style);
- $this->backdropPost($path, $edit, t('Choose'));
- $this->assertResponse(200, format_string('Question style "@style" selected.', array('@style' => $style)));
-
- extract($q_and_a);
-
- $this->assertFieldByName('question', $value);
-
- $edit = array('question' => $answer);
- $this->backdropPost(NULL, $edit, t('Submit your answer'));
- $this->assertRaw($response, 'Dynamic form has been submitted.');
- }
- }
-
- }