明天我还好人 2016-04-22 02:31
浏览 811

laravel中phpunit使用call方法测试controller无法通过integer验证

我在本地用浏览器或者curl方式访问http://api.lizhongde1.dev.anhouse.com.cn/hft/1.0/zf/onlinelist?page_size=10地址时,都能够正常得到数据,但是在服务器中使用laravel自带的call方法验证就一直提示integer验证错误,到底怎么才能通过验证呢?
我的test方法:

 public function testOnLineList($request){
        $response = $this->call('GET', '/hft/1.0/zf/onlinelist?record_offset=10&page_size=1');
        $this->assertEquals(200, $response->getStatusCode());
        $this->assertNotEmpty($content = $response->getContent());
        $content = json_decode($content,true);
        $this->assertEquals($request,$content['msg']);
    }
原方法中的validate调用:
 $aFieldVal = $this->validate($oRequest,[
            'page_size' => 'integer|min:1|max:100',
            'record_offset' => 'integer|min:0',
        ],[
            'page_size.integer' => '每页显示数必须为整数',
            'page_size.min' => '每页显示数不得小于1',
            'page_size.max' => '每页显示数不得大于100',
            'record_offset.integer' => '偏移量必须为整数',
            'record_offset.min' => '偏移量不得小于0',
        ]);

调用测试时候的提示的错误:
ZfControllerTest::testOnLineList with data set #0 (array(10, 'aa', '每页显示数必须为整数'))
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'每页显示数必须为整数'
+'ok'

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 報錯:Person is not mapped,如何解決?
    • ¥15 c++头文件不能识别CDialog