Преглед изворни кода

Merge pull request #341 from froschdesign/hotfix/340

Fixes #340 - Zend_Dojo_View_Helper_Dojo_Container::_renderStylesheets ar...
Rob Allen пре 11 година
родитељ
комит
f7a0e0e815

+ 1 - 1
library/Zend/Dojo/View/Helper/Dojo/Container.php

@@ -1026,7 +1026,7 @@ EOJ;
             return '';
         }
 
-        array_reverse($stylesheets);
+        $stylesheets = array_reverse($stylesheets);
         $style = '<style type="text/css">' . PHP_EOL
                . (($this->_isXhtml) ? '<!--' : '<!--') . PHP_EOL;
         foreach ($stylesheets as $stylesheet) {

+ 33 - 0
tests/Zend/Dojo/View/Helper/DojoTest.php

@@ -51,6 +51,11 @@ require_once 'Zend/View.php';
 class Zend_Dojo_View_Helper_DojoTest extends PHPUnit_Framework_TestCase
 {
     /**
+     * @var Zend_Dojo_View_Helper_Dojo_Container
+     */
+    protected $helper;
+
+    /**
      * Runs the test methods of this class.
      *
      * @return void
@@ -909,6 +914,34 @@ function() {
         $this->assertRegexp('#(function\\(\\){alert\\(\'foo\'\\);})#', $output);
     }
 
+    /**
+     * @group GH-340
+     */
+    public function testRenderStylesheetsOrder()
+    {
+        $helper = $this->helper;
+        $options = array(
+            'localPath'              => '',
+            'stylesheetmodules'      => 'test.stylesheet.module',
+            'registerdojostylesheet' => true,
+            'enable'                 => true,
+        );
+        $helper->setOptions($options);
+
+        $expected = '<style type="text/css">' . "\n"
+                  . '<!--' . "\n"
+                  . '    @import "/dojo/resources/dojo.css";' . "\n"
+                  . '    @import "/test/stylesheet/module/module.css";' . "\n"
+                  . '-->' . "\n"
+                  . '</style>';
+
+        $actual = (string) $helper;
+        $end    = '</style>';
+        $actual = substr($actual, 0, strpos($actual, $end) + strlen($end));
+
+        $this->assertEquals($expected, $actual);
+    }
+
     public function setupDojo()
     {
         $this->helper->requireModule('dijit.layout.ContentPane')