I tend to get beat up really badly whenever I have to do anything involving MAMP, the command line, OSX — basically anything environmental. I get the feeling I was supposed to learn this stuff when I was fourteen. Therefore, learning to run PHPUnit on MAMP has been painful for me, and I assumed all along that I was screwing up some … command line … thing.
Turns out, code is code. My problem was in the bootstrap.php that wp-cli created all along. Once I stopped staring off into the distance wondering why
phpunit wasn’t working, and got back to actually, you know, reading and writing code, I found the problems. I had to make two customizations, and I haven’t seen either one discussed in the popular tutorials for this subject. Here’s the gist:
First, I had to declare
$_tests_dir = '../../../../';, meaning that I have
includes installed one directory above WordPress itself.
Second, I had to change
require dirname( dirname( __FILE__ ) ) . '/the-name-of-your-plugin.php';, which wp-cli scaffolds for you, to
require dirname( dirname( __FILE__ ) ) . '/plugin.php';, which is what my plugin actually uses.
Good to go!