lithium\test\Mocker::chain PHP Method

chain() public static method

Generate a chain class with the current rules of the mock.
public static chain ( mixed $mock ) : object
$mock mixed Mock object, namespaced static mock, namespaced function name.
return object MockerChain instance
    public static function chain($mock)
    {
        $results = array();
        $string = is_string($mock);
        if (is_object($mock) && isset($mock->results)) {
            $results = static::mergeResults($mock->results, $mock::$staticResults);
        } elseif ($string && class_exists($mock) && isset($mock::$staticResults)) {
            $results = $mock::$staticResults;
        } elseif ($string && function_exists($mock) && isset(static::$_functionResults[$mock])) {
            $results = array($mock => static::$_functionResults[$mock]);
        }
        return new MockerChain($results);
    }

Usage Example

Ejemplo n.º 1
0
 public function testFilterDispatcherGensCorrectTransaction()
 {
     // Setup
     $params = array('request' => new stdClass());
     $params['request']->params = array('action' => 'foobar');
     Mocker::overwriteFunction('li3_newrelic\\extensions\\get_class', function () {
         return 'foo\\bar\\BazController';
     });
     NewrelicMock::applyFilter('shouldRun', function ($self, $params, $chain) {
         return false;
     });
     // Call it
     NewrelicMock::filterDispatcher(new stdClass(), $params);
     $chain = Mocker::chain('li3_newrelic\\extensions\\newrelic\\Mock');
     // Assert
     $chain->called('__callStatic')->with('name_transaction', array('Baz/foobar'));
     $this->assertTrue($chain->success());
 }
All Usage Examples Of lithium\test\Mocker::chain