Monday, May 11, 2015

CakePHP 3 Unit Testing: posting data does not seem to be refactored by request object

I wrote a test that posts data like this:

$data = [ 'Clients[username]'=>'asdf' ];
$this->post('/url',$data);


In the controller method, when I print_r $this->request->data, it displays as this:

[ 'Clients[username]'=>'asdf' ]

However, if I go through a browser instead of phpunit, it is formed as such:

[ ['Clients'=>['username'=>'asdf'] ] ] which allows me to patchEntity or use newEntity with that data.


So my question is, what is the proper way to post data when Integration Testing a controller?

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: