最近嘗試用thinkphp 寫項目,現在代碼有一定量了,每次運行正常但是沒有輸出值的時候很難找具體時哪個步驟上沒拿到值,所以找了下關于php做單元測試的框架phpunit,看了下官方的開訪文檔,還是不清楚如何在框架下運行一個單元測試。。。所以想問問大家,如何用phpunit做thinhphp的單元測試(controller和module的)比如我controller目錄下有個叫authController.class.php的文件。<?phpnamespace Home\Controller;use Think\Controller;class authController extends Controller { public function(){ $usr = I('POST.usr'); $pwd = I('POST.pwd'); $result = M('user')->where("usr=$usr AND pwd=$pwd")->find(); if($result == ''){ return 0; } echo $result = 1; }}我想測試這個controller中$usr和$pwd傳入的值是不是為test,并且如果都是test后result應該為真。如何寫這個測試用例,各位大神請解答下,測試用例的文件應該放哪里,怎么寫
- 2 回答
- 0 關注
- 1266 瀏覽
添加回答
舉報
0/150
提交
取消