Updated to Drupal 8.6.4, which is PHP 7.3 friendly. Also updated HTMLaw library....
[yaffs-website] / web / core / modules / system / src / Tests / Ajax / ElementValidationTest.php
1 <?php
2
3 namespace Drupal\system\Tests\Ajax;
4
5 /**
6  * Various tests of AJAX behavior.
7  *
8  * @group Ajax
9  */
10 class ElementValidationTest extends AjaxTestBase {
11
12   /**
13    * Tries to post an Ajax change to a form that has a validated element.
14    *
15    * The drivertext field is Ajax-enabled. An additional field is not, but
16    * is set to be a required field. In this test the required field is not
17    * filled in, and we want to see if the activation of the "drivertext"
18    * Ajax-enabled field fails due to the required field being empty.
19    */
20   public function testAjaxElementValidation() {
21     $edit = ['drivertext' => t('some dumb text')];
22
23     // Post with 'drivertext' as the triggering element.
24     $this->drupalPostAjaxForm('ajax_validation_test', $edit, 'drivertext');
25     // Look for a validation failure in the resultant JSON.
26     $this->assertNoText(t('Error message'), 'No error message in resultant JSON');
27     $this->assertText('ajax_forms_test_validation_form_callback invoked', 'The correct callback was invoked');
28
29     $this->drupalGet('ajax_validation_test');
30     $edit = ['drivernumber' => 12345];
31
32     // Post with 'drivernumber' as the triggering element.
33     $this->drupalPostAjaxForm('ajax_validation_test', $edit, 'drivernumber');
34     // Look for a validation failure in the resultant JSON.
35     $this->assertNoText(t('Error message'), 'No error message in resultant JSON');
36     $this->assertText('ajax_forms_test_validation_number_form_callback invoked', 'The correct callback was invoked');
37   }
38
39 }