/** * @test */ public function it_fetches_a_multiplier_rate() { $url = 'http://www.bnr.ro/nbrfxrates.xml'; $content = file_get_contents(__DIR__ . '/../../Fixtures/Provider/NationalBankOfRomania/nbrfxrates.xml'); $provider = new NationalBankOfRomaniaProvider($this->getHttpAdapterMock($url, $content)); $rate = $provider->fetchRate(new CurrencyPair('RON', 'HUF')); $this->assertSame('0.014092', $rate->getValue()); $this->assertEquals(new \DateTime('2015-01-12'), $rate->getDate()); }
/** * @test */ public function it_fetches_a_multiplier_rate() { $url = 'http://www.bnr.ro/nbrfxrates.xml'; $content = file_get_contents(__DIR__ . '/../../Fixtures/Provider/NationalBankOfRomania/nbrfxrates.xml'); $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($url)->will($this->returnValue($response)); $provider = new NationalBankOfRomaniaProvider($adapter); $rate = $provider->fetchRate(new CurrencyPair('RON', 'HUF')); $this->assertSame('0.014092', $rate->getValue()); $this->assertEquals(new \DateTime('2015-01-12'), $rate->getDate()); }