Skip to content
Advertisement

How to get PHPUnit testing working with a function that returns an IP?

I’m just new to TDD and I’ve installed PHPUnit with PhpStorm.

I have this class and function, and I want to test for the IP address match.

JavaScript

I’m trying to create the code for the test, and I’m not sure what to put in.

I have tried

JavaScript

But $test is undefined obviously.

What should I do next?

Tried suggestion given

JavaScript

But the error I get now is that

JavaScript

Advertisement

Answer

I fixed this similarly to how @hakre suggested,

JavaScript

I added ?? '127.0.0.1' to the end of that statement, and that fixed it.

Also just updated my test function to show only

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement