public function testsubscription_delete() { $data = array('id' => 1); $subscriptionService = $this->getMockBuilder('\\Box\\Mod\\Invoice\\ServiceSubscription')->getMock(); $subscriptionService->expects($this->atLeastOnce())->method('delete')->will($this->returnValue(true)); $validatorMock = $this->getMockBuilder('\\Box_Validate')->getMock(); $validatorMock->expects($this->atLeastOnce())->method('checkRequiredParamsForArray'); $dbMock = $this->getMockBuilder('\\Box_Database')->getMock(); $model = new \Model_Subscription(); $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($subscriptionService) { return $subscriptionService; }); $this->api->setDi($di); $result = $this->api->subscription_delete($data); $this->assertInternalType('bool', $result); $this->assertTrue($result); }
public function testunsubscribe() { $subscribtionModel = new \Model_Subscription(); $subscribtionModel->loadBean(new \RedBeanPHP\OODBBean()); $dbMock = $this->getMockBuilder('\\Box_Database')->getMock(); $dbMock->expects($this->atLeastOnce())->method('store'); $di = new \Box_Di(); $di['db'] = $dbMock; $this->service->setDi($di); $this->service->unsubscribe($subscribtionModel); }