/**
  * @test
  */
 public function dateMatching()
 {
     $rate = new Rate('my_source', 100, 'EUR', 'my_rate_type', new \DateTime('now'), 'EUR');
     $this->assertTrue(RateFilterUtil::matches($rate, array('onDate' => new \DateTime('now'))));
     $this->assertFalse(RateFilterUtil::matches($rate, array('onDate' => new \DateTime('tomorrow'))));
     $this->assertTrue(RateFilterUtil::matches($rate, array('dateTo' => new \DateTime('tomorrow'))));
     $this->assertFalse(RateFilterUtil::matches($rate, array('dateFrom' => new \DateTime('tomorrow'))));
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function all(array $criteria = array())
 {
     if (count($criteria) == 0) {
         return $this->rates;
     } else {
         $result = array();
         /**
          * @var RateInterface $rate
          */
         foreach ($this->rates as $rate) {
             if (RateFilterUtil::matches($rate, $criteria)) {
                 $result[] = $rate;
             }
         }
         return $this->paginate($result, $criteria);
     }
 }