예제 #1
0
 public function testGetClientRebalancerAction()
 {
     $rebalancerActionRepo = new RebalancerActionRepository();
     $rebalancerActions = $rebalancerActionRepo->findAll();
     $rebalancerAction = $rebalancerActions->first();
     /** @var Client $client */
     $client = $this->repository->getClientByRebalancerAction($rebalancerAction);
     $this->assertEquals('*****@*****.**', $client->getEmail());
 }
 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());
 }