Beispiel #1
0
 /**
  * @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);
     }
 }
Beispiel #2
0
 public function testFailGetRateBefore()
 {
     $Repo = new NbpRepository(self::$_NbpCache);
     $test_data = [[['2099-01-02', 'USD'], ENbpEntryNotFound::class], [['150102', 'USD'], EWrongNbpDateFormat::class], [['2001-01-01', 'USD'], ENbpEntryNotFound::class]];
     foreach ($test_data as $data) {
         $date = $data[0][0];
         $currency = $data[0][1];
         $Exc = null;
         try {
             $Repo->getRateBefore($date, $currency);
         } catch (\Exception $Exc) {
         }
         $this->assertNotNull($Exc, "While testing ({$date}, {$currency})");
         $this->assertInstanceOf($data[1], $Exc);
     }
 }