I'm using PHP 5.3 and SimpleTest, but more general answers are welcome. Each plug-in will be a class which extends an abstract class... how do I test that this interface works properly? Do I have to create several plug-ins and test them? Or is there a more satisfying way?
As an example, imagine writing something to represent money. Users can extend this with different currency classes.
abstract class Money
{
private static $symbol;
private static $num_decimals;public function __construct($amount) { ...}
public function __toString() { ... }
}
Then a plugin would look like this:
class GBPound extends Money
{
private static $symbol = "£";
private static $num_decimals = 2;
}
Perhaps I could emulate multiple inheritance, extending the UnitTest class and the money class, but that could get messy!
It's so difficult because unit testing is about testing the interface, but the class itself is the plug-in interface.