/**
  * @covers ::label
  * @covers ::getCountryManager
  *
  * @depends testGetLocale
  */
 function testLabel()
 {
     $languages = LanguageManager::getStandardLanguageList();
     $language_code = array_rand($languages);
     $country_code_a = strtoupper($this->randomMachineName());
     $country_code_b = strtoupper($this->randomMachineName());
     $country_code_c = strtoupper($this->randomMachineName());
     $country_list = [$country_code_a => $this->randomMachineName(), $country_code_b => $this->randomMachineName(), $country_code_c => $this->randomMachineName()];
     $this->countryManager->expects($this->atLeastOnce())->method('getList')->willReturn($country_list);
     $this->sut->setLocale($language_code, $country_code_b);
     $this->assertInstanceOf(TranslatableMarkup::class, $this->sut->label());
 }
 /**
  * @covers ::form
  */
 public function testForm()
 {
     $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('getLanguageCode')->willReturn($language_code);
     $this->currencyLocale->expects($this->once())->method('getCountryCode')->willReturn($country_code);
     $this->currencyLocale->expects($this->once())->method('getPattern')->willReturn($pattern);
     $this->currencyLocale->expects($this->once())->method('getDecimalSeparator')->willReturn($decimal_separator);
     $this->currencyLocale->expects($this->once())->method('getGroupingSeparator')->willReturn($grouping_separator);
     $language = $this->getMock(LanguageInterface::class);
     $this->currencyLocale->expects($this->any())->method('language')->willReturn($language);
     $country_list = array($this->randomMachineName() => $this->randomMachineName());
     $this->countryManager->expects($this->atLeastOnce())->method('getList')->willReturn($country_list);
     $form = array();
     $form_state = $this->getMock(FormStateInterface::class);
     $build = $this->sut->form($form, $form_state);
     unset($build['langcode']);
     unset($build['#process']);
     $expected['language_code'] = ['#default_value' => $language_code, '#empty_value' => '', '#options' => array('af' => 'Afrikaans', 'sq' => 'Albanian', 'am' => 'Amharic', 'ar' => 'Arabic', 'hy' => 'Armenian', 'ast' => 'Asturian', 'az' => 'Azerbaijani', 'ms' => 'Bahasa Malaysia', 'eu' => 'Basque', 'be' => 'Belarusian', 'bn' => 'Bengali', 'bs' => 'Bosnian', 'bg' => 'Bulgarian', 'my' => 'Burmese', 'ca' => 'Catalan', 'zh-hans' => 'Chinese, Simplified', 'zh-hant' => 'Chinese, Traditional', 'hr' => 'Croatian', 'cs' => 'Czech', 'da' => 'Danish', 'nl' => 'Dutch', 'dz' => 'Dzongkha', 'en' => 'English', 'eo' => 'Esperanto', 'et' => 'Estonian', 'fo' => 'Faeroese', 'fil' => 'Filipino', 'fi' => 'Finnish', 'fr' => 'French', 'fy' => 'Frisian, Western', 'gl' => 'Galician', 'ka' => 'Georgian', 'de' => 'German', 'el' => 'Greek', 'gu' => 'Gujarati', 'ht' => 'Haitian Creole', 'he' => 'Hebrew', 'hi' => 'Hindi', 'hu' => 'Hungarian', 'is' => 'Icelandic', 'id' => 'Indonesian', 'ga' => 'Irish', 'it' => 'Italian', 'ja' => 'Japanese', 'jv' => 'Javanese', 'kn' => 'Kannada', 'kk' => 'Kazakh', 'km' => 'Khmer', 'ko' => 'Korean', 'ku' => 'Kurdish', 'ky' => 'Kyrgyz', 'lo' => 'Lao', 'lv' => 'Latvian', 'lt' => 'Lithuanian', 'xx-lolspeak' => 'Lolspeak', 'mk' => 'Macedonian', 'mg' => 'Malagasy', 'ml' => 'Malayalam', 'mr' => 'Marathi', 'mn' => 'Mongolian', 'ne' => 'Nepali', 'se' => 'Northern Sami', 'nb' => 'Norwegian Bokmål', 'nn' => 'Norwegian Nynorsk', 'oc' => 'Occitan', 'fa' => 'Persian, Farsi', 'pl' => 'Polish', 'pt-br' => 'Portuguese, Brazil', 'pt-pt' => 'Portuguese, Portugal', 'pa' => 'Punjabi', 'ro' => 'Romanian', 'ru' => 'Russian', 'sco' => 'Scots', 'gd' => 'Scots Gaelic', 'sr' => 'Serbian', 'si' => 'Sinhala', 'sk' => 'Slovak', 'sl' => 'Slovenian', 'es' => 'Spanish', 'sw' => 'Swahili', 'sv' => 'Swedish', 'gsw-berne' => 'Swiss German', 'ta' => 'Tamil', 'ta-lk' => 'Tamil, Sri Lanka', 'te' => 'Telugu', 'th' => 'Thai', 'bo' => 'Tibetan', 'tr' => 'Turkish', 'tyv' => 'Tuvan', 'uk' => 'Ukrainian', 'ur' => 'Urdu', 'ug' => 'Uyghur', 'vi' => 'Vietnamese', 'cy' => 'Welsh'), '#required' => TRUE, '#type' => 'select'];
     unset($build['language_code']['#title']);
     $expected['country_code'] = ['#default_value' => $country_code, '#empty_value' => '', '#options' => $country_list, '#required' => TRUE, '#type' => 'select'];
     unset($build['country_code']['#title']);
     $expected['formatting'] = ['#open' => TRUE, '#type' => 'details'];
     unset($build['formatting']['#title']);
     $expected['formatting']['decimal_separator'] = ['#default_value' => $decimal_separator, '#maxlength' => 255, '#required' => TRUE, '#size' => 3, '#type' => 'textfield'];
     unset($build['formatting']['decimal_separator']['#title']);
     $expected['formatting']['grouping_separator'] = ['#default_value' => $grouping_separator, '#maxlength' => 255, '#size' => 3, '#type' => 'textfield'];
     unset($build['formatting']['grouping_separator']['#title']);
     $expected['formatting']['pattern'] = ['#default_value' => $pattern, '#maxlength' => 255, '#type' => 'textfield'];
     unset($build['formatting']['pattern']['#title']);
     unset($build['formatting']['pattern']['#description']);
     $expected['#after_build'] = ['::afterBuild'];
     $this->assertSame($expected, $build);
 }