[199] r399@phpspec (orig r199): padraic.brady | 2008-01-15 14:33:34 -0700

1 view
Skip to first unread message

nor...@domain51.com

unread,
Jan 15, 2008, 4:34:15 PM1/15/08
to phpspec...@googlegroups.com
Revision
199
Author
phpspec
Date
2008-01-15 14:34:14 -0700 (Tue, 15 Jan 2008)

Log Message

 r399@phpspec (orig r199):  padraic.brady | 2008-01-15 14:33:34 -0700
 * Added bootstrapping callback for Zend context setup of front controller
 * Fixed any small spec glitches migrating from the base application updates

Modified Paths

Property Changed

Diff

Property changes:


Name: svk:merge
   - d6e91ea2-e33a-0410-98df-1d493bd67c58:/:198
   + d6e91ea2-e33a-0410-98df-1d493bd67c58:/:199

Modified: branches/zend/specs/ContextZendSpec.php (198 => 199)


--- branches/zend/specs/ContextZendSpec.php	2008-01-15 17:22:06 UTC (rev 198)
+++ branches/zend/specs/ContextZendSpec.php	2008-01-15 21:34:14 UTC (rev 199)
@@ -34,21 +34,14 @@
             ->be(array('/path/to/module'));
     }
 
-    public function itShouldAllowSettingSetupCallbackFunction() 
+    public function itShouldAllowSettingSetupCallbackFunction()
     {
-        PHPSpec_Context_Zend::setFrontControllerSetupCallback(
-            array('Boostrap','prepare')
-        );
+        PHPSpec_Context_Zend::setFrontControllerSetupCallback('Bootstrap','prepare');
         $context = new DescribeFooController;
         $context->beforeEach();
         $this->spec(
-            Zend_Controller_Front::getInstance()->getControllerDirectory()
-            )->should->be(
-                array('default'=>dirname(__FILE__) . DIRECTORY_SEPARATOR
-                . '_zend' . DIRECTORY_SEPARATOR
-                . 'application' . DIRECTORY_SEPARATOR
-                . 'controllers')
-        );
+                Zend_Controller_Front::getInstance()->getControllerDirectory()
+            )->should->be(array('default'=>'./application/controllers'));
     }
 
     public function itShouldClearFrontControllerBeforeEachExample()
@@ -88,7 +81,7 @@
         $this->spec($response)->should->match("/This is Index/");
     }
 
-    public function itShouldFormulateAndDispatchRequestWithUserParams() 
+    public function itShouldFormulateAndDispatchRequestWithUserParams()
     {
         $this->setControllerDirectory();
         $context = new DescribeFooController;
@@ -98,7 +91,7 @@
         $this->spec($response)->should->match("/This is User Param/");
     }
 
-    public function itShouldDispatchARelativeUriPath() 
+    public function itShouldDispatchARelativeUriPath()
     {
         $this->setControllerDirectory();
         $context = new DescribeFooController;
@@ -107,7 +100,7 @@
         $this->spec($response)->should->match("/userparampage/");
     }
 
-    public function itShouldDispatchRelativePathWithoutOpeningSlash() 
+    public function itShouldDispatchRelativePathWithoutOpeningSlash()
     {
         $this->setControllerDirectory();
         $context = new DescribeFooController;
@@ -116,18 +109,14 @@
         $this->spec($response)->should->match("/userparampage/");
     }
 
-    public function itShould() 
-    {
-    }
-
     public function after()
     {
         PHPSpec_Context_Zend::clearModuleDirectories();
         PHPSpec_Context_Zend::clearControllerDirectories();
-        PHPSpec_Context_Zend::setFrontControllerSetupCallback(array());
+        PHPSpec_Context_Zend::clearFrontControllerSetupCallback();
     }
 
-    public function setControllerDirectory() 
+    public function setControllerDirectory()
     {
         PHPSpec_Context_Zend::addControllerDirectory(
             dirname(__FILE__)

Modified: branches/zend/src/PHPSpec/Context/Zend.php (198 => 199)


--- branches/zend/src/PHPSpec/Context/Zend.php	2008-01-15 17:22:06 UTC (rev 198)
+++ branches/zend/src/PHPSpec/Context/Zend.php	2008-01-15 21:34:14 UTC (rev 199)
@@ -37,7 +37,7 @@
     
     protected static $_controllerDirectories = array();
 
-    protected static $_frontControllerSetupCallback = array();
+    protected static $_frontControllerSetupCallback = null;
     
     /**
      * Name of the Controller being specified; captured usually
@@ -75,9 +75,18 @@
         $this->_frontController = Zend_Controller_Front::getInstance();
     }
 
-    public static function setFrontControllerSetupCallback(array $callback) 
-    {
-        self::$_frontControllerSetupCallback = $callback;
+    public static function setFrontControllerSetupCallback($func, $staticMethod = null) 
+    {
+        if ($staticMethod !== null) {
+        	self::$_frontControllerSetupCallback = array($func, $staticMethod);
+        	return;
+        }
+        self::$_frontControllerSetupCallback = $func;
+    }
+    
+    public static function clearFrontControllerSetupCallback() 
+    {
+        self::$_frontControllerSetupCallback = null;
     }
     
     public static function addModuleDirectory($path)
@@ -193,8 +202,11 @@
     
     protected function _clearFrontController() {
         $this->_frontController->resetInstance();
-        if (!empty(self::$_frontControllerSetupCallback)) {
-            call_user_func(self::$_frontControllerSetupCallback);
+        if (count(self::$_frontControllerSetupCallback) > 0) {
+            call_user_func(array(
+                self::$_frontControllerSetupCallback[0],
+                self::$_frontControllerSetupCallback[1]
+            ));
         } else {
             $this->_frontController->returnResponse(true);
             $this->_frontController->throwExceptions(true);
Reply all
Reply to author
Forward
0 new messages