Commit bf5258ec authored by catch's avatar catch

Issue #2970831 by alexpott, martin107, catch, huascarmc, Mile23: Fix...

Issue #2970831 by alexpott, martin107, catch, huascarmc, Mile23: Fix "AssertLegacyTrait::getRawContent() is scheduled for removal in Drupal 9.0.0. Use $this->getSession()->getPage()->getContent() instead.

(cherry picked from commit bb7c0570)
parent 23c105cf
......@@ -60,7 +60,7 @@ public function testFeedLabelEscaping() {
$this->assertNoRaw('Test feed title <script>alert(123);</script>');
// Ensure the feed icon title is escaped.
$this->assertTrue(strpos(str_replace(["\n", "\r"], '', $this->getRawContent()), 'class="feed-icon"> Subscribe to Test feed title &lt;script&gt;alert(123);&lt;/script&gt; feed</a>') !== FALSE);
$this->assertTrue(strpos(str_replace(["\n", "\r"], '', $this->getSession()->getPage()->getContent()), 'class="feed-icon"> Subscribe to Test feed title &lt;script&gt;alert(123);&lt;/script&gt; feed</a>') !== FALSE);
}
/**
......
......@@ -296,7 +296,7 @@ public function testBigPipeMultiOccurrencePlaceholders() {
$this->assertRaw('The count is 1.');
$this->assertNoRaw('The count is 2.');
$this->assertNoRaw('The count is 3.');
$raw_content = $this->getRawContent();
$raw_content = $this->getSession()->getPage()->getContent();
$this->assertTrue(substr_count($raw_content, $expected_placeholder_replacement) == 1, 'Only one placeholder replacement was found for the duplicate #lazy_builder arrays.');
// By calling performMetaRefresh() here, we simulate JavaScript being
......@@ -357,7 +357,7 @@ protected function assertBigPipePlaceholders(array $expected_big_pipe_placeholde
// Verify expected placeholder.
$expected_placeholder_html = '<span data-big-pipe-placeholder-id="' . $big_pipe_placeholder_id . '"></span>';
$this->assertRaw($expected_placeholder_html, 'BigPipe placeholder for placeholder ID "' . $big_pipe_placeholder_id . '" found.');
$pos = strpos($this->getRawContent(), $expected_placeholder_html);
$pos = strpos($this->getSession()->getPage()->getContent(), $expected_placeholder_html);
$placeholder_positions[$pos] = $big_pipe_placeholder_id;
// Verify expected placeholder replacement.
$expected_placeholder_replacement = '<script type="application/vnd.drupal-ajax" data-big-pipe-replacement-for-placeholder-with-id="' . $big_pipe_placeholder_id . '">';
......@@ -369,7 +369,7 @@ protected function assertBigPipePlaceholders(array $expected_big_pipe_placeholde
}
$this->assertEqual($expected_ajax_response, trim($result[0]->getText()));
$this->assertRaw($expected_placeholder_replacement);
$pos = strpos($this->getRawContent(), $expected_placeholder_replacement);
$pos = strpos($this->getSession()->getPage()->getContent(), $expected_placeholder_replacement);
$placeholder_replacement_positions[$pos] = $big_pipe_placeholder_id;
}
ksort($placeholder_positions, SORT_NUMERIC);
......@@ -384,13 +384,13 @@ protected function assertBigPipePlaceholders(array $expected_big_pipe_placeholde
}
$this->assertEqual($expected_big_pipe_placeholders_with_replacements, array_filter($expected_big_pipe_placeholders));
$this->assertSetsEqual(array_keys($expected_big_pipe_placeholders_with_replacements), array_values($placeholder_replacement_positions));
$this->assertEqual(count($expected_big_pipe_placeholders_with_replacements), preg_match_all('/' . preg_quote('<script type="application/vnd.drupal-ajax" data-big-pipe-replacement-for-placeholder-with-id="', '/') . '/', $this->getRawContent()));
$this->assertEqual(count($expected_big_pipe_placeholders_with_replacements), preg_match_all('/' . preg_quote('<script type="application/vnd.drupal-ajax" data-big-pipe-replacement-for-placeholder-with-id="', '/') . '/', $this->getSession()->getPage()->getContent()));
$this->pass('Verifying BigPipe start/stop signals…', 'Debug');
$this->assertRaw(BigPipe::START_SIGNAL, 'BigPipe start signal present.');
$this->assertRaw(BigPipe::STOP_SIGNAL, 'BigPipe stop signal present.');
$start_signal_position = strpos($this->getRawContent(), BigPipe::START_SIGNAL);
$stop_signal_position = strpos($this->getRawContent(), BigPipe::STOP_SIGNAL);
$start_signal_position = strpos($this->getSession()->getPage()->getContent(), BigPipe::START_SIGNAL);
$stop_signal_position = strpos($this->getSession()->getPage()->getContent(), BigPipe::STOP_SIGNAL);
$this->assertTrue($start_signal_position < $stop_signal_position, 'BigPipe start signal appears before stop signal.');
$this->pass('Verifying BigPipe placeholder replacements and start/stop signals were streamed in the correct order…', 'Debug');
......
......@@ -63,7 +63,7 @@ public function testBlockRenderOrder() {
}
$this->drupalGet('');
$test_content = $this->getRawContent('');
$test_content = $this->getSession()->getPage()->getContent();
$controller = $this->container->get('entity_type.manager')->getStorage('block');
foreach ($controller->loadMultiple() as $return_block) {
......
......@@ -71,10 +71,10 @@ public function testRecentCommentBlock() {
$this->assertText($comments[$i]->getSubject(), new FormattableMarkup('Comment @number found in block.', ['@number' => 10 - $i]));
if ($i > 1) {
$previous_position = $position;
$position = strpos($this->getRawContent(), $comments[$i]->getSubject());
$position = strpos($this->getSession()->getPage()->getContent(), $comments[$i]->getSubject());
$this->assertTrue($position > $previous_position, new FormattableMarkup('Comment @a appears after comment @b', ['@a' => 10 - $i, '@b' => 11 - $i]));
}
$position = strpos($this->getRawContent(), $comments[$i]->getSubject());
$position = strpos($this->getSession()->getPage()->getContent(), $comments[$i]->getSubject());
}
// Test that links to comments work when comments are across pages.
......
......@@ -190,7 +190,7 @@ public function commentExists(CommentInterface $comment = NULL, $reply = FALSE)
$regex .= $comment->comment_body->value . '(.*?)';
$regex .= '/s';
return (boolean) preg_match($regex, $this->getRawContent());
return (boolean) preg_match($regex, $this->getSession()->getPage()->getContent());
}
else {
return FALSE;
......@@ -204,7 +204,7 @@ public function commentExists(CommentInterface $comment = NULL, $reply = FALSE)
* Contact info is available.
*/
public function commentContactInfoAvailable() {
return preg_match('/(input).*?(name="name").*?(input).*?(name="mail").*?(input).*?(name="homepage")/s', $this->getRawContent());
return preg_match('/(input).*?(name="name").*?(input).*?(name="mail").*?(input).*?(name="homepage")/s', $this->getSession()->getPage()->getContent());
}
/**
......@@ -243,7 +243,7 @@ public function performCommentOperation($comment, $operation, $approval = FALSE)
*/
public function getUnapprovedComment($subject) {
$this->drupalGet('admin/content/comment/approval');
preg_match('/href="(.*?)#comment-([^"]+)"(.*?)>(' . $subject . ')/', $this->getRawContent(), $match);
preg_match('/href="(.*?)#comment-([^"]+)"(.*?)>(' . $subject . ')/', $this->getSession()->getPage()->getContent(), $match);
return $match[2];
}
......
......@@ -336,7 +336,7 @@ public function setCommentSettings($name, $value, $message, $field_name = 'comme
* Contact info is available.
*/
public function commentContactInfoAvailable() {
return preg_match('/(input).*?(name="name").*?(input).*?(name="mail").*?(input).*?(name="homepage")/s', $this->getRawContent());
return preg_match('/(input).*?(name="name").*?(input).*?(name="mail").*?(input).*?(name="homepage")/s', $this->getSession()->getPage()->getContent());
}
/**
......@@ -375,7 +375,7 @@ public function performCommentOperation(CommentInterface $comment, $operation, $
*/
public function getUnapprovedComment($subject) {
$this->drupalGet('admin/content/comment/approval');
preg_match('/href="(.*?)#comment-([^"]+)"(.*?)>(' . $subject . ')/', $this->getRawContent(), $match);
preg_match('/href="(.*?)#comment-([^"]+)"(.*?)>(' . $subject . ')/', $this->getSession()->getPage()->getContent(), $match);
return $match[2];
}
......
......@@ -52,7 +52,7 @@ protected function setUp($import_test_views = TRUE) {
public function testCommentRestExport() {
$this->drupalGet(sprintf('node/%d/comments', $this->nodeUserCommented->id()), ['query' => ['_format' => 'hal_json']]);
$this->assertResponse(200);
$contents = Json::decode($this->getRawContent());
$contents = Json::decode($this->getSession()->getPage()->getContent());
$this->assertEqual($contents[0]['subject'], 'How much wood would a woodchuck chuck');
$this->assertEqual($contents[1]['subject'], 'A lot, apparently');
$this->assertEqual(count($contents), 2);
......
......@@ -134,7 +134,7 @@ public function testExportImport() {
// Export the configuration.
$this->drupalPostForm('admin/config/development/configuration/full/export', [], 'Export');
$this->tarball = $this->getRawContent();
$this->tarball = $this->getSession()->getPage()->getContent();
$this->config('system.site')
->set('slogan', $this->originalSlogan)
......@@ -224,7 +224,7 @@ public function testExportImportCollections() {
// Export the configuration.
$this->drupalPostForm('admin/config/development/configuration/full/export', [], 'Export');
$this->tarball = $this->getRawContent();
$this->tarball = $this->getSession()->getPage()->getContent();
$filename = file_directory_temp() . '/' . $this->randomMachineName();
file_put_contents($filename, $this->tarball);
......
......@@ -53,9 +53,10 @@ public function testNoEditorAvailable() {
$this->drupalGet('admin/config/content/formats/manage/filtered_html');
// Ensure the form field order is correct.
$roles_pos = strpos($this->getRawContent(), 'Roles');
$editor_pos = strpos($this->getRawContent(), 'Text editor');
$filters_pos = strpos($this->getRawContent(), 'Enabled filters');
$raw_content = $this->getSession()->getPage()->getContent();
$roles_pos = strpos($raw_content, 'Roles');
$editor_pos = strpos($raw_content, 'Text editor');
$filters_pos = strpos($raw_content, 'Enabled filters');
$this->assertTrue($roles_pos < $editor_pos && $editor_pos < $filters_pos, '"Text Editor" select appears in the correct location of the text format configuration UI.');
// Verify the <select>.
......
......@@ -282,7 +282,7 @@ protected function getThingsToCheck($field_name, $type = 'textarea') {
// Editor.module's JS settings present.
isset($settings['editor']),
// Editor.module's JS present.
strpos($this->getRawContent(), drupal_get_path('module', 'editor') . '/js/editor.js') !== FALSE,
strpos($this->getSession()->getPage()->getContent(), drupal_get_path('module', 'editor') . '/js/editor.js') !== FALSE,
// Body field.
$this->xpath('//' . $type . '[@id="edit-' . $field_name . '-0-value"]'),
// Format selector.
......
......@@ -110,7 +110,7 @@ public function testFileListingPages() {
$this->assertLinkByHref(file_create_url($file->getFileUri()));
$this->assertLinkByHref('admin/content/files/usage/' . $file->id());
}
$this->assertFalse(preg_match('/views-field-status priority-low\">\s*' . t('Temporary') . '/', $this->getRawContent()), 'All files are stored as permanent.');
$this->assertFalse(preg_match('/views-field-status priority-low\">\s*' . t('Temporary') . '/', $this->getSession()->getPage()->getContent()), 'All files are stored as permanent.');
// Use one file two times and check usage information.
$orphaned_file = $nodes[1]->file->target_id;
......
......@@ -639,7 +639,7 @@ public function testFieldapiField() {
$node->save();
$result = Json::decode($this->drupalGet('test/serialize/node-field', ['query' => ['_format' => 'json']]));
$this->assertEqual($result[1]['nid'], $node->id());
$this->assertTrue(strpos($this->getRawContent(), "<script") === FALSE, "No script tag is present in the raw page contents.");
$this->assertTrue(strpos($this->getSession()->getPage()->getContent(), "<script") === FALSE, "No script tag is present in the raw page contents.");
$this->drupalLogin($this->adminUser);
......
......@@ -397,7 +397,7 @@ protected function assertDefaultSearch($expected, $message = '', $group = 'Other
*/
protected function setDefaultThroughUi($entity_id) {
$this->drupalGet('admin/config/search/pages');
preg_match('|href="([^"]+' . $entity_id . '/set-default[^"]+)"|', $this->getRawContent(), $matches);
preg_match('|href="([^"]+' . $entity_id . '/set-default[^"]+)"|', $this->getSession()->getPage()->getContent(), $matches);
$this->drupalGet($this->getAbsoluteUrl($matches[1]));
}
......
......@@ -28,14 +28,14 @@ class RenderWebTest extends BrowserTestBase {
*/
public function testWrapperFormatCacheContext() {
$this->drupalGet('common-test/type-link-active-class');
$this->assertIdentical(0, strpos($this->getRawContent(), "<!DOCTYPE html>\n<html"));
$this->assertIdentical(0, strpos($this->getSession()->getPage()->getContent(), "<!DOCTYPE html>\n<html"));
$this->assertIdentical('text/html; charset=UTF-8', $this->drupalGetHeader('Content-Type'));
$this->assertTitle('Test active link class | Drupal');
$this->assertCacheContext('url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT);
$this->drupalGet('common-test/type-link-active-class', ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'json']]);
$this->assertIdentical('application/json', $this->drupalGetHeader('Content-Type'));
$json = Json::decode($this->getRawContent());
$json = Json::decode($this->getSession()->getPage()->getContent());
$this->assertEqual(['content', 'title'], array_keys($json));
$this->assertIdentical('Test active link class', $json['title']);
$this->assertCacheContext('url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT);
......
......@@ -426,7 +426,7 @@ public function testSelect() {
'multiple_no_default_required[]' => 'three',
];
$this->drupalPostForm(NULL, $edit, 'Submit');
$values = Json::decode($this->getRawContent());
$values = Json::decode($this->getSession()->getPage()->getContent());
// Verify expected values.
$expected = [
......
......@@ -83,7 +83,7 @@ public function testHiddenLanguageSelectElement() {
// field elements.
$edit = [];
$this->drupalPostForm(NULL, $edit, t('Submit'));
$values = Json::decode($this->getRawContent());
$values = Json::decode($this->getSession()->getPage()->getContent());
$this->assertEqual($values['languages_all'], 'xx');
$this->assertEqual($values['languages_configurable'], 'en');
$this->assertEqual($values['languages_locked'], LanguageInterface::LANGCODE_NOT_SPECIFIED);
......
......@@ -37,7 +37,7 @@ public function testShutdownFunctions() {
// If using PHP-FPM then fastcgi_finish_request() will have been fired
// returning the response before shutdown functions have fired.
// @see \Drupal\system_test\Controller\SystemTestController::shutdownFunctions()
$server_using_fastcgi = strpos($this->getRawContent(), 'The function fastcgi_finish_request exists when serving the request.');
$server_using_fastcgi = strpos($this->getSession()->getPage()->getContent(), 'The function fastcgi_finish_request exists when serving the request.');
if ($server_using_fastcgi) {
// We need to wait to ensure that the shutdown functions have fired.
sleep(1);
......
......@@ -63,7 +63,7 @@ public function testTwigUrlGenerator() {
$this->assertCacheContext('url.site');
// Make sure we got something.
$content = $this->getRawContent();
$content = $this->getSession()->getPage()->getContent();
$this->assertFalse(empty($content), 'Page content is not empty');
foreach ($expected as $string) {
$this->assertRaw('<div>' . $string . '</div>');
......@@ -97,7 +97,7 @@ public function testTwigLinkGenerator() {
// tests for *which* cacheability metadata is bubbled live elsewhere.)
$this->assertCacheContext('url.site');
$content = $this->getRawContent();
$content = $this->getSession()->getPage()->getContent();
$this->assertFalse(empty($content), 'Page content is not empty');
foreach ($expected as $string) {
$this->assertRaw('<div>' . $string . '</div>');
......@@ -116,7 +116,7 @@ public function testTwigUrlToString() {
'rendered url: ' . Url::fromRoute('user.register')->toString(),
];
$content = $this->getRawContent();
$content = $this->getSession()->getPage()->getContent();
$this->assertFalse(empty($content), 'Page content is not empty');
foreach ($expected as $string) {
$this->assertRaw('<div>' . $string . '</div>');
......
......@@ -107,7 +107,8 @@ public function testSpecificSuggestionsAlter() {
$this->resetAll();
$this->drupalGet('theme-test/specific-suggestion-alter');
$this->assertText('Template overridden based on suggestion alter hook determined by the base hook.');
$this->assertTrue(strpos($this->getRawContent(), 'theme_test_specific_suggestions__variant') < strpos($this->getRawContent(), 'theme_test_specific_suggestions__variant__foo'), 'Specific theme call is added to the suggestions array before the suggestions alter hook.');
$raw_content = $this->getSession()->getPage()->getContent();
$this->assertTrue(strpos($raw_content, 'theme_test_specific_suggestions__variant') < strpos($raw_content, 'theme_test_specific_suggestions__variant__foo'), 'Specific theme call is added to the suggestions array before the suggestions alter hook.');
}
/**
......
......@@ -59,7 +59,7 @@ public function testNegotiatorPriorities() {
*/
public function testThemeOnNonHtmlRequest() {
$this->drupalGet('theme-test/non-html');
$json = Json::decode($this->getRawContent());
$json = Json::decode($this->getSession()->getPage()->getContent());
$this->assertFalse($json['theme_initialized']);
}
......
......@@ -178,7 +178,7 @@ public function testUpdateContribOrder() {
// we're really testing that the project listings are in the right order.
$bbb_project_link = '<div class="project-update__title"><a href="http://example.com/project/bbb_update_test">BBB Update test</a>';
$ccc_project_link = '<div class="project-update__title"><a href="http://example.com/project/ccc_update_test">CCC Update test</a>';
$this->assertTrue(strpos($this->getRawContent(), $bbb_project_link) < strpos($this->getRawContent(), $ccc_project_link), "'BBB Update test' project is listed before the 'CCC Update test' project");
$this->assertTrue(strpos($this->getSession()->getPage()->getContent(), $bbb_project_link) < strpos($this->getSession()->getPage()->getContent(), $ccc_project_link), "'BBB Update test' project is listed before the 'CCC Update test' project");
}
/**
......
......@@ -27,7 +27,7 @@ public function testFormWrapper() {
$xpath = $this->cssSelect('.views-form form');
$this->assertIdentical(count($xpath), 1, 'There is one views form on the page.');
// Ensure we don't have nested form elements.
$result = (bool) preg_match('#<form[^>]*?>(?!/form).*<form#s', $this->getRawContent());
$result = (bool) preg_match('#<form[^>]*?>(?!/form).*<form#s', $this->getSession()->getPage()->getContent());
$this->assertFalse($result, 'The views form element is not nested.');
}
......
......@@ -57,7 +57,7 @@ public function testItemsPerPage() {
// appear in the expected order.
$this->assertUrl($view['page[path]']);
$this->assertText($view['page[title]']);
$content = $this->getRawContent();
$content = $this->getSession()->getPage()->getContent();
$this->assertText($node5->label());
$this->assertText($node4->label());
$this->assertText($node3->label());
......@@ -80,7 +80,7 @@ public function testItemsPerPage() {
$this->drupalPlaceBlock("views_block:{$view['id']}-block_1");
$this->drupalGet('user');
$content = $this->getRawContent();
$content = $this->getSession()->getPage()->getContent();
$this->assertText($node5->label());
$this->assertText($node4->label());
$this->assertText($node3->label());
......
......@@ -42,7 +42,7 @@ public function testSorting() {
// Make sure the view shows the nodes in the expected order.
$this->assertUrl($view1['page[path]']);
$this->assertText($view1['page[title]']);
$content = $this->getRawContent();
$content = $this->getSession()->getPage()->getContent();
$this->assertText($node1->label());
$this->assertText($node2->label());
$this->assertText($node3->label());
......@@ -67,7 +67,7 @@ public function testSorting() {
// Make sure the view shows the nodes in the expected order.
$this->assertUrl($view2['page[path]']);
$this->assertText($view2['page[title]']);
$content = $this->getRawContent();
$content = $this->getSession()->getPage()->getContent();
$this->assertText($node3->label());
$this->assertText($node2->label());
$this->assertText($node1->label());
......
......@@ -220,7 +220,7 @@ public function testTextAsserts() {
$this->assertText($sanitized);
// Test getRawContent().
$this->assertSame($this->getSession()->getPage()->getContent(), $this->getRawContent());
$this->assertSame($this->getSession()->getPage()->getContent(), $this->getSession()->getPage()->getContent());
}
/**
......
......@@ -113,7 +113,6 @@ public static function getSkippedDeprecations() {
'Using "null" for the value of node "options" of "Drupal\Core\Template\TwigNodeTrans" is deprecated since version 1.25 and will be removed in 2.0.',
'Using "null" for the value of node "plural" of "Drupal\Core\Template\TwigNodeTrans" is deprecated since version 1.25 and will be removed in 2.0.',
'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::getRawContent() is scheduled for removal in Drupal 9.0.0. Use $this->getSession()->getPage()->getContent() 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}".',
......
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