File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
tests/AssetManagerTest/Service Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 33namespace AssetManagerTest \Service ;
44
55use Assetic \Asset \StringAsset ;
6+ use Assetic \Filter \FilterInterface ;
67use PHPUnit_Framework_TestCase ;
78use AssetManager \Service \AssetFilterManager ;
89use Zend \ServiceManager \ServiceManager ;
@@ -93,4 +94,31 @@ public function testensureByInvalid()
9394
9495 $ assetFilterManager ->setFilters ('test/path.test ' , $ asset );
9596 }
97+
98+ public function testFiltersAreInstantiatedOnce ()
99+ {
100+ $ assetFilterManager = new AssetFilterManager (array (
101+ 'test/path.test ' => array (
102+ array (
103+ 'filter ' => 'CustomFilter '
104+ ),
105+ ),
106+ ));
107+
108+ $ filterInstance = null ;
109+
110+ $ asset = $ this ->getMock ('Assetic\Asset\AssetInterface ' );
111+ $ asset
112+ ->expects ($ this ->any ())
113+ ->method ('ensureFilter ' )
114+ ->with ($ this ->callback (function (FilterInterface $ filter ) use (&$ filterInstance ) {
115+ if ($ filterInstance === null ) {
116+ $ filterInstance = $ filter ;
117+ }
118+ return $ filter === $ filterInstance ;
119+ }));
120+
121+ $ assetFilterManager ->setFilters ('test/path.test ' , $ asset );
122+ $ assetFilterManager ->setFilters ('test/path.test ' , $ asset );
123+ }
96124}
You can’t perform that action at this time.
0 commit comments