Esempio n. 1
0
 /**
  * @covers ::getValueOptions
  */
 public function testGetValueOptionsFormatsValues()
 {
     $this->addressService->expects($this->once())->method('getCountryCodes')->will($this->returnValue(['US', 'DE']));
     $this->countryCodeFormatter->expects($this->any())->method('format')->will($this->returnCallback(function ($countryCode) {
         if ($countryCode === 'US') {
             return 'United States';
         }
         return 'Germany';
     }));
     $countrySelect = new CountrySelect($this->addressService, $this->countryCodeFormatter);
     $this->assertSame(['US' => 'United States', 'DE' => 'Germany'], $countrySelect->getValueOptions());
 }
Esempio n. 2
0
 public function getValueOptions()
 {
     if ($this->valueOptions !== null) {
         return $this->valueOptions;
     }
     $countryCodes = $this->addressService->getCountryCodes();
     $valueOptions = [];
     foreach ($countryCodes as $countryCode) {
         $valueOptions[$countryCode] = $this->countryCodeFormatter->format($countryCode);
     }
     $this->setValueOptions($valueOptions);
     return $this->valueOptions;
 }
 /**
  * @covers ::format
  */
 public function testFormatThrowsExceptionOnInvalidCountryCode()
 {
     $this->setExpectedException('UnexpectedValueException', 'Invalid country code provided: "foobar"');
     $formatter = new CountryCodeFormatter('en-US');
     $formatter->format('foobar');
 }