I'm working on a PHPUnit test for 3rd party code that does an fgets() command and waits for input, which basically blocks my unit test. Does anyone have a suggestion on how to pass data to fgets() from a unit test?
For example sake, what I'd like to do is something like this:
<?php
$myinput = "GO SOUTH\n";
magicallyQueueIntoSTDINBuffer($myinput);
assertTrue($game->listen() === "You enter the cave"); // Right now, this halts everything.
?>
The above assumes that $game->listen() listens to STDIN, hears "GO SOUTH" and returns "You enter the cave"
The real code is more complicated, but the above puts the essence into context.