/**
  * @dataProvider formatDataProvider
  * @param string $format
  * @param string $expected
  * @param bool $formatByCountry
  */
 public function testFormat($format, $expected, $formatByCountry = false)
 {
     $address = new AddressStub();
     $locale = 'en';
     $country = 'CA';
     $addressFormats = array($country => array(LocaleSettings::ADDRESS_FORMAT_KEY => $format));
     $this->localeSettings->expects($this->once())->method('getAddressFormats')->will($this->returnValue($addressFormats));
     $this->localeSettings->expects($this->once())->method('isFormatAddressByAddressCountry')->will($this->returnValue($formatByCountry));
     $this->localeSettings->expects($this->once())->method('getCountry')->will($this->returnValue($country));
     if ($formatByCountry) {
         $this->localeSettings->expects($this->once())->method('getLocaleByCountry')->with($address->getCountryIso2())->will($this->returnValue($locale));
     } else {
         $this->localeSettings->expects($this->once())->method('getLocaleByCountry')->with($country)->will($this->returnValue($locale));
     }
     $this->nameFormatter->expects($this->once())->method('format')->with($address, $locale)->will($this->returnValue('Formatted User NAME'));
     $this->assertEquals($expected, $this->addressFormatter->format($address));
 }
예제 #2
0
 /**
  * @dataProvider formatDataProvider
  * @param string $format
  * @param string $regionCode
  * @param string $expected
  * @param bool $formatByCountry
  * @param string $street2
  * @param string|null $separator
  */
 public function testFormat($format, $regionCode, $expected, $formatByCountry = false, $street2 = 'apartment 10', $separator = "\n")
 {
     $address = new AddressStub($street2);
     $address->setRegionCode($regionCode);
     $locale = 'en';
     $country = 'CA';
     $addressFormats = [$country => [LocaleSettings::ADDRESS_FORMAT_KEY => $format]];
     $this->localeSettings->expects($this->once())->method('getAddressFormats')->will($this->returnValue($addressFormats));
     $this->localeSettings->expects($this->once())->method('isFormatAddressByAddressCountry')->will($this->returnValue($formatByCountry));
     $this->localeSettings->expects($this->once())->method('getCountry')->will($this->returnValue($country));
     if ($formatByCountry) {
         $this->localeSettings->expects($this->once())->method('getLocaleByCountry')->with($address->getCountryIso2())->will($this->returnValue($locale));
     } else {
         $this->localeSettings->expects($this->once())->method('getLocaleByCountry')->with($country)->will($this->returnValue($locale));
     }
     $this->nameFormatter->expects($this->once())->method('format')->with($address, $locale)->will($this->returnValue('Formatted User NAME'));
     $this->assertEquals($expected, $this->addressFormatter->format($address, null, $separator));
 }