Example #1
0
 public function testfunds_invoice()
 {
     $generatedHash = 'generatedHashString';
     $validatorMock = $this->getMockBuilder('\\Box_Validate')->getMock();
     $validatorMock->expects($this->atLeastOnce())->method('checkRequiredParamsForArray');
     $serviceMock = $this->getMockBuilder('\\Box\\Mod\\Invoice\\Service')->getMock();
     $model = new \Model_Invoice();
     $model->loadBean(new \RedBeanPHP\OODBBean());
     $model->hash = $generatedHash;
     $serviceMock->expects($this->atLeastOnce())->method('generateFundsInvoice')->will($this->returnValue($model));
     $serviceMock->expects($this->atLeastOnce())->method('approveInvoice');
     $di = new \Box_Di();
     $di['validator'] = $validatorMock;
     $di['logger'] = new \Box_Log();
     $this->api->setDi($di);
     $this->api->setService($serviceMock);
     $identity = new \Model_Client();
     $identity->loadBean(new \RedBeanPHP\OODBBean());
     $this->api->setIdentity($identity);
     $data['amount'] = 10;
     $result = $this->api->funds_invoice($data);
     $this->assertInternalType('string', $result);
     $this->assertEquals($generatedHash, $result);
 }