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

ZF-8847 Zend_App Can now set doctype through config file

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@20471 44c647ce-9c0f-0410-b52a-842ac1e357ba
freak пре 16 година
родитељ
комит
b1c11ea6e3

+ 6 - 1
library/Zend/Application/Resource/View.php

@@ -60,7 +60,12 @@ class Zend_Application_Resource_View extends Zend_Application_Resource_ResourceA
     public function getView()
     {
         if (null === $this->_view) {
-            $this->_view = new Zend_View($this->getOptions());
+            $options = $this->getOptions();
+            $this->_view = new Zend_View($options);
+
+            if(isset($options['doctype'])) {
+                $this->_view->doctype()->setDoctype(strtoupper($options['doctype']));
+            }
         }
         return $this->_view;
     }

+ 11 - 2
tests/Zend/Application/Resource/ViewTest.php

@@ -34,6 +34,8 @@ require_once dirname(__FILE__) . '/../../../TestHelper.php';
  */
 require_once 'Zend/Loader/Autoloader.php';
 
+require_once 'Zend/Application/Resource/View.php';
+
 /**
  * @category   Zend
  * @package    Zend_Application
@@ -89,7 +91,6 @@ class Zend_Application_Resource_ViewTest extends PHPUnit_Framework_TestCase
 
     public function testInitializationInitializesViewObject()
     {
-        require_once 'Zend/Application/Resource/View.php';
         $resource = new Zend_Application_Resource_View(array());
         $resource->init();
         $this->assertTrue($resource->getView() instanceof Zend_View);
@@ -97,7 +98,6 @@ class Zend_Application_Resource_ViewTest extends PHPUnit_Framework_TestCase
 
     public function testInitializationInjectsViewIntoViewRenderer()
     {
-        require_once 'Zend/Application/Resource/View.php';
         $resource = new Zend_Application_Resource_View(array());
         $resource->init();
         $view = $resource->getView();
@@ -117,6 +117,15 @@ class Zend_Application_Resource_ViewTest extends PHPUnit_Framework_TestCase
         $paths = $view->getScriptPaths();
         $this->assertContains(dirname(__FILE__) . DIRECTORY_SEPARATOR, $paths, var_export($paths, 1));
     }
+
+    public function testDoctypeIsSet()
+    {
+        $options = array('doctype' => 'XHTML1_FRAMESET');
+	$resource = new Zend_Application_Resource_View($options);
+        $resource->init();
+        $view  = $resource->getView();
+	$this->assertEquals('XHTML1_FRAMESET', $view->doctype()->getDoctype());
+    }
 }
 
 if (PHPUnit_MAIN_METHOD == 'Zend_Application_Resource_ViewTest::main') {