A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2009 yearUnit testing Zend controllers - how do I test what has been set in the view - page 1
User InfoPosts
Unit testing Zend controllers - how do I test what has been set in the view#1
In Zend, models are added to the view:

//In a controller
public function indexAction() {
//Do some work and get a model
$this->view->model = $model;
}


We can easily check that "model" exists in the view (I(m using simpletest for this):

//In a unit test
public function testModelIsSetInView() {
//Call the controllers index action
$this->assertTrue(isset($this->controller->view->model));
}


However, testing the "value" doesn(t work as well:

//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());
}


How do I get (or at least test) that the controller has set a valid model?

posted date: 2009-04-16 06:50:00


Re: Unit testing Zend controllers - how do I test what has been set in the view#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2009-04-16 06:50:01


Re: Unit testing Zend controllers - how do I test what has been set in the view#3
http://www.contentwithstyle.co.uk/content/unit-testing-controllers-with-zend-framework

posted date: 2009-04-16 06:56:00


Re: Unit testing Zend controllers - how do I test what has been set in the view#4
So, the solution (at least the planned one at this time) is make a testable view that implements Zend_View_Interface. This will include a "get" method that returns objects passed to "__set". Then we(ll hook up the controller to use this view during the test bootstrapping process.Since this may not be the optimal approach, I(d still love to hear from others who have potential solutions.

posted date: 2009-04-16 07:31:00


select page: « 1 »
Copyright ©2008-2017 www.momige.com, all rights reserved.