You are here

public function ViewExecutableTest::testValidateNestedLoops in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/views/tests/src/Kernel/ViewExecutableTest.php \Drupal\Tests\views\Kernel\ViewExecutableTest::testValidateNestedLoops()
  2. 10 core/modules/views/tests/src/Kernel/ViewExecutableTest.php \Drupal\Tests\views\Kernel\ViewExecutableTest::testValidateNestedLoops()

Tests that nested loops of the display handlers won't break validation.

File

core/modules/views/tests/src/Kernel/ViewExecutableTest.php, line 465

Class

ViewExecutableTest
Tests the ViewExecutable class.

Namespace

Drupal\Tests\views\Kernel

Code

public function testValidateNestedLoops() {
  $view = View::create([
    'id' => 'test_validate_nested_loops',
  ]);
  $executable = $view
    ->getExecutable();
  $executable
    ->newDisplay('display_test');
  $executable
    ->newDisplay('display_test');
  $errors = $executable
    ->validate();
  $total_error_count = array_reduce($errors, function ($carry, $item) {
    $carry += count($item);
    return $carry;
  });

  // Assert that there were 9 total errors across 3 displays.
  $this
    ->assertIdentical(9, $total_error_count);
  $this
    ->assertCount(3, $errors);
}