Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 1 | <?php |
| 2 | |
Pascal Kriete | fe372e3 | 2011-04-21 00:59:45 -0400 | [diff] [blame] | 3 | class CI_TestCase extends PHPUnit_Framework_TestCase { |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 4 | |
dchill42 | 7ecc5cd | 2012-10-12 16:25:51 -0400 | [diff] [blame] | 5 | public $ci_vfs_root; |
| 6 | public $ci_app_root; |
| 7 | public $ci_base_root; |
Pascal Kriete | ae7b3f9 | 2011-04-21 01:21:27 -0400 | [diff] [blame] | 8 | protected $ci_instance; |
| 9 | protected static $ci_test_instance; |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 10 | |
Pascal Kriete | ae7b3f9 | 2011-04-21 01:21:27 -0400 | [diff] [blame] | 11 | private $global_map = array( |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 12 | 'benchmark' => 'bm', |
| 13 | 'config' => 'cfg', |
| 14 | 'hooks' => 'ext', |
| 15 | 'utf8' => 'uni', |
| 16 | 'router' => 'rtr', |
| 17 | 'output' => 'out', |
| 18 | 'security' => 'sec', |
| 19 | 'input' => 'in', |
| 20 | 'lang' => 'lang', |
Greg Aker | 8da6903 | 2011-04-21 11:28:27 -0500 | [diff] [blame] | 21 | 'loader' => 'load', |
| 22 | 'model' => 'model' |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 23 | ); |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 24 | |
Eric Barnes | 68286a4 | 2011-04-21 22:00:33 -0400 | [diff] [blame] | 25 | // -------------------------------------------------------------------- |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 26 | |
Pascal Kriete | fe372e3 | 2011-04-21 00:59:45 -0400 | [diff] [blame] | 27 | public function __construct() |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 28 | { |
| 29 | parent::__construct(); |
Abdul Malik Ikhsan | a8b29ac | 2013-04-01 01:14:39 +0700 | [diff] [blame] | 30 | $this->ci_instance = new stdClass(); |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 31 | } |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 32 | |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 33 | // -------------------------------------------------------------------- |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 34 | |
Eric Barnes | 68286a4 | 2011-04-21 22:00:33 -0400 | [diff] [blame] | 35 | public function setUp() |
| 36 | { |
dchill42 | 7ecc5cd | 2012-10-12 16:25:51 -0400 | [diff] [blame] | 37 | // Setup VFS with base directories |
| 38 | $this->ci_vfs_root = vfsStream::setup(); |
| 39 | $this->ci_app_root = vfsStream::newDirectory('application')->at($this->ci_vfs_root); |
| 40 | $this->ci_base_root = vfsStream::newDirectory('system')->at($this->ci_vfs_root); |
dchill42 | 4f42be5 | 2012-10-21 21:31:19 -0400 | [diff] [blame] | 41 | $this->ci_view_root = vfsStream::newDirectory('views')->at($this->ci_app_root); |
dchill42 | 7ecc5cd | 2012-10-12 16:25:51 -0400 | [diff] [blame] | 42 | |
Eric Barnes | 68286a4 | 2011-04-21 22:00:33 -0400 | [diff] [blame] | 43 | if (method_exists($this, 'set_up')) |
| 44 | { |
| 45 | $this->set_up(); |
| 46 | } |
| 47 | } |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 48 | |
Eric Barnes | 68286a4 | 2011-04-21 22:00:33 -0400 | [diff] [blame] | 49 | // -------------------------------------------------------------------- |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 50 | |
| 51 | public function tearDown() |
Eric Barnes | 68286a4 | 2011-04-21 22:00:33 -0400 | [diff] [blame] | 52 | { |
| 53 | if (method_exists($this, 'tear_down')) |
| 54 | { |
| 55 | $this->tear_down(); |
| 56 | } |
| 57 | } |
Taufan Aditya | e1dc9ea | 2012-03-28 16:49:49 +0700 | [diff] [blame] | 58 | |
| 59 | // -------------------------------------------------------------------- |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 60 | |
Taufan Aditya | e1dc9ea | 2012-03-28 16:49:49 +0700 | [diff] [blame] | 61 | public static function instance() |
| 62 | { |
| 63 | return self::$ci_test_instance; |
| 64 | } |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 65 | |
Eric Barnes | 68286a4 | 2011-04-21 22:00:33 -0400 | [diff] [blame] | 66 | // -------------------------------------------------------------------- |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 67 | |
dchill42 | 7ecc5cd | 2012-10-12 16:25:51 -0400 | [diff] [blame] | 68 | public function ci_set_config($key = '', $val = '') |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 69 | { |
dchill42 | 7ecc5cd | 2012-10-12 16:25:51 -0400 | [diff] [blame] | 70 | // Add test config |
| 71 | if ( ! isset($this->ci_instance->config)) |
| 72 | { |
| 73 | $this->ci_instance->config = new CI_TestConfig(); |
| 74 | } |
| 75 | |
| 76 | // Empty key means just do setup above |
| 77 | if ($key === '') |
| 78 | { |
| 79 | return; |
| 80 | } |
| 81 | |
Pascal Kriete | ae7b3f9 | 2011-04-21 01:21:27 -0400 | [diff] [blame] | 82 | if (is_array($key)) |
| 83 | { |
dchill42 | 7ecc5cd | 2012-10-12 16:25:51 -0400 | [diff] [blame] | 84 | $this->ci_instance->config->config = $key; |
Pascal Kriete | ae7b3f9 | 2011-04-21 01:21:27 -0400 | [diff] [blame] | 85 | } |
| 86 | else |
| 87 | { |
dchill42 | 7ecc5cd | 2012-10-12 16:25:51 -0400 | [diff] [blame] | 88 | $this->ci_instance->config->config[$key] = $val; |
Pascal Kriete | ae7b3f9 | 2011-04-21 01:21:27 -0400 | [diff] [blame] | 89 | } |
Pascal Kriete | fe372e3 | 2011-04-21 00:59:45 -0400 | [diff] [blame] | 90 | } |
Taufan Aditya | e1dc9ea | 2012-03-28 16:49:49 +0700 | [diff] [blame] | 91 | |
| 92 | // -------------------------------------------------------------------- |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 93 | |
| 94 | public function ci_get_config() |
Taufan Aditya | e1dc9ea | 2012-03-28 16:49:49 +0700 | [diff] [blame] | 95 | { |
dchill42 | 7ecc5cd | 2012-10-12 16:25:51 -0400 | [diff] [blame] | 96 | return isset($this->ci_instance->config) ? $this->ci_instance->config->config : array(); |
Taufan Aditya | e1dc9ea | 2012-03-28 16:49:49 +0700 | [diff] [blame] | 97 | } |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 98 | |
Pascal Kriete | fe372e3 | 2011-04-21 00:59:45 -0400 | [diff] [blame] | 99 | // -------------------------------------------------------------------- |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 100 | |
| 101 | public function ci_instance($obj = FALSE) |
Pascal Kriete | fe372e3 | 2011-04-21 00:59:45 -0400 | [diff] [blame] | 102 | { |
| 103 | if ( ! is_object($obj)) |
| 104 | { |
| 105 | return $this->ci_instance; |
| 106 | } |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 107 | |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 108 | $this->ci_instance = $obj; |
| 109 | } |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 110 | |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 111 | // -------------------------------------------------------------------- |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 112 | |
| 113 | public function ci_instance_var($name, $obj = FALSE) |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 114 | { |
Pascal Kriete | fe372e3 | 2011-04-21 00:59:45 -0400 | [diff] [blame] | 115 | if ( ! is_object($obj)) |
| 116 | { |
| 117 | return $this->ci_instance->$name; |
| 118 | } |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 119 | |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 120 | $this->ci_instance->$name =& $obj; |
| 121 | } |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 122 | |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 123 | // -------------------------------------------------------------------- |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 124 | |
| 125 | /** |
| 126 | * Grab a core class |
| 127 | * |
| 128 | * Loads the correct core class without extensions |
| 129 | * and returns a reference to the class name in the |
| 130 | * globals array with the correct key. This way the |
| 131 | * test can modify the variable it assigns to and |
| 132 | * still maintain the global. |
| 133 | */ |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 134 | public function &ci_core_class($name) |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 135 | { |
| 136 | $name = strtolower($name); |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 137 | |
Pascal Kriete | ae7b3f9 | 2011-04-21 01:21:27 -0400 | [diff] [blame] | 138 | if (isset($this->global_map[$name])) |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 139 | { |
| 140 | $class_name = ucfirst($name); |
Pascal Kriete | ae7b3f9 | 2011-04-21 01:21:27 -0400 | [diff] [blame] | 141 | $global_name = $this->global_map[$name]; |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 142 | } |
Pascal Kriete | ae7b3f9 | 2011-04-21 01:21:27 -0400 | [diff] [blame] | 143 | elseif (in_array($name, $this->global_map)) |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 144 | { |
Pascal Kriete | ae7b3f9 | 2011-04-21 01:21:27 -0400 | [diff] [blame] | 145 | $class_name = ucfirst(array_search($name, $this->global_map)); |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 146 | $global_name = $name; |
| 147 | } |
| 148 | else |
| 149 | { |
| 150 | throw new Exception('Not a valid core class.'); |
| 151 | } |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 152 | |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 153 | if ( ! class_exists('CI_'.$class_name)) |
| 154 | { |
dchill42 | 7ecc5cd | 2012-10-12 16:25:51 -0400 | [diff] [blame] | 155 | require_once SYSTEM_PATH.'core/'.$class_name.'.php'; |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 156 | } |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 157 | |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 158 | $GLOBALS[strtoupper($global_name)] = 'CI_'.$class_name; |
| 159 | return $GLOBALS[strtoupper($global_name)]; |
| 160 | } |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 161 | |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 162 | // -------------------------------------------------------------------- |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 163 | |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 164 | // convenience function for global mocks |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 165 | public function ci_set_core_class($name, $obj) |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 166 | { |
| 167 | $orig =& $this->ci_core_class($name); |
| 168 | $orig = $obj; |
| 169 | } |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 170 | |
dchill42 | 7ecc5cd | 2012-10-12 16:25:51 -0400 | [diff] [blame] | 171 | /** |
| 172 | * Create VFS directory |
| 173 | * |
| 174 | * @param string Directory name |
| 175 | * @param object Optional root to create in |
| 176 | * @return object New directory object |
| 177 | */ |
| 178 | public function ci_vfs_mkdir($name, $root = NULL) |
| 179 | { |
| 180 | // Check for root |
| 181 | if ( ! $root) |
| 182 | { |
| 183 | $root = $this->ci_vfs_root; |
| 184 | } |
| 185 | |
| 186 | // Return new directory object |
| 187 | return vfsStream::newDirectory($name)->at($root); |
| 188 | } |
| 189 | |
| 190 | // -------------------------------------------------------------------- |
| 191 | |
| 192 | /** |
| 193 | * Create VFS content |
| 194 | * |
| 195 | * @param string File name |
| 196 | * @param string File content |
| 197 | * @param object VFS directory object |
| 198 | * @param mixed Optional subdirectory path or array of subs |
| 199 | * @return void |
| 200 | */ |
| 201 | public function ci_vfs_create($file, $content = '', $root = NULL, $path = NULL) |
| 202 | { |
| 203 | // Check for array |
| 204 | if (is_array($file)) |
| 205 | { |
| 206 | foreach ($file as $name => $content) |
| 207 | { |
| 208 | $this->ci_vfs_create($name, $content, $root, $path); |
| 209 | } |
| 210 | return; |
| 211 | } |
| 212 | |
| 213 | // Assert .php extension if none given |
| 214 | if (pathinfo($file, PATHINFO_EXTENSION) == '') |
| 215 | { |
| 216 | $file .= '.php'; |
| 217 | } |
| 218 | |
| 219 | // Build content |
| 220 | $tree = array($file => $content); |
| 221 | |
| 222 | // Check for path |
| 223 | $subs = array(); |
| 224 | if ($path) |
| 225 | { |
| 226 | // Explode if not array |
| 227 | $subs = is_array($path) ? $path : explode('/', trim($path, '/')); |
| 228 | } |
| 229 | |
| 230 | // Check for root |
| 231 | if ( ! $root) |
| 232 | { |
| 233 | // Use base VFS root |
| 234 | $root = $this->ci_vfs_root; |
| 235 | } |
| 236 | |
| 237 | // Handle subdirectories |
| 238 | while (($dir = array_shift($subs))) |
| 239 | { |
| 240 | // See if subdir exists under current root |
| 241 | $dir_root = $root->getChild($dir); |
| 242 | if ($dir_root) |
| 243 | { |
| 244 | // Yes - recurse into subdir |
| 245 | $root = $dir_root; |
| 246 | } |
| 247 | else |
| 248 | { |
| 249 | // No - put subdirectory back and quit |
| 250 | array_unshift($subs, $dir); |
| 251 | break; |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | // Create any remaining subdirectories |
| 256 | if ($subs) |
| 257 | { |
| 258 | foreach (array_reverse($subs) as $dir) |
| 259 | { |
| 260 | // Wrap content in subdirectory for creation |
| 261 | $tree = array($dir => $tree); |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | // Create tree |
| 266 | vfsStream::create($tree, $root); |
| 267 | } |
| 268 | |
| 269 | // -------------------------------------------------------------------- |
| 270 | |
| 271 | /** |
| 272 | * Clone a real file into VFS |
| 273 | * |
| 274 | * @param string Path from base directory |
| 275 | * @return bool TRUE on success, otherwise FALSE |
| 276 | */ |
Dan Bernardic | 168ba6c | 2015-01-10 21:11:01 -0600 | [diff] [blame] | 277 | public function ci_vfs_clone($path, $dest='') |
dchill42 | 7ecc5cd | 2012-10-12 16:25:51 -0400 | [diff] [blame] | 278 | { |
dchill42 | e9435dc | 2012-10-14 15:44:39 -0400 | [diff] [blame] | 279 | // Check for array |
| 280 | if (is_array($path)) |
| 281 | { |
| 282 | foreach ($path as $file) |
| 283 | { |
Dan Bernardic | 168ba6c | 2015-01-10 21:11:01 -0600 | [diff] [blame] | 284 | $this->ci_vfs_clone($file, $dest); |
dchill42 | e9435dc | 2012-10-14 15:44:39 -0400 | [diff] [blame] | 285 | } |
| 286 | return; |
| 287 | } |
| 288 | |
dchill42 | 7ecc5cd | 2012-10-12 16:25:51 -0400 | [diff] [blame] | 289 | // Get real file contents |
| 290 | $content = file_get_contents(PROJECT_BASE.$path); |
| 291 | if ($content === FALSE) |
| 292 | { |
| 293 | // Couldn't find file to clone |
| 294 | return FALSE; |
| 295 | } |
| 296 | |
Dan Bernardic | 168ba6c | 2015-01-10 21:11:01 -0600 | [diff] [blame] | 297 | if (empty($dest)) |
| 298 | { |
| 299 | $dest = dirname($path); |
| 300 | } |
| 301 | |
| 302 | $this->ci_vfs_create(basename($path), $content, NULL, $dest); |
dchill42 | 7ecc5cd | 2012-10-12 16:25:51 -0400 | [diff] [blame] | 303 | return TRUE; |
| 304 | } |
| 305 | |
| 306 | // -------------------------------------------------------------------- |
| 307 | |
| 308 | /** |
| 309 | * Helper to get a VFS URL path |
| 310 | * |
| 311 | * @param string Path |
| 312 | * @param string Optional base path |
| 313 | * @return string Path URL |
| 314 | */ |
| 315 | public function ci_vfs_path($path, $base = '') |
| 316 | { |
| 317 | // Check for base path |
| 318 | if ($base) |
| 319 | { |
| 320 | // Prepend to path |
| 321 | $path = rtrim($base, '/').'/'.ltrim($path, '/'); |
| 322 | |
| 323 | // Is it already in URL form? |
| 324 | if (strpos($path, '://') !== FALSE) |
| 325 | { |
| 326 | // Done - return path |
| 327 | return $path; |
| 328 | } |
| 329 | } |
| 330 | |
| 331 | // Trim leading slash and return URL |
| 332 | return vfsStream::url(ltrim($path, '/')); |
| 333 | } |
| 334 | |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 335 | // -------------------------------------------------------------------- |
Pascal Kriete | ae7b3f9 | 2011-04-21 01:21:27 -0400 | [diff] [blame] | 336 | // Internals |
| 337 | // -------------------------------------------------------------------- |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 338 | |
Pascal Kriete | ae7b3f9 | 2011-04-21 01:21:27 -0400 | [diff] [blame] | 339 | /** |
| 340 | * Overwrite runBare |
| 341 | * |
| 342 | * PHPUnit instantiates the test classes before |
| 343 | * running them individually. So right before a test |
| 344 | * runs we set our instance. Normally this step would |
| 345 | * happen in setUp, but someone is bound to forget to |
| 346 | * call the parent method and debugging this is no fun. |
| 347 | */ |
| 348 | public function runBare() |
Pascal Kriete | fe372e3 | 2011-04-21 00:59:45 -0400 | [diff] [blame] | 349 | { |
Pascal Kriete | ae7b3f9 | 2011-04-21 01:21:27 -0400 | [diff] [blame] | 350 | self::$ci_test_instance = $this; |
| 351 | parent::runBare(); |
Pascal Kriete | fe372e3 | 2011-04-21 00:59:45 -0400 | [diff] [blame] | 352 | } |
Taufan Aditya | e1dc9ea | 2012-03-28 16:49:49 +0700 | [diff] [blame] | 353 | |
Pascal Kriete | fe372e3 | 2011-04-21 00:59:45 -0400 | [diff] [blame] | 354 | // -------------------------------------------------------------------- |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 355 | |
| 356 | public function helper($name) |
Pascal Kriete | ae7b3f9 | 2011-04-21 01:21:27 -0400 | [diff] [blame] | 357 | { |
dchill42 | 7ecc5cd | 2012-10-12 16:25:51 -0400 | [diff] [blame] | 358 | require_once(SYSTEM_PATH.'helpers/'.$name.'_helper.php'); |
| 359 | } |
| 360 | |
| 361 | // -------------------------------------------------------------------- |
| 362 | |
| 363 | public function lang($name) |
| 364 | { |
| 365 | require(SYSTEM_PATH.'language/english/'.$name.'_lang.php'); |
| 366 | return $lang; |
Pascal Kriete | fe372e3 | 2011-04-21 00:59:45 -0400 | [diff] [blame] | 367 | } |
Taufan Aditya | 8749bc7 | 2012-03-11 05:43:45 +0700 | [diff] [blame] | 368 | |
| 369 | // -------------------------------------------------------------------- |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 370 | |
Taufan Aditya | 8749bc7 | 2012-03-11 05:43:45 +0700 | [diff] [blame] | 371 | /** |
| 372 | * This overload is useful to create a stub, that need to have a specific method. |
| 373 | */ |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 374 | public function __call($method, $args) |
Taufan Aditya | 8749bc7 | 2012-03-11 05:43:45 +0700 | [diff] [blame] | 375 | { |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 376 | if ($this->{$method} instanceof Closure) |
Taufan Aditya | 8749bc7 | 2012-03-11 05:43:45 +0700 | [diff] [blame] | 377 | { |
| 378 | return call_user_func_array($this->{$method},$args); |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 379 | } |
Andrey Andreev | fbe4d79 | 2017-12-27 19:49:03 +0200 | [diff] [blame^] | 380 | |
| 381 | return parent::__call($method, $args); |
Taufan Aditya | 8749bc7 | 2012-03-11 05:43:45 +0700 | [diff] [blame] | 382 | } |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 383 | |
Dan Bernardic | 168ba6c | 2015-01-10 21:11:01 -0600 | [diff] [blame] | 384 | } |