diff --git a/core/includes/common.inc b/core/includes/common.inc index 03af03b..7bb70a2 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -568,7 +568,7 @@ function drupal_js_defaults($data = NULL) { * @param $elements * A renderable array element having a #states property as described above. * - * @see form_example_states_form() + * @see \Drupal\form_test\Form\JavascriptStatesForm */ function drupal_process_states(&$elements) { $elements['#attached']['library'][] = 'core/drupal.states'; diff --git a/core/modules/system/tests/modules/form_test/src/Form/JavascriptStatesForm.php b/core/modules/system/tests/modules/form_test/src/Form/JavascriptStatesForm.php index 8b94871..5bb45c8 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/JavascriptStatesForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/JavascriptStatesForm.php @@ -1,10 +1,5 @@ assertElementVisible('#edit-average'); $this->assertElementNotVisible('#edit-comment--description'); - $driver->selectOption(CssSelector::toXPath('#edit-how-many-years'), '5'); + $driver->selectOption($this->cssSelect('#edit-how-many-years'), '5'); $this->assertElementVisible('#edit-comment--description'); $this->assertElementNotVisible('#edit-country-writein'); - $driver->selectOption(CssSelector::toXPath('#edit-school-country'), 'Other'); + $driver->selectOption($this->cssSelect('#edit-school-country'), 'Other'); $this->assertElementVisible('#edit-country-writein'); - $driver->selectOption(CssSelector::toXPath('#edit-school-country'), 'UK'); + $driver->selectOption($this->cssSelect('#edit-school-country'), 'UK'); $this->assertElementNotVisible('#edit-country-writein'); // Graduate form testing. @@ -92,12 +86,13 @@ public function testJavascriptStates() { $this->assertElementVisible('#edit-graduate'); $this->assertElementNotVisible('#edit-average'); - $this->assertFalse($driver->isChecked(CssSelector::toXPath('#edit-info-provide')), '#edit-info-provide is not checked'); - $driver->setValue(CssSelector::toXPath('#edit-more-info'), 'Some text'); - $this->assertTrue($driver->isChecked(CssSelector::toXPath('#edit-info-provide')), '#edit-info-provide is checked'); + $this->assertFalse($driver->isChecked($this->cssSelect('#edit-info-provide')), '#edit-info-provide is not checked'); + $driver->setValue($this->cssSelect('#edit-more-info'), 'Some text'); + $this->assertTrue($driver->isChecked($this->cssSelect('#edit-info-provide')), '#edit-info-provide is checked'); // This is not working for some reason. -// $driver->setValue(CssSelector::toXPath('#edit-more-info'), ''); -// $this->assertFalse($driver->isChecked(CssSelector::toXPath('#edit-info-provide')), '#edit-info-provide is not checked'); + $driver->setValue($this->cssSelect('#edit-more-info'), NULL); + $this->assertJsCondition('!jQuery("#edit-more-info").val()'); + $this->assertFalse($driver->isChecked($this->cssSelect('#edit-info-provide')), '#edit-info-provide is not checked'); // Feedback testing. $this->assertElementNotVisible('#edit-feedback'); diff --git a/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php b/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php index 2862d4c..55c7f77 100644 --- a/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php +++ b/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php @@ -44,7 +44,7 @@ protected function initMink() { */ protected function assertElementVisible($css_selector, $message = '') { $message = $message ?: "Element ($css_selector) is visible."; - $this->assertTrue($this->getSession()->getDriver()->isVisible(CssSelector::toXPath($css_selector)), $message); + $this->assertTrue($this->getSession()->getDriver()->isVisible($this->cssSelect($css_selector)), $message); } /** @@ -57,7 +57,7 @@ protected function assertElementVisible($css_selector, $message = '') { */ protected function assertElementNotVisible($css_selector, $message = '') { $message = $message ?: "Element ($css_selector) is not visible."; - $this->assertFalse($this->getSession()->getDriver()->isVisible(CssSelector::toXPath($css_selector)), $message); + $this->assertFalse($this->getSession()->getDriver()->isVisible($this->cssSelect($css_selector)), $message); } /** diff --git a/core/tests/Drupal/Tests/BrowserTestBase.php b/core/tests/Drupal/Tests/BrowserTestBase.php index 8d8ea2b..a3fa3a7 100644 --- a/core/tests/Drupal/Tests/BrowserTestBase.php +++ b/core/tests/Drupal/Tests/BrowserTestBase.php @@ -20,6 +20,7 @@ use Drupal\Core\StreamWrapper\StreamWrapperInterface; use Drupal\Core\Test\TestRunnerKernel; use Drupal\Core\Url; +use Drupal\simpletest\AssertContentTrait; use Drupal\simpletest\RandomGeneratorTrait; use Drupal\simpletest\SessionTestTrait; use Drupal\simpletest\WebAssert; @@ -44,6 +45,7 @@ * @todo Move these into Drupal\Tests namespace and leave deprecated stubs * in simpletest module. See https://www.drupal.org/node/2702281 */ + use AssertContentTrait; use RandomGeneratorTrait; use SessionTestTrait;