Re: testing return type of getters?
Posted: Wed Mar 18, 2009 8:26 pm
Not really. Not if this object must be passed to function (that you didn't write, such as the Authentication layer in ZF) that has a type-hint on it. You're not going to start editing ZF to remove its type-hints, so you make sure your own code is returning the appropriate type. Having the correct methods does not make it the correct type.Jenk wrote:Which is implicitly tested by calling isAuthenticated(). I wouldn't test for the interface then.
However, I got confused and thought we were talking more about primitive types. For example, 0, null, "" and false all act the same in boolean context. But sometimes the return type is very important (such as in strpos() or readdir()). In those cases you definitely should be checking the type.