public function test_getLastDate_noSnapshot() { /** === Test Data === */ $tsMinDate = '2015-12-07 10:00:00'; $period = 'period'; $dsDayBefore = '20151206'; /** === Setup Mocks === */ // $snapMaxDate = $this->_repoSnap->getMaxDatestamp(); $this->mRepoSnap->shouldReceive('getMaxDatestamp')->once()->andReturn(null); // $changelogMinDate = $this->_repoChange->getChangelogMinDate(); $this->mRepoChange->shouldReceive('getChangelogMinDate')->once()->andReturn($tsMinDate); // $period = $this->_toolPeriod->getPeriodCurrent($changelogMinDate); $this->mToolPeriod->shouldReceive('getPeriodCurrent')->once()->andReturn($period); // $dayBefore = $this->_toolPeriod->getPeriodPrev($period); $this->mToolPeriod->shouldReceive('getPeriodPrev')->once()->andReturn($dsDayBefore); /** === Call and asserts === */ $req = new Request\GetLastDate(); $resp = $this->obj->getLastDate($req); $this->assertTrue($resp->isSucceed()); $this->assertEquals($dsDayBefore, $resp->getLastDate()); }
public function test_getLastDate_withTransactionMinDate() { /** === Test Data === */ $ASSET_TYPE_ID = 21; $DS_MIN_DATE = '20151123'; $PERIOD = 'period'; $DATESTAMP_LAST = '20151122'; /** === Setup Mocks === */ // $balanceMaxDate = $this->_repoMod->getBalanceMaxDate($assetTypeId); $this->mRepoMod->shouldReceive('getBalanceMaxDate')->once()->andReturn(null); // $transactionMinDate = $this->_repoMod->getTransactionMinDateApplied($assetTypeId); $this->mRepoMod->shouldReceive('getTransactionMinDateApplied')->once()->andReturn($DS_MIN_DATE); // $period = $this->_toolPeriod->getPeriodCurrent($transactionMinDate); $this->mToolPeriod->shouldReceive('getPeriodCurrent')->once()->andReturn($PERIOD); // $dayBefore = $this->_toolPeriod->getPeriodPrev($period, IPeriod::TYPE_DAY); $this->mToolPeriod->shouldReceive('getPeriodPrev')->once()->andReturn($DATESTAMP_LAST); /** === Call and asserts === */ $req = new Request\GetLastDate(); $req->setAssetTypeId($ASSET_TYPE_ID); $res = $this->obj->getLastDate($req); $this->assertTrue($res->isSucceed()); $this->assertEquals($DATESTAMP_LAST, $res->getLastDate()); }