public function testLoadStopTlhValue() { $clientRepo = new ClientRepository(); $clientMiles = $clientRepo->findClientByEmail('*****@*****.**'); $this->assertNull($clientMiles->getStopTlhValue()); $this->repository->loadStopTlhValue($clientMiles); $this->assertEquals(4.2, $clientMiles->getStopTlhValue()); $clientBoshen = $clientRepo->findClientByEmail('*****@*****.**'); $this->repository->loadStopTlhValue($clientBoshen); $this->assertEquals(5.6, $clientBoshen->getStopTlhValue()); }
public function testSaveStatus() { $jobRepo = new JobRepository(); $clientRepo = new ClientRepository(); $portfolioRepo = new PortfolioRepository(); $job = $jobRepo->findFirst(); $client = $clientRepo->findClientByEmail('*****@*****.**'); $portfolio = $portfolioRepo->findPortfolioByClient($client); $rebalancerActions = $this->repository->findByPortfolioAndJob($portfolio, $job); /** @var RebalancerAction $rebalancerAction */ $rebalancerAction = $rebalancerActions->first(); $sql = "SELECT * FROM " . BaseRepository::TABLE_REBALANCER_ACTION . " ra where ra.id = :id"; $connection = WealthbotMySqlSqliteConnection::getInstance(); $pdo = $connection->getPdo(); $statement = $pdo->prepare($sql); $statement->execute(array('id' => $rebalancerAction->getId())); $result = $statement->fetch(\PDO::FETCH_ASSOC); $this->assertNotEquals(Job::REBALANCE_TYPE_NO_ACTIONS, $result['status']); $tmpStatus = $result['status']; $rebalancerAction->setStatus(Job::REBALANCE_TYPE_NO_ACTIONS); $this->repository->saveStatus($rebalancerAction); $statement = $pdo->prepare($sql); $statement->execute(array('id' => $rebalancerAction->getId())); $result = $statement->fetch(\PDO::FETCH_ASSOC); $this->assertEquals(Job::REBALANCE_TYPE_NO_ACTIONS, $result['status']); $rebalancerAction->setStatus($tmpStatus); $this->repository->saveStatus($rebalancerAction); }
public function testLoadPortfolioValues() { $clientRepo = new ClientRepository(); $client = $clientRepo->findClientByEmail('*****@*****.**'); $portfolio = $this->repository->findPortfolioByClient($client); $this->repository->loadPortfolioValues($client); $this->assertEquals('2451038.0', $portfolio->getTotalValue()); $this->assertEquals('699098.0', $portfolio->getTotalInSecurities()); $this->assertEquals('992397.0', $portfolio->getTotalCashInAccounts()); $this->assertEquals('759543.0', $portfolio->getTotalCashInMoneyMarket()); $this->assertEquals('0.0', $portfolio->getSasCash()); $this->assertEquals('0.0', $portfolio->getCashBuffer()); $this->assertEquals('0.0', $portfolio->getBillingCash()); $notExistClient = new Client(); $notExistPortfolio = new Portfolio(); $notExistPortfolio->setId(0); $notExistClient->setPortfolio($notExistPortfolio); $this->repository->loadPortfolioValues($notExistClient); $this->assertNull($notExistPortfolio->getTotalValue()); $this->assertNull($notExistPortfolio->getTotalInSecurities()); $this->assertNull($notExistPortfolio->getTotalCashInAccounts()); $this->assertNull($notExistPortfolio->getTotalCashInMoneyMarket()); $this->assertNull($notExistPortfolio->getSasCash()); $this->assertNull($notExistPortfolio->getCashBuffer()); $this->assertNull($notExistPortfolio->getBillingCash()); }
public function testFindAccountById() { $clientRepo = new ClientRepository(); $client = $clientRepo->findClientByEmail('*****@*****.**'); $accounts = $this->repository->findClientAccounts($client); foreach ($accounts as $account) { $foundedAccount = $this->repository->findAccountById($account->getId()); $this->assertEquals($account->getId(), $foundedAccount->getId()); } $this->assertNull($this->repository->findAccountById('incorrect_id')); }
public function testFindOneByClient() { $clientRepo = new ClientRepository(); $client = $clientRepo->findClientByEmail('*****@*****.**'); $ria = $this->repository->findOneByClient($client); $this->assertEquals('*****@*****.**', $ria->getEmail()); $this->assertEquals(true, $ria->getIsTlhEnabled()); $this->assertEquals(0.1, $ria->getClientTaxBracket()); $this->assertEquals(50000, $ria->getMinRelationshipValue()); $this->assertEquals(100, $ria->getMinTlh()); $this->assertEquals(0.1, $ria->getMinTlhPercent()); $this->assertTrue($ria->getIsUseMunicipalBond()); $this->assertTrue($ria->getuseTransactionFees()); }
public function testClientGainsOrLossesSumForYear() { $clientRepo = new ClientRepository(); $client = $clientRepo->findClientByEmail('*****@*****.**'); $this->assertEquals(-36.22, $this->repository->getClientLossesSumForYear($client, '2013')); $this->assertEquals(-161.41, $this->repository->getClientLossesSumForYear($client, '2014')); }