public function AssetCollectionTest::testNestedCollectionLoad

File

drupal/core/vendor/kriswallsmith/assetic/tests/Assetic/Test/Asset/AssetCollectionTest.php, line 45

Class

AssetCollectionTest

Namespace

Assetic\Test\Asset

Code

public function testNestedCollectionLoad() {
  $content = 'foobar';
  $count = 0;
  $matches = array();
  $filter = new CallablesFilter(function ($asset) use ($content, &$matches, &$count) {
    ++$count;
    if ($content == $asset
      ->getContent()) {
      $matches[] = $asset;
    }
  });
  $innerColl = new AssetCollection(array(
    new StringAsset($content),
  ));
  $outerColl = new AssetCollection(array(
    $innerColl,
  ), array(
    $filter,
  ));
  $outerColl
    ->load();
  $this
    ->assertEquals(1, count($matches), '->load() applies filters to leaves');
  $this
    ->assertEquals(1, $count, '->load() applies filters to leaves only');
}