public function test_getForWriteOff_noPeriodData_noTransactions() { /** === Test Data === */ $CALC_TYPE_ID = 1024; /** === Mocks === */ $mLogger = $this->_mockLogger(); $mConn = $this->_mockConnection(); $mDba = $this->_mockDbAdapter(null, $mConn); $mToolPeriod = $this->_mockFor('Praxigento\\Core\\Tool\\IPeriod'); $mToolbox = $this->_mockToolbox(null, null, null, $mToolPeriod); $mCallRepo = $this->_mockCallRepo(); $mSubDb = $this->_mockFor('Praxigento\\Bonus\\Hybrid\\Lib\\Service\\Period\\Sub\\Db'); $mSubWriteOff = $this->_mockFor('\\Praxigento\\Bonus\\Hybrid\\Lib\\Service\\Period\\Sub\\BasedCalcs'); // $calcWriteOffId = $this->_subDb->getCalcIdByCode($calcWriteOffCode); $mSubDb->expects($this->once())->method('getCalcIdByCode')->willReturn($CALC_TYPE_ID); // $respWriteOffLastPeriod = $this->_subDb->getLastPeriodData($calcWriteOffId); $mRespLastPeriod = new BonusBasePeriodGetLatestResponse(); $mRespLastPeriod->markSucceed(); $mSubDb->expects($this->once())->method('getLastPeriodData')->willReturn($mRespLastPeriod); // $ts = $this->_subDb->getFirstDateForPvTransactions(); $mSubDb->expects($this->once())->method('getFirstDateForPvTransactions')->willReturn(false); /** * Prepare request and perform call. */ /** @var $call Call */ $call = new Call($mLogger, $mDba, $mToolbox, $mCallRepo, $mSubDb, $mSubWriteOff); $req = new Request\GetForWriteOff(); $resp = $call->getForWriteOff($req); $this->assertTrue($resp->isSucceed()); $this->assertTrue($resp->hasNoPvTransactionsYet()); }
public function test_getLastPeriodData() { /** === Test Data === */ $CALC_ID = 512; /** === Mocks === */ $mLogger = $this->_mockLogger(); $mConn = $this->_mockConnection(); $mDba = $this->_mockDbAdapter(null, $mConn); $mToolbox = $this->_mockToolbox(); $mCallRepo = $this->_mockCallRepo(); $mCallBonusBasePeriod = $this->_mockFor('\\Praxigento\\BonusBase\\Service\\IPeriod'); $mCallTypeCalc = $this->_mockFor('\\Praxigento\\BonusBase\\Service\\ITypeCalc'); // $result = $this->_callBonusBasePeriod->getLatest($reqLastPeriod); $mResult = new BonusBasePeriodGetLatestResponse(); $mResult->markSucceed(); $mCallBonusBasePeriod->expects($this->once())->method('getLatest')->willReturn($mResult); /** * Prepare request and perform call. */ /** @var $sub Db */ $sub = new Db($mLogger, $mDba, $mToolbox, $mCallRepo, $mCallBonusBasePeriod, $mCallTypeCalc); $data = $sub->getLastPeriodData($CALC_ID); $this->assertTrue($data->isSucceed()); }