You are here

protected function BricksTest::recurseBricks in Bricks​ 2.x

Parameters

array $tree:

\Symfony\Component\DomCrawler\Crawler $bricks:

Return value

int

1 call to BricksTest::recurseBricks()
BricksTest::testBricks in tests/src/Kernel/BricksTest.php
@dataProvider getTrees

File

tests/src/Kernel/BricksTest.php, line 82

Class

BricksTest
Class BricksTest

Namespace

Drupal\Tests\bricks\Kernel

Code

protected function recurseBricks(array $tree, Crawler $bricks) : int {
  $total = count($tree);
  foreach (array_keys($tree) as $delta => $paragraph_id) {
    $brick = $bricks
      ->eq($delta);

    // This is just <div><div> but DOM is clumsy.
    $content = $brick
      ->children()
      ->first()
      ->children()
      ->first();
    $this
      ->assertSame("testplain {$paragraph_id}", $content
      ->text());
    $total += $this
      ->recurseBricks($tree[$paragraph_id], $brick
      ->children()
      ->filter('.paragraph'));
  }
  return $total;
}