diff --git a/core/modules/views/src/Tests/ViewExecutableTest.php b/core/modules/views/src/Tests/ViewExecutableTest.php index a19588b..b1c03a0 100644 --- a/core/modules/views/src/Tests/ViewExecutableTest.php +++ b/core/modules/views/src/Tests/ViewExecutableTest.php @@ -8,6 +8,7 @@ namespace Drupal\views\Tests; use Drupal\comment\Tests\CommentTestTrait; +use Drupal\views\Entity\View; use Drupal\views\Views; use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutableFactory; @@ -436,4 +437,24 @@ public function testValidate() { $this->assertNotIdentical($validate, $validate_deleted, 'Master display has not been validated.'); } + /** + * Tests that nested loops of the display handlers won't break validation. + */ + public function testValidateNestedLoops() { + $view = Views::getView('test_validate_nested_loops'); + $view = View::create(array('id' => 'test_executable_displays')); + $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->assertIdentical(3, count($errors)); + } + } diff --git a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/display/DisplayTest.php b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/display/DisplayTest.php index 442285c..5842f1e 100644 --- a/core/modules/views/tests/modules/views_test_data/src/Plugin/views/display/DisplayTest.php +++ b/core/modules/views/tests/modules/views_test_data/src/Plugin/views/display/DisplayTest.php @@ -149,4 +149,14 @@ public function calculateDependencies() { ]; } + /** + * {@inheritdoc} + */ + public function validate() { + $errors = parent::validate(); + foreach ($this->view->displayHandlers->getInstances() as $display_handler) { + $errors[] = 'error'; + } + return $errors; + } }