diff --git a/core/modules/book/tests/src/Functional/BookTest.php b/core/modules/book/tests/src/Functional/BookTest.php index 66edec9..d7771f0 100644 --- a/core/modules/book/tests/src/Functional/BookTest.php +++ b/core/modules/book/tests/src/Functional/BookTest.php @@ -335,15 +335,20 @@ public function generateOutlinePattern($nodes) { * A book node ID or set to 'new' to create a new book. * @param int|null $parent * (optional) Parent book reference ID. Defaults to NULL. + * @param string $submit + * (optional) Value of the submit button whose click is to be emulated. + * Defaults to 'Save'. * * @return \Drupal\node\NodeInterface * The created node. */ - public function createBookNode($book_nid, $parent = NULL) { + public function createBookNode($book_nid, $parent = NULL, $submit = NULL) { // $number does not use drupal_static as it should not be reset // since it uniquely identifies each call to createBookNode(). static $number = 0; // Used to ensure that when sorted nodes stay in same order. + $submit = $submit ?: t('Save'); + $edit = []; $edit['title[0][value]'] = str_pad($number, 2, '0', STR_PAD_LEFT) . ' - SimpleTest test node ' . $this->randomMachineName(10); $edit['body[0][value]'] = 'SimpleTest test body ' . $this->randomMachineName(32) . ' ' . $this->randomMachineName(32); @@ -353,13 +358,13 @@ public function createBookNode($book_nid, $parent = NULL) { $this->drupalPostForm('node/add/book', $edit, t('Change book (update list of parents)')); $edit['book[pid]'] = $parent; - $this->drupalPostForm(NULL, $edit, t('Save')); + $this->drupalPostForm(NULL, $edit, $submit); // Make sure the parent was flagged as having children. $parent_node = \Drupal::entityManager()->getStorage('node')->loadUnchanged($parent); $this->assertFalse(empty($parent_node->book['has_children']), 'Parent node is marked as having children'); } else { - $this->drupalPostForm('node/add/book', $edit, t('Save')); + $this->drupalPostForm('node/add/book', $edit, $submit); } // Check to make sure the book node was created.