jsmitty12 / phpWhois

phpWhois general repository
GNU General Public License v2.0
56 stars 20 forks source link

Fixed the fixture loading function for unit tests #63

Closed stollr closed 4 years ago

stollr commented 4 years ago

The loadFixture function of the abstract HandlerTest used PHP's file function to load the fixture files. The problem is that 'Each line in the resulting array will include the line ending, unless FILE_IGNORE_NEW_LINES is used'[1]. An empty line in the fixture file will be represented by an array item consisting of "\n" instead of "".

But this differs from the real WhoisClient where explode("\n", $raw) is used to convert the raw result from the whois server to the array that will be parsed. This way empty lines will be represented by an empty string "" in the array.

At the end the parser uses other data in tests compared to real life.

stollr commented 4 years ago

Btw this is why tests are okay while in reality the responses for .de domains are not processed correctly (see #40).

jsmitty12 commented 4 years ago

Really good catch!

jsmitty12 commented 4 years ago

I'm including this work in #66 .