You are here

public function CurrencyLocaleImportFormTest::testSubmitFormImportEdit in Currency 8.3

Same name in this branch
  1. 8.3 tests/src/Unit/Controller/CurrencyLocaleImportFormTest.php \Drupal\Tests\currency\Unit\Controller\CurrencyLocaleImportFormTest::testSubmitFormImportEdit()
  2. 8.3 tests/src/Unit/Form/CurrencyLocaleImportFormTest.php \Drupal\Tests\currency\Unit\Form\CurrencyLocaleImportFormTest::testSubmitFormImportEdit()

@covers ::submitForm

File

tests/src/Unit/Form/CurrencyLocaleImportFormTest.php, line 182

Class

CurrencyLocaleImportFormTest
@coversDefaultClass \Drupal\currency\Form\CurrencyLocaleImportForm

Namespace

Drupal\Tests\currency\Unit\Form

Code

public function testSubmitFormImportEdit() {
  $locale = $this
    ->randomMachineName();
  $url = new Url($this
    ->randomMachineName());
  $currency_locale = $this
    ->createMock(CurrencyLocaleInterface::class);
  $currency_locale
    ->expects($this
    ->atLeastOnce())
    ->method('toUrl')
    ->with('edit-form')
    ->willReturn($url);
  $this->configImporter
    ->expects($this
    ->once())
    ->method('importCurrencyLocale')
    ->with($locale)
    ->willReturn($currency_locale);
  $form = [
    'actions' => [
      'import' => [
        '#name' => 'import',
      ],
      'import_edit' => [
        '#name' => 'import_edit',
      ],
    ],
  ];
  $form_state = $this
    ->createMock(FormStateInterface::class);
  $form_state
    ->expects($this
    ->atLeastOnce())
    ->method('getValues')
    ->willReturn([
    'locale' => $locale,
  ]);
  $form_state
    ->expects($this
    ->atLeastOnce())
    ->method('getTriggeringElement')
    ->willReturn($form['actions']['import_edit']);
  $form_state
    ->expects($this
    ->atLeastOnce())
    ->method('setRedirectUrl');
  $this->sut
    ->submitForm($form, $form_state);
}