Closed ghost closed 4 years ago
I'd love to write the unit tests as well, but I'm not yet well versed in writing them. I just wanted to point out these small improvement possibilities and rather than just opening a new issue I wanted to show the changes in code.
Hi, I think it's possible for someone to pass the validator if the user of your package doesn't validate tax ids on their own as well. Specifically the \DragonBe\Vies\Vies instance method validate Vat always checks if the supplied $vatNumber is in the VIES_TEST_VAT_NRS array if so it performs the validation. Meaning someone could pass the valid 100 code and if a user doesn't perform any other checks the VAT number would be considered valid.
I propose an instance variable $allowTestCodes is added, with 3 methods supporting the turning of its state to true, false or getting the current state. In thing the flag should be turned of by default, this way only development environments are effected.
I also propose all error codes are included in the VIES_TEST_VAT_NRS. For instance I use a custom wrapper with custom error codes based on the error code returned, this allows me to provide localized translations of the error code and it would be nice to be able to test them without having to change the core files.