function BookJavascriptTest::testBookAddOutline

Same name in other branches
  1. 9 core/modules/book/tests/src/FunctionalJavascript/BookJavascriptTest.php \Drupal\Tests\book\FunctionalJavascript\BookJavascriptTest::testBookAddOutline()
  2. 8.9.x core/modules/book/tests/src/FunctionalJavascript/BookJavascriptTest.php \Drupal\Tests\book\FunctionalJavascript\BookJavascriptTest::testBookAddOutline()
  3. 11.x core/modules/book/tests/src/FunctionalJavascript/BookJavascriptTest.php \Drupal\Tests\book\FunctionalJavascript\BookJavascriptTest::testBookAddOutline()

Tests book outline AJAX request.

File

core/modules/book/tests/src/FunctionalJavascript/BookJavascriptTest.php, line 173

Class

BookJavascriptTest
Tests Book javascript functionality.

Namespace

Drupal\Tests\book\FunctionalJavascript

Code

public function testBookAddOutline() : void {
    $this->drupalLogin($this->drupalCreateUser([
        'create book content',
        'create new books',
        'add content to books',
    ]));
    $this->drupalGet('node/add/book');
    $assert_session = $this->assertSession();
    $session = $this->getSession();
    $page = $session->getPage();
    $page->find('css', '#edit-book')
        ->click();
    $book_select = $page->findField("book[bid]");
    $book_select->setValue('new');
    $assert_session->waitForText('This will be the top-level page in this book.');
    $assert_session->pageTextContains('This will be the top-level page in this book.');
    $assert_session->pageTextNotContains('No book selected.');
    $book_select->setValue(0);
    $assert_session->waitForText('No book selected.');
    $assert_session->pageTextContains('No book selected.');
    $assert_session->pageTextNotContains('This will be the top-level page in this book.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.