In Zend werden die Modelle zur Ansicht hinzugefügt:
//In a controller
public function indexAction() {
//Do some work and get a model
$this->view->model = $model;
}
Wir können leicht überprüfen, ob "model" in der Ansicht vorhanden ist (ich verwende simpletest für diese Aufgabe):
//In a unit test
public function testModelIsSetInView() {
//Call the controllers index action
$this->assertTrue(isset($this->controller->view->model));
}
Das Testen des "Wertes" funktioniert jedoch nicht so gut:
//In a unit test
public function testModelValue() {
//Call the controllers index action
//Both of these return null, though I'd like to access them!
$this->assertNull($this->controller->view->model);
$this->assertNull($this->controller->view->__get('model'));
}
Wie bekomme ich (oder zumindest testen), dass der Controller ein gültiges Modell gesetzt hat?