ElementsTableSelectTest.php in Drupal 8
File
core/modules/system/tests/src/FunctionalJavascript/Form/ElementsTableSelectTest.php
View source
<?php
namespace Drupal\Tests\system\FunctionalJavascript\Form;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
class ElementsTableSelectTest extends WebDriverTestBase {
protected static $modules = [
'form_test',
];
protected $defaultTheme = 'stark';
public function testAjax() {
$this
->drupalGet('form_test/tableselect/multiple-true');
$session = $this
->getSession();
$page = $session
->getPage();
for ($i = 1; $i <= 3; $i++) {
$row = 'row' . $i;
$page
->hasUncheckedField($row);
$page
->checkField($row);
$this
->assertSession()
->assertWaitOnAjaxRequest();
for ($j = 1; $j <= $i; $j++) {
$other_row = 'row' . $j;
$page
->hasCheckedField($other_row);
}
}
$this
->drupalGet('form_test/tableselect/multiple-false');
for ($i = 1; $i <= 3; $i++) {
$row = 'input[value="row' . $i . '"]';
$page
->hasUncheckedField($row);
$this
->click($row);
$this
->assertSession()
->assertWaitOnAjaxRequest();
$page
->hasCheckedField($row);
for ($j = 1; $j <= 3; $j++) {
if ($j == $i) {
continue;
}
$other_row = 'edit-tableselect-row' . $j;
$page
->hasUncheckedField($other_row);
}
}
}
}