コード例 #1
0
 /**
  * @covers ::submitForm
  */
 function testSubmitForm()
 {
     $this->currency->expects($this->once())->method('delete');
     $form = array();
     $form_state = $this->getMock(FormStateInterface::class);
     $form_state->expects($this->once())->method('setRedirectUrl');
     $this->sut->submitForm($form, $form_state);
 }
コード例 #2
0
 /**
  * @covers ::validateForm
  * @dataProvider providerTestValidate
  */
 public function testValidateForm($input_value_language_code, $input_value_country_code, $locale, $currency_locale_is_new, $locale_is_used)
 {
     $form = array('locale' => array('#foo' => $this->randomMachineName()));
     $form_state = $this->getMock(FormStateInterface::class);
     $form_state->expects($this->any())->method('getValues')->willReturn(array('country_code' => $input_value_country_code, 'language_code' => $input_value_language_code));
     $this->currencyLocale->expects($this->atLeastOnce())->method('isNew')->willReturn($currency_locale_is_new);
     if ($currency_locale_is_new) {
         if ($locale_is_used) {
             $loaded_currency_locale = $this->getMock(CurrencyLocaleInterface::class);
             $this->currencyLocaleStorage->expects($this->once())->method('load')->with($locale)->willReturn($loaded_currency_locale);
             $form_state->expects($this->once())->method('setError')->with($form['locale'], 'A pattern for this locale already exists.');
         } else {
             $this->currencyLocaleStorage->expects($this->once())->method('load')->with($locale)->willReturn(FALSE);
             $form_state->expects($this->never())->method('setError');
         }
     } else {
         $this->currencyLocaleStorage->expects($this->never())->method('load');
         $form_state->expects($this->never())->method('setError');
     }
     $this->sut->validateForm($form, $form_state);
 }