/**
  * @test
  */
 public function it_fetches_a_rate()
 {
     $uri = 'https://globalcurrencies.xignite.com/xGlobalCurrencies.json/GetRealTimeRates?Symbols=GBPAWG&_fields=Outcome,Message,Symbol,Date,Time,Bid&_Token=token';
     $content = file_get_contents(__DIR__ . '/../../Fixtures/Provider/Xignite/success.json');
     $provider = new XigniteProvider($this->getHttpAdapterMock($uri, $content), 'token');
     $rate = $provider->fetchRate(new CurrencyPair('GBP', 'AWG'));
     $this->assertEquals('2.982308', $rate->getValue());
     $this->assertEquals(new \DateTime('2014-05-11 21:22:00', new \DateTimeZone('UTC')), $rate->getDate());
 }
Example #2
0
 /**
  * @test
  */
 public function it_fetches_a_rate()
 {
     $uri = 'https://globalcurrencies.xignite.com/xGlobalCurrencies.json/GetRealTimeRates?Symbols=GBPAWG&_fields=Outcome,Message,Symbol,Date,Time,Bid&_Token=token';
     $content = file_get_contents(__DIR__ . '/../../Fixtures/Provider/Xignite/success.json');
     $body = $this->getMock('Psr\\Http\\Message\\StreamInterface');
     $body->expects($this->once())->method('__toString')->will($this->returnValue($content));
     $response = $this->getMock('\\Ivory\\HttpAdapter\\Message\\ResponseInterface');
     $response->expects($this->once())->method('getBody')->will($this->returnValue($body));
     $adapter = $this->getMock('Ivory\\HttpAdapter\\HttpAdapterInterface');
     $adapter->expects($this->once())->method('get')->with($uri)->will($this->returnValue($response));
     $provider = new XigniteProvider($adapter, 'token');
     $rate = $provider->fetchRate(new CurrencyPair('GBP', 'AWG'));
     $this->assertEquals('2.982308', $rate->getValue());
     $this->assertEquals(new \DateTime('2014-05-11 21:22:00', new \DateTimeZone('UTC')), $rate->getDate());
 }