How can i test an Add function on CakePHP2.0

前端 未结 2 1427
清酒与你
清酒与你 2021-01-20 19:36

I have been told that we have to test also the functions created by Cake like add/delete...

If i have a function like this one, how can i test it if it doesn\'t have

2条回答
  •  青春惊慌失措
    2021-01-20 20:09

    public function add() {
            $this->autoRender = false;
            if ($this->request->is('post')) {
                $this->Comment->create();
                if ($this->Comment->save($this->request->data)) {
                    echo json_encode(array('status' => 'ok'));
                } else {  
                    echo json_encode(array('status' => 'fail'));              
                }
            }
        }
    

提交回复
热议问题