public function testCurrent() { $this->assertEquals($this->data[0], $this->arrayCollection->current()); $this->arrayCollection->next(); $this->assertEquals($this->data[1], $this->arrayCollection->current()); }
public function testGetTradeDataCollectionForJob() { $riaRepo = new RiaRepository(); $ria = $riaRepo->findOneBy(array('email' => '*****@*****.**')); $jobRepo = new JobRepository(); $job = $jobRepo->findOneBy(array('user_id' => $ria->getId())); $tradeDataCollection = $this->repository->getTradeDataCollectionForJob($job); $this->assertCount(3, $tradeDataCollection); $securityRepo = new SecurityRepository(); $accountRepo = new AccountRepository(); $tradeDataExpectedArray = array(array('job_id' => $job->getId(), 'security_id' => $securityRepo->findOneBySymbol('RWX')->getId(), 'account_id' => $accountRepo->findOneByAccountNumber('916985328')->getId(), 'account_number' => '916985328', 'account_type' => TradeData::ACCOUNT_TYPE_CASH_ACCOUNT, 'security_type' => TradeData::SECURITY_TYPE_EQUITY, 'action' => TradeData::ACTION_SELL, 'quantity_type' => TradeData::QUANTITY_TYPE_ALL_SHARES, 'quantity' => '56', 'symbol' => 'RWX'), array('job_id' => $job->getId(), 'security_id' => $securityRepo->findOneBySymbol('VCIT')->getId(), 'account_id' => $accountRepo->findOneByAccountNumber('480888811')->getId(), 'account_number' => '480888811', 'account_type' => TradeData::ACCOUNT_TYPE_CASH_ACCOUNT, 'security_type' => TradeData::SECURITY_TYPE_EQUITY, 'action' => TradeData::ACTION_BUY, 'quantity_type' => TradeData::QUANTITY_TYPE_SHARES, 'quantity' => '12', 'symbol' => 'VCIT'), array('job_id' => $job->getId(), 'security_id' => $securityRepo->findOneBySymbol('BND')->getId(), 'account_id' => $accountRepo->findOneByAccountNumber('122223334')->getId(), 'account_number' => '122223334', 'account_type' => TradeData::ACCOUNT_TYPE_CASH_ACCOUNT, 'security_type' => TradeData::SECURITY_TYPE_EQUITY, 'action' => TradeData::ACTION_BUY, 'quantity_type' => TradeData::QUANTITY_TYPE_SHARES, 'quantity' => '1', 'symbol' => 'BND'), array('job_id' => '59', 'security_id' => $securityRepo->findOneBySymbol('VGIT')->getId(), 'account_id' => $accountRepo->findOneByAccountNumber('916985328')->getId(), 'account_number' => '916985328', 'account_type' => TradeData::ACCOUNT_TYPE_CASH_ACCOUNT, 'security_type' => TradeData::SECURITY_TYPE_EQUITY, 'action' => TradeData::ACTION_SELL, 'quantity_type' => TradeData::QUANTITY_TYPE_ALL_SHARES, 'quantity' => '10', 'symbol' => 'VGIT')); $tradeDataCollectionExpected = new ArrayCollection(); foreach ($tradeDataExpectedArray as $key => $tradeDataExpected) { $tradeData = new TradeData(); $tradeData->loadFromArray($tradeDataExpected); $tradeDataCollectionExpected->add($tradeData, $key); } foreach ($tradeDataCollection as $tradeData) { $tradeData->setId(null); $tradeDataExpected = $tradeDataCollectionExpected->current(); $this->assertEquals($tradeData, $tradeDataExpected); $tradeDataCollectionExpected->next(); } }