diff --git a/core/modules/book/tests/src/Functional/BookTest.php b/core/modules/book/tests/src/Functional/BookTest.php index 354b887..53afc1a 100644 --- a/core/modules/book/tests/src/Functional/BookTest.php +++ b/core/modules/book/tests/src/Functional/BookTest.php @@ -584,7 +584,7 @@ public function testBookOutline() { $this->drupalLogin($this->adminUser); $this->drupalGet('node/' . $empty_book->id() . '/outline'); $this->assertRaw(t('Book outline')); -// $this->assertOptionSelected('edit-book-bid', 0, 'Node does not belong to a book'); + $this->assertOptionSelected('edit-book-bid', 0); $this->assertNoLink(t('Remove from book outline')); $edit = array(); @@ -624,7 +624,7 @@ public function testBookOutline() { // Test the form itself. $this->drupalGet('node/' . $node->id() . '/edit'); -// $this->assertOptionSelected('edit-book-bid', $node->id()); + $this->assertOptionSelected('edit-book-bid', $node->id()); } /** diff --git a/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php b/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php index 20f16c5..ad42806 100644 --- a/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php +++ b/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php @@ -217,6 +217,26 @@ protected function assertPattern($pattern) { } /** + * Asserts that a select option in the current page is checked. + * + * @param string $select + * The locator of the select field to assert. + * @param string $option + * Option to assert. + * + * @deprecated Scheduled for removal in Drupal 9.0.0. Use methods provided by + * \Drupal\Tests\WebAssert instead, for example: + * @code + * $option = $this->assertSession()->optionExists($select, $value); + * $this->assertTrue($option->getAttribute('selected')); + * @endcode + */ + protected function assertOptionSelected($select, $option) { + $node = $this->assertSession()->optionExists($select, $option); + $this->assertTrue($node->getAttribute('selected')); + } + + /** * Pass if the page title is the given string. * * @param string $expected_title