public function testSetClient()
 {
     $newClient = new Client();
     $newClient->setId(789);
     $this->rebalancerAction->setClient($newClient);
     $this->assertEquals(789, $this->rebalancerAction->getClient()->getId());
 }
示例#2
0
 /**
  * @param RebalancerAction $rebalancerAction
  * @return Client
  */
 public function getClientByRebalancerAction(RebalancerAction $rebalancerAction)
 {
     $sql = "SELECT c.*, up.client_account_managed as accountManaged, up.estimated_income_tax as taxBracket FROM " . $this->table . " c\n                  LEFT JOIN " . self::TABLE_CLIENT_PORTFOLIO . " cp ON cp.client_id = c.id\n                  LEFT JOIN " . self::TABLE_CLIENT_PORTFOLIO_VALUE . " cpv ON cpv.client_portfolio_id = cp.id\n                  LEFT JOIN " . self::TABLE_REBALANCER_ACTION . " ra ON ra.client_portfolio_value_id = cpv.id\n                  LEFT JOIN " . self::TABLE_USER_PROFILE . " up ON c.id = up.user_id\n                WHERE ra.id = :rebalancerActionId AND cp.is_active = 1 AND c.roles LIKE :roles;\n        ";
     $parameters = array('rebalancerActionId' => $rebalancerAction->getId(), 'roles' => '%ROLE_CLIENT%');
     $result = $this->db->queryOne($sql, $parameters);
     $client = $this->bindObject($result);
     $rebalancerAction->setClient($client);
     return $client;
 }
 public function testGetAccountByRebalancerActionAccount()
 {
     /** @var AccountRepository $repository */
     $repository = $this->getMockBuilder('Model\\WealthbotRebalancer\\Repository\\AccountRepository')->disableOriginalConstructor()->setMethods(array('findClientAccounts', 'findAccountById'))->getMock();
     $client = new Client();
     $client->setId(45);
     $client->setAccountManaged(Client::ACCOUNT_MANAGED_ACCOUNT);
     $rebalancerAction = new RebalancerAction();
     $rebalancerAction->setClient($client);
     $mockAccount = $this->getMock('Model\\WealthbotRebalancer\\Account');
     $repository->expects($this->once())->method('findAccountById')->will($this->returnValue($mockAccount));
     $repository->getAccountsByRebalancerAction($rebalancerAction);
 }