public function testUpdate() { $id = PatientRepo::add('M', 'Lucas', 'Mascaro', '3 rue des fleurs qui sentent bon', NULL, 'Pimpous-Les-Bains', '31524', '1996-11-19', 'Toulouse', '123456789876543', 69); $this->assertEquals(0, PatientRepo::update($id, 'F', 'Lucas', 'Mascaro', '3 rue des fleurs qui sentent bon', 'lol', 'Pimpous-Les-Bains', '31524', '19/11/1996', 'Toulouse', '123456789876543', 69)); $patient = PatientRepo::getById($id); $this->assertEquals('F', $patient['Civilite']); PatientRepo::delete($id); }
public function delete($params) { if (PatientRepo::delete($params['id_patient']) !== FALSE) { $_status = 'success'; $_title = 'Patient supprimé!'; $_message = 'Le patient a bien été supprimé de la base de données!'; if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { Response::quickResponse(200, json_encode(['status' => $_status, 'title' => $_title, 'message' => $_message])); } else { $response = new Response(); $response->setHeader('Location', 'http://' . $_SERVER['HTTP_HOST'] . '/Patients.php?status=' . $_status . '&title=' . $_title . '&message=' . $_message); $response->send(); } } else { $_status = 'error'; $_title = 'Erreur de suppression!'; $_message = 'Erreur lors de la suppression. Réessayez!'; if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { Response::quickResponse(200, json_encode(['status' => $_status, 'title' => $_title, 'message' => $_message])); } else { $response = new Response(); $response->setHeader('Location', 'http://' . $_SERVER['HTTP_HOST'] . '/Patients.php?status=' . $_status . '&title=' . $_title . '&message=' . $_message); $response->send(); } } }