Exemple #1
0
 /**
  * @test
  */
 public function shouldReturnNullIfCurrencyIsNotInBalances()
 {
     $response = $this->getResponseMock(array('balances' => array('currencies' => array())));
     $client = $this->getUpholdClientMock();
     $client->expects($this->once())->method('get')->with('/me')->will($this->returnValue($response));
     $user = new User($client, array());
     $balance = $user->getBalanceByCurrency('EUR');
     $this->assertEquals(null, $balance);
 }
Exemple #2
0
 /**
  * @test
  * @dataProvider getCurrenciesProvider
  */
 public function shouldReturnOneBalanceByCurrency($currency)
 {
     $data = array('balances' => array('currencies' => array('EUR' => array('balance' => $this->getFaker()->randomFloat(2), 'amount' => $this->getFaker()->randomFloat(2), 'rate' => $this->getFaker()->randomFloat(2, 1, 2), 'currency' => 'EUR'), 'USD' => array('balance' => $this->getFaker()->randomFloat(2), 'amount' => $this->getFaker()->randomFloat(2), 'rate' => $this->getFaker()->randomFloat(2, 1, 2), 'currency' => 'EUR'), 'XAU' => array('balance' => $this->getFaker()->randomFloat(2), 'amount' => $this->getFaker()->randomFloat(2), 'rate' => $this->getFaker()->randomFloat(2), 'currency' => 'EUR')), 'total' => $this->getFaker()->randomFloat(2)));
     $response = $this->getResponseMock($data);
     $client = $this->getUpholdClientMock();
     $client->expects($this->once())->method('get')->with('/me')->will($this->returnValue($response));
     $user = new User($client, $data);
     $balances = $user->getBalanceByCurrency($currency);
     $this->assertEquals($data['balances']['currencies'][$currency], $balances);
 }