Unverified Commit 402567d1 authored by alexpott's avatar alexpott

Issue #3142749 by munish.kumar, shaktik, pavnish, sja112, ravi.shankar, Lal_,...

Issue #3142749 by munish.kumar, shaktik, pavnish, sja112, ravi.shankar, Lal_, mondrake, daffie, xjm: AssertLegacyTrait::assertPattern() calls in functional tests still have a message passed in
parent 54124628
......@@ -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.
......
......@@ -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 . ')');
}
......
......@@ -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.');
......
......@@ -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();
......
......@@ -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.');
......
......@@ -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');
......
......@@ -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.
......
......@@ -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'];
......
......@@ -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/');
}
/**
......
......@@ -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.
......
......@@ -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);
}
/**
......
......@@ -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/');
}
/**
......
......@@ -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']));
}
}
......
......@@ -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" [^>]*>|');
}
}
......@@ -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>|');
}
}
......@@ -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);
}
/**
......
......@@ -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/');
}
/**
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment