Chris@17: drupalGet('ajax_validation_test');
Chris@17: $page = $this->getSession()->getPage();
Chris@17: $assert = $this->assertSession();
Chris@17:
Chris@17: // Partially complete the form with a string.
Chris@17: $page->fillField('drivertext', 'some dumb text');
Chris@17: // Move focus away from this field to trigger AJAX.
Chris@17: $page->findField('spare_required_field')->focus();
Chris@17:
Chris@17: // When the AJAX command updates the DOM a
unsorted list
Chris@17: // "message__list" structure will appear on the page echoing back the
Chris@17: // "some dumb text" message.
Chris@17: $placeholder_text = $assert->waitForElement('css', "ul.messages__list li.messages__item em:contains('some dumb text')");
Chris@17: $this->assertNotNull($placeholder_text, 'A callback successfully echoed back a string.');
Chris@17:
Chris@17: $this->drupalGet('ajax_validation_test');
Chris@17: // Partialy complete the form with a number.
Chris@17: $page->fillField('drivernumber', '12345');
Chris@17: $page->findField('spare_required_field')->focus();
Chris@17:
Chris@17: // The AJAX request/resonse will complete successfully when a InsertCommand
Chris@17: // injects a message with a placeholder element into the DOM with the
Chris@17: // submitted number.
Chris@17: $placeholder_number = $assert->waitForElement('css', "ul.messages__list li.messages__item em:contains('12345')");
Chris@17: $this->assertNotNull($placeholder_number, 'A callback successfully echoed back a number.');
Chris@17: }
Chris@17:
Chris@17: }