diff --git a/core/modules/simpletest/src/AssertContentTrait.php b/core/modules/simpletest/src/AssertContentTrait.php index 8d6c211..f18ff86 100644 --- a/core/modules/simpletest/src/AssertContentTrait.php +++ b/core/modules/simpletest/src/AssertContentTrait.php @@ -1215,8 +1215,8 @@ protected function assertOption($drupal_selector, $option, $message = '', $group * TRUE on pass, FALSE on fail. */ protected function assertOptionWithDrupalSelector($drupal_selector, $option, $message = '', $group = 'Browser') { - $options = $this->xpath('//select[@data-drupal-selector=:data_drupal_selector]//option[@value=:option]', array(':data_drupal_selector' => $drupal_selector, ':option' => $option)); - return $this->assertTrue(isset($options[0]), $message ? $message : SafeMarkup::format('Option @option for field @data_drupal_selector exists.', array('@option' => $option, '@data_drupal_selector' => $drupal_selector)), $group); + $options = $this->xpath('//select[@data-drupal-selector=:data_drupal_selector]//option[@value=:option]', [':data_drupal_selector' => $drupal_selector, ':option' => $option]); + return $this->assertTrue(!empty((string) $options[0]), $message ? $message : SafeMarkup::format('Option @option for field @data_drupal_selector exists.', array('@option' => $option, '@data_drupal_selector' => $drupal_selector)), $group); } /** @@ -1240,8 +1240,9 @@ protected function assertOptionWithDrupalSelector($drupal_selector, $option, $me * TRUE on pass, FALSE on fail. */ protected function assertNoOption($drupal_selector, $option, $message = '', $group = 'Browser') { - $options = $this->xpath('//select[@data-drupal-selector=:data_drupal_selector]//option[@value=:option]', array(':data_drupal_selector' => $drupal_selector, ':option' => $option)); - return $this->assertFalse(isset($options[0]), $message ? $message : SafeMarkup::format('Option @option for field @data_drupal_selector exists.', array('@option' => $option, '@data_drupal_selector' => $drupal_selector)), $group); + $selects = $this->xpath('//select[@data-drupal-selector=:data_drupal_selector]', [':data_drupal_selector' => $drupal_selector]); + $options = $this->xpath('//select[@data-drupal-selector=:data_drupal_selector]//option[@value=:option]', [':data_drupal_selector' => $drupal_selector, ':option' => $option]); + return $this->assertTrue(isset($selects[0]->option) && empty($options[0]), $message ? $message : SafeMarkup::format('Option @option for field @data_drupal_selector exists.', array('@option' => $option, '@data_drupal_selector' => $drupal_selector)), $group); } /**