public function testCallingNamespaceMethodWithCustomSeparator() { $proxy = new Proxy($this->client, '_'); $this->client->expects($this->at(0))->method('call')->with('namespace_method', array(1, 2))->will($this->returnValue('namespace method return')); $this->client->expects($this->at(1))->method('call')->with('namespace_another_namespace_method', array(1, 2))->will($this->returnValue('another namespace method return')); $this->assertSame('namespace method return', $proxy->namespace->method(1, 2)); $this->assertSame('another namespace method return', $proxy->namespace->another_namespace->method(1, 2)); }
public function testGlobalErrorHandler() { $this->client->expects($this->once())->method('call')->with('system.multicall', array(array(array('methodName' => 'method1', 'params' => array('arg11', 'arg12')), array('methodName' => 'method2', 'params' => array('arg21', 'arg22')))))->will($this->returnValue(array('return1', array('faultCode' => 200)))); $individualSuccessHandlerResults = array(); $individualSuccessHandler = function ($result) use(&$individualSuccessHandlerResults) { $individualSuccessHandlerResults[] = $result; }; $globalSuccessHandlerResults = array(); $globalSuccessHandler = function ($result) use(&$globalSuccessHandlerResults) { $globalSuccessHandlerResults[] = $result; }; $globalErrorHandlerResults = array(); $globalErrorHandler = function ($result) use(&$globalErrorHandlerResults) { $globalErrorHandlerResults[] = $result; }; $results = $this->multicallBuilder->addCall('method1', array('arg11', 'arg12'), $individualSuccessHandler)->addCall('method2', array('arg21', 'arg22'), $individualSuccessHandler)->onSuccess($globalSuccessHandler)->onError($globalErrorHandler)->execute(); $this->assertSame(array('return1', array('faultCode' => 200)), $results); $this->assertSame($results, $individualSuccessHandlerResults); $this->assertSame(array('return1'), $globalSuccessHandlerResults); $this->assertSame(array(array('faultCode' => 200)), $globalErrorHandlerResults); }
public function testRecordTimeIsCalled() { $this->timer->expects($this->once())->method('recordTiming')->with($this->equalTo(0, 0.1), 'method', array('arg1', 'arg2')); $this->wrapped->expects($this->once())->method('call')->with('method', array('arg1', 'arg2')); $this->decorator->call('method', array('arg1', 'arg2')); }
public function testMulticallMethodWrapped() { $this->wrapped->expects($this->once())->method('multicall')->will($this->returnValue('m')); $this->assertSame('m', $this->decorator->multicall()); }