Issue #2970052 by martin107, marcel66, Mile23, longwave, dawehner, borisson_, alexpott, catch: Fix "assertNoPattern() is deprecated and scheduled for removal in Drupal 9.0.0. Use $this->assertSession()->responseNotMatches($pattern) instead"

8.7.x
Alex Pott 2018-09-11 11:41:53 +02:00
parent 6a9a7fd01b
commit e4b39ba7b9
No known key found for this signature in database
GPG Key ID: 31905460D4A69276
11 changed files with 14 additions and 14 deletions

View File

@ -169,7 +169,7 @@ class CommentAnonymousTest extends CommentTestBase {
// NOTE: if authenticated user has permission to post comments, then a // NOTE: if authenticated user has permission to post comments, then a
// "Login or register to post comments" type link may be shown. // "Login or register to post comments" type link may be shown.
$this->drupalGet('node/' . $this->node->id()); $this->drupalGet('node/' . $this->node->id());
$this->assertNoPattern('@<h2[^>]*>Comments</h2>@', 'Comments were not displayed.'); $this->assertSession()->responseNotMatches('@<h2[^>]*>Comments</h2>@', 'Comments were not displayed.');
$this->assertNoLink('Add new comment', 'Link to add comment was found.'); $this->assertNoLink('Add new comment', 'Link to add comment was found.');
// Attempt to view node-comment form while disallowed. // Attempt to view node-comment form while disallowed.
@ -192,7 +192,7 @@ class CommentAnonymousTest extends CommentTestBase {
'skip comment approval' => TRUE, 'skip comment approval' => TRUE,
]); ]);
$this->drupalGet('node/' . $this->node->id()); $this->drupalGet('node/' . $this->node->id());
$this->assertNoPattern('@<h2[^>]*>Comments</h2>@', 'Comments were not displayed.'); $this->assertSession()->responseNotMatches('@<h2[^>]*>Comments</h2>@', 'Comments were not displayed.');
$this->assertFieldByName('subject[0][value]', '', 'Subject field found.'); $this->assertFieldByName('subject[0][value]', '', 'Subject field found.');
$this->assertFieldByName('comment_body[0][value]', '', 'Comment field found.'); $this->assertFieldByName('comment_body[0][value]', '', 'Comment field found.');

View File

@ -26,7 +26,7 @@ class CommentInterfaceTest extends CommentTestBase {
// Make sure that comment field title is not displayed when there's no // Make sure that comment field title is not displayed when there's no
// comments posted. // comments posted.
$this->drupalGet($this->node->urlInfo()); $this->drupalGet($this->node->urlInfo());
$this->assertNoPattern('@<h2[^>]*>Comments</h2>@', 'Comments title is not displayed.'); $this->assertSession()->responseNotMatches('@<h2[^>]*>Comments</h2>@', 'Comments title is not displayed.');
// Set comments to have subject and preview disabled. // Set comments to have subject and preview disabled.
$this->setCommentPreview(DRUPAL_DISABLED); $this->setCommentPreview(DRUPAL_DISABLED);

View File

@ -341,7 +341,7 @@ class CommentNonNodeTest extends BrowserTestBase {
// Attempt to view comments while disallowed. // Attempt to view comments while disallowed.
$this->drupalGet('entity-test/' . $this->entity->id()); $this->drupalGet('entity-test/' . $this->entity->id());
$this->assertNoPattern('@<h2[^>]*>Comments</h2>@', 'Comments were not displayed.'); $this->assertSession()->responseNotMatches('@<h2[^>]*>Comments</h2>@', 'Comments were not displayed.');
$this->assertNoLink('Add new comment', 'Link to add comment was found.'); $this->assertNoLink('Add new comment', 'Link to add comment was found.');
// Attempt to view test entity comment form while disallowed. // Attempt to view test entity comment form while disallowed.
@ -373,7 +373,7 @@ class CommentNonNodeTest extends BrowserTestBase {
'view test entity' => TRUE, 'view test entity' => TRUE,
]); ]);
$this->drupalGet('entity_test/' . $this->entity->id()); $this->drupalGet('entity_test/' . $this->entity->id());
$this->assertNoPattern('@<h2[^>]*>Comments</h2>@', 'Comments were not displayed.'); $this->assertSession()->responseNotMatches('@<h2[^>]*>Comments</h2>@', 'Comments were not displayed.');
$this->assertFieldByName('subject[0][value]', '', 'Subject field found.'); $this->assertFieldByName('subject[0][value]', '', 'Subject field found.');
$this->assertFieldByName('comment_body[0][value]', '', 'Comment field found.'); $this->assertFieldByName('comment_body[0][value]', '', 'Comment field found.');

View File

@ -42,7 +42,7 @@ class CommentTitleTest extends CommentTestBase {
$regex .= '/s'; $regex .= '/s';
$this->assertPattern($regex, 'Comment is created successfully'); $this->assertPattern($regex, 'Comment is created successfully');
// Tests that markup is not generated for the comment without header. // Tests that markup is not generated for the comment without header.
$this->assertNoPattern('|<h3[^>]*></h3>|', 'Comment title H3 element not found when title is an empty string.'); $this->assertSession()->responseNotMatches('|<h3[^>]*></h3>|', 'Comment title H3 element not found when title is an empty string.');
} }
/** /**

View File

@ -358,7 +358,7 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
$this->drupalGet('node/' . $node->id()); $this->drupalGet('node/' . $node->id());
// Verify that no image is displayed on the page by checking for the class // Verify that no image is displayed on the page by checking for the class
// that would be used on the image field. // that would be used on the image field.
$this->assertNoPattern('<div class="(.*?)field--name-' . strtr($field_name, '_', '-') . '(.*?)">', 'No image displayed when no image is attached and no default image specified.'); $this->assertSession()->responseNotMatches('<div class="(.*?)field--name-' . strtr($field_name, '_', '-') . '(.*?)">', 'No image displayed when no image is attached and no default image specified.');
$cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags'); $cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags');
$this->assertTrue(!preg_match('/ image_style\:/', $cache_tags_header), 'No image style cache tag found.'); $this->assertTrue(!preg_match('/ image_style\:/', $cache_tags_header), 'No image style cache tag found.');

View File

@ -189,7 +189,7 @@ class PageCacheTest extends BrowserTestBase {
// Fill the cache. // Fill the cache.
$this->drupalGet(''); $this->drupalGet('');
// Verify the page is not printed twice when the cache is cold. // Verify the page is not printed twice when the cache is cold.
$this->assertNoPattern('#<html.*<html#'); $this->assertSession()->responseNotMatches('#<html.*<html#');
$this->drupalGet(''); $this->drupalGet('');
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.'); $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.');
@ -213,7 +213,7 @@ class PageCacheTest extends BrowserTestBase {
$this->drupalGet('', [], ['If-Modified-Since' => $last_modified, 'If-None-Match' => NULL]); $this->drupalGet('', [], ['If-Modified-Since' => $last_modified, 'If-None-Match' => NULL]);
// Verify the page is not printed twice when the cache is warm. // Verify the page is not printed twice when the cache is warm.
$this->assertNoPattern('#<html.*<html#'); $this->assertSession()->responseNotMatches('#<html.*<html#');
$this->assertResponse(200, 'Conditional request without If-None-Match returned 200 OK.'); $this->assertResponse(200, 'Conditional request without If-None-Match returned 200 OK.');
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.'); $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.');

View File

@ -99,13 +99,13 @@ class StatisticsLoggingTest extends BrowserTestBase {
// Verify that logging scripts are not found on a non-node page. // Verify that logging scripts are not found on a non-node page.
$this->drupalGet('node'); $this->drupalGet('node');
$settings = $this->getDrupalSettings(); $settings = $this->getDrupalSettings();
$this->assertNoPattern($expected_library, 'Statistics library JS not found on node page.'); $this->assertSession()->responseNotMatches($expected_library, 'Statistics library JS not found on node page.');
$this->assertFalse(isset($settings['statistics']), 'Statistics settings not found on node page.'); $this->assertFalse(isset($settings['statistics']), 'Statistics settings not found on node page.');
// Verify that logging scripts are not found on a non-existent node page. // Verify that logging scripts are not found on a non-existent node page.
$this->drupalGet('node/9999'); $this->drupalGet('node/9999');
$settings = $this->getDrupalSettings(); $settings = $this->getDrupalSettings();
$this->assertNoPattern($expected_library, 'Statistics library JS not found on non-existent node page.'); $this->assertSession()->responseNotMatches($expected_library, 'Statistics library JS not found on non-existent node page.');
$this->assertFalse(isset($settings['statistics']), 'Statistics settings not found on node page.'); $this->assertFalse(isset($settings['statistics']), 'Statistics settings not found on node page.');
// Verify that logging scripts are found on a valid node page. // Verify that logging scripts are found on a valid node page.

View File

@ -61,7 +61,7 @@ class NoJavaScriptAnonymousTest extends BrowserTestBase {
// Ensure no other JavaScript file exists on the page, while ignoring the // Ensure no other JavaScript file exists on the page, while ignoring the
// HTML5 shiv. // HTML5 shiv.
$this->assertNoPattern('/(?<!html5shiv\.min)\.js/', "No other JavaScript exists."); $this->assertSession()->responseNotMatches('/(?<!html5shiv\.min)\.js/');
} }
} }

View File

@ -48,7 +48,7 @@ class TaxonomyTermPagerTest extends TaxonomyTestBase {
// Get Page 1. // Get Page 1.
$this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview'); $this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview');
$this->assertNoPattern('|<nav class="pager" [^>]*>|', 'Pager is not visible on page 1'); $this->assertSession()->responseNotMatches('|<nav class="pager" [^>]*>|', 'Pager is not visible on page 1');
// Create 3 more terms to show pager. // Create 3 more terms to show pager.
for ($x = 1; $x <= 3; $x++) { for ($x = 1; $x <= 3; $x++) {

View File

@ -156,6 +156,7 @@ class AssertLegacyTraitTest extends UnitTestCase {
/** /**
* @covers ::assertNoPattern * @covers ::assertNoPattern
* @expectedDeprecation assertNoPattern() is deprecated and scheduled for removal in Drupal 9.0.0. Use $this->assertSession()->responseNotMatches($pattern) instead. See https://www.drupal.org/node/2864262.
*/ */
public function testAssertNoPattern() { public function testAssertNoPattern() {
$this->webAssert $this->webAssert

View File

@ -110,7 +110,6 @@ trait DeprecationListenerTrait {
'Drupal\system\Tests\Update\DbUpdatesTrait is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Use \Drupal\FunctionalTests\Update\DbUpdatesTrait instead. See https://www.drupal.org/node/2896640.', 'Drupal\system\Tests\Update\DbUpdatesTrait is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Use \Drupal\FunctionalTests\Update\DbUpdatesTrait instead. See https://www.drupal.org/node/2896640.',
'Providing settings under \'handler_settings\' is deprecated and will be removed before 9.0.0. Move the settings in the root of the configuration array. See https://www.drupal.org/node/2870971.', 'Providing settings under \'handler_settings\' is deprecated and will be removed before 9.0.0. Move the settings in the root of the configuration array. See https://www.drupal.org/node/2870971.',
'AssertLegacyTrait::getAllOptions() is scheduled for removal in Drupal 9.0.0. Use $element->findAll(\'xpath\', \'option\') instead.', 'AssertLegacyTrait::getAllOptions() is scheduled for removal in Drupal 9.0.0. Use $element->findAll(\'xpath\', \'option\') instead.',
'assertNoPattern() is deprecated and scheduled for removal in Drupal 9.0.0. Use $this->assertSession()->responseNotMatches($pattern) instead. See https://www.drupal.org/node/2864262.',
'Using UTF-8 route patterns without setting the "utf8" option is deprecated since Symfony 3.2 and will throw a LogicException in 4.0. Turn on the "utf8" route option for pattern "/system-test/Ȅchȏ/meφΩ/{text}".', 'Using UTF-8 route patterns without setting the "utf8" option is deprecated since Symfony 3.2 and will throw a LogicException in 4.0. Turn on the "utf8" route option for pattern "/system-test/Ȅchȏ/meφΩ/{text}".',
'Using UTF-8 route patterns without setting the "utf8" option is deprecated since Symfony 3.2 and will throw a LogicException in 4.0. Turn on the "utf8" route option for pattern "/somewhere/{item}/over/the/קainbow".', 'Using UTF-8 route patterns without setting the "utf8" option is deprecated since Symfony 3.2 and will throw a LogicException in 4.0. Turn on the "utf8" route option for pattern "/somewhere/{item}/over/the/קainbow".',
'Using UTF-8 route patterns without setting the "utf8" option is deprecated since Symfony 3.2 and will throw a LogicException in 4.0. Turn on the "utf8" route option for pattern "/place/meφω".', 'Using UTF-8 route patterns without setting the "utf8" option is deprecated since Symfony 3.2 and will throw a LogicException in 4.0. Turn on the "utf8" route option for pattern "/place/meφω".',