protected function FixedRatesTest::prepareExchangeRates in Currency 8.3
Stores random exchange rates in the mocked config and returns them.
Return value
array An array of the same format as the return value of \Drupal\currency\Plugin\Currency\ExchangeRateProvider\FixedRates::loadAll().
5 calls to FixedRatesTest::prepareExchangeRates()
- FixedRatesTest::testDelete in tests/
src/ Unit/ Plugin/ Currency/ ExchangeRateProvider/ FixedRatesTest.php - @covers ::delete
- FixedRatesTest::testLoad in tests/
src/ Unit/ Plugin/ Currency/ ExchangeRateProvider/ FixedRatesTest.php - @covers ::save @covers ::load
- FixedRatesTest::testLoadConfiguration in tests/
src/ Unit/ Plugin/ Currency/ ExchangeRateProvider/ FixedRatesTest.php - @covers ::loadAll
- FixedRatesTest::testLoadMultiple in tests/
src/ Unit/ Plugin/ Currency/ ExchangeRateProvider/ FixedRatesTest.php - @covers ::loadMultiple
- FixedRatesTest::testSave in tests/
src/ Unit/ Plugin/ Currency/ ExchangeRateProvider/ FixedRatesTest.php - @covers ::save
File
- tests/
src/ Unit/ Plugin/ Currency/ ExchangeRateProvider/ FixedRatesTest.php, line 176
Class
- FixedRatesTest
- @coversDefaultClass \Drupal\currency\Plugin\Currency\ExchangeRateProvider\FixedRates
Namespace
Drupal\Tests\currency\Unit\Plugin\Currency\ExchangeRateProviderCode
protected function prepareExchangeRates() {
$rates = array(
'EUR' => array(
'DEM' => '1.95583',
'NLG' => '2.20371',
),
'NLG' => array(
'EUR' => '0.453780216',
),
);
$rates_data = array();
foreach ($rates as $currency_code_from => $currency_code_from_rates) {
foreach ($currency_code_from_rates as $currency_code_to => $rate) {
$rates_data[] = array(
'currency_code_from' => $currency_code_from,
'currency_code_to' => $currency_code_to,
'rate' => $rate,
);
}
}
$this->config = $this
->getMockBuilder(Config::class)
->disableOriginalConstructor()
->getMock();
$this->config
->expects($this
->any())
->method('get')
->with('rates')
->willReturn($rates_data);
$this->configFactory
->expects($this
->any())
->method('get')
->with('currency.exchanger.fixed_rates')
->willReturn($this->config);
$this->configFactory
->expects($this
->any())
->method('getEditable')
->with('currency.exchanger.fixed_rates')
->willReturn($this->config);
return array(
$rates,
$rates_data,
);
}