No they do not have a common interface. In the grand scheme of things, the method I posted is essentially a factory to a composite classes (the model and the view) because I wanted to support being able to load multiple views or models into a controller.
So, what I'm trying to test is essentially the behavior of if a class isn't there, or if a component was returned.. more so to make if things are refactored, the class doesn't break.
I'm not actually testing this method I've posted, obviously, it's just that the class has a dependency on certain classes (models, views, etc) being loaded (which I'm trying to mock). Now, it is my understanding that testing should be completely indepedent from it's environment.. so if I want to test that a component is returned from the factory, how would I if the class doesn't exist.
My test would look something like
Code: Select all
public function testAttachingComponent()
{
$component = new Northern_Component();
try {
$component->attachComponent('Index', 'View');
} catch (Exception $e) {
$this->fail();
}
}
So the $component object would autoload Application_View_Index, although it won't exist in the test suite. Would I have to simply include
at the top of this particular test case?
To complicate things furthur, I'm looking to check if the component classes (views, etc) have certain properties, and if they do.. test something else. So lets say I figure out how to mock this properly, is it possible to inject properties into the class? I know it's possible to inject return values of methods.. hrm..
Hope that even made sense
Thanks.