瀏覽代碼

[AsseticBundle] Sort Twig assets by name before loading for filesystem-independent results

Previously, the unit test was breaking in Ubuntu with an ext4 filesystem, while passing in OSX.
Jeremy Mikola 14 年之前
父節點
當前提交
9b15b6950c

+ 1 - 1
src/Symfony/Bundle/AsseticBundle/CacheWarmer/TwigAssetsCacheWarmer.php

@@ -33,7 +33,7 @@ class TwigAssetsCacheWarmer extends CacheWarmer
         foreach ($this->kernel->getBundles() as $name => $bundle) {
             if (is_dir($dir = $bundle->getPath().'/Resources/views/')) {
                 $finder = new Finder();
-                $finder->files()->name('*.twig')->in($dir);
+                $finder->files()->name('*.twig')->in($dir)->sortByName();
                 foreach ($finder as $file) {
                     $formulae += $this->loader->load($name.':'.substr($file->getPath(), strlen($dir)).':'.$file->getBasename());
                 }

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

@@ -52,17 +52,17 @@ class TwigAssetsCacheWarmerTest extends \PHPUnit_Framework_TestCase
             ->method('getPath')
             ->will($this->returnValue(strtr(__DIR__.'/bundle', '\\', '/')));
         $this->loader->expects($this->at(0))
-            ->method('load')
-            ->with('MyBundle::grandparent.html.twig')
-            ->will($this->returnValue(array('grandparent' => array())));
-        $this->loader->expects($this->at(1))
             ->method('load')
             ->with('MyBundle:Parents/Children:child.html.twig')
             ->will($this->returnValue(array('child' => array())));
-        $this->loader->expects($this->at(2))
+        $this->loader->expects($this->at(1))
             ->method('load')
             ->with('MyBundle:Parents:parent.html.twig')
             ->will($this->returnValue(array('parent' => array())));
+        $this->loader->expects($this->at(2))
+            ->method('load')
+            ->with('MyBundle::grandparent.html.twig')
+            ->will($this->returnValue(array('grandparent' => array())));
 
         $this->cacheWarmer->warmUp($this->cacheDir);
     }