/**
  * @covers ::process
  * @covers ::processCallback
  */
 function testProcess()
 {
     $cache_contexts = Cache::mergeContexts(['baz', 'qux']);
     $cache_tags = Cache::mergeTags(['foo', 'bar']);
     $map = [['100', TRUE, LanguageInterface::TYPE_CONTENT, '€100.00'], ['100.7654', TRUE, LanguageInterface::TYPE_CONTENT, '€100.77'], ['1.99', TRUE, LanguageInterface::TYPE_CONTENT, '€1.99'], ['2.99', TRUE, LanguageInterface::TYPE_CONTENT, '€2.99']];
     $currency = $this->getMock(CurrencyInterface::class);
     $currency->expects($this->any())->method('formatAmount')->willReturnMap($map);
     $currency->expects($this->atLeastOnce())->method('getCacheContexts')->willReturn($cache_contexts);
     $currency->expects($this->atLeastOnce())->method('getCacheTags')->willReturn($cache_tags);
     $this->currencyStorage->expects($this->any())->method('load')->with('EUR')->willReturn($currency);
     $this->input->expects($this->any())->method('parseAmount')->will($this->returnArgument(0));
     $langcode = $this->randomMachineName(2);
     $tokens_valid = ['[currency-localize:EUR:100]' => '€100.00', '[currency-localize:EUR:100.7654]' => '€100.77', '[currency-localize:EUR:1.99]' => '€1.99', '[currency-localize:EUR:2.99]' => '€2.99'];
     $tokens_invalid = ['[currency-localize]', '[currency-localize:]', '[currency-localize::]', '[currency-localize:EUR]', '[currency-localize:123:456]', '[currency-localize:123]'];
     foreach ($tokens_valid as $token => $replacement) {
         $result = $this->sut->process($token, $langcode);
         $this->assertInstanceOf(FilterProcessResult::class, $result);
         $this->assertSame($replacement, $result->getProcessedText());
         $this->assertSame($cache_contexts, $result->getCacheContexts());
         $this->assertSame($cache_tags, $result->getCacheTags());
     }
     foreach ($tokens_invalid as $token) {
         $result = $this->sut->process($token, $langcode);
         $this->assertInstanceOf(FilterProcessResult::class, $result);
         $this->assertSame($token, $result->getProcessedText());
         $this->assertEmpty($result->getCacheContexts());
         $this->assertEmpty($result->getCacheTags());
     }
 }
 /**
  * @covers ::process
  * @covers ::processCallback
  */
 public function testProcess()
 {
     $cache_contexts = Cache::mergeContexts(['baz', 'qux']);
     $cache_tags = Cache::mergeTags(['foo', 'bar']);
     $currency_code_from = 'EUR';
     $currency_code_to = 'NLG';
     $rate = '2.20371';
     $exchange_rate_provider_id = 'foo_bar';
     $exchange_rate = new ExchangeRate($currency_code_from, $currency_code_to, $rate, $exchange_rate_provider_id);
     $exchange_rate->addCacheContexts($cache_contexts);
     $exchange_rate->addCacheTags($cache_tags);
     $this->input->expects($this->any())->method('parseAmount')->will($this->returnArgument(0));
     $this->exchangeRateProvider->expects($this->any())->method('load')->with($currency_code_from, $currency_code_to)->willReturn($exchange_rate);
     $langcode = $this->randomMachineName(2);
     $tokens_valid = ['[currency:EUR:NLG]' => '2.20371', '[currency:EUR:NLG:1]' => '2.20371', '[currency:EUR:NLG:2]' => '4.40742'];
     $tokens_invalid = ['[currency]', '[currency:]', '[currency::]', '[currency:EUR]', '[currency:EUR:123]', '[currency:123:EUR]', '[currency:123]'];
     foreach ($tokens_valid as $token => $replacement) {
         $result = $this->sut->process($token, $langcode);
         $this->assertInstanceOf(FilterProcessResult::class, $result);
         $this->assertSame($replacement, $result->getProcessedText());
         $this->assertSame($cache_contexts, $result->getCacheContexts());
         $this->assertSame($cache_tags, $result->getCacheTags());
     }
     foreach ($tokens_invalid as $token) {
         $result = $this->sut->process($token, $langcode);
         $this->assertInstanceOf(FilterProcessResult::class, $result);
         $this->assertSame($token, $result->getProcessedText());
         $this->assertEmpty($result->getCacheContexts());
         $this->assertEmpty($result->getCacheTags());
     }
 }
 /**
  * @covers ::validateRoundingStep
  * @dataProvider providerTestValidateRoundingStep
  */
 public function testValidateRoundingStep($valid, $input_value, $parsed_value)
 {
     $element = array('#value' => $input_value);
     $form = array();
     $form_state = $this->getMock(FormStateInterface::class);
     $this->inputParser->expects($this->once())->method('parseAmount')->with($input_value)->willReturn($parsed_value);
     if (!$valid) {
         $form_state->expects($this->once())->method('setError')->with($element, 'The rounding step is not numeric.');
     } else {
         $form_state->expects($this->never())->method('setError');
         $form_state->expects($this->never())->method('setErrorByName');
     }
     $form_state->expects($this->once())->method('setValueForElement')->with($element, $parsed_value);
     $this->sut->validateRoundingStep($element, $form_state, $form);
 }