Zend では、モデルがビューに追加されます。
//In a controller
public function indexAction() {
//Do some work and get a model
$this->view->model = $model;
}
ビューに「モデル」が存在することを簡単に確認できます (これには simpletest を使用しています)。
//In a unit test
public function testModelIsSetInView() {
//Call the controllers index action
$this->assertTrue(isset($this->controller->view->model));
}
ただし、「値」のテストも同様に機能しません。
//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'));
}
コントローラーが有効なモデルを設定したことをどのように取得 (または少なくともテスト) しますか?