Skip to content
Snippets Groups Projects
Unverified Commit 9dc42330 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3135077 by mondrake, sja112, daffie, longwave, xjm: Remove usage of...

Issue #3135077 by mondrake, sja112, daffie, longwave, xjm: Remove usage of AssertLegacyTrait::pass() from traits
parent 0c700b50
No related branches found
No related tags found
8 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!1012Issue #3226887: Hreflang on non-canonical content pages,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10,!596Issue #3046532: deleting an entity reference field, used in a contextual view, makes the whole site unrecoverable,!496Issue #2463967: Use .user.ini file for PHP settings,!144Issue #2666286: Clean up menu_ui to conform to Drupal coding standards,!16Draft: Resolve #2081585 "History storage",!13Resolve #2903456
...@@ -97,9 +97,6 @@ public function checkBookNode(EntityInterface $node, $nodes, $previous, $up, $ne ...@@ -97,9 +97,6 @@ public function checkBookNode(EntityInterface $node, $nodes, $previous, $up, $ne
if ($nodes !== NULL) { if ($nodes !== NULL) {
$this->assertPattern($this->generateOutlinePattern($nodes), new FormattableMarkup('Node @number outline confirmed.', ['@number' => $number])); $this->assertPattern($this->generateOutlinePattern($nodes), new FormattableMarkup('Node @number outline confirmed.', ['@number' => $number]));
} }
else {
$this->pass(new FormattableMarkup('Node %number does not have outline.', ['%number' => $number]));
}
// Check previous, up, and next links. // Check previous, up, and next links.
if ($previous) { if ($previous) {
......
...@@ -283,12 +283,7 @@ protected function createRole(array $permissions, $rid = NULL, $name = NULL, $we ...@@ -283,12 +283,7 @@ protected function createRole(array $permissions, $rid = NULL, $name = NULL, $we
$this->grantPermissions($role, $permissions); $this->grantPermissions($role, $permissions);
$assigned_permissions = Role::load($role->id())->getPermissions(); $assigned_permissions = Role::load($role->id())->getPermissions();
$missing_permissions = array_diff($permissions, $assigned_permissions); $missing_permissions = array_diff($permissions, $assigned_permissions);
if (!$missing_permissions) { $this->assertEmpty($missing_permissions);
$this->pass(new FormattableMarkup('Created permissions: @perms', ['@perms' => implode(', ', $permissions)]), 'Role');
}
else {
$this->fail(new FormattableMarkup('Failed to create permissions: @perms', ['@perms' => implode(', ', $missing_permissions)]), 'Role');
}
} }
return $role->id(); return $role->id();
} }
......
...@@ -50,13 +50,12 @@ protected function assertViewsCacheTags(ViewExecutable $view, $expected_results_ ...@@ -50,13 +50,12 @@ protected function assertViewsCacheTags(ViewExecutable $view, $expected_results_
$request_stack->push($request); $request_stack->push($request);
$renderer->renderRoot($build); $renderer->renderRoot($build);
// Render array cache tags. // Check render array cache tags.
$this->pass('Checking render array cache tags.');
sort($expected_render_array_cache_tags); sort($expected_render_array_cache_tags);
$this->assertEqual($build['#cache']['tags'], $expected_render_array_cache_tags); $this->assertEqual($build['#cache']['tags'], $expected_render_array_cache_tags);
if ($views_caching_is_enabled) { if ($views_caching_is_enabled) {
$this->pass('Checking Views results cache item cache tags.'); // Check Views render cache item cache tags.
/** @var \Drupal\views\Plugin\views\cache\CachePluginBase $cache_plugin */ /** @var \Drupal\views\Plugin\views\cache\CachePluginBase $cache_plugin */
$cache_plugin = $view->display_handler->getPlugin('cache'); $cache_plugin = $view->display_handler->getPlugin('cache');
...@@ -76,8 +75,7 @@ protected function assertViewsCacheTags(ViewExecutable $view, $expected_results_ ...@@ -76,8 +75,7 @@ protected function assertViewsCacheTags(ViewExecutable $view, $expected_results_
$this->assertNull($results_cache_item, 'Results cache item not found.'); $this->assertNull($results_cache_item, 'Results cache item not found.');
} }
$this->pass('Checking Views render cache item cache tags.'); // Check Views render cache item cache tags.
$original['#cache'] += ['contexts' => []]; $original['#cache'] += ['contexts' => []];
$original['#cache']['contexts'] = Cache::mergeContexts($original['#cache']['contexts'], $this->container->getParameter('renderer.config')['required_cache_contexts']); $original['#cache']['contexts'] = Cache::mergeContexts($original['#cache']['contexts'], $this->container->getParameter('renderer.config')['required_cache_contexts']);
...@@ -132,12 +130,11 @@ protected function assertViewsCacheTagsFromStaticRenderArray(ViewExecutable $vie ...@@ -132,12 +130,11 @@ protected function assertViewsCacheTagsFromStaticRenderArray(ViewExecutable $vie
$request_stack->push($request); $request_stack->push($request);
$renderer->renderRoot($build); $renderer->renderRoot($build);
// Render array cache tags. // Check render array cache tags.
$this->pass('Checking render array cache tags.');
sort($expected_render_array_cache_tags); sort($expected_render_array_cache_tags);
$this->assertEqual($build['#cache']['tags'], $expected_render_array_cache_tags); $this->assertEqual($build['#cache']['tags'], $expected_render_array_cache_tags);
$this->pass('Checking Views render cache item cache tags.'); // Check Views render cache item cache tags.
$original['#cache'] += ['contexts' => []]; $original['#cache'] += ['contexts' => []];
$original['#cache']['contexts'] = Cache::mergeContexts($original['#cache']['contexts'], $this->container->getParameter('renderer.config')['required_cache_contexts']); $original['#cache']['contexts'] = Cache::mergeContexts($original['#cache']['contexts'], $this->container->getParameter('renderer.config')['required_cache_contexts']);
......
...@@ -127,16 +127,12 @@ protected function parse() { ...@@ -127,16 +127,12 @@ protected function parse() {
$html_dom = new \DOMDocument(); $html_dom = new \DOMDocument();
@$html_dom->loadHTML('<?xml encoding="UTF-8">' . $this->getRawContent()); @$html_dom->loadHTML('<?xml encoding="UTF-8">' . $this->getRawContent());
if ($html_dom) { if ($html_dom) {
$this->pass(new FormattableMarkup('Valid HTML found on "@path"', ['@path' => $this->getUrl()]), 'Browser');
// It's much easier to work with simplexml than DOM, luckily enough // It's much easier to work with simplexml than DOM, luckily enough
// we can just simply import our DOM tree. // we can just simply import our DOM tree.
$this->elements = simplexml_import_dom($html_dom); $this->elements = simplexml_import_dom($html_dom);
} }
} }
if ($this->elements === FALSE) { $this->assertNotFalse($this->elements, 'The current HTML page should be available for DOM navigation.');
$this->fail('Parsed page successfully.', 'Browser');
}
return $this->elements; return $this->elements;
} }
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
use Drupal\Core\Config\TypedConfigManagerInterface; use Drupal\Core\Config\TypedConfigManagerInterface;
use Drupal\Core\Config\Schema\SchemaCheckTrait; use Drupal\Core\Config\Schema\SchemaCheckTrait;
use Drupal\Component\Render\FormattableMarkup;
/** /**
* Provides a class for checking configuration schema. * Provides a class for checking configuration schema.
...@@ -24,25 +23,19 @@ trait SchemaCheckTestTrait { ...@@ -24,25 +23,19 @@ trait SchemaCheckTestTrait {
* The configuration data. * The configuration data.
*/ */
public function assertConfigSchema(TypedConfigManagerInterface $typed_config, $config_name, $config_data) { public function assertConfigSchema(TypedConfigManagerInterface $typed_config, $config_name, $config_data) {
$errors = $this->checkConfigSchema($typed_config, $config_name, $config_data); $check = $this->checkConfigSchema($typed_config, $config_name, $config_data);
if ($errors === FALSE) { $message = '';
// @todo Since the use of this trait is under TestBase, it works. if ($check === FALSE) {
// Can be fixed as part of https://www.drupal.org/node/2260053. $message = 'Error: No schema exists.';
$this->fail(new FormattableMarkup('No schema for @config_name', ['@config_name' => $config_name]));
return;
} }
elseif ($errors === TRUE) { elseif ($check !== TRUE) {
// @todo Since the use of this trait is under TestBase, it works. $this->assertIsArray($check, "The config schema check errors should be in the form of an array.");
// Can be fixed as part of https://www.drupal.org/node/2260053. $message = "Errors:\n";
$this->pass(new FormattableMarkup('Schema found for @config_name and values comply with schema.', ['@config_name' => $config_name])); foreach ($check as $key => $error) {
} $message .= "Schema key $key failed with: $error\n";
else {
foreach ($errors as $key => $error) {
// @todo Since the use of this trait is under TestBase, it works.
// Can be fixed as part of https://www.drupal.org/node/2260053.
$this->fail(new FormattableMarkup('Schema key @key failed with: @error', ['@key' => $key, '@error' => $error]));
} }
} }
$this->assertTrue($check, "There should be no errors in configuration '$config_name'. $message");
} }
/** /**
......
...@@ -20,7 +20,6 @@ public function testConfigSchemaChecker() { ...@@ -20,7 +20,6 @@ public function testConfigSchemaChecker() {
$this->fail($message); $this->fail($message);
} }
catch (SchemaIncompleteException $e) { catch (SchemaIncompleteException $e) {
$this->pass($message);
$this->assertEqual('No schema for config_schema_test.schemaless', $e->getMessage()); $this->assertEqual('No schema for config_schema_test.schemaless', $e->getMessage());
} }
...@@ -29,7 +28,6 @@ public function testConfigSchemaChecker() { ...@@ -29,7 +28,6 @@ public function testConfigSchemaChecker() {
$config = $this->config('config_test.types')->set('int', 10); $config = $this->config('config_test.types')->set('int', 10);
try { try {
$config->save(); $config->save();
$this->pass($message);
} }
catch (SchemaIncompleteException $e) { catch (SchemaIncompleteException $e) {
$this->fail($message); $this->fail($message);
...@@ -42,7 +40,6 @@ public function testConfigSchemaChecker() { ...@@ -42,7 +40,6 @@ public function testConfigSchemaChecker() {
$config->get('int'); $config->get('int');
try { try {
$config->save(); $config->save();
$this->pass($message);
} }
catch (SchemaIncompleteException $e) { catch (SchemaIncompleteException $e) {
$this->fail($message); $this->fail($message);
...@@ -58,7 +55,6 @@ public function testConfigSchemaChecker() { ...@@ -58,7 +55,6 @@ public function testConfigSchemaChecker() {
$this->fail($message); $this->fail($message);
} }
catch (SchemaIncompleteException $e) { catch (SchemaIncompleteException $e) {
$this->pass($message);
$this->assertEqual('Schema errors for config_test.types with the following errors: config_test.types:array variable type is integer but applied schema class is Drupal\Core\Config\Schema\Sequence, config_test.types:foo missing schema', $e->getMessage()); $this->assertEqual('Schema errors for config_test.types with the following errors: config_test.types:array variable type is integer but applied schema class is Drupal\Core\Config\Schema\Sequence, config_test.types:foo missing schema', $e->getMessage());
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment