/** * @test */ public function it_fetches_a_rate_enterprise_mode() { $uri = 'https://openexchangerates.org/api/latest.json?app_id=secret&base=USD&symbols=EUR'; $expectedDate = new \DateTime(); $expectedDate->setTimestamp(1399748450); $content = file_get_contents(__DIR__ . '/../../Fixtures/Provider/OpenExchangeRates/success.json'); $provider = new OpenExchangeRatesProvider($this->getHttpAdapterMock($uri, $content), 'secret', true); $rate = $provider->fetchRate(new CurrencyPair('USD', 'EUR')); $this->assertEquals('0.726804', $rate->getValue()); $this->assertEquals($expectedDate, $rate->getDate()); }
/** * @test */ public function it_fetches_a_rate_enterprise_mode() { $uri = 'https://openexchangerates.org/api/latest.json?app_id=secret&base=USD&symbols=EUR'; $expectedDate = new \DateTime(); $expectedDate->setTimestamp(1399748450); $content = file_get_contents(__DIR__ . '/../../Fixtures/Provider/OpenExchangeRates/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 OpenExchangeRatesProvider($adapter, 'secret', true); $rate = $provider->fetchRate(new CurrencyPair('USD', 'EUR')); $this->assertEquals('0.726804', $rate->getValue()); $this->assertEquals($expectedDate, $rate->getDate()); }