Commit cef0c900 authored by catch's avatar catch
Browse files

Issue #3227060 by mondrake, ankithashetty, daffie, catch: [backport] Replace...

Issue #3227060 by mondrake, ankithashetty, daffie, catch: [backport] Replace usages of AssertLegacyTrait::assertNoRaw, that is deprecated
parent e7e84162
......@@ -66,7 +66,7 @@ public function testFeedLabelEscaping() {
$this->assertSession()->statusCodeEquals(200);
$this->assertSession()->assertEscaped('Test feed title <script>alert(123);</script>');
$this->assertNoRaw('Test feed title <script>alert(123);</script>');
$this->assertSession()->responseNotContains('Test feed title <script>alert(123);</script>');
// Ensure the feed icon title is escaped.
$this->assertStringContainsString('class="feed-icon"> Subscribe to Test feed title &lt;script&gt;alert(123);&lt;/script&gt; feed</a>', str_replace(["\n", "\r"], '', $this->getSession()->getPage()->getContent()));
......
......@@ -87,18 +87,18 @@ public function testNoJsDetection() {
$this->drupalGet(Url::fromRoute('<front>'));
$this->assertSessionCookieExists(FALSE);
$this->assertBigPipeNoJsCookieExists(FALSE);
$this->assertNoRaw('<noscript><meta http-equiv="Refresh" content="0; URL=');
$this->assertNoRaw($no_js_to_js_markup);
$this->assertSession()->responseNotContains('<noscript><meta http-equiv="Refresh" content="0; URL=');
$this->assertSession()->responseNotContains($no_js_to_js_markup);
// 2. Session (authenticated).
$this->drupalLogin($this->rootUser);
$this->assertSessionCookieExists(TRUE);
$this->assertBigPipeNoJsCookieExists(FALSE);
$this->assertRaw('<noscript><meta http-equiv="Refresh" content="0; URL=' . base_path() . 'big_pipe/no-js?destination=' . base_path() . 'user/1" />' . "\n" . '</noscript>');
$this->assertNoRaw($no_js_to_js_markup);
$this->assertSession()->responseNotContains($no_js_to_js_markup);
$this->assertBigPipeNoJsMetaRefreshRedirect();
$this->assertBigPipeNoJsCookieExists(TRUE);
$this->assertNoRaw('<noscript><meta http-equiv="Refresh" content="0; URL=');
$this->assertSession()->responseNotContains('<noscript><meta http-equiv="Refresh" content="0; URL=');
$this->assertRaw($no_js_to_js_markup);
$this->drupalLogout();
......@@ -111,10 +111,10 @@ public function testNoJsDetection() {
$this->assertSessionCookieExists(TRUE);
$this->assertBigPipeNoJsCookieExists(FALSE);
$this->assertRaw('<noscript><meta http-equiv="Refresh" content="0; URL=' . base_path() . 'big_pipe/no-js?destination=' . base_path() . 'user/login" />' . "\n" . '</noscript>');
$this->assertNoRaw($no_js_to_js_markup);
$this->assertSession()->responseNotContains($no_js_to_js_markup);
$this->assertBigPipeNoJsMetaRefreshRedirect();
$this->assertBigPipeNoJsCookieExists(TRUE);
$this->assertNoRaw('<noscript><meta http-equiv="Refresh" content="0; URL=');
$this->assertSession()->responseNotContains('<noscript><meta http-equiv="Refresh" content="0; URL=');
$this->assertRaw($no_js_to_js_markup);
// Close the prior connection and remove the collected state.
......@@ -124,14 +124,14 @@ public function testNoJsDetection() {
$this->drupalGet(Url::fromRoute('no_big_pipe'));
$this->assertSessionCookieExists(FALSE);
$this->assertBigPipeNoJsCookieExists(FALSE);
$this->assertNoRaw('<noscript><meta http-equiv="Refresh" content="0; URL=');
$this->assertNoRaw($no_js_to_js_markup);
$this->assertSession()->responseNotContains('<noscript><meta http-equiv="Refresh" content="0; URL=');
$this->assertSession()->responseNotContains($no_js_to_js_markup);
$this->drupalLogin($this->rootUser);
$this->drupalGet(Url::fromRoute('no_big_pipe'));
$this->assertSessionCookieExists(TRUE);
$this->assertBigPipeNoJsCookieExists(FALSE);
$this->assertNoRaw('<noscript><meta http-equiv="Refresh" content="0; URL=');
$this->assertNoRaw($no_js_to_js_markup);
$this->assertSession()->responseNotContains('<noscript><meta http-equiv="Refresh" content="0; URL=');
$this->assertSession()->responseNotContains($no_js_to_js_markup);
}
/**
......@@ -214,8 +214,8 @@ public function testBigPipe() {
$this->assertRaw('The website encountered an unexpected error. Please try again later');
$this->assertRaw('You are not allowed to say llamas are not cool!');
// Check that stop signal and closing body tag are absent.
$this->assertNoRaw(BigPipe::STOP_SIGNAL);
$this->assertNoRaw('</body>');
$this->assertSession()->responseNotContains(BigPipe::STOP_SIGNAL);
$this->assertSession()->responseNotContains('</body>');
// The exception is expected. Do not interpret it as a test failure.
unlink($this->root . '/' . $this->siteDirectory . '/error.log');
}
......@@ -265,8 +265,8 @@ public function testBigPipeNoJs() {
// Verifying there are no BigPipe placeholders & replacements.
$this->assertSession()->responseHeaderEquals('BigPipe-Test-Placeholders', '<none>');
// Verifying BigPipe start/stop signals are absent.
$this->assertNoRaw(BigPipe::START_SIGNAL);
$this->assertNoRaw(BigPipe::STOP_SIGNAL);
$this->assertSession()->responseNotContains(BigPipe::START_SIGNAL);
$this->assertSession()->responseNotContains(BigPipe::STOP_SIGNAL);
// Verifying BigPipe assets are absent.
$this->assertArrayNotHasKey('bigPipePlaceholderIds', $this->getDrupalSettings());
......@@ -285,7 +285,7 @@ public function testBigPipeNoJs() {
// The 'edge_case__html_exception' case throws an exception.
$this->assertRaw('The website encountered an unexpected error. Please try again later');
$this->assertRaw('You are not allowed to say llamas are not cool!');
$this->assertNoRaw('</body>');
$this->assertSession()->responseNotContains('</body>');
// The exception is expected. Do not interpret it as a test failure.
unlink($this->root . '/' . $this->siteDirectory . '/error.log');
}
......@@ -308,8 +308,8 @@ public function testBigPipeMultiOccurrencePlaceholders() {
$big_pipe_placeholder_id = 'callback=Drupal%5CCore%5CRender%5CElement%5CStatusMessages%3A%3ArenderMessages&amp;args%5B0%5D&amp;token=_HAdUpwWmet0TOTe2PSiJuMntExoshbm1kh2wQzzzAA';
$expected_placeholder_replacement = '<script type="application/vnd.drupal-ajax" data-big-pipe-replacement-for-placeholder-with-id="' . $big_pipe_placeholder_id . '">';
$this->assertRaw('The count is 1.');
$this->assertNoRaw('The count is 2.');
$this->assertNoRaw('The count is 3.');
$this->assertSession()->responseNotContains('The count is 2.');
$this->assertSession()->responseNotContains('The count is 3.');
$raw_content = $this->getSession()->getPage()->getContent();
$this->assertSame(1, substr_count($raw_content, $expected_placeholder_replacement), 'Only one placeholder replacement was found for the duplicate #lazy_builder arrays.');
......@@ -322,8 +322,8 @@ public function testBigPipeMultiOccurrencePlaceholders() {
$this->assertBigPipeNoJsCookieExists(TRUE);
$this->drupalGet(Url::fromRoute('big_pipe_test_multi_occurrence'));
$this->assertRaw('The count is 1.');
$this->assertNoRaw('The count is 2.');
$this->assertNoRaw('The count is 3.');
$this->assertSession()->responseNotContains('The count is 2.');
$this->assertSession()->responseNotContains('The count is 3.');
}
protected function assertBigPipeResponseHeadersPresent() {
......@@ -345,7 +345,7 @@ protected function assertBigPipeNoJsPlaceholders(array $expected_big_pipe_nojs_p
foreach ($expected_big_pipe_nojs_placeholders as $big_pipe_nojs_placeholder => $expected_replacement) {
// Checking whether the replacement for the BigPipe no-JS placeholder
// $big_pipe_nojs_placeholder is present.
$this->assertNoRaw($big_pipe_nojs_placeholder);
$this->assertSession()->responseNotContains($big_pipe_nojs_placeholder);
if ($expected_replacement !== NULL) {
$this->assertRaw($expected_replacement);
}
......@@ -376,7 +376,7 @@ protected function assertBigPipePlaceholders(array $expected_big_pipe_placeholde
$result = $this->xpath('//script[@data-big-pipe-replacement-for-placeholder-with-id=:id]', [':id' => Html::decodeEntities($big_pipe_placeholder_id)]);
if ($expected_ajax_response === NULL) {
$this->assertCount(0, $result);
$this->assertNoRaw($expected_placeholder_replacement);
$this->assertSession()->responseNotContains($expected_placeholder_replacement);
continue;
}
$this->assertEquals($expected_ajax_response, trim($result[0]->getText()));
......@@ -494,7 +494,7 @@ protected function assertBigPipeNoJsMetaRefreshRedirect() {
$this->assertEquals('no-store, content="BigPipe/1.0"', $headers[1]['Surrogate-Control'][0], 'The second response has a "Surrogate-Control" header.');
// Check that the <meta> refresh is absent, only one redirect ever happens.
$this->assertNoRaw('<noscript><meta http-equiv="Refresh" content="0; URL=');
$this->assertSession()->responseNotContains('<noscript><meta http-equiv="Refresh" content="0; URL=');
}
}
......@@ -80,8 +80,8 @@ public function testSevenAdminTheme() {
$this->drupalGet('admin');
// Check if contextual link classes are unavailable.
$this->assertNoRaw('<div data-contextual-id="block:block=' . $block->id() . ':langcode=en"></div>');
$this->assertNoRaw('contextual-region');
$this->assertSession()->responseNotContains('<div data-contextual-id="block:block=' . $block->id() . ':langcode=en"></div>');
$this->assertSession()->responseNotContains('contextual-region');
}
}
......@@ -65,7 +65,7 @@ public function testBlockVisibility() {
// Confirm that an empty block is not displayed.
$this->assertSession()->pageTextNotContains('Powered by Drupal');
$this->assertNoRaw('sidebar-first');
$this->assertSession()->responseNotContains('sidebar-first');
}
/**
......@@ -256,7 +256,7 @@ public function testBlock() {
$this->submitForm([], 'Remove');
$this->assertRaw(t('The block %name has been removed.', ['%name' => $block->label()]));
$this->assertSession()->addressEquals('admin');
$this->assertNoRaw($block->id());
$this->assertSession()->responseNotContains($block->id());
}
/**
......
......@@ -217,7 +217,7 @@ public function testContextAwareBlocks() {
$expected_text = '<div id="test_context_aware--username">' . \Drupal::currentUser()->getAccountName() . '</div>';
$this->drupalGet('');
$this->assertSession()->pageTextNotContains('Test context-aware block');
$this->assertNoRaw($expected_text);
$this->assertSession()->responseNotContains($expected_text);
$block_url = 'admin/structure/block/add/test_context_aware/classy';
$arguments = [
......@@ -264,7 +264,7 @@ public function testContextAwareBlocks() {
// Tests that conditions with missing context are not displayed.
$this->drupalGet('admin/structure/block/manage/testcontextawareblock');
$this->assertNoRaw('No existing type');
$this->assertSession()->responseNotContains('No existing type');
$this->assertSession()->elementNotExists('xpath', '//*[@name="visibility[condition_test_no_existing_type][negate]"]');
}
......
......@@ -51,7 +51,7 @@ public function testXssInTitle() {
\Drupal::state()->set('block_test.content', $this->randomMachineName());
$this->drupalGet('');
// Check that the block title was properly sanitized when rendered.
$this->assertNoRaw('<script>alert("XSS label");</script>');
$this->assertSession()->responseNotContains('<script>alert("XSS label");</script>');
$this->drupalLogin($this->drupalCreateUser([
'administer blocks',
......@@ -61,7 +61,7 @@ public function testXssInTitle() {
$this->drupalGet('admin/structure/block/list/' . $default_theme);
// Check that the block title was properly sanitized in Block Plugin UI
// Admin page.
$this->assertNoRaw("<script>alert('XSS subject');</script>");
$this->assertSession()->responseNotContains("<script>alert('XSS subject');</script>");
}
/**
......@@ -76,7 +76,7 @@ public function testXssInCategory() {
]));
$this->drupalGet(Url::fromRoute('block.admin_display'));
$this->clickLink('Place block');
$this->assertNoRaw("<script>alert('XSS category');</script>");
$this->assertSession()->responseNotContains("<script>alert('XSS category');</script>");
}
/**
......@@ -92,7 +92,7 @@ public function testBlockXss() {
$this->drupalGet(Url::fromRoute('block.admin_display'));
$this->clickLink('Place block');
// Check that the page does not have double escaped HTML tags.
$this->assertNoRaw('&amp;lt;');
$this->assertSession()->responseNotContains('&amp;lt;');
}
/**
......@@ -135,14 +135,14 @@ protected function doViewTest() {
// Assert that the blocks have their admin labels escaped and
// don't appear anywhere unescaped.
$this->assertSession()->assertEscaped('<script>alert("view1");</script>');
$this->assertNoRaw('<script>alert("view1");</script>');
$this->assertSession()->responseNotContains('<script>alert("view1");</script>');
$this->assertSession()->assertEscaped('<script>alert("view2");</script>: Fish & chips');
$this->assertNoRaw('<script>alert("view2");</script>');
$this->assertNoRaw('Fish & chips');
$this->assertSession()->responseNotContains('<script>alert("view2");</script>');
$this->assertSession()->responseNotContains('Fish & chips');
// Assert the Display label doesn't appear anywhere double escaped.
$this->assertNoRaw('Fish & chips');
$this->assertNoRaw('Fish &amp;amp; chips');
$this->assertSession()->responseNotContains('Fish & chips');
$this->assertSession()->responseNotContains('Fish &amp;amp; chips');
}
/**
......@@ -158,7 +158,7 @@ protected function doMenuTest() {
$this->clickLink('Place block');
$this->assertSession()->assertEscaped('<script>alert("menu");</script>');
$this->assertNoRaw('<script>alert("menu");</script>');
$this->assertSession()->responseNotContains('<script>alert("menu");</script>');
}
/**
......@@ -179,7 +179,7 @@ protected function doBlockContentTest() {
$this->clickLink('Place block');
$this->assertSession()->assertEscaped('<script>alert("block_content");</script>');
$this->assertNoRaw('<script>alert("block_content");</script>');
$this->assertSession()->responseNotContains('<script>alert("block_content");</script>');
}
}
......@@ -272,7 +272,7 @@ public function testBlockDelete() {
$this->drupalGet('block/add/basic');
$this->submitForm($edit2, 'Save');
$this->assertNoRaw('Error message');
$this->assertSession()->responseNotContains('Error message');
// Create another block with no instances, and test we don't get a
// confirmation message about deleting instances.
......
......@@ -101,11 +101,11 @@ public function testLoading() {
// Verify that a single text format hidden input does not exist on the page.
$this->assertSession()->elementNotExists('xpath', '//input[@type="hidden" and contains(@class, "editor")]');
// Verify that CKEditor glue JS is absent.
$this->assertNoRaw(drupal_get_path('module', 'ckeditor') . '/js/ckeditor.js');
$this->assertSession()->responseNotContains(drupal_get_path('module', 'ckeditor') . '/js/ckeditor.js');
// On pages where there would never be a text editor, CKEditor JS is absent.
$this->drupalGet('user');
$this->assertNoRaw(drupal_get_path('module', 'ckeditor') . '/js/ckeditor.js');
$this->assertSession()->responseNotContains(drupal_get_path('module', 'ckeditor') . '/js/ckeditor.js');
// The normal user:
// - has access to 2 text formats;
......
......@@ -55,7 +55,7 @@ public function testColorPreview() {
$this->drupalGet($url);
$this->assertSession()->pageTextContains('TEST COLOR PREVIEW');
$this->assertNoRaw('<script>alert("security filter test");</script>');
$this->assertSession()->responseNotContains('<script>alert("security filter test");</script>');
$this->assertRaw('<h2>TEST COLOR PREVIEW</h2>');
}
......
......@@ -213,7 +213,7 @@ public function testOverrideAndResetScheme() {
$this->drupalGet('');
// Make sure the color logo is not being used.
$this->assertNoRaw('files/color/bartik-');
$this->assertSession()->responseNotContains('files/color/bartik-');
// Make sure the original bartik logo exists.
$this->assertRaw('bartik/logo.svg');
......@@ -229,7 +229,7 @@ public function testOverrideAndResetScheme() {
// Make sure the color logo is being used.
$this->assertRaw('files/color/bartik-');
// Make sure the original bartik logo does not exist.
$this->assertNoRaw('bartik/logo.svg');
$this->assertSession()->responseNotContains('bartik/logo.svg');
// Log in and set the color scheme back to default (delete config).
$this->drupalLogin($this->bigUser);
......@@ -241,7 +241,7 @@ public function testOverrideAndResetScheme() {
$this->drupalLogout();
$this->drupalGet('');
// Make sure the color logo is not being used.
$this->assertNoRaw('files/color/bartik-');
$this->assertSession()->responseNotContains('files/color/bartik-');
// Make sure the original bartik logo exists.
$this->assertRaw('bartik/logo.svg');
}
......
......@@ -162,7 +162,7 @@ public function testAnonymous() {
$this->performCommentOperation($anonymous_comment3, 'delete');
$this->drupalGet('admin/content/comment');
$this->assertNoRaw('comments[' . $anonymous_comment3->id() . ']');
$this->assertSession()->responseNotContains('comments[' . $anonymous_comment3->id() . ']');
$this->drupalLogout();
// Comment 3 was deleted.
......
......@@ -351,7 +351,7 @@ public function testViewMode() {
// mode this time.
$comment_element = $this->cssSelect('.comment-wrapper');
$this->assertTrue(!empty($comment_element));
$this->assertNoRaw('<p>' . $comment_text . '</p>');
$this->assertSession()->responseNotContains('<p>' . $comment_text . '</p>');
}
}
......@@ -324,7 +324,7 @@ public function testCommentFunctionality() {
// Delete the comment.
$this->performCommentOperation($comment1, 'delete');
$this->drupalGet('admin/content/comment');
$this->assertNoRaw('comments[' . $comment1->id() . ']');
$this->assertSession()->responseNotContains('comments[' . $comment1->id() . ']');
// Post another comment.
$comment1 = $this->postComment($this->entity, $this->randomMachineName(), $this->randomMachineName());
......
......@@ -78,7 +78,7 @@ public function testCommentRss() {
$this->node->set('comment', CommentItemInterface::HIDDEN);
$this->node->save();
$this->drupalGet('rss.xml');
$this->assertNoRaw($raw);
$this->assertSession()->responseNotContains($raw);
}
}
......@@ -274,11 +274,11 @@ public function testPager() {
// Item 51 should not be present.
$this->assertRaw('Test config entity 50');
$this->assertNoRaw('Test config entity 51');
$this->assertSession()->responseNotContains('Test config entity 51');
// Browse to the next page, test config entity 51 is on page 2.
$this->clickLink('Page 2');
$this->assertNoRaw('Test config entity 50');
$this->assertSession()->responseNotContains('Test config entity 50');
$this->assertRaw('dotted.default');
$this->assertRaw('Test config entity 51');
}
......
......@@ -90,7 +90,7 @@ public function testExport() {
// Check the single export form doesn't have "form-required" elements.
$this->drupalGet('admin/config/development/configuration/single/export');
$this->assertNoRaw('js-form-required form-required');
$this->assertSession()->responseNotContains('js-form-required form-required');
// Ensure the temporary file is not available to users without the
// permission.
......
......@@ -128,11 +128,11 @@ public function testImport() {
// Import and verify that both do not appear anymore.
$this->submitForm([], 'Import all');
$this->assertNoRaw('<td>' . $name);
$this->assertNoRaw('<td>' . $dynamic_name);
$this->assertNoRaw('<td>core.extension');
$this->assertNoRaw('<td>system.theme');
$this->assertNoRaw('<td>automated_cron.settings');
$this->assertSession()->responseNotContains('<td>' . $name);
$this->assertSession()->responseNotContains('<td>' . $dynamic_name);
$this->assertSession()->responseNotContains('<td>core.extension');
$this->assertSession()->responseNotContains('<td>system.theme');
$this->assertSession()->responseNotContains('<td>automated_cron.settings');
$this->assertSession()->buttonNotExists('Import all');
......@@ -199,9 +199,9 @@ public function testImport() {
// Import and verify that both do not appear anymore.
$this->submitForm([], 'Import all');
$this->assertNoRaw('<td>core.extension');
$this->assertNoRaw('<td>system.theme');
$this->assertNoRaw('<td>automated_cron.settings');
$this->assertSession()->responseNotContains('<td>core.extension');
$this->assertSession()->responseNotContains('<td>system.theme');
$this->assertSession()->responseNotContains('<td>automated_cron.settings');
$this->rebuildContainer();
$this->assertFalse(\Drupal::moduleHandler()->moduleExists('ban'), 'Ban module uninstalled during import.');
......@@ -298,7 +298,7 @@ public function testImportDiff() {
// Load the diff UI and verify that the diff reflects the change.
$this->drupalGet('admin/config/development/configuration/sync/diff/' . $config_name);
$this->assertNoRaw('&amp;nbsp;');
$this->assertSession()->responseNotContains('&amp;nbsp;');
$this->assertSession()->titleEquals("View changes of $config_name | Drupal");
// The following assertions do not use
......
......@@ -682,7 +682,7 @@ public function testPluralConfigStringsSourceElements() {
$this->assertRaw('edit-source-config-names-viewsviewfiles-display-default-display-options-fields-count-format-plural-string-' . $index);
}
else {
$this->assertNoRaw('edit-source-config-names-viewsviewfiles-display-default-display-options-fields-count-format-plural-string-' . $index);
$this->assertSession()->responseNotContains('edit-source-config-names-viewsviewfiles-display-default-display-options-fields-count-format-plural-string-' . $index);
}
}
}
......
......@@ -116,7 +116,7 @@ public function testSendPersonalContactMessage() {
];
$this->assertRaw(new FormattableMarkup('@sender_name (@sender_email) sent @recipient_name an email.', $placeholders));
// Ensure an unescaped version of the email does not exist anywhere.
$this->assertNoRaw($this->webUser->getEmail());
$this->assertSession()->responseNotContains($this->webUser->getEmail());
// Test HTML mails.
$mail_config = $this->config('system.mail');
......
......@@ -46,7 +46,7 @@ public function testEnable() {
$this->drupalGet('admin/config/regional/content-language');
// The node entity type should not be an option because it has no bundles.
$this->assertNoRaw('entity_types[node]');
$this->assertSession()->responseNotContains('entity_types[node]');
// Enable content translation on entity types that have will have a
// content_translation_uid.
$edit = [
......
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