public function testFindOneBySymbol() { $security = $this->repository->findOneBySymbol('VTI'); $this->assertNotNull($security->getId()); $this->assertEquals('VTI', $security->getSymbol()); $this->assertEquals('Vanguard Total Stock Market ETF', $security->getName()); }
public function testFindOneByPortfolioAndSecurity() { $clientRepo = new ClientRepository(); $client = $clientRepo->findOneBy(array('email' => '*****@*****.**')); $portfolioRepository = new PortfolioRepository(); $portfolio = $portfolioRepository->findPortfolioByClient($client); $securityRepo = new SecurityRepository(); $security = $securityRepo->findOneBySymbol('VTV'); $securityTransaction = $this->repository->findOneByPortfolioAndSecurity($portfolio, $security); $this->assertEquals(66, $securityTransaction->getRedemptionPenaltyInterval()); $this->assertEquals(77, $securityTransaction->getRedemptionFee()); $portfolio->setId(0); $security->setId(0); $securityTransaction = $this->repository->findOneByPortfolioAndSecurity($portfolio, $security); $this->assertNull($securityTransaction); }
public function testFindVSPForTradeData() { $riaRepo = new RiaRepository(); $ria = $riaRepo->findOneBy(array('email' => '*****@*****.**')); $jobRepo = new JobRepository(); $job = $jobRepo->findOneBy(array('user_id' => $ria->getId())); $accountRepo = new AccountRepository(); $securityRepo = new SecurityRepository(); $tradeData = new TradeData(); $tradeData->setJobId($job->getId()); $tradeData->setAccountId($accountRepo->findOneByAccountNumber('916985328')->getId()); $tradeData->setSecurityId($securityRepo->findOneBySymbol('RWX')->getId()); $vsps = $this->repository->findVSPForTradeData($tradeData); $vspsExpected = array(array('purchase' => 'VSP', 'purchase_date' => '02132013', 'quantity' => 36), array('purchase' => 'VSP', 'purchase_date' => '02162013', 'quantity' => 20)); $this->assertEquals($vspsExpected, $vsps); }
public function testFindLotsByAccountAndSecurity() { $accountRepo = new AccountRepository(); $securityRepo = new SecurityRepository(); $clientRepo = new ClientRepository(); $portfolioRepo = new PortfolioRepository(); $security = $securityRepo->findOneBySymbol('RWX'); $account = $accountRepo->findOneByAccountNumber('744888386'); $client = $clientRepo->findClientByEmail('*****@*****.**'); $portfolioRepo->findPortfolioByClient($client); $account->setClient($client); $lots = $this->repository->findLotsByAccountAndSecurity($account, $security); $this->assertCount(1, $lots); /** @var Lot $lot */ $lot = $lots->first(); $this->assertEquals(2156.54, $lot->getAmount()); $this->assertEquals(65, $lot->getQuantity()); $this->assertTrue($lot->isOpen()); $this->assertFalse($lot->getIsMuni()); $security = $securityRepo->findOneBySymbol('BND'); $lots = $this->repository->findLotsByAccountAndSecurity($account, $security); $this->assertTrue($lots->isEmpty()); $account = $accountRepo->findOneByAccountNumber('214888609'); $security = $securityRepo->findOneBySymbol('VTI'); $account->setClient($client); $lots = $this->repository->findLotsByAccountAndSecurity($account, $security); $this->assertCount(1, $lots); $lot = $lots->first(); $this->assertEquals(1000, $lot->getAmount()); $this->assertEquals(100, $lot->getQuantity()); $this->assertTrue($lot->isInitial()); $this->assertTrue($lot->getIsMuni()); }