Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 3
CRAP
6.67% covered (danger)
6.67%
2 / 30
FunctionCollection
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 3
129.08
6.67% covered (danger)
6.67%
2 / 30
 __callStatic($method, $args)
0.00% covered (danger)
0.00%
0 / 1
51.96
11.76% covered (danger)
11.76%
2 / 17
 mockFunctionReturn($functionName, $result, $arguments = array())
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 11
 clearMockReturns()
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
<?php
/*
    unit tested
 */
namespace aae\abstr {
    /**
     *
     * @package aae\abstr
     */
    abstract class FunctionCollection /*extends \aae\abstr\Uninstantiable*/ {
        protected static $_mockFunctionReturns = array();
        public static function __callStatic($method, $args) {
            if (count(static::$_mockFunctionReturns) > 0) {
                if (array_key_exists($method, static::$_mockFunctionReturns)) {
                    $results = static::$_mockFunctionReturns[$method];
                    if (count($args) < 1) {
                        return $results[0]->result;
                    }
                    foreach ($results as $rslt) {
                        $rsltArguments = $rslt->arguments;
                        $rsltArgumentsSize = count($rsltArguments);
                        for ($i=0; $i < count($args); $i++) {
                            if ($i < $rsltArgumentsSize &&
                                $args[$i] == $rsltArguments[$i]) {
                                return $rslt->result;
                            }
                        }
                    }
                }
            }
            return call_user_func_array(get_called_class().'::'.$method, $args);
        }
        public static function mockFunctionReturn($functionName, $result, $arguments = array()) {
            if (!is_array($arguments)) {
                $arguments = array($arguments);
            }
            $obj = new \stdClass();
            $obj->result = $result;
            $obj->arguments = $arguments;
            if (!array_key_exists($functionName, static::$_mockFunctionReturns)) {
                static::$_mockFunctionReturns[$functionName] = array();
            }
            static::$_mockFunctionReturns[$functionName][] = $obj;
        }
        public static function clearMockReturns() {
            static::$_mockFunctionReturns = array();
        }
    }
}