Beispiel #1
0
 public function testupdateTax()
 {
     $validatorMock = $this->getMockBuilder('\\Box_Validate')->getMock();
     $validatorMock->expects($this->atLeastOnce())->method('checkRequiredParamsForArray');
     $taxService = $this->getMockBuilder('\\Box\\Mod\\Invoice\\ServiceTax')->getMock();
     $taxService->expects($this->atLeastOnce())->method('update')->will($this->returnValue(true));
     $dbMock = $this->getMockBuilder('\\Box_Database')->getMock();
     $model = new \Model_Tax();
     $model->loadBean(new \RedBeanPHP\OODBBean());
     $dbMock->expects($this->atLeastOnce())->method('getExistingModelById')->will($this->returnValue($model));
     $di = new \Box_Di();
     $di['validator'] = $validatorMock;
     $di['db'] = $dbMock;
     $di['mod_service'] = $di->protect(function () use($taxService) {
         return $taxService;
     });
     $this->api->setDi($di);
     $this->api->setService($taxService);
     $this->api->setIdentity(new \Model_Admin());
     $data['id'] = 1;
     $result = $this->api->tax_update($data);
     $this->assertInternalType('boolean', $result);
     $this->assertTrue($result);
 }
 public function testtoApiArray()
 {
     $taxModel = new \Model_Tax();
     $taxModel->loadBean(new \RedBeanPHP\OODBBean());
     $dbMock = $this->getMockBuilder('\\Box_Database')->getMock();
     $dbMock->expects($this->atLeastOnce())->method('toArray')->with($taxModel)->willReturn(array());
     $di = new \Box_Di();
     $di['db'] = $dbMock;
     $this->service->setDi($di);
     $result = $this->service->toApiArray($taxModel);
     $this->assertInternalType('array', $result);
 }