public function CurrencyImportFormTest::testSubmitFormImportEdit in Currency 8.3
Same name in this branch
- 8.3 tests/src/Unit/Controller/CurrencyImportFormTest.php \Drupal\Tests\currency\Unit\Controller\CurrencyImportFormTest::testSubmitFormImportEdit()
- 8.3 tests/src/Unit/Form/CurrencyImportFormTest.php \Drupal\Tests\currency\Unit\Form\CurrencyImportFormTest::testSubmitFormImportEdit()
@covers ::submitForm
File
- tests/
src/ Unit/ Form/ CurrencyImportFormTest.php, line 181
Class
- CurrencyImportFormTest
- @coversDefaultClass \Drupal\currency\Form\CurrencyImportForm
Namespace
Drupal\Tests\currency\Unit\FormCode
public function testSubmitFormImportEdit() {
$currency_code = $this
->randomMachineName();
$url = new Url($this
->randomMachineName());
$currency = $this
->createMock(CurrencyInterface::class);
$currency
->expects($this
->atLeastOnce())
->method('toUrl')
->with('edit-form')
->willReturn($url);
$this->configImporter
->expects($this
->once())
->method('importCurrency')
->with($currency_code)
->willReturn($currency);
$form = [
'actions' => [
'import' => [
'#name' => 'import',
],
'import_edit' => [
'#name' => 'import_edit',
],
],
];
$form_state = $this
->createMock(FormStateInterface::class);
$form_state
->expects($this
->atLeastOnce())
->method('getValues')
->willReturn([
'currency_code' => $currency_code,
]);
$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);
}