PHPUnit, Testing "Behaves Like A..."

I have a series of PHPUnit tests to validate a class, "Class A". I have another class, "Class B" which extends Class A.

Is there a good way to test that "Class B passes Class A's tests", or in other words "Class B behaves like Class A" without duplicating the test code?

I could test for the extends (using instanceof), but that seems like a misleading test. I care that it behaves like Class A, not that it extends Class A, right? or wrong?

Answers


Just extend the PHPUnit test case of class A, for class B, that should do it.


Need Your Help

Customise displayed message in Slack from SVN integration

perl svn slack-api slack

I'm pretty new to Slack. I've created a team, and I've added an integration with our SVN repository. I've set up a "post-commit" script and I get a notification in the intended Slack channel. All i...

IE slows down animated GIFs with more than 6-8 FPS. Is there a fix or a cross-browser alternative (except flash)?

javascript internet-explorer animation gif animated-gif

Honestly, until now I never noticed, but IE actually slows animated GIFs with more than 6-8 FPS (12-16ms/frame) down. For example, open this GIF in IE and in Chrome - you will see the difference: