public function testDumper() { $nb = 0; $filter = new CallablesFilter(null, function ($asset) use(&$nb) { $nb++; }); $filter->filterDump($this->getMock('Assetic\\Asset\\AssetInterface')); $this->assertEquals(1, $nb, '->filterDump() calls the loader callable'); }
public function testDependencyExtractor() { $nb = 0; $self = $this; $assetFactoryMock = $this->getMockBuilder('Assetic\\Factory\\AssetFactory')->disableOriginalConstructor()->getMock(); $result = array(new StringAsset("test")); $filter = new CallablesFilter(null, null, function (AssetFactory $factory, $content, $loadPath) use(&$nb, $assetFactoryMock, $self, $result) { $self->assertSame($factory, $assetFactoryMock, '-> the asset factory is passed to the callable'); $self->assertEquals('content', $content, '-> the content is passed to the callable'); $self->assertEquals('loadPath', $loadPath, '-> the load path is passed to the callable'); $nb++; return $result; }); $r = $filter->getChildren($assetFactoryMock, 'content', 'loadPath'); $this->assertEquals($result, $r, "->getChildren() returns the callable's result"); $this->assertEquals(1, $nb, '->getChildren() calls the extractor callable'); $filter = new CallablesFilter(); $this->assertEquals(array(), $filter->getChildren($assetFactoryMock, 'ignored', 'ignored'), '-> without an extractor callable, the filter just returns an empty array (of assets)'); }