HttpTestCase.php #1

  • //
  • guest/
  • perforce_software/
  • chronicle/
  • main/
  • library/
  • P4Cms/
  • Controller/
  • Request/
  • HttpTestCase.php
  • View
  • Commits
  • Open Download .zip Download (1 KB)
<?php
/**
 * More testable version of http requests. Allows server variables to be mocked.
 *
 * @copyright   2011 Perforce Software. All rights reserved.
 * @license     Please see LICENSE.txt in top-level folder of this distribution.
 * @version     <release>/<patch>
 */
class P4Cms_Controller_Request_HttpTestCase extends Zend_Controller_Request_Http
{
    protected   $_server    = array();

    /**
     * Get one or all server variables. Extended to read from test values first.
     *
     * @param   string  $key        optional - a specific server variable to get
     *                              if no $key is passed, returns the entire $_SERVER array
     * @param   mixed   $default    default value to use if key not found
     * @return  mixed   Returns null if key does not exist
     */
    public function getServer($key = null, $default = null)
    {
        if ($key && isset($this->_server[$key])) {
            return $this->_server[$key];
        }

        return parent::getServer($key, $default);
    }

    /**
     * Override a server variable for testing purposes.
     *
     * @param   string  $key    the name of the variable
     * @param   mixed   $value  the value of the variable
     */
    public function setServer($key, $value)
    {
        $this->_server[$key] = $value;

        return $this;
    }
}
# Change User Description Committed
#1 16170 perforce_software Move Chronicle files to follow new path scheme for branching.
//guest/perforce_software/chronicle/library/P4Cms/Controller/Request/HttpTestCase.php
#1 8972 Matt Attaway Initial add of the Chronicle source code