1: <?php
2: /**
3: * @category Horde
4: * @package Controller
5: * @author Gunnar Wrobel <wrobel@pardus.de>
6: * @license http://www.horde.org/licenses/bsd BSD
7: */
8: class Horde_Controller_Request_Mock extends Horde_Controller_Request_Http
9: {
10: /**
11: * Request variables.
12: *
13: * @var array
14: */
15: protected $_vars;
16:
17: /**
18: * Constructor.
19: *
20: * @param array $vars The request variables.
21: */
22: public function __construct($vars = array())
23: {
24: $this->setVars($vars);
25: $server = $this->getServerVars();
26: if (!empty($server['REDIRECT_URL'])) {
27: $this->setPath($server['REDIRECT_URL']);
28: } else if (!empty($server['REQUEST_URI'])) {
29: $this->setPath($server['REQUEST_URI']);
30: }
31: }
32:
33: /**
34: * Set the request variables GET, POST, COOKIE, SERVER, REQUEST etc.
35: *
36: * @param array $vars The request variables.
37: */
38: public function setVars($vars)
39: {
40: foreach ($vars as $key => $sub) {
41: $this->_vars[strtoupper($key)] = $sub;
42: }
43: }
44:
45: /**
46: * Gets the request variables GET, POST, COOKIE, SERVER, REQUEST etc.
47: *
48: * @param string $name The name of the superglobal whose vars to return
49: */
50: protected function getVars($name)
51: {
52: if (isset($this->_vars[$name])) {
53: return $this->_vars[$name];
54: }
55: }
56: }
57: