CommerceGuys\Addressing\Tests\Validator\Constraints\AddressFormatConstraintValidatorTest::testEmptyPostalCodeReportedAsGoodFormat PHP Method

testEmptyPostalCodeReportedAsGoodFormat() public method

    public function testEmptyPostalCodeReportedAsGoodFormat()
    {
        $address = new Address();
        $address = $address->withCountryCode('CL')->withAdministrativeArea('Antofagasta')->withLocality('San Pedro de Atacama')->withPostalCode('')->withAddressLine1('GUSTAVO LE PAIGE ST #159')->withGivenName('John')->withFamilyName('Smith');
        $this->validator->validate($address, $this->constraint);
        $this->assertNoViolation();
        // Now check for US addresses, which require a postal code. The following
        // address's postal code is wrong because it is missing a required field, not
        // because it doesn't match the expected postal code pattern.
        $address = new Address();
        $address = $address->withCountryCode('US')->withAdministrativeArea('CA')->withLocality('California')->withAddressLine1('1098 Alta Ave')->withGivenName('John')->withFamilyName('Smith');
        $this->validator->validate($address, $this->constraint);
        $this->buildViolation($this->constraint->notBlankMessage)->atPath('[postalCode]')->setInvalidValue(null)->assertRaised();
    }