You are here

public function CurrencyLocaleFormTest::testCopyFormValuesToEntity in Currency 8.3

@covers ::copyFormValuesToEntity

File

tests/src/Unit/Entity/CurrencyLocale/CurrencyLocaleFormTest.php, line 139

Class

CurrencyLocaleFormTest
@coversDefaultClass \Drupal\currency\Entity\CurrencyLocale\CurrencyLocaleForm

Namespace

Drupal\Tests\currency\Unit\Entity\CurrencyLocale

Code

public function testCopyFormValuesToEntity() {
  $language_code = $this
    ->randomMachineName();
  $country_code = $this
    ->randomMachineName();
  $pattern = $this
    ->randomMachineName();
  $decimal_separator = $this
    ->randomMachineName();
  $grouping_separator = $this
    ->randomMachineName();
  $this->currencyLocale
    ->expects($this
    ->once())
    ->method('setLocale')
    ->with($language_code, $country_code);
  $this->currencyLocale
    ->expects($this
    ->once())
    ->method('setPattern')
    ->with($pattern);
  $this->currencyLocale
    ->expects($this
    ->once())
    ->method('setDecimalSeparator')
    ->with($decimal_separator);
  $this->currencyLocale
    ->expects($this
    ->once())
    ->method('setGroupingSeparator')
    ->with($grouping_separator);
  $form = array();
  $form_state = $this
    ->createMock(FormStateInterface::class);
  $form_state
    ->expects($this
    ->atLeastOnce())
    ->method('getValues')
    ->willReturn(array(
    'language_code' => $language_code,
    'country_code' => $country_code,
    'pattern' => $pattern,
    'decimal_separator' => $decimal_separator,
    'grouping_separator' => $grouping_separator,
  ));
  $method = new \ReflectionMethod($this->sut, 'copyFormValuesToEntity');
  $method
    ->setAccessible(TRUE);
  $method
    ->invokeArgs($this->sut, array(
    $this->currencyLocale,
    $form,
    $form_state,
  ));
}