CommerceGuys\Addressing\Tests\Formatter\DefaultFormatterTest::testTaiwanAddress PHP Method

testTaiwanAddress() public method

public testTaiwanAddress ( )
    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('Taipei City')->withLocality("Da'an District")->withAddressLine1('Sec. 3 Hsin-yi Rd.')->withPostalCode('106')->withOrganization('Giant <h2>Bike</h2> Store')->withGivenName('Te-Chiang')->withFamilyName('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 &lt;h2&gt;Bike&lt;/h2&gt; Store</span><br>', '<span class="family-name">Liu</span> <span class="given-name">Te-Chiang</span>', '</p>'];
        $htmlAddress = $this->formatter->format($address);
        $this->assertFormattedAddress($expectedHtmlLines, $htmlAddress);
        $expectedTextLines = ['台灣', '106', '台北市大安區', 'Sec. 3 Hsin-yi Rd.', 'Giant Bike Store', 'Liu Te-Chiang'];
        $this->formatter->setOption('html', false);
        $textAddress = $this->formatter->format($address);
        $this->assertFormattedAddress($expectedTextLines, $textAddress);
    }