You are here

public function HandlerTest::testBrokenHandlers in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/views_ui/tests/src/Functional/HandlerTest.php \Drupal\Tests\views_ui\Functional\HandlerTest::testBrokenHandlers()
  2. 10 core/modules/views_ui/tests/src/Functional/HandlerTest.php \Drupal\Tests\views_ui\Functional\HandlerTest::testBrokenHandlers()

Tests broken handlers.

File

core/modules/views_ui/tests/src/Functional/HandlerTest.php, line 206

Class

HandlerTest
Tests handler UI for views.

Namespace

Drupal\Tests\views_ui\Functional

Code

public function testBrokenHandlers() {
  $handler_types = ViewExecutable::getHandlerTypes();
  foreach ($handler_types as $type => $type_info) {
    $this
      ->drupalGet('admin/structure/views/view/test_view_broken/edit');
    $href = "admin/structure/views/nojs/handler/test_view_broken/default/{$type}/id_broken";
    $result = $this
      ->xpath('//a[contains(@href, :href)]', [
      ':href' => $href,
    ]);
    $this
      ->assertCount(1, $result, new FormattableMarkup('Handler (%type) edit link found.', [
      '%type' => $type,
    ]));
    $text = 'Broken/missing handler';
    $this
      ->assertIdentical($result[0]
      ->getText(), $text, 'Ensure the broken handler text was found.');
    $this
      ->drupalGet($href);
    $result = $this
      ->xpath('//h1[@class="page-title"]');
    $this
      ->assertStringContainsString($text, $result[0]
      ->getText(), 'Ensure the broken handler text was found.');
    $original_configuration = [
      'field' => 'id_broken',
      'id' => 'id_broken',
      'relationship' => 'none',
      'table' => 'views_test_data',
      'plugin_id' => 'numeric',
    ];
    foreach ($original_configuration as $key => $value) {
      $this
        ->assertText(new FormattableMarkup('@key: @value', [
        '@key' => $key,
        '@value' => $value,
      ]));
    }
  }
}