public function test_qualification() { $obm = \Magento\Framework\App\ObjectManager::getInstance(); /** @var $dba \Praxigento\Core\Lib\Context\IDbAdapter */ $dba = $obm->get(\Praxigento\Core\Lib\Context\IDbAdapter::class); $dba->getDefaultConnection()->beginTransaction(); /** @var $call \Praxigento\Bonus\GlobalSales\Lib\Service\ICalc */ $call = $obm->get(\Praxigento\Bonus\GlobalSales\Lib\Service\ICalc::class); $req = new Request\Qualification(); $req->setGvMaxLevels(2); $resp = $call->qualification($req); $this->assertTrue($resp->isSucceed()); $dba->getDefaultConnection()->rollback(); }
/** * @expectedException \Exception */ public function test_qualification_rollback() { /** === Test Data === */ $DATE_PERFORMED = 'performed'; $DATE_APPLIED = 'applied'; $GV_MAX_LEVELS = 3; /** === Setup Mocks === */ $this->mLogger->shouldReceive('info'); // $respGetPeriod = $this->_callBasePeriod->getForDependentCalc($reqGetPeriod); $mRespGetPeriod = new \Praxigento\BonusBase\Service\Period\Response\GetForDependentCalc(); $this->mCallBasePeriod->shouldReceive('getForDependentCalc')->once()->andReturn($mRespGetPeriod); // if($respGetPeriod->isSucceed()) { $mRespGetPeriod->markSucceed(); // $this->_getConn()->beginTransaction(); $this->mConn->shouldReceive('beginTransaction')->once(); // $tree = $this->_repoMod->getCompressedTree($calcIdBase); $this->mRepoMod->shouldReceive('getCompressedTree')->andThrow(new \Exception()); // $conn->rollback(); $this->mConn->shouldReceive('rollback')->once(); /** === Call and asserts === */ $req = new Request\Qualification(); $req->setDatePerformed($DATE_PERFORMED); $req->setDateApplied($DATE_APPLIED); $req->setGvMaxLevels($GV_MAX_LEVELS); $resp = $this->call->qualification($req); $this->assertFalse($resp->isSucceed()); }