我在本地用浏览器或者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'