Parcourir la source

[AsseticBundle] Update the cache warmer tests

Victor Berchet il y a 14 ans
Parent
commit
f7b1839296

+ 18 - 3
src/Symfony/Bundle/AsseticBundle/Tests/CacheWarmer/AssetManagerCacheWarmerTest.php

@@ -24,13 +24,28 @@ class AssetManagerCacheWarmerTest extends \PHPUnit_Framework_TestCase
 
     public function testWarmUp()
     {
-        $am = $this->getMockBuilder('Assetic\\Factory\\LazyAssetManager')
+        $am = $this
+            ->getMockBuilder('Assetic\\Factory\\LazyAssetManager')
             ->disableOriginalConstructor()
-            ->getMock();
+            ->getMock()
+        ;
 
         $am->expects($this->once())->method('load');
+        
+        $container = $this
+            ->getMockBuilder('Symfony\\Component\\DependencyInjection\\Container')
+            ->setConstructorArgs(array())
+            ->getMock()
+        ;
+        
+        $container
+            ->expects($this->once())
+            ->method('get')
+            ->with('assetic.asset_manager')
+            ->will($this->returnValue($am))
+        ;
 
-        $warmer = new AssetManagerCacheWarmer($am);
+        $warmer = new AssetManagerCacheWarmer($container);
         $warmer->warmUp('/path/to/cache');
     }
 }

+ 23 - 5
src/Symfony/Bundle/AsseticBundle/Tests/CacheWarmer/AssetWriterCacheWarmerTest.php

@@ -25,15 +25,33 @@ class AssetWriterCacheWarmerTest extends \PHPUnit_Framework_TestCase
     public function testWarmUp()
     {
         $am = $this->getMock('Assetic\\AssetManager');
-        $writer = $this->getMockBuilder('Assetic\\AssetWriter')
+        
+        $writer = $this
+            ->getMockBuilder('Assetic\\AssetWriter')
             ->disableOriginalConstructor()
-            ->getMock();
+            ->getMock()
+        ;
 
-        $writer->expects($this->once())
+        $writer
+            ->expects($this->once())
             ->method('writeManagerAssets')
-            ->with($am);
+            ->with($am)
+        ;
+        
+        $container = $this
+            ->getMockBuilder('Symfony\\Component\\DependencyInjection\\Container')
+            ->setConstructorArgs(array())
+            ->getMock()
+        ;
+        
+        $container
+            ->expects($this->once())
+            ->method('get')
+            ->with('assetic.asset_manager')
+            ->will($this->returnValue($am))
+        ;        
 
-        $warmer = new AssetWriterCacheWarmer($am, $writer);
+        $warmer = new AssetWriterCacheWarmer($container, $writer);
         $warmer->warmUp('/path/to/cache');
     }
 }