Diff
Property changes:
Name: svk:merge
- d6e91ea2-e33a-0410-98df-1d493bd67c58:/:193
+ d6e91ea2-e33a-0410-98df-1d493bd67c58:/:194
Modified: branches/zend/specs/_zend/application/.htaccess (193 => 194)
--- branches/zend/specs/_zend/application/.htaccess 2008-01-14 21:03:53 UTC (rev 193)
+++ branches/zend/specs/_zend/application/.htaccess 2008-01-14 21:15:54 UTC (rev 194)
@@ -0,0 +1 @@
+deny from all
\ No newline at end of file
Modified: branches/zend/specs/_zend/index.php (193 => 194)
--- branches/zend/specs/_zend/index.php 2008-01-14 21:03:53 UTC (rev 193)
+++ branches/zend/specs/_zend/index.php 2008-01-14 21:15:54 UTC (rev 194)
@@ -8,7 +8,7 @@
error_reporting(E_ALL|E_STRICT);
date_default_timezone_set('Europe/London');
// assume Zend Framework on default include_path
- require_once 'Zend/Framework/Front.php';
+ require_once 'Zend/Controller/Front.php';
// setup front controller
$frontController = Zend_Controller_Front::getInstance();
Added: branches/zend/src/PHPSpec/Context/Zend/Request.php (0 => 194)
--- branches/zend/src/PHPSpec/Context/Zend/Request.php (rev 0)
+++ branches/zend/src/PHPSpec/Context/Zend/Request.php 2008-01-14 21:15:54 UTC (rev 194)
@@ -0,0 +1,8 @@
+<?php
+
+require_once 'Zend/Controller/Request/Http.php';
+
+class PHPSpec_Context_Zend_Request extends Zend_Controller_Request_Http
+{
+
+}
\ No newline at end of file
Modified: branches/zend/src/PHPSpec/Context/Zend.php (193 => 194)
--- branches/zend/src/PHPSpec/Context/Zend.php 2008-01-14 21:03:53 UTC (rev 193)
+++ branches/zend/src/PHPSpec/Context/Zend.php 2008-01-14 21:15:54 UTC (rev 194)
@@ -19,7 +19,6 @@
*/
require_once 'Zend/Controller/Front.php';
-require_once 'Zend/Controller/Request/Http.php';
/**
* @category PHPSpec
@@ -32,6 +31,14 @@
protected static $_moduleDirectories = array();
+ protected static $_controllerDirectories = array();
+
+ /**
+ * Name of the Controller being specified; captured usually
+ * from the Context classname.
+ *
+ * @var string
+ */
protected $_controller = '';
/**
@@ -72,23 +79,54 @@
return self::$_moduleDirectories;
}
+ public static function clearModuleDirectories()
+ {
+ self::$_moduleDirectories = array();
+ }
+
+ public static function addControllerDirectory($path, $module = null)
+ {
+ if (!isset($module)) {
+ $module = 'NULL';
+ }
+
+ self::$_controllerDirectories[$module] = $path;
+ }
+
+ public static function getControllerDirectories()
+ {
+ return self::$_controllerDirectories;
+ }
+
+ public static function clearControllerDirectories()
+ {
+ self::$_controllerDirectories = array();
+ }
+
public function beforeEach()
{
- $this->_request = new Zend_Controller_Request_Http;
+ $_GET = array();
+ $_POST = array();
+ $_COOKIE = array();
+ $this->_request = new PHPSpec_Context_Zend_Request;
$this->_clearFrontController();
}
public function get($actionName, array $getArray = null, array $paramArray = null)
{
- $this->request()->setControllerName($this->getController());
- $this->request()->setActionName($actionName);
if (!empty($getArray)) {
- $this->request()->setParams($getArray); // override later with subclass!
+ $_GET = $getArray;
}
- if (!empty($paramArray)) {
- $this->request()->setParams($paramArray);
+ $this->_response = $this->_makeRequest($actionName, $paramArray);
+ return $this->response();
+ }
+
+ public function post($actionName, array $postArray = null, array $paramArray = null)
+ {
+ if (!empty($postArray)) {
+ $_POST = $postArray;
}
- $this->_response = $this->_frontController->dispatch($this->request());
+ $this->_response = $this->_makeRequest($actionName, $paramArray);
return $this->response();
}
@@ -126,9 +164,27 @@
return $this->_frontController;
}
+ protected function _makeRequest($actionName, array $paramArray = null)
+ {
+ $this->request()->setControllerName($this->getController());
+ $this->request()->setActionName($actionName);
+ if (!empty($paramArray)) {
+ $this->request()->setParams($paramArray);
+ }
+ $response = $this->_frontController->dispatch($this->request());
+ return $response;
+ }
+
protected function _clearFrontController() {
$this->_frontController->resetInstance();
$this->_frontController->returnResponse(true);
+ $this->_frontController->throwExceptions(true);
+ foreach (self::getControllerDirectories() as $module=>$path) {
+ if ($module == 'NULL') {
+ $module = null;
+ }
+ $this->_frontController->addControllerDirectory($path, $module);
+ }
foreach (self::getModuleDirectories() as $path) {
$this->_frontController->addModuleDirectory($path);
}
@@ -136,7 +192,8 @@
protected function _setController()
{
- $this->_controller = substr(get_class($this), 8, strlen(substr(get_class($this), 8))-10);
+ $controllerClassName = substr(get_class($this), 8);
+ $this->_controller = substr($controllerClassName, 0, strlen($controllerClassName)-10);
}
}
\ No newline at end of file
Modified: branches/zend/src/PHPSpec/Context.php (193 => 194)
--- branches/zend/src/PHPSpec/Context.php 2008-01-14 21:03:53 UTC (rev 193)
+++ branches/zend/src/PHPSpec/Context.php 2008-01-14 21:15:54 UTC (rev 194)
@@ -14,14 +14,14 @@
*
* @category PHPSpec
* @package PHPSpec
- * @copyright Copyright (c) 2007 P�draic Brady, Travis Swicegood
+ * @copyright Copyright (c) 2007 Pádraic Brady, Travis Swicegood
* @license http://www.gnu.org/licenses/lgpl-3.0.txt GNU Lesser General Public Licence Version 3
*/
/**
* @category PHPSpec
* @package PHPSpec
- * @copyright Copyright (c) 2007 P�draic Brady, Travis Swicegood
+ * @copyright Copyright (c) 2007 Pádraic Brady, Travis Swicegood
* @license http://www.gnu.org/licenses/lgpl-3.0.txt GNU Lesser General Public Licence Version 3
*/
class PHPSpec_Context implements Countable