コード例 #1
0
 public function test_getBalancesOnDate()
 {
     /** === Test Data === */
     $ASSET_TYPE_ID = '21';
     $DATE = '20150810';
     $TBL_ACC = 'account table';
     $TBL_BALANCE = 'balance table';
     /** === Extract mocks === */
     /** === Setup Mocks === */
     // $tblAccount = $this->_resource->getTableName(Account::ENTITY_NAME);
     $this->mResource->shouldReceive('getTableName')->with(\Praxigento\Accounting\Data\Entity\Account::ENTITY_NAME)->andReturn($TBL_ACC);
     // $tblBalance = $this->_resource->getTableName(Balance::ENTITY_NAME);
     $this->mResource->shouldReceive('getTableName')->with(\Praxigento\Accounting\Data\Entity\Balance::ENTITY_NAME)->andReturn($TBL_BALANCE);
     // $q4Max = $conn->select();
     $mQ4Max = $this->_mockDbSelect();
     $this->mConn->shouldReceive('select')->once()->andReturn($mQ4Max);
     // $q4Max->from([ $asBal4Max => $tblBalance ], [ Balance::ATTR_ACCOUNT_ID, $expMaxDate ]);
     $mQ4Max->shouldReceive('from');
     // $q4Max->group($asBal4Max . '.' . Balance::ATTR_ACCOUNT_ID);
     $mQ4Max->shouldReceive('group');
     // $q4Max->where($asBal4Max . '.' . Balance::ATTR_DATE . '<=:date');
     $mQ4Max->shouldReceive('where');
     // $query = $conn->select();
     $mQuery = $this->_mockDbSelect();
     $this->mConn->shouldReceive('select')->once()->andReturn($mQuery);
     // $query->from([ $asAccount => $tblAccount ], [ Account::ATTR_ID, Account::ATTR_CUST_ID ]);
     $mQuery->shouldReceive('from');
     // $query->joinLeft([ $asMax => $q4Max ], $on, $cols);
     // $query->joinLeft([ $asBal => $tblBalance ], $on, $cols);
     $mQuery->shouldReceive('joinLeft');
     // $query->where("$whereByAssetType AND $whereByDate");
     $mQuery->shouldReceive('where');
     // $rows = $conn->fetchAll($query, $bind);
     $this->mConn->shouldReceive('fetchAll')->andReturn([Account::ATTR_ID => 1024]);
     /** === Call and asserts  === */
     $resp = $this->repo->getBalancesOnDate($ASSET_TYPE_ID, $DATE);
     $this->assertTrue(is_array($resp));
 }
コード例 #2
0
 public function test_getBalancesOnDate()
 {
     $data = $this->_obj->getBalancesOnDate(6, '20160220');
     $this->assertTrue($data > 0);
 }