/** * @covers \CommerceGuys\Addressing\Formatter\DefaultFormatter * * @uses \CommerceGuys\Addressing\Collection\LazySubdivisionCollection * @uses \CommerceGuys\Addressing\Model\Address * @uses \CommerceGuys\Addressing\Model\AddressFormat * @uses \CommerceGuys\Addressing\Model\FormatStringTrait * @uses \CommerceGuys\Addressing\Model\Subdivision * @uses \CommerceGuys\Addressing\Repository\AddressFormatRepository * @uses \CommerceGuys\Addressing\Repository\CountryRepository * @uses \CommerceGuys\Addressing\Repository\SubdivisionRepository * @uses \CommerceGuys\Addressing\Repository\DefinitionTranslatorTrait */ public function testTaiwanAddress() { // Real addresses in the major-to-minor order would be completely in // Traditional Chinese. That's not the case here, for readability. $address = new Address(); $address = $address->withCountryCode('TW')->withAdministrativeArea('TW-TPE')->withLocality('TW-TPE-e3cc33')->withAddressLine1('Sec. 3 Hsin-yi Rd.')->withPostalCode('106')->withOrganization('Giant <h2>Bike</h2> Store')->withRecipient('Mr. Liu')->withLocale('zh-hant'); $this->formatter->setLocale('zh-hant'); // Test adding a new wrapper attribute, and passing a value as an array. $options = ['translate' => 'no', 'class' => ['address', 'postal-address']]; $this->formatter->setOption('html_attributes', $options); $expectedHtmlLines = ['<p translate="no" class="address postal-address">', '<span class="country">台灣</span><br>', '<span class="postal-code">106</span><br>', '<span class="administrative-area">台北市</span><span class="locality">大安區</span><br>', '<span class="address-line1">Sec. 3 Hsin-yi Rd.</span><br>', '<span class="organization">Giant <h2>Bike</h2> Store</span><br>', '<span class="recipient">Mr. Liu</span>', '</p>']; $htmlAddress = $this->formatter->format($address); $this->assertFormattedAddress($expectedHtmlLines, $htmlAddress); $expectedTextLines = ['台灣', '106', '台北市大安區', 'Sec. 3 Hsin-yi Rd.', 'Giant Bike Store', 'Mr. Liu']; $this->formatter->setOption('html', false); $textAddress = $this->formatter->format($address); $this->assertFormattedAddress($expectedTextLines, $textAddress); }