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

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

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

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

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Hire Dedicated PHP Developer

Looking to hire affordable yet experienced PHP developers? **[Hire Dedicated PHP Developer](https://hourlydeveloper.io/hire-dedicated-php-developer/ "Hire Dedicated PHP Developer")**, who can convert your idea to reality, within the stipulated...

CakePHP Development Company | Hire CakePHP Developers | Skenix

Skenix Infotech is a top CakePHP Website Development Company that offers feature-rich CakePHP Development Services. Hire expert CakePHP Developers from Skenix.

PHP Web Application Development Company

As a top **PHP Web Application Development Company in USA**[https://www.dataeximit.com/php-development-services/](https://www.dataeximit.com/php-development-services/ "https://www.dataeximit.com/php-development-services/"), we at Data EximIT have...

How to use highchart in php with example

Here, i will let you know that how to use highchart in php application with example. Highchart provides feature to draw different type of charts.

Advantages of Hiring PHP Developer for your Website Project

PHP - Hypertext pre-processor, a scripting language used by many people in developing web pages, but most of us are unaware even of the full form. To train someone and make them learn this whole language is as difficult and time-consuming as it is...