You are here

public function ViewExecutableTest::testValidateNestedLoops in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/views/tests/src/Kernel/ViewExecutableTest.php \Drupal\Tests\views\Kernel\ViewExecutableTest::testValidateNestedLoops()
  2. 9 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 468

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
    ->assertSame(9, $total_error_count);
  $this
    ->assertCount(3, $errors);
}