addressFormatRepository = new AddressFormatRepository(); $this->countryRepository = new CountryRepository(); $this->subdivisionRepository = new SubdivisionRepository(); $this->formatter = new PostalLabelFormatter($this->addressFormatRepository, $this->countryRepository, $this->subdivisionRepository); } /** * @covers ::format */ public function testMissingOriginCountryCode() { $this->expectException(\InvalidArgumentException::class); $address = new Address(); $this->formatter->format($address); } /** * @covers \CommerceGuys\Addressing\Formatter\PostalLabelFormatter */ public function testEmptyAddress() { $expectedLines = []; $formattedAddress = $this->formatter->format(new Address('US'), ['origin_country' => 'US']); $this->assertFormattedAddress($expectedLines, $formattedAddress); } /** * @covers \CommerceGuys\Addressing\Formatter\PostalLabelFormatter */ public function testUnitedStatesAddress() { $address = new Address(); $address = $address ->withCountryCode('US') ->withAdministrativeArea('CA') ->withLocality('Mt View') ->withPostalCode('94043') ->withAddressLine1('1098 Alta Ave'); // Test a US address formatted for sending from the US. $expectedLines = [ '1098 Alta Ave', 'MT VIEW, CA 94043', ]; $formattedAddress = $this->formatter->format($address, ['origin_country' => 'US']); $this->assertFormattedAddress($expectedLines, $formattedAddress); // Test a US address formatted for sending from France. $expectedLines = [ '1098 Alta Ave', 'MT VIEW, CA 94043', 'ÉTATS-UNIS - UNITED STATES', ]; $formattedAddress = $this->formatter->format($address, [ 'locale' => 'fr', 'origin_country' => 'FR', ]); $this->assertFormattedAddress($expectedLines, $formattedAddress); } /** * @covers \CommerceGuys\Addressing\Formatter\PostalLabelFormatter */ public function testJapanAddressShippedFromFrance() { $address = new Address(); $address = $address ->withCountryCode('JP') ->withAdministrativeArea('Hokkaido') ->withLocality('Some City') ->withAddressLine1('Address Line 1') ->withAddressLine2('Address Line 2') ->withPostalCode('04') ->withLocale('ja'); // Test a JP address formatted for sending from France. $expectedLines = [ 'JAPON - JAPAN', '〒04', '北海道Some City', 'Address Line 1', 'Address Line 2', ]; $formattedAddress = $this->formatter->format($address, [ 'locale' => 'fr', 'origin_country' => 'FR', ]); $this->assertFormattedAddress($expectedLines, $formattedAddress); } /** * @covers \CommerceGuys\Addressing\Formatter\PostalLabelFormatter */ public function testAddressLeadingPostPrefix() { $address = new Address(); $address = $address ->withCountryCode('CH') ->withLocality('Herrliberg') ->withPostalCode('8047'); // Domestic mail shouldn't have the postal code prefix added. $expectedLines = [ '8047 Herrliberg', ]; $formattedAddress = $this->formatter->format($address, ['origin_country' => 'CH']); $this->assertFormattedAddress($expectedLines, $formattedAddress); // International mail should have the postal code prefix added. $expectedLines = [ 'CH-8047 Herrliberg', 'SWITZERLAND', ]; $formattedAddress = $this->formatter->format($address, ['origin_country' => 'FR']); $this->assertFormattedAddress($expectedLines, $formattedAddress); } /** * Asserts that the formatted address is valid. * * @param array $expectedLines * @param string $formattedAddress */ protected function assertFormattedAddress(array $expectedLines, $formattedAddress) { $expectedLines = implode("\n", $expectedLines); $this->assertEquals($expectedLines, $formattedAddress); } } __halt_compiler();----SIGNATURE:----Eu+0ZWb/3OTOgQYo0Cod1UzfBFQEzcS5WI6iRXyJq3luJvbnW8nxmMgL2Aohs3F/xUEGmrqSiLnVxP0mLOKg876D4O0nfrbv/l7W7680M6B9Y2Bkn6NOWXHcc4CMxlIPKQwxNsfqFcVBju+HRKs6xk4rjXvcHuaSrzhXxsG/5T+/844qLym3LJtu4O45LLLDaKhI2OUlw6HHpC2yqSYp2YO5hhbHq7Na9G0KalhRmhMo6x0DbA+5+VvjGJ5uDFS/8ML4gvTFqVlv/CczBsB8ivl8kB5pcwMhO+INvG48RXIh00JkNMqomahUNWDSVEZWtY17SzHoVjbjsoKEHWiFDi0+sXCdgDxjUedaU5/y+udeMx47N1tHpyyTO1shjBJfgCxOqGVRyPN9dWTchA0QeGRxe+KNNOEVgkLZqnFiR2YRpkTVMGkL90oAkxzJpwGDH6tslayxwfT5fOKsqFSKsqdUFaMeMuTGxy8DQq8gTcvub7phy1Y0rBV9eIoxglUWwghLXZw+QRI0nj9cnWf2xuAHq/EQI5MmjMFybajkI7DvltWOfr4//aeBv0Q1Zjco9fWjIvsp6KgS9xkIBwqJKrnCjK9FKqX3JwS+YeRCFhfVipWpWtRu/l9lnRG/jYaK38B6Gs3xoDx5MMWz2N4KqNTDQ8gQiEyWb5Yl65/vp9A=----ATTACHMENT:----NTY4MTIwMzMxNjU2NzE3OCA4OTc3NjY1NDI2MTExODkyIDc4NDA3MDkwMzU4NzQyMDQ=