/** * Request is populated with all the superglobals from page request if * data is not passed in. * * @param array $options Associative array with all superglobals */ public function __construct($options = array()) { try { $this->_initRequestId(); $this->_initSessionData(); // register default mime types Mad_Controller_Mime_Type::registerTypes(); // superglobal data if not passed in thru constructor $this->_get = isset($options['get']) ? $options['get'] : $_GET; $this->_post = isset($options['post']) ? $options['post'] : $_POST; $this->_cookie = isset($options['cookie']) ? $options['cookie'] : $_COOKIE; $this->_request = isset($options['request']) ? $options['request'] : $_REQUEST; $this->_server = isset($options['server']) ? $options['server'] : $_SERVER; $this->_env = isset($options['env']) ? $options['env'] : $_ENV; $this->_pathParams = array(); $this->_formattedRequestParams = $this->_parseFormattedRequestParameters(); // use FileUpload object to store files $this->_setFilesSuperglobals(); // clear superglobals forces developers to use the request object if (empty($options['preserveSuperglobals'])) { $_GET = $_POST = $_FILES = $_COOKIE = $_REQUEST = $_SERVER = array(); } $this->_domain = $this->getServer('SERVER_NAME'); $this->_uri = trim($this->getServer('REQUEST_URI'), '/'); $this->_method = $this->getServer('REQUEST_METHOD'); $this->_remoteIp = $this->getServer('REMOTE_ADDR'); $this->_port = $this->getServer('SERVER_PORT'); $this->_https = $this->getServer('HTTPS'); $this->_isAjax = $this->getServer('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest'; } catch (Exception $e) { $this->_malformed = true; $this->_exception = $e; } }
public function testRegisterTypes() { Mad_Controller_Mime_Type::$registered = false; Mad_Controller_Mime_Type::$set = array(); $this->assertTrue(empty(Mad_Controller_Mime_Type::$set)); Mad_Controller_Mime_Type::registerTypes(); $this->assertFalse(empty(Mad_Controller_Mime_Type::$set)); }