Need to set up data values in $this->request->data object for testing purpose

I am using CakePHP 2.X and need to use the $this->request->data->object (or a Mock) to test a Controller method. I have a condition in the controller that verify if $this->request->data is empty (if (empty($this->request->data)) {EXECUTE SOMETHING}) and I need to add data in this object on the testing side, to not enter in the if statement.

I've been looking on the web already and didn't find anything that suits me. Here's the Controller Code :

function default($user = null) {
$subsite = $this->Session->read('subsite');
        if ($subsite == "www" || $subsite == "xxx") {
            $this->redirect("/application/addtool");
            return "ok1";
        }
        if (empty($this->request->data)) {
            $this->render();
        } else {
            $this->request->data['Project']['actif'] = true;
            $user_id = $this->Session->read('user_id');
            $this->request->data['Project']['user_id'] = $user_id;
        }
}


#php #cakephp

3 Likes1.55 GEEK