/** * @covers ::loadCurrency * @covers ::getCurrencyResourceDirectory * @covers ::createCurrencyFromJson * * @depends testListCurrencies */ public function testLoadCurrency() { foreach ($this->sut->listCurrencies() as $currencyCode) { $currency = $this->sut->loadCurrency($currencyCode); $this->assertInstanceOf(CurrencyInterface::class, $currency); foreach ($currency->getUsages() as $usage) { $this->assertInstanceOf(UsageInterface::class, $usage); } } }
/** * {@inheritdoc} */ public function getImportableCurrencies() { $existing_currencies = $this->currencyStorage->loadMultiple(); $currencies = []; foreach ($this->currencyResourceRepository->listCurrencies() as $currency_code) { if (!isset($existing_currencies[$currency_code])) { $currencies[$currency_code] = $this->createCurrencyFromRepository($currency_code); } } return $currencies; }
/** * @covers ::importCurrency * @covers ::createCurrencyFromRepository */ public function testImportCurrency() { $resource_repository = new ResourceRepository(); $currency_codes = $resource_repository->listCurrencies(); $currency_code = $currency_codes[array_rand($currency_codes)]; $currency = $this->getMock(CurrencyInterface::class); $this->currencyStorage->expects($this->atLeastOnce())->method('create')->with()->willReturn($currency); $this->sut->setConfigStorage($this->configStorage); $this->assertSame($currency, $this->sut->importCurrency($currency_code)); }