Unverified Commit 90d16a85 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

(cherry picked from commit 9dc42330)
parent bf8bbd98
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -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) {
+1 −6
Original line number Diff line number Diff line
@@ -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();
    }
+5 −8
Original line number Diff line number Diff line
@@ -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']);

+1 −5
Original line number Diff line number Diff line
@@ -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;
  }

+10 −17
Original line number Diff line number Diff line
@@ -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");
  }

  /**
Loading