You are here

public function BookJavascriptTest::testBookAddOutline in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/book/tests/src/FunctionalJavascript/BookJavascriptTest.php \Drupal\Tests\book\FunctionalJavascript\BookJavascriptTest::testBookAddOutline()
  2. 10 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 168

Class

BookJavascriptTest
Tests Book javascript functionality.

Namespace

Drupal\Tests\book\FunctionalJavascript

Code

public function testBookAddOutline() {
  $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.');
}