diff --git a/core/modules/book/book.permissions.yml b/core/modules/book/book.permissions.yml index 52dd9d0..e3ec489 100644 --- a/core/modules/book/book.permissions.yml +++ b/core/modules/book/book.permissions.yml @@ -3,7 +3,7 @@ administer book outlines: create new books: title: 'Create new books' add content to books: - title: 'Add content and child pages to books' + title: 'Add content and child pages to books and manage their hierarchies.' access printer-friendly version: title: 'View printer-friendly books' description: 'View a book page and all of its sub-pages as a single document for ease of printing. Can be performance heavy.' diff --git a/core/modules/contact/src/Tests/ContactAuthenticatedUserTest.php b/core/modules/contact/tests/src/Functional/ContactAuthenticatedUserTest.php similarity index 84% rename from core/modules/contact/src/Tests/ContactAuthenticatedUserTest.php rename to core/modules/contact/tests/src/Functional/ContactAuthenticatedUserTest.php index eb7c527..4b4a520 100644 --- a/core/modules/contact/src/Tests/ContactAuthenticatedUserTest.php +++ b/core/modules/contact/tests/src/Functional/ContactAuthenticatedUserTest.php @@ -1,15 +1,15 @@ drupalGet('contact'); - $this->assertResponse(200, 'The page exists'); + $this->assertResponse(200); $this->assertNoField('edit-langcode-0-value'); // Enable language select from content language settings page. @@ -57,7 +57,7 @@ public function testContactLanguage() { // Ensure that contact form now shows the language select. $this->drupalGet('contact'); - $this->assertResponse(200, 'The page exists'); + $this->assertResponse(200); $this->assertField('edit-langcode-0-value'); } diff --git a/core/modules/contact/src/Tests/ContactPersonalTest.php b/core/modules/contact/tests/src/Functional/ContactPersonalTest.php similarity index 94% rename from core/modules/contact/src/Tests/ContactPersonalTest.php rename to core/modules/contact/tests/src/Functional/ContactPersonalTest.php index 936aed5..9573206 100644 --- a/core/modules/contact/src/Tests/ContactPersonalTest.php +++ b/core/modules/contact/tests/src/Functional/ContactPersonalTest.php @@ -1,19 +1,22 @@ drupalGet('user/' . $this->contactUser->id() . '/contact'); $this->assertEscaped($mail); $message = $this->submitPersonalContact($this->contactUser); - $mails = $this->drupalGetMails(); + $mails = $this->getMails(); $this->assertEqual(1, count($mails)); $mail = $mails[0]; $this->assertEqual($mail['to'], $this->contactUser->getEmail()); @@ -127,14 +130,14 @@ function testPersonalContactAccess() { $original_email = $this->contactUser->getEmail(); $this->contactUser->setEmail(FALSE)->save(); $this->drupalGet('user/' . $this->contactUser->id() . '/contact'); - $this->assertResponse(404, 'Not found (404) returned when visiting a personal contact form for a user with no email address'); + $this->assertResponse(404); // Test that the 'contact tab' does not appear on the user profiles // for users without an email address configured. $this->drupalGet('user/' . $this->contactUser->id()); $contact_link = '/user/' . $this->contactUser->id() . '/contact'; $this->assertResponse(200); - $this->assertNoLinkByHref ($contact_link, 'The "contact" tab is hidden on profiles for users with no email address'); + $this->assertNoLinkByHref ($contact_link); // Restore original email address. $this->contactUser->setEmail($original_email)->save(); @@ -170,7 +173,7 @@ function testPersonalContactAccess() { $this->drupalLogin($this->adminUser); $edit = array('contact_default_status' => FALSE); $this->drupalPostForm('admin/config/people/accounts', $edit, t('Save configuration')); - $this->assertText(t('The configuration options have been saved.'), 'Setting successfully saved.'); + $this->assertText(t('The configuration options have been saved.')); $this->drupalLogout(); // Re-create our contacted user with personal contact forms disabled by @@ -232,17 +235,17 @@ function testPersonalContactFlood() { // Submit contact form with correct values and check flood interval. for ($i = 0; $i < $flood_limit; $i++) { $this->submitPersonalContact($this->contactUser); - $this->assertText(t('Your message has been sent.'), 'Message sent.'); + $this->assertText(t('Your message has been sent.')); } // Submit contact form one over limit. $this->submitPersonalContact($this->contactUser); - $this->assertRaw(t('You cannot send more than %number messages in @interval. Try again later.', array('%number' => $flood_limit, '@interval' => \Drupal::service('date.formatter')->formatInterval($this->config('contact.settings')->get('flood.interval')))), 'Normal user denied access to flooded contact form.'); + $this->assertRaw(t('You cannot send more than %number messages in @interval. Try again later.', array('%number' => $flood_limit, '@interval' => \Drupal::service('date.formatter')->formatInterval($this->config('contact.settings')->get('flood.interval'))))); // Test that the admin user can still access the contact form even though // the flood limit was reached. $this->drupalLogin($this->adminUser); - $this->assertNoText('Try again later.', 'Admin user not denied access to flooded contact form.'); + $this->assertNoText('Try again later.Admin user not denied access to flooded contact form.'); } /** diff --git a/core/modules/contact/src/Tests/ContactSitewideTest.php b/core/modules/contact/tests/src/Functional/ContactSitewideTest.php similarity index 96% rename from core/modules/contact/src/Tests/ContactSitewideTest.php rename to core/modules/contact/tests/src/Functional/ContactSitewideTest.php index b049f25..d092766 100644 --- a/core/modules/contact/src/Tests/ContactSitewideTest.php +++ b/core/modules/contact/tests/src/Functional/ContactSitewideTest.php @@ -1,12 +1,13 @@ drupalPlaceBlock('system_breadcrumb_block'); - $this->drupalPlaceBlock('local_actions_block'); - $this->drupalPlaceBlock('page_title_block'); + $this->placeBlock('system_breadcrumb_block'); + $this->placeBlock('local_actions_block'); + $this->placeBlock('page_title_block'); } /** @@ -89,7 +91,7 @@ function testSiteWideContact() { // Delete old forms to ensure that new forms are used. $this->deleteContactForms(); $this->drupalGet('admin/structure/contact'); - $this->assertText('Personal', 'Personal form was not deleted'); + $this->assertText('Personal'); $this->assertNoLinkByHref('admin/structure/contact/manage/feedback'); // Ensure that the contact form won't be shown without forms. @@ -147,7 +149,7 @@ function testSiteWideContact() { $this->assertEqual($langcode, $default_langcode); // Make sure the newly created form is included in the list of forms. - $this->assertNoUniqueText($label, 'New form included in forms list.'); + $this->assertNoUniqueText($label); // Ensure that the recipient email is escaped on the listing. $this->drupalGet('admin/structure/contact'); @@ -293,7 +295,7 @@ function testSiteWideContact() { $field_name . '[0][value]' => $this->randomMachineName(), ); $this->drupalPostForm(NULL, $edit, t('Send message')); - $mails = $this->drupalGetMails(); + $mails = $this->getMails(); $mail = array_pop($mails); $this->assertEqual($mail['subject'], t('[@label] @subject', array('@label' => $label, '@subject' => $edit['subject[0][value]']))); $this->assertTrue(strpos($mail['body'], $field_label)); @@ -325,7 +327,7 @@ function testAutoReply() { $this->submitContact($this->randomMachineName(16), $email, $subject, 'foo', $this->randomString(128)); // We are testing the auto-reply, so there should be one email going to the sender. - $captured_emails = $this->drupalGetMails(array('id' => 'contact_page_autoreply', 'to' => $email)); + $captured_emails = $this->getMails(array('id' => 'contact_page_autoreply', 'to' => $email)); $this->assertEqual(count($captured_emails), 1); $this->assertEqual(trim($captured_emails[0]['body']), trim(MailFormatHelper::htmlToText($foo_autoreply))); @@ -334,14 +336,14 @@ function testAutoReply() { $this->submitContact($this->randomMachineName(16), $email, $this->randomString(64), 'bar', $this->randomString(128)); // Auto-reply for form 'bar' should result in one auto-reply email to the sender. - $captured_emails = $this->drupalGetMails(array('id' => 'contact_page_autoreply', 'to' => $email)); + $captured_emails = $this->getMails(array('id' => 'contact_page_autoreply', 'to' => $email)); $this->assertEqual(count($captured_emails), 1); $this->assertEqual(trim($captured_emails[0]['body']), trim(MailFormatHelper::htmlToText($bar_autoreply))); // Verify that no auto-reply is sent when the auto-reply field is left blank. $email = $this->randomMachineName(32) . '@example.com'; $this->submitContact($this->randomMachineName(16), $email, $this->randomString(64), 'no_autoreply', $this->randomString(128)); - $captured_emails = $this->drupalGetMails(array('id' => 'contact_page_autoreply', 'to' => $email)); + $captured_emails = $this->getMails(array('id' => 'contact_page_autoreply', 'to' => $email)); $this->assertEqual(count($captured_emails), 0); } diff --git a/core/modules/contact/src/Tests/ContactStorageTest.php b/core/modules/contact/tests/src/Functional/ContactStorageTest.php similarity index 98% rename from core/modules/contact/src/Tests/ContactStorageTest.php rename to core/modules/contact/tests/src/Functional/ContactStorageTest.php index 6fd3edd..069cbcf 100644 --- a/core/modules/contact/src/Tests/ContactStorageTest.php +++ b/core/modules/contact/tests/src/Functional/ContactStorageTest.php @@ -1,6 +1,6 @@ assertSession()->buildXPathQuery() instead. */ - protected function buildXPathQuery($xpath, array $args = array()) { + public function buildXPathQuery($xpath, array $args = array()) { return $this->assertSession()->buildXPathQuery($xpath, $args); } + /** + /** + * Asserts whether an expected cache context was present in the last response. + * + * @param string $expected_cache_context + * The expected cache context. + * + * @deprecated Scheduled for removal in Drupal 9.0.0. + * Use $this->assertSession()->responseHeaderContains() instead. + */ + protected function assertCacheContext($expected_cache_context) { + $cache_contexts = explode(' ', $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Contexts', $expected_cache_context)); + $this->assertTrue(in_array($expected_cache_context, $cache_contexts), "'" . $expected_cache_context . "' is present in the X-Drupal-Cache-Contexts header."); + } + + /** + * Asserts that a checkbox field in the current page is checked. + * + * @param string $id + * ID of field to assert. + * @param string $message + * (optional) A message to display with the assertion. Do not translate + * messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed + * variables in the message text, not t(). If left blank, a default message + * will be displayed. + * @param string $group + * (optional) The group this message is in, which is displayed in a column + * in test output. Use 'Debug' to indicate this is debugging output. Do not + * translate this string. Defaults to 'Browser'; most tests do not override + * this default. + * + * @return bool + * TRUE on pass, FALSE on fail. + * + * @deprecated Scheduled for removal in Drupal 9.0.0. + * Use $this->getSession()->getPage()->findField instead. + */ + protected function assertFieldChecked($id, $message = '', $group = 'Browser') { + $elements = $this->getSession()->getPage()->findField($id); + $checked = $elements->hasCheckedField($id); + return $this->assertTrue(isset($checked) , $message ? $message : SafeMarkup::format('Checkbox field @id is checked.', array('@id' => $id)), $group); + } + + /** + * Asserts that a checkbox field in the current page is not checked. + * + * @param string $id + * ID of field to assert. + * @param string $message + * (optional) A message to display with the assertion. Do not translate + * messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed + * variables in the message text, not t(). If left blank, a default message + * will be displayed. + * @param string $group + * (optional) The group this message is in, which is displayed in a column + * in test output. Use 'Debug' to indicate this is debugging output. Do not + * translate this string. Defaults to 'Browser'; most tests do not override + * this default. + * + * @return bool + * TRUE on pass, FALSE on fail. + * + * @deprecated Scheduled for removal in Drupal 9.0.0. + * Use $this->getSession()->getPage()->findField instead. + */ + protected function assertNoFieldChecked($id, $message = '', $group = 'Browser') { + $elements = $this->getSession()->getPage()->findField($id); + $checked = $elements->hasCheckedField($id); + return $this->assertTrue(isset($checked), $message ? $message : SafeMarkup::format('Checkbox field @id is not checked.', array('@id' => $id)), $group); + } }