Commit 2f1345a9 authored by alexpott's avatar alexpott
Browse files

Issue #2421699 by JeroenT: Remove usage of deprecated functions of WebTestBase

parent 374a5bdc
......@@ -68,7 +68,7 @@ function testBlockRenderOrder() {
}
$this->drupalGet('');
$test_content = $this->drupalGetContent('');
$test_content = $this->getRawContent('');
$controller = $this->container->get('entity.manager')->getStorage('block');
foreach ($controller->loadMultiple() as $return_block) {
......
......@@ -74,10 +74,10 @@ function testRecentCommentBlock() {
$this->assertText($comments[$i]->getSubject(), String::format('Comment @number found in block.', array('@number' => 10 - $i)));
if ($i > 1) {
$previous_position = $position;
$position = strpos($this->drupalGetContent(), $comments[$i]->getSubject());
$position = strpos($this->getRawContent(), $comments[$i]->getSubject());
$this->assertTrue($position > $previous_position, String::format('Comment @a appears after comment @b', array('@a' => 10 - $i, '@b' => 11 - $i)));
}
$position = strpos($this->drupalGetContent(), $comments[$i]->getSubject());
$position = strpos($this->getRawContent(), $comments[$i]->getSubject());
}
// Test that links to comments work when comments are across pages.
......
......@@ -186,7 +186,7 @@ function commentExists(CommentInterface $comment = NULL, $reply = FALSE) {
$regex .= $comment->comment_body->value . '(.*?)';
$regex .= '/s';
return (boolean) preg_match($regex, $this->drupalGetContent());
return (boolean) preg_match($regex, $this->getRawContent());
}
else {
return FALSE;
......@@ -200,7 +200,7 @@ function commentExists(CommentInterface $comment = NULL, $reply = FALSE) {
* Contact info is available.
*/
function commentContactInfoAvailable() {
return preg_match('/(input).*?(name="name").*?(input).*?(name="mail").*?(input).*?(name="homepage")/s', $this->drupalGetContent());
return preg_match('/(input).*?(name="name").*?(input).*?(name="mail").*?(input).*?(name="homepage")/s', $this->getRawContent());
}
/**
......@@ -239,7 +239,7 @@ function performCommentOperation($comment, $operation, $approval = FALSE) {
*/
function getUnapprovedComment($subject) {
$this->drupalGet('admin/content/comment/approval');
preg_match('/href="(.*?)#comment-([^"]+)"(.*?)>(' . $subject . ')/', $this->drupalGetContent(), $match);
preg_match('/href="(.*?)#comment-([^"]+)"(.*?)>(' . $subject . ')/', $this->getRawContent(), $match);
return $match[2];
}
......
......@@ -193,7 +193,7 @@ function commentExists(CommentInterface $comment = NULL, $reply = FALSE) {
$regex .= ($reply ? '</article>\s</div>(.*?)' : '');
$regex .= '!s';
return (boolean) preg_match($regex, $this->drupalGetContent());
return (boolean) preg_match($regex, $this->getRawContent());
}
else {
return FALSE;
......@@ -326,7 +326,7 @@ public function setCommentSettings($name, $value, $message, $field_name = 'comme
* Contact info is available.
*/
function commentContactInfoAvailable() {
return preg_match('/(input).*?(name="name").*?(input).*?(name="mail").*?(input).*?(name="homepage")/s', $this->drupalGetContent());
return preg_match('/(input).*?(name="name").*?(input).*?(name="mail").*?(input).*?(name="homepage")/s', $this->getRawContent());
}
/**
......@@ -365,7 +365,7 @@ function performCommentOperation(CommentInterface $comment, $operation, $approva
*/
function getUnapprovedComment($subject) {
$this->drupalGet('admin/content/comment/approval');
preg_match('/href="(.*?)#comment-([^"]+)"(.*?)>(' . $subject . ')/', $this->drupalGetContent(), $match);
preg_match('/href="(.*?)#comment-([^"]+)"(.*?)>(' . $subject . ')/', $this->getRawContent(), $match);
return $match[2];
}
......
......@@ -127,7 +127,7 @@ public function testExportImport() {
// Export the configuration.
$this->drupalPostForm('admin/config/development/configuration/full/export', array(), 'Export');
$this->tarball = $this->drupalGetContent();
$this->tarball = $this->getRawContent();
$this->config('system.site')
->set('slogan', $this->originalSlogan)
......@@ -184,7 +184,7 @@ public function testExportImportCollections() {
// Export the configuration.
$this->drupalPostForm('admin/config/development/configuration/full/export', array(), 'Export');
$this->tarball = $this->drupalGetContent();
$this->tarball = $this->getRawContent();
$filename = file_directory_temp() .'/' . $this->randomMachineName();
file_put_contents($filename, $this->tarball);
......
......@@ -47,7 +47,7 @@ function testExport() {
$this->assertResponse(200, 'User can access the download callback.');
// Get the archived binary file provided to user for download.
$archive_data = $this->drupalGetContent();
$archive_data = $this->getRawContent();
// Temporarily save the archive file.
$uri = file_unmanaged_save_data($archive_data, 'temporary://config.tar.gz');
......
......@@ -131,7 +131,7 @@ public function testContentTranslationContextualLinks() {
$response = $this->renderContextualLinks(array('node:node=1:'), 'node/' . $node->id());
$this->assertResponse(200);
$json = Json::decode($response);
$this->drupalSetContent($json['node:node=1:']);
$this->setRawContent($json['node:node=1:']);
$this->assertLinkByHref($translate_link, 0, 'The contextual link to translate the node is shown.');
// Check that the link leads to the translate page.
......
......@@ -491,7 +491,7 @@ protected function renderTestEntity($id, $view_mode = 'full', $reset = TRUE) {
$display = EntityViewDisplay::collectRenderDisplay($entity, $view_mode);
$build = $display->build($entity);
$output = drupal_render($build);
$this->drupalSetContent($output);
$this->setRawContent($output);
$this->verbose($output);
}
......
......@@ -54,9 +54,9 @@ public function testNoEditorAvailable() {
$this->drupalGet('admin/config/content/formats/manage/filtered_html');
// Ensure the form field order is correct.
$roles_pos = strpos($this->drupalGetContent(), 'Roles');
$editor_pos = strpos($this->drupalGetContent(), 'Text editor');
$filters_pos = strpos($this->drupalGetContent(), 'Enabled filters');
$roles_pos = strpos($this->getRawContent(), 'Roles');
$editor_pos = strpos($this->getRawContent(), 'Text editor');
$filters_pos = strpos($this->getRawContent(), '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>.
......
......@@ -115,7 +115,7 @@ function testBooleanField() {
$entity = entity_load('entity_test', $id);
$display = entity_get_display($entity->getEntityTypeId(), $entity->bundle(), 'full');
$content = $display->build($entity);
$this->drupalSetContent(drupal_render($content));
$this->setRawContent(drupal_render($content));
$this->assertRaw('<div class="field-item">' . $on . '</div>');
// Test the display_label option.
......
......@@ -103,7 +103,7 @@ function testEmailField() {
$entity = entity_load('entity_test', $id);
$display = entity_get_display($entity->getEntityTypeId(), $entity->bundle(), 'full');
$content = $display->build($entity);
$this->drupalSetContent(drupal_render($content));
$this->setRawContent(drupal_render($content));
$this->assertLinkByHref('mailto:test@example.com');
}
......
......@@ -97,7 +97,7 @@ function _testTextfieldWidgets($field_type, $widget_type) {
$entity = entity_load('entity_test', $id);
$display = entity_get_display($entity->getEntityTypeId(), $entity->bundle(), 'full');
$content = $display->build($entity);
$this->drupalSetContent(drupal_render($content));
$this->setRawContent(drupal_render($content));
$this->assertText($value, 'Filtered tags are not displayed');
}
}
......@@ -447,7 +447,7 @@ function assertNodeViewTextHelper(EntityInterface $node, $view_mode, $text, $mes
\Drupal::entityManager()->clearCachedFieldDefinitions();
// Save current content so that we can restore it when we're done.
$old_content = $this->drupalGetContent();
$old_content = $this->getRawContent();
// Render a cloned node, so that we do not alter the original.
$clone = clone $node;
......@@ -456,12 +456,12 @@ function assertNodeViewTextHelper(EntityInterface $node, $view_mode, $text, $mes
$this->verbose(t('Rendered node - view mode: @view_mode', array('@view_mode' => $view_mode)) . '<hr />'. $output);
// Assign content so that WebTestBase functions can be used.
$this->drupalSetContent($output);
$this->setRawContent($output);
$method = ($not_exists ? 'assertNoText' : 'assertText');
$return = $this->{$method}((string) $text, $message);
// Restore previous content.
$this->drupalSetContent($old_content);
$this->setRawContent($old_content);
return $return;
}
......
......@@ -101,7 +101,7 @@ 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->drupalGetContent()), 'All files are stored as permanent.');
$this->assertFalse(preg_match('/views-field-status priority-low\">\s*' . t('Temporary') . '/', $this->getRawContent()), 'All files are stored as permanent.');
// Use one file two times and check usage information.
$orphaned_file = $nodes[1]->file->target_id;
......
......@@ -70,7 +70,7 @@ public function testHandlers() {
$this->executeView($view);
$this->assertEqual(count($view->result), 2);
$output = $view->preview();
$this->drupalSetContent(drupal_render($output));
$this->setRawContent(drupal_render($output));
$result = $this->xpath('//span[@class=:class]', array(':class' => 'marker'));
$this->assertEqual(count($result), 1, 'Just one node is marked as new');
......
......@@ -92,7 +92,7 @@ function testImageFormatterTheme() {
// Test using theme_image_formatter() with a NULL value for the alt option.
$element = $base_element;
$this->drupalSetContent(drupal_render($element));
$this->setRawContent(drupal_render($element));
$elements = $this->xpath('//a[@href=:path]/img[@class="image-style-test" and @src=:url and @width=:width and @height=:height]', array(':path' => base_path() . $path, ':url' => $url, ':width' => $image->getWidth(), ':height' => $image->getHeight()));
$this->assertEqual(count($elements), 1, 'theme_image_formatter() correctly renders with a NULL value for the alt option.');
......@@ -100,7 +100,7 @@ function testImageFormatterTheme() {
// link options.
$element = $base_element;
$element['#item']->alt = '';
$this->drupalSetContent(drupal_render($element));
$this->setRawContent(drupal_render($element));
$elements = $this->xpath('//a[@href=:path]/img[@class="image-style-test" and @src=:url and @width=:width and @height=:height and @alt=""]', array(':path' => base_path() . $path, ':url' => $url, ':width' => $image->getWidth(), ':height' => $image->getHeight()));
$this->assertEqual(count($elements), 1, 'theme_image_formatter() correctly renders without title, alt, or path options.');
......@@ -108,7 +108,7 @@ function testImageFormatterTheme() {
$fragment = $this->randomMachineName();
$element = $base_element;
$element['#url'] = Url::fromRoute('<none>', [], ['fragment' => $fragment]);
$this->drupalSetContent(drupal_render($element));
$this->setRawContent(drupal_render($element));
$elements = $this->xpath('//a[@href=:fragment]/img[@class="image-style-test" and @src=:url and @width=:width and @height=:height and @alt=""]', array(
':fragment' => '#' . $fragment,
':url' => $url,
......@@ -140,14 +140,14 @@ function testImageStyleTheme() {
);
$element = $base_element;
$this->drupalSetContent(drupal_render($element));
$this->setRawContent(drupal_render($element));
$elements = $this->xpath('//img[@class="image-style-image-test" and @src=:url and @alt=""]', array(':url' => $url));
$this->assertEqual(count($elements), 1, 'theme_image_style() renders an image correctly.');
// Test using theme_image_style() with a NULL value for the alt option.
$element = $base_element;
$element['#alt'] = NULL;
$this->drupalSetContent(drupal_render($element));
$this->setRawContent(drupal_render($element));
$elements = $this->xpath('//img[@class="image-style-image-test" and @src=:url]', array(':url' => $url));
$this->assertEqual(count($elements), 1, 'theme_image_style() renders an image correctly with a NULL value for the alt option.');
}
......@@ -167,7 +167,7 @@ function testImageAltFunctionality() {
'#attributes' => array('class' => 'image-with-regular-alt', 'id' => 'my-img'),
);
$this->drupalSetContent(drupal_render($image_with_alt_property));
$this->setRawContent(drupal_render($image_with_alt_property));
$elements = $this->xpath('//img[contains(@class, class) and contains(@alt, :alt)]', array(":class" => "image-with-regular-alt", ":alt" => "Regular alt"));
$this->assertEqual(count($elements), 1, 'Regular alt displays correctly');
......@@ -185,7 +185,7 @@ function testImageAltFunctionality() {
),
);
$this->drupalSetContent(drupal_render($image_with_alt_attribute_alt_attribute));
$this->setRawContent(drupal_render($image_with_alt_attribute_alt_attribute));
$elements = $this->xpath('//img[contains(@class, class) and contains(@alt, :alt)]', array(":class" => "image-with-attribute-alt", ":alt" => "Attribute alt"));
$this->assertEqual(count($elements), 1, 'Attribute alt displays correctly');
......@@ -204,7 +204,7 @@ function testImageAltFunctionality() {
),
);
$this->drupalSetContent(drupal_render($image_with_alt_attribute_both));
$this->setRawContent(drupal_render($image_with_alt_attribute_both));
$elements = $this->xpath('//img[contains(@class, class) and contains(@alt, :alt)]', array(":class" => "image-with-attribute-alt", ":alt" => "Attribute alt"));
$this->assertEqual(count($elements), 1, 'Attribute alt overrides alt property if both set.');
}
......
......@@ -583,7 +583,7 @@ protected function renderTestEntity($id, $view_mode = 'full', $reset = TRUE) {
$display = entity_get_display($entity->getEntityTypeId(), $entity->bundle(), $view_mode);
$content = $display->build($entity);
$output = drupal_render($content);
$this->drupalSetContent($output);
$this->setRawContent($output);
$this->verbose($output);
}
......
......@@ -30,7 +30,7 @@ public function testSummaryLength() {
// Render the node as a teaser.
$content = $this->drupalBuildEntityView($node, 'teaser');
$this->assertTrue(strlen($content['body'][0]['#markup']) < 600, 'Teaser is less than 600 characters long.');
$this->drupalSetContent(drupal_render($content));
$this->setRawContent(drupal_render($content));
// The string 'What is a Drupalism?' is between the 200th and 600th
// characters of the node body, so it should be included if the summary is
// 600 characters long.
......@@ -48,7 +48,7 @@ public function testSummaryLength() {
// 200 characters in length and so does not include 'What is a Drupalism?'.
$content = $this->drupalBuildEntityView($node, 'teaser');
$this->assertTrue(strlen($content['body'][0]['#markup']) < 200, 'Teaser is less than 200 characters long.');
$this->drupalSetContent(drupal_render($content));
$this->setRawContent(drupal_render($content));
$this->assertText($node->label());
$this->assertNoRaw($expected);
}
......
......@@ -45,7 +45,7 @@ public function testNodeContextualLinks() {
$response = $this->renderContextualLinks(array('node:node=1:'), 'node');
$this->assertResponse(200);
$json = Json::decode($response);
$this->drupalSetContent($json['node:node=1:']);
$this->setRawContent($json['node:node=1:']);
// @todo Add these back when the functionality for making Views displays
// appear in contextual links is working again.
......
......@@ -164,7 +164,7 @@ public function testAutocompleteQuickEdit() {
$response = $this->drupalPost($quickedit_uri, 'application/vnd.drupal-ajax', $post);
$this->assertResponse(200);
$ajax_commands = Json::decode($response);
$this->drupalSetContent($ajax_commands[0]['data']);
$this->setRawContent($ajax_commands[0]['data']);
$this->assertLink($this->term1->getName());
$this->assertLink($this->term2->getName());
$this->assertText('new term');
......@@ -180,7 +180,7 @@ public function testAutocompleteQuickEdit() {
// the form to edit the taxonomy term field, it should contain all three
// taxonomy terms, including the one that has just been newly created and
// which is not yet stored.
$this->drupalSetContent($ajax_commands[0]['data']);
$this->setRawContent($ajax_commands[0]['data']);
$this->assertFieldByName($this->fieldName, implode(', ', array($this->term1->getName(), 'new term', $this->term2->label())));
// Save the entity.
......
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