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());
 }
 public function test_calc()
 {
     /** === Test Data === */
     $ASSET_TYPE_ID = 21;
     $DATESTAMP_TO = '20151123';
     $DS = 'datestamp';
     $DS_FROM = 'datestamp from';
     $DS_TO = 'datestamp to';
     $TRANS = 'transactions';
     $UPDATES = 'updates';
     $BALANCES = ['some balances data'];
     /** === Mock object itself === */
     $this->obj = \Mockery::mock(Call::class . '[getLastDate]', $this->objArgs);
     /** === Setup Mocks === */
     // $respLastDate = $this->getLastDate($reqLastDate);
     $this->obj->shouldReceive('getLastDate')->once()->andReturn(new Response\GetLastDate([Response\GetLastDate::LAST_DATE => $DS]));
     // $balances = $this->_repoMod->getBalancesOnDate($assetTypeId, $lastDate);
     $this->mRepoMod->shouldReceive('getBalancesOnDate')->once()->andReturn($BALANCES);
     // $dtFrom = $this->_toolPeriod->getTimestampFrom($lastDate, IPeriod::TYPE_DAY);
     $this->mToolPeriod->shouldReceive('getTimestampFrom')->once()->andReturn($DS_FROM);
     // $dtTo = $this->_toolPeriod->getTimestampTo($dateTo, IPeriod::TYPE_DAY);
     $this->mToolPeriod->shouldReceive('getTimestampTo')->once()->andReturn($DS_TO);
     // $trans = $this->_repoMod->getTransactionsForPeriod($assetTypeId, $dtFrom, $dtTo);
     $this->mRepoMod->shouldReceive('getTransactionsForPeriod')->once()->andReturn($TRANS);
     // $updates = $this->_subCalcSimple->calcBalances($balances, $trans);
     $this->mSubCalcSimple->shouldReceive('calcBalances')->once()->andReturn($UPDATES);
     // $this->_repoMod->updateBalances($updates);
     $this->mRepoMod->shouldReceive('updateBalances')->once();
     /** === Call and asserts  === */
     $req = new Request\Calc();
     $req->setAssetTypeId($ASSET_TYPE_ID);
     $req->setDateTo($DATESTAMP_TO);
     $res = $this->obj->calc($req);
     $this->assertTrue($res->isSucceed());
 }