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

testElSalvadorAddress() public method

    public function testElSalvadorAddress()
    {
        $address = new Address();
        $address = $address->withCountryCode('SV')->withAdministrativeArea('Ahuachapán')->withLocality('Ahuachapán')->withAddressLine1('Some Street 12');
        $expectedHtmlLines = ['<p translate="no">', '<span class="address-line1">Some Street 12</span><br>', '<span class="locality">Ahuachapán</span><br>', '<span class="administrative-area">Ahuachapán</span><br>', '<span class="country">El Salvador</span>', '</p>'];
        $htmlAddress = $this->formatter->format($address);
        $this->assertFormattedAddress($expectedHtmlLines, $htmlAddress);
        $expectedTextLines = ['Some Street 12', 'Ahuachapán', 'Ahuachapán', 'El Salvador'];
        $this->formatter->setOption('html', false);
        $textAddress = $this->formatter->format($address);
        $this->assertFormattedAddress($expectedTextLines, $textAddress);
        $address = $address->withPostalCode('CP 2101');
        $expectedHtmlLines = ['<p translate="no">', '<span class="address-line1">Some Street 12</span><br>', '<span class="postal-code">CP 2101</span>-<span class="locality">Ahuachapán</span><br>', '<span class="administrative-area">Ahuachapán</span><br>', '<span class="country">El Salvador</span>', '</p>'];
        $this->formatter->setOption('html', true);
        $htmlAddress = $this->formatter->format($address);
        $this->assertFormattedAddress($expectedHtmlLines, $htmlAddress);
        $expectedTextLines = ['Some Street 12', 'CP 2101-Ahuachapán', 'Ahuachapán', 'El Salvador'];
        $this->formatter->setOption('html', false);
        $textAddress = $this->formatter->format($address);
        $this->assertFormattedAddress($expectedTextLines, $textAddress);
    }