1: <?php
2: /**
3: * A test replacement for Horde_Registry.
4: *
5: * PHP version 5
6: *
7: * @category Horde
8: * @package Test
9: * @author Gunnar Wrobel <wrobel@pardus.de>
10: * @license http://www.horde.org/licenses/lgpl21 LGPL
11: * @link http://www.horde.org/components/Horde_Test
12: */
13:
14: /**
15: * A test replacement for Horde_Registry.
16: *
17: * Copyright 2011-2012 Horde LLC (http://www.horde.org/)
18: *
19: * See the enclosed file COPYING for license information (LGPL). If you
20: * did not receive this file, see http://www.horde.org/licenses/lgpl21.
21: *
22: * @since Horde_Test 1.2.0
23: *
24: * @category Horde
25: * @package Test
26: * @author Gunnar Wrobel <wrobel@pardus.de>
27: * @license http://www.horde.org/licenses/lgpl21 LGPL
28: * @link http://www.horde.org/components/Horde_Test
29: */
30: class Horde_Test_Stub_Registry
31: {
32: /**
33: * The currrent user.
34: *
35: * @var string
36: */
37: private $_user;
38:
39: /**
40: * The current application.
41: *
42: * @var string
43: */
44: private $_app;
45:
46: /**
47: * Constructor.
48: *
49: * @param string $user The current user.
50: * @param string $app The current application.
51: */
52: public function __construct($user, $app)
53: {
54: $this->_user = $user;
55: $this->_app = $app;
56: }
57:
58: /**
59: * Returns the currently logged in user, if there is one.
60: *
61: * @param string $format The return format, defaults to the unique Horde
62: * ID. Alternative formats:
63: * <pre>
64: * bare - Horde ID without any domain information.
65: * EXAMPLE: foo@example.com would be returned as 'foo'.
66: * domain: Domain of the Horde ID.
67: * EXAMPLE: foo@example.com would be returned as 'example.com'.
68: * original: The username used to originally login to Horde.
69: * </pre>
70: *
71: * @return mixed The user ID or false if no user is logged in.
72: */
73: public function getAuth($format = null)
74: {
75: return $this->_user;
76: }
77:
78: /**
79: * Is a user an administrator?
80: *
81: * @param array $options Options:
82: * <pre>
83: * 'permission' - (string) Allow users with this permission admin access
84: * in the current context.
85: * 'permlevel' - (integer) The level of permissions to check for.
86: * Defaults to Horde_Perms::EDIT.
87: * 'user' - (string) The user to check.
88: * Defaults to self::getAuth().
89: * </pre>
90: *
91: * @return boolean Whether or not this is an admin user.
92: */
93: public function isAdmin(array $options = array())
94: {
95: return false;
96: }
97:
98: /**
99: * Return the requested configuration parameter for the specified
100: * application. If no application is specified, the value of
101: * the current application is used. However, if the parameter is not
102: * present for that application, the Horde-wide value is used instead.
103: * If that is not present, we return null.
104: *
105: * @param string $parameter The configuration value to retrieve.
106: * @param string $app The application to get the value for.
107: *
108: * @return string The requested parameter, or null if it is not set.
109: */
110: public function get($parameter, $app = null)
111: {
112: return '';
113: }
114:
115: /**
116: * Return the current application - the app at the top of the application
117: * stack.
118: *
119: * @return string The current application.
120: */
121: public function getApp()
122: {
123: return $this->_app;
124: }
125:
126: /**
127: * Determine if an interface is implemented by an active application.
128: *
129: * @param string $interface The interface to check for.
130: *
131: * @return mixed The application implementing $interface if we have it,
132: * false if the interface is not implemented.
133: */
134: public function hasInterface($interface)
135: {
136: return false;
137: }
138:
139: /**
140: * Returns all available registry APIs.
141: *
142: * @return array The API list.
143: */
144: public function listAPIs()
145: {
146: return array();
147: }
148: }