public function test_calc() { $obm = \Magento\Framework\App\ObjectManager::getInstance(); /** @var $call \Praxigento\Downline\Service\Snap\Call */ $call = $obm->get('Praxigento\\Downline\\Service\\Snap\\Call'); $req = new Request\Calc(); $req->setDatestampTo('20151219'); /** @var $resp Response\Calc */ $resp = $call->calc($req); $this->assertTrue($resp->isSucceed()); }
public function test_calc() { /** === Test Data === */ $dsTo = '20151207'; $dsLast = 'the last datestamp'; $snapshot = 'snapshot'; $tsFrom = 'from'; $tsTo = 'to'; $changeLog = 'change log'; $updates = 'updates'; /** === Mock object itself === */ $this->obj = \Mockery::mock(Call::class . '[getLastDate]', $this->objArgs); /** === Setup Mocks === */ // $def = $this->_manTrans->begin(); $mDef = $this->_mockTransactionDefinition(); $this->mManTrans->shouldReceive('begin')->once()->andReturn($mDef); // $respLast = $this->getLastDate($reqLast); $mRespLast = new \Praxigento\Downline\Service\Snap\Response\GetLastDate(); $this->obj->shouldReceive('getLastDate')->once()->andReturn($mRespLast); // $lastDatestamp = $respLast->getLastDate(); $mRespLast->setLastDate($dsLast); // $snapshot = $this->_repoSnap->getStateOnDate($lastDatestamp); $this->mRepoSnap->shouldReceive('getStateOnDate')->once()->andReturn($snapshot); // $tsFrom = $this->_toolPeriod->getTimestampNextFrom($lastDatestamp); $this->mToolPeriod->shouldReceive('getTimestampNextFrom')->once()->andReturn($tsFrom); // $tsTo = $this->_toolPeriod->getTimestampTo($periodTo); $this->mToolPeriod->shouldReceive('getTimestampTo')->once()->andReturn($tsTo); // $changelog = $this->_repoChange->getChangesForPeriod($tsFrom, $tsTo); $this->mRepoChange->shouldReceive('getChangesForPeriod')->once()->andReturn($changeLog); // $updates = $this->_subCalc->calcSnapshots($snapshot, $changelog); $this->mSubCalc->shouldReceive('calcSnapshots')->once()->andReturn($updates); // $this->_repoSnap->saveCalculatedUpdates($updates); $this->mRepoSnap->shouldReceive('saveCalculatedUpdates')->once(); // $this->_manTrans->commit($def); $this->mManTrans->shouldReceive('commit')->once(); // $this->_manTrans->end($def); $this->mManTrans->shouldReceive('end')->once(); /** === Call and asserts === */ $req = new Request\Calc(); $req->setDatestampTo($dsTo); $resp = $this->obj->calc($req); $this->assertTrue($resp->isSucceed()); }