Unverified Commit 9dc42330 authored by alexpott's avatar alexpott

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
......@@ -97,9 +97,6 @@ public function checkBookNode(EntityInterface $node, $nodes, $previous, $up, $ne
if ($nodes !== NULL) {
$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.
if ($previous) {
......
......@@ -283,12 +283,7 @@ protected function createRole(array $permissions, $rid = NULL, $name = NULL, $we
$this->grantPermissions($role, $permissions);
$assigned_permissions = Role::load($role->id())->getPermissions();
$missing_permissions = array_diff($permissions, $assigned_permissions);
if (!$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');
}
$this->assertEmpty($missing_permissions);
}
return $role->id();
}
......
......@@ -50,13 +50,12 @@ protected function assertViewsCacheTags(ViewExecutable $view, $expected_results_
$request_stack->push($request);
$renderer->renderRoot($build);
// Render array cache tags.
$this->pass('Checking render array cache tags.');
// Check render array cache tags.
sort($expected_render_array_cache_tags);
$this->assertEqual($build['#cache']['tags'], $expected_render_array_cache_tags);
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 */
$cache_plugin = $view->display_handler->getPlugin('cache');
......@@ -76,8 +75,7 @@ protected function assertViewsCacheTags(ViewExecutable $view, $expected_results_
$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'] = Cache::mergeContexts($original['#cache']['contexts'], $this->container->getParameter('renderer.config')['required_cache_contexts']);
......@@ -132,12 +130,11 @@ protected function assertViewsCacheTagsFromStaticRenderArray(ViewExecutable $vie
$request_stack->push($request);
$renderer->renderRoot($build);
// Render array cache tags.
$this->pass('Checking render array cache tags.');
// Check render array cache tags.
sort($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'] = Cache::mergeContexts($original['#cache']['contexts'], $this->container->getParameter('renderer.config')['required_cache_contexts']);
......
......@@ -127,16 +127,12 @@ protected function parse() {
$html_dom = new \DOMDocument();
@$html_dom->loadHTML('<?xml encoding="UTF-8">' . $this->getRawContent());
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
// we can just simply import our DOM tree.
$this->elements = simplexml_import_dom($html_dom);
}
}
if ($this->elements === FALSE) {
$this->fail('Parsed page successfully.', 'Browser');
}
$this->assertNotFalse($this->elements, 'The current HTML page should be available for DOM navigation.');
return $this->elements;
}
......
......@@ -4,7 +4,6 @@
use Drupal\Core\Config\TypedConfigManagerInterface;
use Drupal\Core\Config\Schema\SchemaCheckTrait;
use Drupal\Component\Render\FormattableMarkup;
/**
* Provides a class for checking configuration schema.
......@@ -24,25 +23,19 @@ trait SchemaCheckTestTrait {
* The configuration data.
*/
public function assertConfigSchema(TypedConfigManagerInterface $typed_config, $config_name, $config_data) {
$errors = $this->checkConfigSchema($typed_config, $config_name, $config_data);
if ($errors === FALSE) {
// @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('No schema for @config_name', ['@config_name' => $config_name]));
return;
$check = $this->checkConfigSchema($typed_config, $config_name, $config_data);
$message = '';
if ($check === FALSE) {
$message = 'Error: No schema exists.';
}
elseif ($errors === TRUE) {
// @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->pass(new FormattableMarkup('Schema found for @config_name and values comply with schema.', ['@config_name' => $config_name]));
}
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]));
elseif ($check !== TRUE) {
$this->assertIsArray($check, "The config schema check errors should be in the form of an array.");
$message = "Errors:\n";
foreach ($check as $key => $error) {
$message .= "Schema key $key failed with: $error\n";
}
}
$this->assertTrue($check, "There should be no errors in configuration '$config_name'. $message");
}
/**
......
......@@ -20,7 +20,6 @@ public function testConfigSchemaChecker() {
$this->fail($message);
}
catch (SchemaIncompleteException $e) {
$this->pass($message);
$this->assertEqual('No schema for config_schema_test.schemaless', $e->getMessage());
}
......@@ -29,7 +28,6 @@ public function testConfigSchemaChecker() {
$config = $this->config('config_test.types')->set('int', 10);
try {
$config->save();
$this->pass($message);
}
catch (SchemaIncompleteException $e) {
$this->fail($message);
......@@ -42,7 +40,6 @@ public function testConfigSchemaChecker() {
$config->get('int');
try {
$config->save();
$this->pass($message);
}
catch (SchemaIncompleteException $e) {
$this->fail($message);
......@@ -58,7 +55,6 @@ public function testConfigSchemaChecker() {
$this->fail($message);
}
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());
}
......
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