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