Mercurial > hg > isophonics-drupal-site
comparison core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxInGroupTest.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\FunctionalJavascriptTests\Ajax; | |
4 | |
5 use Drupal\FunctionalJavascriptTests\WebDriverTestBase; | |
6 | |
7 /** | |
8 * Tests that form elements in groups work correctly with AJAX. | |
9 * | |
10 * @group Ajax | |
11 */ | |
12 class AjaxInGroupTest extends WebDriverTestBase { | |
13 | |
14 /** | |
15 * {@inheritdoc} | |
16 */ | |
17 protected static $modules = ['ajax_forms_test']; | |
18 | |
19 /** | |
20 * {@inheritdoc} | |
21 */ | |
22 protected function setUp() { | |
23 parent::setUp(); | |
24 | |
25 $this->drupalLogin($this->drupalCreateUser(['access content'])); | |
26 } | |
27 | |
28 /** | |
29 * Submits forms with select and checkbox elements via Ajax. | |
30 */ | |
31 public function testSimpleAjaxFormValue() { | |
32 $this->drupalGet('/ajax_forms_test_get_form'); | |
33 | |
34 $assert_session = $this->assertSession(); | |
35 $assert_session->responseContains('Test group'); | |
36 $assert_session->responseContains('AJAX checkbox in a group'); | |
37 | |
38 $session = $this->getSession(); | |
39 $checkbox_original = $session->getPage()->findField('checkbox_in_group'); | |
40 $this->assertNotNull($checkbox_original, 'The checkbox_in_group is on the page.'); | |
41 $original_id = $checkbox_original->getAttribute('id'); | |
42 | |
43 // Triggers a AJAX request/response. | |
44 $checkbox_original->check(); | |
45 | |
46 // The response contains a new nested "test group" form element, similar | |
47 // to the one already in the DOM except for a change in the form build id. | |
48 $checkbox_new = $assert_session->waitForElement('xpath', "//input[@name='checkbox_in_group' and not(@id='$original_id')]"); | |
49 $this->assertNotNull($checkbox_new, 'DOM update: clicking the checkbox refreshed the checkbox_in_group structure'); | |
50 | |
51 $assert_session->responseContains('Test group'); | |
52 $assert_session->responseContains('AJAX checkbox in a group'); | |
53 $assert_session->responseContains('AJAX checkbox in a nested group'); | |
54 $assert_session->responseContains('Another AJAX checkbox in a nested group'); | |
55 } | |
56 | |
57 } |