setAdapter() public static method

public static setAdapter ( mageekguy\atoum\test\adapter $adapter = null )
$adapter mageekguy\atoum\test\adapter
Example #1
0
 public function testResetCalls()
 {
     $this->given($this->newTestedInstance)->if($this->mockGenerator->orphanize('__construct')->orphanize('resetCalls'), php\mocker::setAdapter($adapter = new \mock\atoum\test\adapter()))->then->object($this->testedInstance->resetCalls())->isTestedInstance->mock($adapter)->call('resetCalls')->once->object($this->testedInstance->resetCalls($functionName = uniqid()))->isTestedInstance->mock($adapter)->call('resetCalls')->withArguments($functionName)->once->if($this->testedInstance->setDefaultNamespace($defaultNamespace = uniqid()))->then->object($this->testedInstance->resetCalls($functionName = uniqid()))->isTestedInstance->mock($adapter)->call('resetCalls')->withArguments($defaultNamespace . '\\' . $functionName)->once;
 }
Example #2
0
        }
        return join(', ', $parameters);
    }
    protected static function getParameters(\reflectionFunction $function)
    {
        $parameters = array();
        foreach ($function->getParameters() as $parameter) {
            $parameters[] = ($parameter->isPassedByReference() === false ? '' : '& ') . '$' . $parameter->getName();
        }
        return 'array(' . join(',', $parameters) . ')';
    }
    protected static function getParameterType(\reflectionParameter $parameter)
    {
        switch (true) {
            case $parameter->isArray():
                return 'array ';
            case method_exists($parameter, 'isCallable') && $parameter->isCallable():
                return 'callable ';
            case $class = $parameter->getClass():
                return '\\' . $class->getName() . ' ';
            default:
                return '';
        }
    }
    protected static function defineMockedFunction($namespace, $class, $function, \reflectionFunction $reflectedFunction = null)
    {
        eval(sprintf('namespace %s { function %s(%s) { return \\%s::getAdapter()->invoke(__FUNCTION__, %s); } }', $namespace, $function, $reflectedFunction ? static::getParametersSignature($reflectedFunction) : '', $class, $reflectedFunction ? static::getParameters($reflectedFunction) : 'func_get_args()'));
    }
}
mocker::setAdapter();
Example #3
0
 public function testSetAdapter()
 {
     $this->variable(testedClass::setAdapter($adapter = new atoum\php\mocker\adapter()))->isNull()->object(testedClass::getAdapter())->isIdenticalTo($adapter)->variable(testedClass::setAdapter())->isNull()->object(testedClass::getAdapter())->isNotIdenticalTo($adapter)->isEqualTo(new atoum\php\mocker\adapter());
 }