Answer the question
In order to leave comments, you need to log in
How to organize testing of controllers in the MVC pattern using phpUnit?
There is a cabinet_conrtoller controller class with an index() method:
class cabinet_controller
{
...
public function index()
{
...
$users = new users_model();
$user = $users->get(array('id'=>$_SESSION['user_id']));
...
}
...
}
public function testIndex()
{
$users_model = $this->getMock('users_model');
$users_model->expects($this->any())
->method('get')
->will($this->returnValue(array(...));
$cabinet_controller = new cabinet_controller();
$cabinet_controller->index($users_model);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question