ZF3 - Unit testing controllers, POST/GET data not sending

梦想的初衷 提交于 2019-12-25 03:38:23

问题


I have define below in unit test

 $p = new Parameters();
    $p->set('email','test@gmail.com');
    $p->set('password','abcd'); 
    $p->set('username','abcd');       

    $this->getRequest()->setMethod('POST',$p);
    $this->getRequest()->setPost($p);
    $this->dispatch('/default/register');
    $this->assertModuleName('default');


    //assertActionName
    $this->assertResponseStatusCode(200);
    $this->assertControllerName(TestController::class);
    $this->assertControllerClass('TestController');
    $this->assertActionName('register');
    $this->assertMatchedRouteName('register');

I am echo the post array in the module/default/src/TestController but this returning empty error on CLI while printing on browser. Below is the output of CLI

PHPUnit 6.2.4 by Sebastian Bergmann and contributors.

Starting test 'DefaultTest\Controller\TestControllerTest::testRegisterUser'. Array ( )

来源:https://stackoverflow.com/questions/53946184/zf3-unit-testing-controllers-post-get-data-not-sending

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!