public function test_insert_cart() { $data = array('customer_id' => 1, 'item_id' => 2); $_POST = $data; $expected = TRUE; $Cart_model = new Cart_model(); $list = $Cart_model->insert_cart(); $actual = $list['status']; $this->assertEquals($expected, $actual); }
public function add_put() { $Cart_model = new Cart_model(); if ($this->_detect_method() == 'put') { $result = $Cart_model->insert_cart(); if ($result['status'] === FALSE) { $this->response(['status' => FALSE, 'message' => 'Could not save the item into cart'], REST_Controller::HTTP_INTERNAL_SERVER_ERROR); // INTERNAL_SERVER_ERROR (500) being the HTTP response code } else { $this->response(['status' => TRUE, 'id' => $result['id']], REST_Controller::HTTP_CREATED); // CREATED (201) being the HTTP response code } } else { $this->response(['status' => FALSE, 'message' => 'Nothing Post'], REST_Controller::HTTP_INTERNAL_SERVER_ERROR); // INTERNAL_SERVER_ERROR (500) being the HTTP response code } }