The solution was easy (but took me a lot..)
I checked that the class was declared with get_declared_classes()
.
Then I read that assertInstanceOf
needs a full qualified namespace if executed inside a namespace.
So I just changed the
Creator
$classname = __NAMESPACE__."\\".$classname;
if (class_exists($classname)) {
try {
return new $classname;
} //...
and the
Test
public function testCanBuildJSON()
{
$s = StorageFactory::build("JSON");
$this->assertInstanceOf(__NAMESPACE__."\\JsonStorage", $s);
}
Hope it could help someone.
PS - Feel free to add details or suggestions for better practices