Unverified Commit 33700d01 authored by alexpott's avatar alexpott

Issue #3193163 by mondrake, longwave: Deprecate AssertLegacyTrait::verbose and remove its usage

parent 82c63a2a
......@@ -149,8 +149,14 @@ protected function assertMailPattern($field_name, $regex, $message = '', $group
*
* @param int $count
* Optional number of emails to output.
*
* @deprecated in drupal:9.2.0 and is removed from drupal:10.0.0. Use
* dump() instead.
*
* @see https://www.drupal.org/node/3197514
*/
protected function verboseEmail($count = 1) {
@trigger_error('AssertMailTrait::verboseEmail() is deprecated in drupal:9.2.0 and is removed from drupal:10.0.0. Use dump() instead. See https://www.drupal.org/node/3197514', E_USER_DEPRECATED);
$mails = $this->getMails();
for ($i = count($mails) - 1; $i >= count($mails) - $count && $i >= 0; $i--) {
$mail = $mails[$i];
......
......@@ -161,7 +161,6 @@ protected function doTestFilters($display_id) {
$executable = Views::getView('comment');
$build = $executable->preview($display_id);
$this->setRawContent($renderer->renderRoot($build));
$this->verbose($this->getRawContent());
// Assert the exposed filters on the admin page.
$this->assertField('subject');
......@@ -178,7 +177,6 @@ protected function doTestFilters($display_id) {
$executable->setExposedInput(['subject' => 'Anonymous']);
$build = $executable->preview($display_id);
$this->setRawContent($renderer->renderRoot($build));
$this->verbose($this->getRawContent());
$elements = $this->cssSelect('input[type="checkbox"]');
$this->assertCount(1, $elements, 'Only anonymous comment is visible.');
......@@ -189,7 +187,6 @@ protected function doTestFilters($display_id) {
$executable->setExposedInput(['subject' => 'My comment']);
$build = $executable->preview($display_id);
$this->setRawContent($renderer->renderRoot($build));
$this->verbose($this->getRawContent());
$elements = $this->cssSelect('input[type="checkbox"]');
$this->assertCount(1, $elements, 'Only admin comment is visible.');
......@@ -201,7 +198,6 @@ protected function doTestFilters($display_id) {
$executable->setExposedInput(['author_name' => 'barry']);
$build = $executable->preview($display_id);
$this->setRawContent($renderer->renderRoot($build));
$this->verbose($this->getRawContent());
$elements = $this->cssSelect('input[type="checkbox"]');
$this->assertCount(1, $elements, 'Only anonymous comment is visible.');
......@@ -213,7 +209,6 @@ protected function doTestFilters($display_id) {
$executable->setExposedInput(['author_name' => $this->adminUser->label()]);
$build = $executable->preview($display_id);
$this->setRawContent($renderer->renderRoot($build));
$this->verbose($this->getRawContent());
$elements = $this->cssSelect('input[type="checkbox"]');
$this->assertCount(1, $elements, 'Only admin comment is visible.');
......@@ -225,7 +220,6 @@ protected function doTestFilters($display_id) {
$executable->setExposedInput(['langcode' => '***LANGUAGE_site_default***']);
$build = $executable->preview($display_id);
$this->setRawContent($renderer->renderRoot($build));
$this->verbose($this->getRawContent());
$elements = $this->cssSelect('input[type="checkbox"]');
$this->assertCount(2, $elements, 'Both comments are visible.');
......@@ -260,7 +254,6 @@ protected function doTestFilters($display_id) {
$executable->setExposedInput(['langcode' => 'ur']);
$build = $executable->preview($display_id);
$this->setRawContent($renderer->renderRoot($build));
$this->verbose($this->getRawContent());
$elements = $this->cssSelect('input[type="checkbox"]');
$this->assertCount(2, $elements, 'Both comments are visible.');
......
......@@ -149,7 +149,6 @@ public function testUsername() {
$executable = Views::getView($view_id);
$build = $executable->preview();
$this->setRawContent($renderer->renderRoot($build));
$this->verbose($this->getRawContent());
$this->assertLink('My comment title');
$this->assertLink('Anonymous comment title');
......@@ -174,7 +173,6 @@ public function testUsername() {
$this->assertNoLink($this->adminUser->label());
// Note: External users aren't pointing to drupal user profiles.
$this->assertLink('barry (not verified)');
$this->verbose($this->getRawContent());
$this->assertLink('My comment title');
$this->assertLink('Anonymous comment title');
}
......
......@@ -106,7 +106,6 @@ public function testSeparatorTranslation() {
$display = EntityViewDisplay::collectRenderDisplay($entity, 'default');
$build = $display->build($entity);
$output = $this->container->get('renderer')->renderRoot($build);
$this->verbose($output);
$this->assertStringContainsString('UNTRANSLATED', (string) $output);
// Translate the separator.
......@@ -123,7 +122,6 @@ public function testSeparatorTranslation() {
$display = EntityViewDisplay::collectRenderDisplay($entity, 'default');
$build = $display->build($entity);
$output = $this->container->get('renderer')->renderRoot($build);
$this->verbose($output);
$this->assertStringContainsString('NL_TRANSLATED!', (string) $output);
}
......
......@@ -68,17 +68,14 @@ public function testCheckMarkupFilterSubset() {
$expected_filter_text_without_html_generators = "Text with evil content and a URL: https://www.drupal.org!";
$actual_filtered_text = check_markup($text, 'filtered_html', '', []);
$this->verbose("Actual:<pre>$actual_filtered_text</pre>Expected:<pre>$expected_filtered_text</pre>");
$this->assertEqual($expected_filtered_text, $actual_filtered_text, 'Expected filter result.');
$actual_filtered_text_without_html_generators = check_markup($text, 'filtered_html', '', [FilterInterface::TYPE_MARKUP_LANGUAGE]);
$this->verbose("Actual:<pre>$actual_filtered_text_without_html_generators</pre>Expected:<pre>$expected_filter_text_without_html_generators</pre>");
$this->assertEqual($expected_filter_text_without_html_generators, $actual_filtered_text_without_html_generators, 'Expected filter result when skipping FilterInterface::TYPE_MARKUP_LANGUAGE filters.');
// Related to @see FilterSecurityTest.php/testSkipSecurityFilters(), but
// this check focuses on the ability to filter multiple filter types at once.
// Drupal core only ships with these two types of filters, so this is the
// most extensive test possible.
$actual_filtered_text_without_html_generators = check_markup($text, 'filtered_html', '', [FilterInterface::TYPE_HTML_RESTRICTOR, FilterInterface::TYPE_MARKUP_LANGUAGE]);
$this->verbose("Actual:<pre>$actual_filtered_text_without_html_generators</pre>Expected:<pre>$expected_filter_text_without_html_generators</pre>");
$this->assertEqual($expected_filter_text_without_html_generators, $actual_filtered_text_without_html_generators, 'Expected filter result when skipping FilterInterface::TYPE_MARKUP_LANGUAGE filters, even when trying to disable filters of the FilterInterface::TYPE_HTML_RESTRICTOR type.');
}
......
......@@ -389,10 +389,7 @@ public function testLineBreakFilter() {
$limit = max(ini_get('pcre.backtrack_limit'), ini_get('pcre.recursion_limit'));
$source = $this->randomMachineName($limit);
$result = _filter_autop($source);
$success = $this->assertEqual($result, '<p>' . $source . "</p>\n", 'Line break filter can process very long strings.');
if (!$success) {
$this->verbose("\n" . $source . "\n<hr />\n" . $result);
}
$this->assertEqual($result, '<p>' . $source . "</p>\n", 'Line break filter can process very long strings.');
}
/**
......
......@@ -841,9 +841,7 @@ protected function renderTestEntity($id, $view_mode = 'full', $reset = TRUE) {
->getViewDisplay($entity->getEntityTypeId(), $entity->bundle(), $view_mode);
$content = $display->build($entity);
$output = \Drupal::service('renderer')->renderRoot($content);
$output = (string) $output;
$this->verbose($output);
return $output;
return (string) $output;
}
}
......@@ -33,9 +33,7 @@ protected function setUp(): void {
public function testLocaleUpdateDevelopmentRelease() {
$projects = locale_translation_build_projects();
$this->verbose($projects['drupal']->info['version']);
$this->assertEqual('8.0.x', $projects['drupal']->info['version'], 'The branch of the core dev release.');
$this->verbose($projects['contrib']->info['version']);
$this->assertEqual('12.x-10.x', $projects['contrib']->info['version'], 'The branch of the contrib module dev release.');
}
......
......@@ -173,8 +173,6 @@ public function testSearchExcerptSimplified() {
$text = str_repeat($lorem3, 20) . ' ' . $lorem1;
$result = $this->doSearchExcerpt('Lìbêró', $text);
$this->assertStringContainsString('<strong>libero</strong>', $result, 'Search excerpt works with caps and accents in longer text with whitespace');
$this->verbose('Elapsed time: ' . (microtime(TRUE) - $start_time));
}
/**
......
......@@ -58,11 +58,6 @@ protected function assertHtmlToText($html, $text, $message, $allowed_tags = NULL
$message .= ' (' . $tested_tags . ')';
$result = MailFormatHelper::htmlToText($html, $allowed_tags);
$this->assertEqual($text, $result, Html::escape($message));
$verbose = 'html = <pre>' . $this->stringToHtml($html)
. '</pre><br />result = <pre>' . $this->stringToHtml($result)
. '</pre><br />expected = <pre>' . $this->stringToHtml($text)
. '</pre>';
$this->verbose($verbose);
}
/**
......@@ -239,25 +234,11 @@ public function testDrupalHtmlToTextBlockTagToNewline() {
EOT;
$input = str_replace(["\r", "\n"], '', $input);
$output = MailFormatHelper::htmlToText($input);
$pass = $this->assertNotRegExp('/\][^\n]*\[/s', $output, 'Block-level HTML tags should force newlines');
if (!$pass) {
$this->verbose($this->stringToHtml($output));
}
$this->assertNotRegExp('/\][^\n]*\[/s', $output, 'Block-level HTML tags should force newlines');
$output_upper = mb_strtoupper($output);
$upper_input = mb_strtoupper($input);
$upper_output = MailFormatHelper::htmlToText($upper_input);
$pass = $this->assertEqual(
$upper_output,
$output_upper,
'Tag recognition should be case-insensitive'
);
if (!$pass) {
$this->verbose(
$upper_output
. '<br />should be equal to <br />'
. $output_upper
);
}
$this->assertEquals($output_upper, $upper_output, 'Tag recognition should be case-insensitive');
}
/**
......
......@@ -351,7 +351,6 @@ public function testTrackerOrderingNewComments() {
// on the tracker page.
// It's almost certainly too brittle.
$pattern = '/' . preg_quote($node_one->getTitle()) . '.+' . preg_quote($node_two->getTitle()) . '/s';
$this->verbose($pattern);
// Verify that the most recent comment on node appears at the top of
// tracker.
$this->assertSession()->responseMatches($pattern);
......
......@@ -126,12 +126,6 @@ protected function assertIdenticalResultsetHelper($view, $expected_result, $colu
$expected_result[$key] = $row;
}
$this->verbose('<pre style="white-space: pre-wrap;">'
. "\n\nQuery:\n" . $view->build_info['query']
. "\n\nQuery arguments:\n" . var_export($view->build_info['query']->getArguments(), TRUE)
. "\n\nActual result:\n" . var_export($result, TRUE)
. "\n\nExpected result:\n" . var_export($expected_result, TRUE));
// Reset the numbering of the arrays.
$result = array_values($result);
$expected_result = array_values($expected_result);
......
......@@ -4,7 +4,6 @@
use Behat\Mink\Exception\ElementNotFoundException;
use Drupal\Core\Database\Database;
use Drupal\Core\Database\Query\SelectInterface;
use Drupal\Tests\BrowserTestBase;
use Drupal\views\Tests\ViewResultAssertionTrait;
use Drupal\views\Tests\ViewTestData;
......@@ -114,7 +113,7 @@ protected function helperButtonHasLabel($id, $expected_label, $message = 'Label
}
/**
* Executes a view with debugging.
* Executes a view.
*
* @param \Drupal\views\ViewExecutable $view
* The view object.
......@@ -127,11 +126,6 @@ protected function executeView(ViewExecutable $view, $args = []) {
$view->setDisplay();
$view->preExecute($args);
$view->execute();
$verbose_message = '<pre>Executed view: ' . ((string) $view->build_info['query']) . '</pre>';
if ($view->build_info['query'] instanceof SelectInterface) {
$verbose_message .= '<pre>Arguments: ' . print_r($view->build_info['query']->getArguments(), TRUE) . '</pre>';
}
$this->verbose($verbose_message);
}
/**
......
......@@ -3,7 +3,6 @@
namespace Drupal\Tests\views\Kernel;
use Drupal\Core\Database\Database;
use Drupal\Core\Database\Query\SelectInterface;
use Drupal\KernelTests\KernelTestBase;
use Drupal\views\Tests\ViewResultAssertionTrait;
use Drupal\views\Tests\ViewTestData;
......@@ -118,7 +117,7 @@ protected function orderResultSet($result_set, $column, $reverse = FALSE) {
}
/**
* Executes a view with debugging.
* Executes a view.
*
* @param \Drupal\views\ViewExecutable $view
* The view object.
......@@ -129,11 +128,6 @@ protected function executeView($view, array $args = []) {
$view->setDisplay();
$view->preExecute($args);
$view->execute();
$verbose_message = '<pre>Executed view: ' . ((string) $view->build_info['query']) . '</pre>';
if ($view->build_info['query'] instanceof SelectInterface) {
$verbose_message .= '<pre>Arguments: ' . print_r($view->build_info['query']->getArguments(), TRUE) . '</pre>';
}
$this->verbose($verbose_message);
}
/**
......
......@@ -885,11 +885,6 @@ protected function assertThemeOutput($callback, array $variables = [], $expected
$output = (string) $renderer->executeInRenderContext(new RenderContext(), function () use ($callback, $variables) {
return \Drupal::theme()->render($callback, $variables);
});
$this->verbose(
'<hr />' . 'Result:' . '<pre>' . Html::escape(var_export($output, TRUE)) . '</pre>'
. '<hr />' . 'Expected:' . '<pre>' . Html::escape(var_export($expected, TRUE)) . '</pre>'
. '<hr />' . $output
);
if (!$message) {
$message = '%callback rendered correctly.';
}
......
......@@ -113,8 +113,14 @@ protected function pass($message) {
/**
* @see \Drupal\simpletest\TestBase::verbose()
*
* @deprecated in drupal:9.2.0 and is removed from drupal:10.0.0. Use
* dump() instead.
*
* @see https://www.drupal.org/node/3197514
*/
protected function verbose($message) {
@trigger_error('AssertLegacyTrait::verbose() is deprecated in drupal:9.2.0 and is removed from drupal:10.0.0. Use dump() instead. See https://www.drupal.org/node/3197514', E_USER_DEPRECATED);
if (in_array('--debug', $_SERVER['argv'], TRUE)) {
// Write directly to STDOUT to not produce unexpected test output.
// The STDOUT stream does not obey output buffering.
......
......@@ -271,7 +271,6 @@ public function testDataTypes() {
$name = 'config_test.types';
$config = $this->config($name);
$original_content = file_get_contents(drupal_get_path('module', 'config_test') . '/' . InstallStorage::CONFIG_INSTALL_DIRECTORY . "/$name.yml");
$this->verbose('<pre>' . $original_content . "\n" . var_export($storage->read($name), TRUE));
// Verify variable data types are intact.
$data = [
......@@ -297,7 +296,6 @@ public function testDataTypes() {
$this->assertSame($data, $config->get());
// Assert the data against the file storage.
$this->assertSame($data, $storage->read($name));
$this->verbose('<pre>' . $name . var_export($storage->read($name), TRUE));
// Set data using config::setData().
$config->setData($data)->save();
......
......@@ -37,13 +37,6 @@ protected function setUp(): void {
*/
protected function assertElements(array $elements, $expected_html, $message) {
$actual_html = (string) \Drupal::service('renderer')->renderRoot($elements);
$out = '<table><tr>';
$out .= '<td valign="top"><pre>' . Html::escape($expected_html) . '</pre></td>';
$out .= '<td valign="top"><pre>' . Html::escape($actual_html) . '</pre></td>';
$out .= '</tr></table>';
$this->verbose($out);
$this->assertSame($expected_html, $actual_html, Html::escape($message));
}
......
......@@ -2,7 +2,6 @@
namespace Drupal\KernelTests\Core\Render\Element;
use Drupal\Component\Utility\Html;
use Drupal\Core\Utility\TableSort;
use Drupal\KernelTests\KernelTestBase;
use Symfony\Component\HttpFoundation\Request;
......@@ -34,7 +33,6 @@ public function testTableSortInit() {
$request->query->replace([]);
\Drupal::getContainer()->get('request_stack')->push($request);
$ts = TableSort::getContextFromRequest($headers, $request);
$this->verbose(strtr('$ts: <pre>!ts</pre>', ['!ts' => Html::escape(var_export($ts, TRUE))]));
$this->assertEqual($expected_ts, $ts, 'Simple table headers sorted correctly.');
// Test with simple table headers plus $_GET parameters that should _not_
......@@ -47,7 +45,6 @@ public function testTableSortInit() {
]);
\Drupal::getContainer()->get('request_stack')->push($request);
$ts = TableSort::getContextFromRequest($headers, $request);
$this->verbose(strtr('$ts: <pre>!ts</pre>', ['!ts' => Html::escape(var_export($ts, TRUE))]));
$this->assertEqual($expected_ts, $ts, 'Simple table headers plus non-overriding $_GET parameters sorted correctly.');
// Test with simple table headers plus $_GET parameters that _should_
......@@ -63,7 +60,6 @@ public function testTableSortInit() {
$expected_ts['sort'] = 'desc';
$expected_ts['query'] = ['alpha' => 'beta'];
$ts = TableSort::getContextFromRequest($headers, $request);
$this->verbose(strtr('$ts: <pre>!ts</pre>', ['!ts' => Html::escape(var_export($ts, TRUE))]));
$this->assertEqual($expected_ts, $ts, 'Simple table headers plus $_GET parameters sorted correctly.');
// Test complex table headers.
......@@ -95,7 +91,6 @@ public function testTableSortInit() {
'sort' => 'desc',
'query' => [],
];
$this->verbose(strtr('$ts: <pre>!ts</pre>', ['!ts' => Html::escape(var_export($ts, TRUE))]));
$this->assertEqual($expected_ts, $ts, 'Complex table headers sorted correctly.');
// Test complex table headers plus $_GET parameters that should _not_
......@@ -114,7 +109,6 @@ public function testTableSortInit() {
'sort' => 'asc',
'query' => [],
];
$this->verbose(strtr('$ts: <pre>!ts</pre>', ['!ts' => Html::escape(var_export($ts, TRUE))]));
$this->assertEqual($expected_ts, $ts, 'Complex table headers plus non-overriding $_GET parameters sorted correctly.');
// Test complex table headers plus $_GET parameters that _should_
......@@ -135,7 +129,6 @@ public function testTableSortInit() {
'query' => ['alpha' => 'beta'],
];
$ts = TableSort::getContextFromRequest($headers, $request);
$this->verbose(strtr('$ts: <pre>!ts</pre>', ['!ts' => Html::escape(var_export($ts, TRUE))]));
$this->assertEquals($expected_ts, $ts, 'Complex table headers plus $_GET parameters sorted correctly.');
// Test the initial_click_sort parameter.
......@@ -174,14 +167,12 @@ public function testTableSortInit() {
]);
\Drupal::getContainer()->get('request_stack')->push($request);
$ts = TableSort::getContextFromRequest($headers, $request);
$this->verbose(strtr('$ts: <pre>!ts</pre>', ['!ts' => Html::escape(var_export($ts, TRUE))]));
$expected_ts = [
'name' => '1',
'sql' => 'one',
'sort' => 'desc',
'query' => [],
];
$this->verbose(strtr('$ts: <pre>!ts</pre>', ['!ts' => Html::escape(var_export($ts, TRUE))]));
$this->assertEquals($expected_ts, $ts, 'Complex table headers using the initial_click_sort parameter are sorted correctly.');
// Test that if the initial_click_sort parameter is not defined, the default
......@@ -198,7 +189,6 @@ public function testTableSortInit() {
'sort' => 'asc',
'query' => [],
];
$this->verbose(strtr('$ts: <pre>!ts</pre>', ['!ts' => Html::escape(var_export($ts, TRUE))]));
$this->assertEquals($expected_ts, $ts, 'Complex table headers without using the initial_click_sort parameter are sorted correctly.');
// Test that if the initial_click_sort parameter is defined, and the sort
......@@ -215,7 +205,6 @@ public function testTableSortInit() {
'sort' => 'asc',
'query' => [],
];
$this->verbose(strtr('$ts: <pre>!ts</pre>', ['!ts' => Html::escape(var_export($ts, TRUE))]));
$this->assertEquals($expected_ts, $ts, 'Complex table headers using the initial_click_sort and sort parameters are sorted correctly.');
// Test that if the initial_click_sort parameter is defined and the value
......@@ -232,7 +221,6 @@ public function testTableSortInit() {
'sort' => 'asc',
'query' => [],
];
$this->verbose(strtr('$ts: <pre>!ts</pre>', ['!ts' => Html::escape(var_export($ts, TRUE))]));
$this->assertEquals($expected_ts, $ts, 'Complex table headers with the initial_click_sort set as ASC are sorted correctly.');
// Tests that if the initial_click_sort is defined with a non expected value
......@@ -249,7 +237,6 @@ public function testTableSortInit() {
'sort' => 'foo',
'query' => [],
];
$this->verbose(strtr('$ts: <pre>!ts</pre>', ['!ts' => Html::escape(var_export($ts, TRUE))]));
$this->assertEquals($expected_ts, $ts, 'Complex table headers with the initial_click_sort set as foo are sorted correctly.');
}
......
......@@ -5,7 +5,6 @@
use Drupal\Component\FileCache\ApcuFileCacheBackend;
use Drupal\Component\FileCache\FileCache;
use Drupal\Component\FileCache\FileCacheFactory;
use Drupal\Component\Utility\Html;
use Drupal\Core\Config\Development\ConfigSchemaChecker;
use Drupal\Core\Database\Database;
use Drupal\Core\DependencyInjection\ContainerBuilder;
......@@ -901,7 +900,6 @@ protected function render(array &$elements) {
// Glean the content from the response object.
$content = $response->getContent();
$this->setRawContent($content);
$this->verbose('<pre style="white-space: pre-wrap">' . Html::escape($content));
return $content;
}
......
......@@ -386,6 +386,16 @@ public function testAssertNotIdentical() {
$this->assertNotIdentical('foo', 'bar');
}
/**
* Tests the deprecation of AssertLegacyTrait::verbose().
*
* @group legacy
*/
public function testVerbose() {
$this->expectDeprecation('AssertLegacyTrait::verbose() is deprecated in drupal:9.2.0 and is removed from drupal:10.0.0. Use dump() instead. See https://www.drupal.org/node/3197514');
$this->verbose('The show must go on');
}
/**
* Tests the deprecation of ::installSchema with the tables key_value(_expire).
*
......
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