How can I write a custom assertion, like assertFoo($expected, $actual), that behaves like the built-in assertions with respect to the error "stack trace"?
I currently have the following method defined (within a class that extends PHPUnit_Framework_TestCase):
public static function assertFoo($expected, $actual) {
self::assertEquals($expected, $actual);
}
If I call this from a test and the test fails, I get two items in the call stack:
1) PreferencesTest::testSignupTeacher
Failed asserting that 5 matches expected 3.
/vagrant/myproject/tests/integration/PreferencesTest.php:17
/vagrant/myproject/tests/integration/PreferencesTest.php:136
Line 17 is where assertFoo() calls the built-in assertEquals() and fails; line 136 is there assertFoo() is called.
If I change the test to call assertEquals() directly, I only get one:
1) PreferencesTest::testSignupTeacher
Failed asserting that 3 is true.
/vagrant/myproject/tests/integration/PreferencesTest.php:136
There's some documentation in the manual, but it doesn't seem to cover this.