public function test_getTransactionsForPeriod() { /** === Test Data === */ $ASSET_TYPE_ID = '21'; $DATE_FROM = '20150810'; $DATE_TO = '20150815'; $TBL_ACC = 'account table'; $TBL_TRANS = 'transaction table'; /** === Setup Mocks === */ // $paramAssetType = $this->_conn->quote($assetTypeId, \Zend_Db::INT_TYPE); $this->mConn->shouldReceive('quote')->andReturn((int) $ASSET_TYPE_ID); // $tblAccount = $this->_resource->getTableName(Account::ENTITY_NAME); $this->mResource->shouldReceive('getTableName')->once()->with(\Praxigento\Accounting\Data\Entity\Account::ENTITY_NAME)->andReturn($TBL_ACC); // $tblTrans = $this->_resource->getTableName(Transaction::ENTITY_NAME); $this->mResource->shouldReceive('getTableName')->once()->with(\Praxigento\Accounting\Data\Entity\Transaction::ENTITY_NAME)->andReturn($TBL_TRANS); // $query = $this->_conn->select(); $mQuery = $this->_mockDbSelect(); $this->mConn->shouldReceive('select')->andReturn($mQuery); // $query->from([ $asAccount => $tblAccount ], [ ]); $mQuery->shouldReceive('from'); // $query->join([ $asTrans => $tblTrans ], $on); $mQuery->shouldReceive('join'); //$query->where($asAccount . '.' . Account::ATTR_ASSET_TYPE_ID . '=:asset_type_id'); //$query->where($asTrans . '.' . Transaction::ATTR_ID . ' IS NOT NULL'); //$query->where($asTrans . '.' . Transaction::ATTR_DATE_APPLIED . '>=:date_from'); //$query->where($asTrans . '.' . Transaction::ATTR_DATE_APPLIED . '<=:date_to'); $mQuery->shouldReceive('where'); // $query->order($asTrans . '.' . Transaction::ATTR_DATE_APPLIED . ' ASC'); $mQuery->shouldReceive('order'); // $result = $this->_conn->fetchAll($query, $bind); $this->mConn->shouldReceive('fetchAll')->andReturn([Transaction::ATTR_ID => 1024]); /** === Call and asserts === */ $resp = $this->repo->getTransactionsForPeriod($ASSET_TYPE_ID, $DATE_FROM, $DATE_TO); $this->assertTrue(is_array($resp)); }
public function test_getTransactionsForPeriod() { $data = $this->_obj->getTransactionsForPeriod(6, '2015-01-01 00:00:00', '2016-12-31 23:59:59'); $this->assertTrue($data > 0); }