1
我想为接收带JSON格式数据的POST方法的操作创建功能测试。功能测试:如何在POST方法中设置JSON数据?
这是我有:
info('set car')->
post('/user/'.$user->getId().'/set-car/'.$car->getId()'->
with('request')->ifFormat('json')->begin()->
isParameter('module', 'myModule')->
isParameter('action', 'myAction')->
end()->
But..where我应该设置接收JSON数据?
SF 1.4
问候
哈维
你测试你想要什么谢谢,但在行动中,我通过$ request-> getContent()检索JSON日期。所以,如果我在你粘贴的post()函数中写入JSON数据,我在运行测试时从$ request-> getContent()调用中获得'NULL'(当然,如果我使用普通浏览器FF,$ request-> getContent()可以正确返回JSON数据)。那么,你有什么建议? – ziiweb 2011-04-28 10:24:31
以及我的意思是“JSON数据”,而不是“JSON日期”。 – ziiweb 2011-04-28 10:30:42
你尝试了$ request-> getParameter('data');或$ request-> getPostParameter('data')。显然,你必须有数据= {我们的JSON在这里}。它应该工作。 – maectpo 2011-04-28 15:04:53