diff --git a/core/modules/book/tests/src/Functional/BookTestTrait.php b/core/modules/book/tests/src/Functional/BookTestTrait.php index 38a93f44b24f21d41ae57ddefb9645197c04efa8..f2d78b511200630c1e660855c017549ef9f9bf38 100644 --- a/core/modules/book/tests/src/Functional/BookTestTrait.php +++ b/core/modules/book/tests/src/Functional/BookTestTrait.php @@ -95,7 +95,7 @@ public function checkBookNode(EntityInterface $node, $nodes, $previous, $up, $ne // Check outline structure. if ($nodes !== NULL) { - $this->assertPattern($this->generateOutlinePattern($nodes), new FormattableMarkup('Node @number outline confirmed.', ['@number' => $number])); + $this->assertPattern($this->generateOutlinePattern($nodes)); } // Check previous, up, and next links. diff --git a/core/modules/color/tests/src/Functional/ColorTest.php b/core/modules/color/tests/src/Functional/ColorTest.php index 015d7202944f46db7b9caabd36d2c5a01255cb53..66199d533de3af6b0b165fdab60effd4243c8369 100644 --- a/core/modules/color/tests/src/Functional/ColorTest.php +++ b/core/modules/color/tests/src/Functional/ColorTest.php @@ -120,8 +120,9 @@ public function _testColor($theme, $test_values) { $this->drupalGet('<front>'); $stylesheets = $this->config('color.theme.' . $theme)->get('stylesheets'); + // Make sure the color stylesheet is included in the content. foreach ($stylesheets as $stylesheet) { - $this->assertPattern('|' . file_url_transform_relative(file_create_url($stylesheet)) . '|', 'Make sure the color stylesheet is included in the content. (' . $theme . ')'); + $this->assertPattern('|' . file_url_transform_relative(file_create_url($stylesheet)) . '|'); $stylesheet_content = implode("\n", file($stylesheet)); $this->assertStringContainsString('color: #123456', $stylesheet_content, 'Make sure the color we changed is in the color stylesheet. (' . $theme . ')'); } diff --git a/core/modules/comment/tests/src/Functional/CommentAnonymousTest.php b/core/modules/comment/tests/src/Functional/CommentAnonymousTest.php index a502a0b5f669ee813a44b1a5eb1d03ce0d97b4eb..6366ce6d1519dd1f7f08a767748bc7ee492b33bf 100644 --- a/core/modules/comment/tests/src/Functional/CommentAnonymousTest.php +++ b/core/modules/comment/tests/src/Functional/CommentAnonymousTest.php @@ -188,7 +188,8 @@ public function testAnonymous() { 'skip comment approval' => FALSE, ]); $this->drupalGet('node/' . $this->node->id()); - $this->assertPattern('@<h2[^>]*>Comments</h2>@', 'Comments were displayed.'); + // Verify that the comment field title is displayed. + $this->assertPattern('@<h2[^>]*>Comments</h2>@'); $this->assertSession()->linkExists('Log in', 1, 'Link to login was found.'); $this->assertSession()->linkExists('register', 1, 'Link to register was found.'); diff --git a/core/modules/comment/tests/src/Functional/CommentInterfaceTest.php b/core/modules/comment/tests/src/Functional/CommentInterfaceTest.php index e557c7ce194a53cafd9a95fb916dc05dd88a25c1..5018d5664ebc052ecc5fef5f7068c32c4e59f3ce 100644 --- a/core/modules/comment/tests/src/Functional/CommentInterfaceTest.php +++ b/core/modules/comment/tests/src/Functional/CommentInterfaceTest.php @@ -55,7 +55,7 @@ public function testCommentInterface() { // Test the comment field title is displayed when there's comments. $this->drupalGet($this->node->toUrl()); - $this->assertPattern('@<h2[^>]*>Comments</h2>@', 'Comments title is displayed.'); + $this->assertPattern('@<h2[^>]*>Comments</h2>@'); // Set comments to have subject and preview to required. $this->drupalLogout(); diff --git a/core/modules/comment/tests/src/Functional/CommentNonNodeTest.php b/core/modules/comment/tests/src/Functional/CommentNonNodeTest.php index 8023bd204fbec35add35f07bbd0f3dfdcfde6eaa..5a19a817b22f225681d9acb34acb9e04c86ea3ce 100644 --- a/core/modules/comment/tests/src/Functional/CommentNonNodeTest.php +++ b/core/modules/comment/tests/src/Functional/CommentNonNodeTest.php @@ -370,7 +370,8 @@ public function testCommentFunctionality() { 'skip comment approval' => FALSE, ]); $this->drupalGet('entity_test/' . $this->entity->id()); - $this->assertPattern('@<h2[^>]*>Comments</h2>@', 'Comments were displayed.'); + // Verify that the comment field title is displayed. + $this->assertPattern('@<h2[^>]*>Comments</h2>@'); $this->assertSession()->linkExists('Log in', 0, 'Link to login was found.'); $this->assertSession()->linkExists('register', 0, 'Link to register was found.'); $this->assertNoFieldByName('subject[0][value]', '', 'Subject field not found.'); diff --git a/core/modules/comment/tests/src/Functional/CommentTitleTest.php b/core/modules/comment/tests/src/Functional/CommentTitleTest.php index 0565d88a275ce502abe1f376eea21eeeb5bd8095..7897acbaa2c64ee177df7e4ac2896afa83ce946f 100644 --- a/core/modules/comment/tests/src/Functional/CommentTitleTest.php +++ b/core/modules/comment/tests/src/Functional/CommentTitleTest.php @@ -45,7 +45,8 @@ public function testCommentEmptyTitles() { $regex = '/<article(.*?)id="comment-' . $comment->id() . '"(.*?)'; $regex .= $comment->comment_body->value . '(.*?)'; $regex .= '/s'; - $this->assertPattern($regex, 'Comment is created successfully'); + // Verify that the comment is created successfully. + $this->assertPattern($regex); // Tests that markup is not generated for the comment without header. $this->assertSession()->responseNotMatches('|<h3[^>]*></h3>|', 'Comment title H3 element not found when title is an empty string.'); } @@ -76,7 +77,7 @@ public function testCommentPopulatedTitles() { // Confirm that the comment was created. $this->assertTrue($this->commentExists($comment1), 'Comment #1. Comment found.'); // Tests that markup is created for comment with heading. - $this->assertPattern('|<h3[^>]*><a[^>]*>' . $subject_text . '</a></h3>|', 'Comment title is rendered in h3 when title populated.'); + $this->assertPattern('|<h3[^>]*><a[^>]*>' . $subject_text . '</a></h3>|'); // Tests that the comment's title link is the permalink of the comment. $comment_permalink = $this->cssSelect('.permalink'); $comment_permalink = $comment_permalink[0]->getAttribute('href'); diff --git a/core/modules/field/tests/src/Functional/FormTest.php b/core/modules/field/tests/src/Functional/FormTest.php index 6bf6a3464da7fdc5d8c18b908a0b0d67b43da003..381ec8df9e4e5e9dae4614ffa1d5fa454658ed93 100644 --- a/core/modules/field/tests/src/Functional/FormTest.php +++ b/core/modules/field/tests/src/Functional/FormTest.php @@ -315,7 +315,8 @@ public function testFieldFormUnlimited() { } ksort($pattern); $pattern = implode('.*', array_values($pattern)); - $this->assertPattern("|$pattern|s", 'Widgets are displayed in the correct order'); + // Verify that the widgets are displayed in the correct order. + $this->assertPattern("|$pattern|s"); $this->assertFieldByName("{$field_name}[$delta][value]", '', "New widget is displayed"); $this->assertFieldByName("{$field_name}[$delta][_weight]", $delta, "New widget has the right weight"); // Verify that no extraneous widget is displayed. diff --git a/core/modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php b/core/modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php index 36175f8c853310f17f628c7a63ffd79f5cabce65..175360180a31ab57852ccd9cabdbfb7687eea016 100644 --- a/core/modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php +++ b/core/modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php @@ -78,12 +78,12 @@ public function testMenuNodeFormWidget() { // Verify that the menu link title has the correct maxlength. $title_max_length = \Drupal::service('entity_field.manager')->getBaseFieldDefinitions('menu_link_content')['title']->getSetting('max_length'); $this->drupalGet('node/add/page'); - $this->assertPattern('/<input .* id="edit-menu-title" .* maxlength="' . $title_max_length . '" .* \/>/', 'Menu link title field has correct maxlength in node add form.'); + $this->assertPattern('/<input .* id="edit-menu-title" .* maxlength="' . $title_max_length . '" .* \/>/'); // Verify that the menu link description has the correct maxlength. $description_max_length = \Drupal::service('entity_field.manager')->getBaseFieldDefinitions('menu_link_content')['description']->getSetting('max_length'); $this->drupalGet('node/add/page'); - $this->assertPattern('/<input .* id="edit-menu-description" .* maxlength="' . $description_max_length . '" .* \/>/', 'Menu link description field has correct maxlength in node add form.'); + $this->assertPattern('/<input .* id="edit-menu-description" .* maxlength="' . $description_max_length . '" .* \/>/'); // Disable the default main menu, so that no menus are enabled. $edit = [ @@ -193,8 +193,12 @@ public function testMenuNodeFormWidget() { $this->drupalGet('node/' . $node->id() . '/edit'); $this->assertFieldById('edit-menu-weight', 17, 'Menu weight correct in edit form'); - $this->assertPattern('/<input .* id="edit-menu-title" .* maxlength="' . $title_max_length . '" .* \/>/', 'Menu link title field has correct maxlength in node edit form.'); - $this->assertPattern('/<input .* id="edit-menu-description" .* maxlength="' . $description_max_length . '" .* \/>/', 'Menu link description field has correct maxlength in node add form.'); + // Verify that the menu link title field has correct maxlength in node edit + // form. + $this->assertPattern('/<input .* id="edit-menu-title" .* maxlength="' . $title_max_length . '" .* \/>/'); + // Verify that the menu link description field has correct maxlength in + // node add form. + $this->assertPattern('/<input .* id="edit-menu-description" .* maxlength="' . $description_max_length . '" .* \/>/'); // Disable the menu link, then edit the node--the link should stay disabled. $link_id = menu_ui_get_menu_link_defaults($node)['entity_id']; diff --git a/core/modules/node/tests/src/Functional/Views/FrontPageTest.php b/core/modules/node/tests/src/Functional/Views/FrontPageTest.php index 35e04d0905bdb987402940c0f584d0fd00bf321f..8d5b0f048758729bba213032254dfb790f6340d4 100644 --- a/core/modules/node/tests/src/Functional/Views/FrontPageTest.php +++ b/core/modules/node/tests/src/Functional/Views/FrontPageTest.php @@ -187,7 +187,7 @@ public function testAdminFrontPage() { $this->drupalGet('node'); $this->assertSession()->statusCodeEquals(200); // Check that the frontpage view was rendered. - $this->assertPattern('/class=".+view-frontpage/', 'Frontpage view was rendered'); + $this->assertPattern('/class=".+view-frontpage/'); } /** diff --git a/core/modules/statistics/tests/src/Functional/StatisticsLoggingTest.php b/core/modules/statistics/tests/src/Functional/StatisticsLoggingTest.php index c089649c62e6c2496d0e56d5d139057ba672a395..23b810d080e7acaa975c2a710553ddbbe958838a 100644 --- a/core/modules/statistics/tests/src/Functional/StatisticsLoggingTest.php +++ b/core/modules/statistics/tests/src/Functional/StatisticsLoggingTest.php @@ -117,13 +117,13 @@ public function testLogging() { // Verify that logging scripts are found on a valid node page. $this->drupalGet($path); $settings = $this->getDrupalSettings(); - $this->assertPattern($expected_library, 'Found statistics library JS on node page.'); + $this->assertPattern($expected_library); $this->assertIdentical($this->node->id(), $settings['statistics']['data']['nid'], 'Found statistics settings on node page.'); // Verify the same when loading the site in a non-default language. $this->drupalGet($this->language['langcode'] . '/' . $path); $settings = $this->getDrupalSettings(); - $this->assertPattern($expected_library, 'Found statistics library JS on a valid node page in a non-default language.'); + $this->assertPattern($expected_library); $this->assertIdentical($this->node->id(), $settings['statistics']['data']['nid'], 'Found statistics settings on valid node page in a non-default language.'); // Manually call statistics.php to simulate ajax data collection behavior. diff --git a/core/modules/system/tests/src/Functional/Batch/ProcessingTest.php b/core/modules/system/tests/src/Functional/Batch/ProcessingTest.php index 69e23ed0c6eea4a7f35cd1dde6a1de8dace7d05a..4e98379aedc719795e30cba7dd5f3ea84bcbf802 100644 --- a/core/modules/system/tests/src/Functional/Batch/ProcessingTest.php +++ b/core/modules/system/tests/src/Functional/Batch/ProcessingTest.php @@ -221,7 +221,7 @@ public function testBatchLargePercentage() { */ public function assertBatchMessages($texts, $message) { $pattern = '|' . implode('.*', $texts) . '|s'; - return $this->assertPattern($pattern, $message); + return $this->assertPattern($pattern); } /** diff --git a/core/modules/system/tests/src/Functional/Form/StorageTest.php b/core/modules/system/tests/src/Functional/Form/StorageTest.php index 09780a0688b369b252c3592f576b375ce96bff5f..602d52ed04cdf3d809f9fd8ef907cf76bdfe1759 100644 --- a/core/modules/system/tests/src/Functional/Form/StorageTest.php +++ b/core/modules/system/tests/src/Functional/Form/StorageTest.php @@ -101,7 +101,8 @@ public function testFormCached() { */ public function testValidation() { $this->drupalPostForm('form_test/form-storage', ['title' => '', 'value' => 'value_is_set'], 'Continue submit'); - $this->assertPattern('/value_is_set/', 'The input values have been kept.'); + // Ensure that the input values have been kept. + $this->assertPattern('/value_is_set/'); } /** diff --git a/core/modules/system/tests/src/Kernel/Common/AddFeedTest.php b/core/modules/system/tests/src/Kernel/Common/AddFeedTest.php index 9926b189921971149a0305b7db1cffed1af1fb87..efa055746f74e1f0ba7a7fe576df106ff25bbff4 100644 --- a/core/modules/system/tests/src/Kernel/Common/AddFeedTest.php +++ b/core/modules/system/tests/src/Kernel/Common/AddFeedTest.php @@ -2,7 +2,6 @@ namespace Drupal\Tests\system\Kernel\Common; -use Drupal\Component\Render\FormattableMarkup; use Drupal\Core\Url; use Drupal\KernelTests\KernelTestBase; @@ -69,7 +68,7 @@ public function testBasicFeedAddNoTitle() { $this->setRawContent($response->getContent()); // Assert that the content contains the RSS links we specified. foreach ($urls as $description => $feed_info) { - $this->assertPattern($this->urlToRSSLinkPattern($feed_info['url'], $feed_info['title']), new FormattableMarkup('Found correct feed header for %description', ['%description' => $description])); + $this->assertPattern($this->urlToRSSLinkPattern($feed_info['url'], $feed_info['title'])); } } diff --git a/core/modules/taxonomy/tests/src/Functional/TaxonomyTermPagerTest.php b/core/modules/taxonomy/tests/src/Functional/TaxonomyTermPagerTest.php index 1641e0c8a98aaba145b82733e4274be449d08323..27db54e98537c227e9f20da0b614c14475b85d53 100644 --- a/core/modules/taxonomy/tests/src/Functional/TaxonomyTermPagerTest.php +++ b/core/modules/taxonomy/tests/src/Functional/TaxonomyTermPagerTest.php @@ -63,13 +63,13 @@ public function testTaxonomyTermOverviewPager() { $this->createTerm($this->vocabulary); } - // Get Page 1. + // Ensure that pager is visible on page 1. $this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview'); - $this->assertPattern('|<nav class="pager" [^>]*>|', 'Pager is visible on page 1'); + $this->assertPattern('|<nav class="pager" [^>]*>|'); - // Get Page 2. + // Ensure that pager is visible on page 2. $this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview', ['query' => ['page' => 1]]); - $this->assertPattern('|<nav class="pager" [^>]*>|', 'Pager is visible on page 2'); + $this->assertPattern('|<nav class="pager" [^>]*>|'); } } diff --git a/core/modules/taxonomy/tests/src/Functional/TermLanguageTest.php b/core/modules/taxonomy/tests/src/Functional/TermLanguageTest.php index 78482be633eabd266c853845ca04b1fd25fb5eaf..6e6daac92d491443a8e82ec9ff884a1f452314ca 100644 --- a/core/modules/taxonomy/tests/src/Functional/TermLanguageTest.php +++ b/core/modules/taxonomy/tests/src/Functional/TermLanguageTest.php @@ -142,7 +142,7 @@ public function testTermTranslatedOnOverviewPage() { // Overview page in the other language shows the translated term $this->drupalGet('bb/admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview'); - $this->assertPattern('|<a[^>]*>' . $translated_title . '</a>|', 'The term language is correct'); + $this->assertPattern('|<a[^>]*>' . $translated_title . '</a>|'); } } diff --git a/core/modules/tracker/tests/src/Functional/TrackerTest.php b/core/modules/tracker/tests/src/Functional/TrackerTest.php index abef371799697d30a101c269f650928f7b5f26c7..e111400ecb10dfd44f6d49c035109ae058063706 100644 --- a/core/modules/tracker/tests/src/Functional/TrackerTest.php +++ b/core/modules/tracker/tests/src/Functional/TrackerTest.php @@ -353,7 +353,9 @@ public function testTrackerOrderingNewComments() { // It's almost certainly too brittle. $pattern = '/' . preg_quote($node_one->getTitle()) . '.+' . preg_quote($node_two->getTitle()) . '/s'; $this->verbose($pattern); - $this->assertPattern($pattern, 'Most recently commented on node appears at the top of tracker'); + // Verify that the most recent comment on node appears at the top of + // tracker. + $this->assertPattern($pattern); } /** diff --git a/core/modules/update/tests/src/Functional/UpdateUploadTest.php b/core/modules/update/tests/src/Functional/UpdateUploadTest.php index 34995cfd4ff3cc2f5929a6f6fc0878af9496ae00..74762ad2598a81d36c5c86146f5e95986aceb99c 100644 --- a/core/modules/update/tests/src/Functional/UpdateUploadTest.php +++ b/core/modules/update/tests/src/Functional/UpdateUploadTest.php @@ -147,9 +147,9 @@ public function testUploadModule() { public function testFileNameExtensionMerging() { $this->drupalGet('admin/modules/install'); // Make sure the bogus extension supported by update_test.module is there. - $this->assertPattern('/file extensions are supported:.*update-test-extension/', "Found 'update-test-extension' extension."); + $this->assertPattern('/file extensions are supported:.*update-test-extension/'); // Make sure it didn't clobber the first option from core. - $this->assertPattern('/file extensions are supported:.*tar/', "Found 'tar' extension."); + $this->assertPattern('/file extensions are supported:.*tar/'); } /** diff --git a/core/modules/user/tests/src/Functional/UserBlocksTest.php b/core/modules/user/tests/src/Functional/UserBlocksTest.php index 36b70cd7af5e2ee1d90721de2954cf318f150b3b..fc0079235c48f1df83079d0d65c007b03cf7d8d0 100644 --- a/core/modules/user/tests/src/Functional/UserBlocksTest.php +++ b/core/modules/user/tests/src/Functional/UserBlocksTest.php @@ -88,7 +88,8 @@ public function testUserLoginBlock() { $this->assertEqual('MISS', $this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER)); $this->drupalPostForm(NULL, $edit, t('Log in')); $this->assertNoText(t('User login'), 'Logged in.'); - $this->assertPattern('!<title.*?Compose tips.*?</title>!', 'Still on the same page after login for allowed page'); + // Verify that we are still on the same page after login for allowed page. + $this->assertPattern('!<title.*?Compose tips.*?</title>!'); // Log out again and repeat with a non-403 page including query arguments. $this->drupalLogout(); @@ -96,7 +97,8 @@ public function testUserLoginBlock() { $this->assertEqual('HIT', $this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER)); $this->drupalPostForm(NULL, $edit, t('Log in')); $this->assertNoText(t('User login'), 'Logged in.'); - $this->assertPattern('!<title.*?Compose tips.*?</title>!', 'Still on the same page after login for allowed page'); + // Verify that we are still on the same page after login for allowed page. + $this->assertPattern('!<title.*?Compose tips.*?</title>!'); $this->assertStringContainsString('/filter/tips?foo=bar', $this->getUrl(), 'Correct query arguments are displayed after login'); // Repeat with different query arguments. @@ -105,7 +107,8 @@ public function testUserLoginBlock() { $this->assertEqual('HIT', $this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER)); $this->drupalPostForm(NULL, $edit, t('Log in')); $this->assertNoText(t('User login'), 'Logged in.'); - $this->assertPattern('!<title.*?Compose tips.*?</title>!', 'Still on the same page after login for allowed page'); + // Verify that we are still on the same page after login for allowed page. + $this->assertPattern('!<title.*?Compose tips.*?</title>!'); $this->assertStringContainsString('/filter/tips?foo=baz', $this->getUrl(), 'Correct query arguments are displayed after login'); // Check that the user login block is not vulnerable to information