From 8a79828d2393b94281430aca81f40059819ffc53 Mon Sep 17 00:00:00 2001 From: "alextselegidis@gmail.com" Date: Wed, 8 May 2013 14:31:17 +0000 Subject: [PATCH] =?UTF-8?q?=CE=A0=CF=81=CE=BF=CF=83=CE=B8=CE=AE=CE=BA?= =?UTF-8?q?=CE=B7=20unit=20test=20=CE=B3=CE=B9=CE=B1=20=CF=84=CE=BF=20Appo?= =?UTF-8?q?intments=5FModel.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/easy_appointments.sql | 58 ++++- src/application/config/constants.php | 1 - src/application/config/hooks.php | 9 +- src/application/controllers/appointments.php | 1 - src/application/controllers/google.php | 17 ++ src/application/hooks/DisplayHook.php | 12 + src/application/libraries/notifications.php | 49 ++-- src/application/models/appointments_model.php | 4 +- src/application/models/customers_model.php | 2 +- src/application/models/providers_model.php | 34 ++- src/application/models/roles_model.php | 24 ++ src/application/models/services_model.php | 17 ++ src/assets/js/frontend/book-appointment.js | 10 +- src/assets/js/general_functions.js | 63 ++++++ src/system/core/Utf8.php | 3 +- test/AppointmentsModelTest.php | 132 +++++++++++ test/bootstrap.php | 212 ++++++++++++++++++ test/phpunit.xml | 10 + 18 files changed, 620 insertions(+), 38 deletions(-) create mode 100644 src/application/hooks/DisplayHook.php create mode 100644 src/application/models/roles_model.php create mode 100644 src/assets/js/general_functions.js create mode 100644 test/AppointmentsModelTest.php create mode 100644 test/bootstrap.php create mode 100644 test/phpunit.xml diff --git a/db/easy_appointments.sql b/db/easy_appointments.sql index da86ab81..cc602087 100644 --- a/db/easy_appointments.sql +++ b/db/easy_appointments.sql @@ -3,7 +3,7 @@ -- http://www.phpmyadmin.net -- -- Φιλοξενητής: localhost --- Χρόνος δημιουργίας: 20 Απρ 2013 στις 20:18:59 +-- Χρόνος δημιουργίας: 08 Μάη 2013 στις 17:29:41 -- Έκδοση διακομιστή: 5.5.24-log -- Έκδοση PHP: 5.4.3 @@ -38,7 +38,48 @@ CREATE TABLE IF NOT EXISTS `ea_appointments` ( KEY `id_users_customer` (`id_users_customer`), KEY `id_services` (`id_services`), KEY `id_users_provider` (`id_users_provider`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=18 ; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=50 ; + +-- +-- Άδειασμα δεδομένων του πίνακα `ea_appointments` +-- + +INSERT INTO `ea_appointments` (`id`, `start_datetime`, `end_datetime`, `notes`, `id_users_provider`, `id_users_customer`, `id_services`) VALUES +(14, '2013-04-26 12:40:00', '2013-04-26 12:40:00', '', 2, 1, 1), +(15, '2013-04-26 16:00:00', '2013-04-26 16:00:00', '', 2, 1, 1), +(16, '2013-04-26 13:00:00', '2013-04-26 13:00:00', 'Something else here ...', 2, 19, 1), +(17, '2013-04-26 14:00:00', '2013-04-26 14:00:00', '', 2, 20, 1), +(18, '2013-04-26 14:20:00', '2013-04-26 14:20:00', '', 2, 19, 1), +(19, '2013-04-26 14:20:00', '2013-04-26 14:20:00', 'Some notes ...', 2, 20, 1), +(20, '2013-04-26 14:30:00', '2013-04-26 14:30:00', 'ooo', 3, 20, 2), +(21, '2013-04-26 15:40:00', '2013-04-26 15:40:00', '', 2, 21, 1), +(22, '2013-04-26 16:40:00', '2013-04-26 16:40:00', '', 2, 21, 1), +(23, '2013-04-26 14:40:00', '2013-04-26 14:40:00', '', 2, 21, 1), +(24, '2013-05-01 18:00:00', '2013-05-01 18:00:00', '', 2, 19, 1), +(25, '2013-05-01 18:20:00', '2013-05-01 18:20:00', '', 2, 19, 1), +(26, '2013-05-01 18:40:00', '2013-05-01 18:40:00', '', 2, 19, 1), +(27, '2013-05-02 00:00:00', '2013-05-02 19:01:00', '', 2, 19, 1), +(28, '2013-05-03 13:00:00', '2013-05-03 13:00:00', '', 2, 19, 1), +(29, '2013-05-03 13:40:00', '2013-05-03 13:40:00', '', 2, 19, 1), +(30, '2013-05-03 14:20:00', '2013-05-03 14:20:00', '', 2, 19, 1), +(31, '2013-05-04 08:00:00', '2013-05-04 08:00:00', '', 3, 19, 3), +(32, '2013-05-03 00:00:00', '2013-05-03 20:45:00', '', 3, 19, 2), +(33, '2013-05-04 08:20:00', '2013-05-04 08:20:00', '', 2, 19, 1), +(34, '2013-05-04 09:20:00', '2013-05-04 09:20:00', '', 2, 19, 1), +(35, '2013-05-04 12:40:00', '2013-05-04 12:40:00', '', 2, 19, 1), +(36, '2013-05-04 13:20:00', '2013-05-04 13:20:00', '', 2, 19, 1), +(37, '2013-05-04 08:00:00', '2013-05-04 08:00:00', '', 2, 19, 1), +(38, '2013-05-03 00:00:00', '2013-05-03 23:18:00', '', 2, 19, 1), +(40, '2013-05-04 11:20:00', '2013-05-04 11:20:00', '', 2, 19, 1), +(41, '2013-05-04 12:00:00', '2013-05-04 12:00:00', '', 2, 19, 1), +(42, '2013-05-04 17:30:00', '2013-05-04 17:30:00', '', 3, 19, 2), +(43, '2013-05-04 19:00:00', '2013-05-04 19:00:00', '', 3, 19, 3), +(44, '2013-05-04 18:30:00', '2013-05-04 18:30:00', '', 4, 20, 2), +(45, '2013-05-07 11:00:00', '2013-05-07 11:00:00', 'Some notes ...', 2, 19, 1), +(46, '2013-05-07 11:20:00', '2013-05-07 11:20:00', '', 2, 19, 1), +(47, '2013-05-07 14:40:00', '2013-05-07 14:40:00', '', 2, 19, 1), +(48, '2013-05-07 15:00:00', '2013-05-07 15:00:00', '', 2, 20, 1), +(49, '2013-05-07 11:40:00', '2013-05-07 11:40:00', '', 2, 19, 1); -- -------------------------------------------------------- @@ -155,7 +196,7 @@ CREATE TABLE IF NOT EXISTS `ea_settings` ( INSERT INTO `ea_settings` (`id`, `name`, `value`) VALUES (1, 'business_name', 'Javation & Co'), (2, 'business_working_hours', '{}'), -(3, NULL, NULL); +(3, 'business_email', 'alextselegidis@gmail.com'); -- -------------------------------------------------------- @@ -180,17 +221,20 @@ CREATE TABLE IF NOT EXISTS `ea_users` ( `id_roles` bigint(20) unsigned NOT NULL, PRIMARY KEY (`id`), KEY `id_roles` (`id_roles`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=35 ; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=22 ; -- -- Άδειασμα δεδομένων του πίνακα `ea_users` -- INSERT INTO `ea_users` (`id`, `username`, `password`, `first_name`, `last_name`, `email`, `mobile_number`, `phone_number`, `address`, `city`, `state`, `zip_code`, `notes`, `id_roles`) VALUES -(1, 'admin', 'admin', 'Alex', 'Tselegidis', 'alextselegidis@gmail.com', '123456789', '987654321', 'Pantazopoulou 11', 'Thessaloniki', NULL, '56121', 'This is me making Easy!Appointments', 1), -(2, 'provider_1', 'provider_1', 'Γιώργος', 'Παπαδόπουλος', 'prov1@testing.gr', '1212121212', '2121212121', 'John Doe 23', 'Washington DC', NULL, '12345', 'This is a test provider', 2), +(1, 'admin', 'admin', '', '1', 'alextselegidis@gmail.com', '123456789', '1', '', '', NULL, '', 'This is me making Easy!Appointments', 1), +(2, 'provider_1', 'provider_1', 'Γεώργιος', 'Παπαδόπουλος', 'alextselegidis@gmail.com', '1212121212', '1', '', '', NULL, '', 'This is a test provider', 2), (3, 'provider_2', 'provider_2', 'Νίκος', 'Αναστασίου', 'prov2@test.gr', '1313133113131', '32132165146', 'Some Street 3', NULL, NULL, NULL, NULL, 2), -(4, 'provider_3', 'provider_3', 'Ηρώ', 'Καριοφύλη', 'prov3@test.gr', '239203490', '029340923', 'John Doe 3 ', NULL, NULL, NULL, NULL, 2); +(4, 'provider_3', 'provider_3', 'Ηρώ', 'Καριοφύλη', 'prov3@test.gr', '239203490', '029340923', 'John Doe 3 ', NULL, NULL, NULL, NULL, 2), +(19, NULL, NULL, '', 'a', 'alextselegidis@gmail.com', NULL, 'a', '', '', NULL, '', NULL, 3), +(20, NULL, NULL, 'Alex', 'Tselegidis', 'alextselegidis@yahoo.gr', NULL, '6988589365', '', '', NULL, '', NULL, 3), +(21, NULL, NULL, '', '1', 'black-sabbath1967@hotmail.com', NULL, '1', '', '', NULL, '', NULL, 3); -- -- Περιορισμοί για άχρηστους πίνακες diff --git a/src/application/config/constants.php b/src/application/config/constants.php index 40bb44dd..dcf9e149 100644 --- a/src/application/config/constants.php +++ b/src/application/config/constants.php @@ -50,6 +50,5 @@ define('DB_SLUG_PROVIDER', 'provider'); define('DB_SLUG_ADMIN', 'admin'); define('DB_SLUG_SECRETARY', 'secretary'); - /* End of file constants.php */ /* Location: ./application/config/constants.php */ \ No newline at end of file diff --git a/src/application/config/hooks.php b/src/application/config/hooks.php index a58cbca9..6c6fb6cf 100644 --- a/src/application/config/hooks.php +++ b/src/application/config/hooks.php @@ -9,7 +9,14 @@ | http://codeigniter.com/user_guide/general/hooks.html | */ - +// This hook is necessary to make the phpunit work with +// the codeigniter framework. +$hook['display_override'] = array( + 'class' => 'DisplayHook', + 'function' => 'captureOutput', + 'filename' => 'DisplayHook.php', + 'filepath' => 'hooks' +); /* End of file hooks.php */ /* Location: ./application/config/hooks.php */ \ No newline at end of file diff --git a/src/application/controllers/appointments.php b/src/application/controllers/appointments.php index 6c3cd561..5882f11a 100644 --- a/src/application/controllers/appointments.php +++ b/src/application/controllers/appointments.php @@ -109,6 +109,5 @@ class Appointments extends CI_Controller { } } - /* End of file appointments.php */ /* Location: ./application/controllers/appointments.php */ \ No newline at end of file diff --git a/src/application/controllers/google.php b/src/application/controllers/google.php index 20b00d38..8fd7058a 100644 --- a/src/application/controllers/google.php +++ b/src/application/controllers/google.php @@ -1,6 +1,23 @@ CI =& get_instance(); + $output = $this->CI->output->get_output(); + if (ENVIRONMENT != 'testing') { + echo $output; + } + } +} \ No newline at end of file diff --git a/src/application/libraries/notifications.php b/src/application/libraries/notifications.php index 5276c969..945b64df 100644 --- a/src/application/libraries/notifications.php +++ b/src/application/libraries/notifications.php @@ -1,5 +1,8 @@ Settings_Model->get_setting('business_name'); $subject = 'Appointment Book Success!'; - - $headers = 'MIME-Version: 1.0' . "\r\n"; - $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n"; - $headers .= 'To: ' . $customer_data['last_name'] . ' ' . $customer_data['first_name'] . ' <' . $customer_data['email'] . '>' . "\r\n"; - $headers .= 'From: ' . $from_name . ' <' . $from_email . '>' . "\r\n"; + $headers = $this->get_email_headers($customer_data['last_name'] . ' ' . $customer_data['first_name'], $customer_data['email'], $from_name, $from_email); return mail($to, $subject, $html, $headers); } + /** + * Create the email headers. + * + * This method cretes the email header depending the sender and + * the receiver. + * + * @param type $to_name Receiver's name + * @param type $to_email Receiver's email address + * @param type $from_name Sender's name + * @param type $from_email Sender's email + * @return string Returns the email headers. + */ + private function get_email_headers($to_name, $to_email, $from_name, $from_email) { + $headers = EMAIL_HEADER_MIME_VERSION; + $headers .= EMAIL_HEADER_CONTENT_TYPE; + $headers .= 'To: ' . $to_name . ' <' . $to_email . '>' . "\r\n"; + $headers .= 'From: ' . $from_name . ' <' . $from_email . '>' . "\r\n"; + return $headers; + } + /** * Send an email notification to a provider that * a new appointment has been added to his plan. @@ -161,21 +180,17 @@ class Notifications { '; // Send email to the customer - $to = $CI->Providers_Model->get_value('email', $appointment_data['id_users_provider']); - $providerNicename = $CI->Providers_Model->get_value('last_name', $appointment_data['id_users_provider']) . ' ' . $CI->Providers_Model->get_value('first_name', $appointment_data['id_users_provider']); + $provider_email = $CI->Providers_Model->get_value('email', $appointment_data['id_users_provider']); + $provider_nicename = $CI->Providers_Model->get_value('last_name', $appointment_data['id_users_provider']) . ' ' . $CI->Providers_Model->get_value('first_name', $appointment_data['id_users_provider']); $CI->load->model('Settings_Model'); - $fromEmail = $CI->Settings_Model->get_setting('business_email'); - $fromName = $CI->Settings_Model->get_setting('business_name'); + $from_email = $CI->Settings_Model->get_setting('business_email'); + $from_name = $CI->Settings_Model->get_setting('business_name'); $subject = 'A new appointment has been added to your plan.'; + $headers = $this->get_email_headers($provider_nicename, $provider_email, $from_name, $from_email); - $headers = 'MIME-Version: 1.0' . "\r\n"; - $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n"; - $headers .= 'To: ' . $providerNicename . '<' . $to . '>' . "\r\n"; - $headers .= 'From: ' . $fromName . ' <' . $fromEmail . '>' . "\r\n"; - - return mail($to, $subject, $html, $headers); + return mail($provider_email, $subject, $html, $headers); } } diff --git a/src/application/models/appointments_model.php b/src/application/models/appointments_model.php index b5190cbe..4050df2e 100644 --- a/src/application/models/appointments_model.php +++ b/src/application/models/appointments_model.php @@ -33,7 +33,7 @@ class Appointments_Model extends CI_Model { return $appointment_id; } catch (Exception $exc) { - echo $exc->getTraceAsString(); + echo $exc->getMessage() . '
' . $exc->getTraceAsString() . '
'; } } @@ -142,7 +142,7 @@ class Appointments_Model extends CI_Model { $this->db->where($where_clause); } - return $this->db->get('ea_appointments')->results_array(); + return $this->db->get('ea_appointments')->result_array(); } } diff --git a/src/application/models/customers_model.php b/src/application/models/customers_model.php index 40240ef5..88de6d03 100644 --- a/src/application/models/customers_model.php +++ b/src/application/models/customers_model.php @@ -157,7 +157,7 @@ class Customers_Model extends CI_Model { $this->db->where('id_roles', $customers_role_id); - return $this->db->get('ea_users')->results_array(); + return $this->db->get('ea_users')->result_array(); } /** diff --git a/src/application/models/providers_model.php b/src/application/models/providers_model.php index 6406717d..7b44f7e3 100644 --- a/src/application/models/providers_model.php +++ b/src/application/models/providers_model.php @@ -1,4 +1,5 @@ -db->get_where('ea_users', array('id' => $provider_id))->row_array()[$field_name]; } + /** + * Get all, or specific records from provider's table. + * + * @example $this->Model->getBatch('id = ' . $recordId); + * + * @param string $whereClause (OPTIONAL) The WHERE clause of + * the query to be executed. DO NOT INCLUDE 'WHERE' KEYWORD. + * @return array Returns the rows from the database. + */ + public function get_batch($where_clause = '') { + $providers_role_id = $this->get_providers_role_id(); + + if ($where_clause != '') { + $this->db->where($where_clause); + } + + $this->db->where('id_roles', $providers_role_id); + + return $this->db->get('ea_users')->result_array(); + } + /** * This method returns the available providers and * the services that can provide. @@ -66,8 +88,16 @@ class Providers_Model extends CI_Model { return $providers; } + + /** + * Get the providers role id from the database. + * + * @return int Returns the role id for the customer records. + */ + public function get_providers_role_id() { + return $this->db->get_where('ea_roles', array('slug' => DB_SLUG_PROVIDER))->row()->id; + } } - /* End of file providers_model.php */ /* Location: ./application/models/providers_model.php */ \ No newline at end of file diff --git a/src/application/models/roles_model.php b/src/application/models/roles_model.php new file mode 100644 index 00000000..556286ac --- /dev/null +++ b/src/application/models/roles_model.php @@ -0,0 +1,24 @@ +db->get_where('ea_roles', array('slug' => $role_slug))->row()->id; + } +} + +/* End of file roles_model.php */ +/* Location: ./application/models/roles_model.php */ \ No newline at end of file diff --git a/src/application/models/services_model.php b/src/application/models/services_model.php index 818a2c60..93cc9744 100644 --- a/src/application/models/services_model.php +++ b/src/application/models/services_model.php @@ -31,6 +31,23 @@ class Services_Model extends CI_Model { return $this->db->get_where('ea_services', array('id' => $service_id))->row_array()[$field_name]; } + /** + * Get all, or specific records from service's table. + * + * @example $this->Model->getBatch('id = ' . $recordId); + * + * @param string $whereClause (OPTIONAL) The WHERE clause of + * the query to be executed. DO NOT INCLUDE 'WHERE' KEYWORD. + * @return array Returns the rows from the database. + */ + public function get_batch($where_clause = NULL) { + if ($where_clause != NULL) { + $this->db->where($where_clause); + } + + return $this->db->get('ea_services')->result_array(); + } + /** * This method returns all the services from the database. * diff --git a/src/assets/js/frontend/book-appointment.js b/src/assets/js/frontend/book-appointment.js index 0c8e51b8..2ef7f55b 100644 --- a/src/assets/js/frontend/book-appointment.js +++ b/src/assets/js/frontend/book-appointment.js @@ -151,13 +151,13 @@ var bookAppointment = { var ajaxurl = GlobalVariables.baseUrl + 'appointments/ajax_get_available_hours'; jQuery.post(ajaxurl, postData, function(postResponse) { //////////////////////////////////////////////////////////////////////////////// - console.log('\n\n Get Available Hours Post Response :', postResponse, '\n\n'); + //console.log('\n\n Get Available Hours Post Response :', postResponse, '\n\n'); //////////////////////////////////////////////////////////////////////////////// try { var jsonResponse = jQuery.parseJSON(postResponse); //////////////////////////////////////////////////////////////////////////////// - console.log('\n\n Get Available Hours JSON Response :', jsonResponse, '\n\n'); + //console.log('\n\n Get Available Hours JSON Response :', jsonResponse, '\n\n'); //////////////////////////////////////////////////////////////////////////////// // Fill the available time div @@ -176,10 +176,10 @@ var bookAppointment = { // Set the first item as selected. $('.available-hour:eq(0)').addClass('selected-hour'); bookAppointment.updateConfirmData(); - } catch(exception) { - // @task Display message to the user. - }; + GeneralFunctions.displayMessageBox('Unexpected Error', 'An unexpected error occured during ' + + 'the available hours calculation. Please refresh the page and try again.'); + } }); }, diff --git a/src/assets/js/general_functions.js b/src/assets/js/general_functions.js new file mode 100644 index 00000000..e9fc7c93 --- /dev/null +++ b/src/assets/js/general_functions.js @@ -0,0 +1,63 @@ +/** + * This file contains the Genral Functions javascript namespace. + * It contains functions that apply both on the front and back + * end of the application. + * + * @namespace General javascript functions. + */ +var GeneralFunctions = {}; + +/** + * This functions displays a message box in + * the admin array. It is usefull when user + * decisions or verifications are needed. + * + * @param {string} title The title of the message box. + * @param {string} message The message of the dialog. + * @param {array} messageButtons Contains the dialog + * buttons along with their functions. + */ +GeneralFunctions.displayMessageBox = function(title, message, messageButtons) { + // Check arguments integrity. + if (title == undefined || title == "") { + title = ""; + } + + if (message == undefined || message == "") { + message = ""; + } + + if (messageButtons == undefined) { + messageButtons = { + Close: function() { + jQuery("#message_box").dialog("close"); + } + }; + } + + // Destroy previous dialog instances. + jQuery("#message_box").dialog("destroy"); + jQuery("#message_box").remove(); + + // Create the html of the message box. + jQuery("body").append( + "
" + + "

" + message + "

" + + "
" + ); + + jQuery("#message_box").dialog({ + autoOpen : false, + modal : true, + resize : "auto", + width : 400, + height : "auto", + resizable : false, + buttons : messageButtons, + closeOnEscape : false + }); + + jQuery("#message_box").dialog("open"); + jQuery("#message_box .ui-dialog-titlebar-close").hide(); +} + diff --git a/src/system/core/Utf8.php b/src/system/core/Utf8.php index 2a27d1f3..21544159 100644 --- a/src/system/core/Utf8.php +++ b/src/system/core/Utf8.php @@ -38,7 +38,8 @@ class CI_Utf8 { { log_message('debug', "Utf8 Class Initialized"); - global $CFG; + //global $CFG; + $CFG =& load_class('Config', 'core'); // This is changed due to php unit conflict : http://www.jamesfairhurst.co.uk/posts/view/codeigniter_phpunit_and_netbeans if ( preg_match('/./u', 'é') === 1 // PCRE must support UTF-8 diff --git a/test/AppointmentsModelTest.php b/test/AppointmentsModelTest.php new file mode 100644 index 00000000..4ccc0c37 --- /dev/null +++ b/test/AppointmentsModelTest.php @@ -0,0 +1,132 @@ +CI =& get_instance(); + $this->CI->load->model('Appointments_Model'); // This model will be used in all test methods. + + $this->CI->load->model('Providers_Model'); + $providers = $this->Providers_Model->get_row(2); +// if (count($providers) > 0) { +// $this->id_users_provider = $providers[0]['id']; +// } else { +// throw new Exception('There are no provider records ' +// . 'in the database. Add at least one provider ' +// . 'record before proceeding with the test.'); +// } +// +// $this->CI->load->model('Customers_Model'); +// $customers = $this->Customers_Model->get_batch(); +// if (count($customers) > 0) { +// $this->id_users_customer = $customers[0]['id']; +// } else { +// throw new Exception('There are no customer records ' +// . 'in the database. Add at least one customer ' +// . 'record before proceeding with the test.'); +// } +// +// $this->CI->load->model('Services_Model'); +// $services = $this->Services_Model->get_batch(); +// if (count($services) > 0) { +// $this->id_services = $services[0]['id']; +// } else { +// throw new Exception('There are no customer records ' +// . 'in the database. Add at least one customer ' +// . 'record before proceeding with the test.'); +// } + } + + public function test_sample() { + //$this->assertEquals(1,1); + } + + ///////////////////////////////////////////////////////////////////////////////// + // ADD RECORD METHOD TESTS + ///////////////////////////////////////////////////////////////////////////////// +// public function test_add_appointment_insert() { +// // To trigger the insert method no record id needs to be +// // provided. +// $appointment_data = array( +// 'start_datetime' => '2013-05-01 12:30:00', +// 'end_datetime' => '2013-05-01 13:00:00', +// 'notes' => 'Some notes right here...', +// 'id_users_provider' => $this->id_users_provider, +// 'id_users_customer' => $this->id_users_customer, +// 'id_services' => $this->id_services +// ); +// +// $appointment_id = $this->Appointments_Model->add($appointment_data); +// +// // Check if the record is the one that was inserted. +// $db_data = $this->Appointments_Model->get_row($appointment_id); +// +// $this->assertEquals($appointment_data['start_datetime'], $db_data['start_datetime']); +// $this->assertEquals($appointment_data['end_datetime'], $db_data['end_datetime']); +// $this->assertEquals($appointment_data['notes'], $db_data['notes']); +// $this->assertEquals($appointment_data['id_users_provider'], $db_data['id_users_provider']); +// $this->assertEquals($appointment_data['id_users_customer'], $db_data['id_users_customer']); +// $this->assertEquals($appointment_data['id_services'], $db_data['id_services']); +// +// // Delete inserted record. +// $this->Appointments_Model->delete($appointment_id); +// } +// +// public function test_add_appointment_update() { +// // Insert new record. +// $appointment_data = array( +// 'start_datetime' => '2013-05-01 12:30:00', +// 'end_datetime' => '2013-05-01 13:00:00', +// 'notes' => 'Some notes right here...', +// 'id_users_provider' => $this->id_users_provider, +// 'id_users_customer' => $this->id_users_customer, +// 'id_services' => $this->id_services +// ); +// +// $appointment_id = $this->Appointments_Model->add($appointment_data); +// +// // Update new record. +// $new_notes_content = 'Some OTHER notes here ...'; +// $appointment_data['notes'] = $new_notes_content; +// $this->Appointments_Model->add($appointment_data); +// +// // Check if the record was successfully updated. +// $db_data = $this->Appointments_Model->get_row($appointment_id); +// +// $this->assertEquals($appointment_data['start_datetime'], $db_data['start_datetime']); +// $this->assertEquals($appointment_data['end_datetime'], $db_data['end_datetime']); +// $this->assertEquals($appointment_data['notes'], $db_data['notes']); +// $this->assertEquals($appointment_data['id_users_provider'], $db_data['id_users_provider']); +// $this->assertEquals($appointment_data['id_users_customer'], $db_data['id_users_customer']); +// $this->assertEquals($appointment_data['id_services'], $db_data['id_services']); +// +// // Delete inserted record. +// $this->Appointments_Model->delete($appointment_id); +// } +// +// public function test_add_appointment_no_foreign_keys() { +// +// +// } +// +// ///////////////////////////////////////////////////////////////////////////////// +// // RECORD EXISTS METHOD TESTS +// ///////////////////////////////////////////////////////////////////////////////// +// public function test_exists_true() { +// +// } +// +// public function test_exists_false() { +// +// } +// +// public function test_exists_wrong_data() { +// +// } +} + +/* End of file appointments_modelTest.php */ +/* Location: ../test/appointments_modelTest.php */ \ No newline at end of file diff --git a/test/bootstrap.php b/test/bootstrap.php new file mode 100644 index 00000000..6f59dd91 --- /dev/null +++ b/test/bootstrap.php @@ -0,0 +1,212 @@ + + \ No newline at end of file