/** * @Then /^I should get the rate(s)? (?<rates>([0-9 ,\.]|and)+)$/ */ public function iShouldGetTheRates(array $rates) { \PHPUnit_Framework_TestCase::assertGreaterThan(0, count($rates)); reset($this->_requested_currencies); foreach ($rates as $expected) { $requested_currency = current($this->_requested_currencies); $Rate = null; if ($this->_work_day_before) { $Rate = $this->_NbpRepo->getRateBefore($this->_inputDate, $requested_currency); } else { $Rate = $this->_NbpRepo->getRate($this->_inputDate, $requested_currency); } \PHPUnit_Framework_TestCase::assertEquals($expected, $Rate->avg, "", 1.0E-5); next($this->_requested_currencies); } }
public function testFailGetRate() { $Repo = new NbpRepository(self::$_NbpCache); $test_data = [[['2099-01-02', 'USD'], ENbpEntryNotFound::class]]; foreach ($test_data as $data) { $date = $data[0][0]; $currency = $data[0][1]; $Exc = null; try { $Repo->getRate($date, $currency); } catch (\Exception $Exc) { } $this->assertNotNull($Exc); $this->assertInstanceOf($data[1], $Exc); } }