all...my subject says it all. I'm trying to do a test that actually intentionally makes "Invalid argument supplied for foreach()" happen. I'm trying to get PHPUnit to expect it, but...nope, my tests still come to a screeching halt. The reason: "invalid argument supplied for foreach()" right at the exact point where I'm telling it that it's going to happen.
At the top of my file I have:
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Error\Error;
use PHPUnit\Framework\Error\Notice;
use PHPUnit\Framework\Error\Warning;
My class declaration starts with:
Class flirzelkwerpTest extends TestCase {
Here are the lines in the test file:
// Let's try to add nothing.
// (It should throw an error because of "Invalid argument supplied for foreach()" in barabajagal.php.)
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid argument supplied for foreach()');
$resp = $barabajagal->add();
The error happens on that last line. Shouldn't the previous two lines be telling PHPUnit, "Hey, bub, I expect there to be an error here, and this is the message you should be getting verbatim"??
We're using PHP 7.3.4 and PHPUnit 8.3.2.