I have added a test data point containing a null byte to the nonnumericStrings data provider method to cover the case of a null byte passed to DateTime::createFromFormat in \Spoorsny\ValueObjects\SouthAfricanId::assertStartsWithDate() method. DateTime::createFromFormat raises a ValueError in case a null byte is passed to it. Using a try-catch in assertStartsWithDate to cover that condition is never covered completely by tests, because the null byte is always detected by assertIsNumeric firstly. A comment needs to be added to the data provider method to explain that.
A separate explit test could use a null byte in the date segment, then assert that the exception message thrown by the test for nonnumeric strings is received.
I have added a test data point containing a null byte to the nonnumericStrings data provider method to cover the case of a null byte passed to
DateTime::createFromFormat
in \Spoorsny\ValueObjects\SouthAfricanId::assertStartsWithDate() method. DateTime::createFromFormat raises a ValueError in case a null byte is passed to it. Using a try-catch in assertStartsWithDate to cover that condition is never covered completely by tests, because the null byte is always detected by assertIsNumeric firstly. A comment needs to be added to the data provider method to explain that.A separate explit test could use a null byte in the date segment, then assert that the exception message thrown by the test for nonnumeric strings is received.