/**
  * Exception when rates are not loaded.
  *
  * @expectedException \ONGR\CurrencyExchangeBundle\Exception\RatesNotLoadedException
  */
 public function testException()
 {
     $this->repositoryMock->expects($this->any())->method('execute')->willReturn([]);
     $pool = $this->getCachePool();
     $pool->expects($this->any())->method('getItem')->with('ongr_currency')->willReturn($this->getCacheItem([]));
     $service = new CurrencyRatesService($this->getDriverMock('EUR', []), $this->esManagerMock, $pool, false);
     $service->setLogger($this->getLogger());
     $service->getRates();
 }
Exemplo n.º 2
0
 /**
  * Test for get().
  *
  * @param string $key
  * @param string $value
  * @param bool   $exception
  *
  * @dataProvider getDataSetForSet
  */
 public function testGet($key, $value, $exception)
 {
     if ($exception) {
         $this->repositoryMock->expects($this->once())->method('find')->will($this->returnValue(null));
     } else {
         $pair = new Pair();
         $pair->setId($key);
         $pair->setValue($value);
         $this->repositoryMock->expects($this->once())->method('find')->willReturn($pair);
     }
     $this->ormManagerMock->expects($this->once())->method('getRepository')->willReturn($this->repositoryMock);
     $pairStorage = $this->getPairStorage($this->ormManagerMock);
     $this->assertEquals($exception ? null : $value, $pairStorage->get($key));
 }