예제 #1
0
 public function testSetClient()
 {
     $newClient = new Client();
     $newClient->setId(789);
     $this->rebalancerAction->setClient($newClient);
     $this->assertEquals(789, $this->rebalancerAction->getClient()->getId());
 }
예제 #2
0
 public function testFindPortfolioByClient()
 {
     $clientRepo = new ClientRepository();
     $client = $clientRepo->findClientByEmail('*****@*****.**');
     $portfolio = $this->repository->findPortfolioByClient($client);
     $this->assertNotNull($portfolio->getId());
     $this->assertNotNull($client->getPortfolio()->getId());
     $notExistClient = new Client();
     $notExistClient->setId(0);
     $portfolio = $this->repository->findPortfolioByClient($notExistClient);
     $this->assertNull($notExistClient->getPortfolio());
     $this->assertNull($portfolio);
 }
 public function testGetAccountsByRebalancerActionData()
 {
     $rebalancerActionRepo = new RebalancerActionRepository();
     $rebalancerActions = $rebalancerActionRepo->findAll();
     /** @var RebalancerAction $rebalancerAction */
     $rebalancerAction = $rebalancerActions->first();
     $sql = "SELECT u.*, up.client_account_managed as account_managed from rebalancer_actions ra\n                  LEFT JOIN client_portfolio_values cpv ON cpv.id = ra.client_portfolio_value_id\n                  LEFT JOIN client_portfolio cp ON cp.id = cpv.client_portfolio_id\n                  LEFT JOIN users u ON u.id = cp.client_id\n                  LEFT JOIN user_profiles up ON up.user_id = u.id\n                  WHERE ra.id = :rebalancerActionId\n        ";
     $parameters = array('rebalancerActionId' => $rebalancerAction->getId());
     $connection = WealthbotMySqlSqliteConnection::getInstance();
     $pdo = $connection->getPdo();
     $statement = $pdo->prepare($sql);
     $statement->execute($parameters);
     $result = $statement->fetch(\PDO::FETCH_ASSOC);
     $client = new Client();
     $client->setId($result['id']);
     $accounts = $this->repository->findClientAccounts($client);
     $rebalancerAction->setClient($client);
     $client->setAccountManaged(Client::ACCOUNT_MANAGED_HOUSEHOLD);
     $collection = $this->repository->getAccountsByRebalancerAction($rebalancerAction);
     $this->assertCount(4, $collection);
     //-------------------------------------------------------------------------
     $rebalancerAction->setAccountId($accounts->first()->getId());
     $client->setAccountManaged(Client::ACCOUNT_MANAGED_ACCOUNT);
     $collection = $this->repository->getAccountsByRebalancerAction($rebalancerAction);
     $account = $collection->first();
     $this->assertCount(1, $collection);
     $this->assertEquals($rebalancerAction->getAccountId(), $account->getId());
     $this->assertEquals($client->getId(), $account->getClient()->getId());
 }
예제 #4
0
 public function testSetClient()
 {
     $newClient = new Client();
     $newClient->setId(29);
     $this->account->setClient($newClient);
     $this->assertEquals(29, $this->account->getClient()->getId());
 }