简体   繁体   English

通过同时使用POST和GET数据的phpunit进行Cakephp测试

[英]Cakephp test via phpunit that uses both POST and GET data

I am building a test suite in Cakephp using its built in test framework. 我正在使用内置的测试框架在Cakephp中构建测试套件。 I am running into the following issue. 我遇到了以下问题。 I have a controller method that when executed makes use of both GET and POST data. 我有一个控制器方法,该方法在执行时会同时使用GETPOST数据。 I know that to simulate GET data via a test you can easily include that as followed: 我知道要通过测试模拟GET数据,您可以轻松地将其包括如下:

$result = $this->testAction('/api/checkuser/', array('data' => $data, 'method' => 'get');

The same thing can be done for POST as followed: 可以对POST执行相同的操作,如下所示:

$result = $this->testAction('/api/currentuser/', array('data' => $data, 'method' => 'post');

But I'm not sure how I would use both together. 但是我不确定如何将两者一起使用。 Does anyone know how to send POST and GET data to a given test. 有谁知道如何将POSTGET数据发送到给定的测试。 Thanks to anyone that can help. 感谢任何可以提供帮助的人。

I have never had to send both GET and POST data and the same time, but if you can I imagine it would be something like. 我从不需要同时发送GET和POST数据,但是如果您可以想象的话,那会是类似的事情。

$result = $this->testAction('/api/currentuser/', array('data' => $data, 'method' => array('post', 'get')); $ result = $ this-> testAction('/ api / currentuser /',array('data'=> $ data,'method'=> array('post','get'));

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM