Προσθήκη unit test για το Appointments_Model.
This commit is contained in:
parent
11274ff7be
commit
8a79828d23
18 changed files with 620 additions and 38 deletions
|
@ -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);
|
||||
|
||||
--
|
||||
-- Περιορισμοί για άχρηστους πίνακες
|
||||
|
|
|
@ -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 */
|
|
@ -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 */
|
|
@ -109,6 +109,5 @@ class Appointments extends CI_Controller {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/* End of file appointments.php */
|
||||
/* Location: ./application/controllers/appointments.php */
|
|
@ -1,6 +1,23 @@
|
|||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Google extends CI_Controller {
|
||||
/**
|
||||
* Class Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Google API authorization redirect page.
|
||||
*
|
||||
* This is the page that the google api should redirect after the
|
||||
* user allows the api to handle his data. A redirect page must be
|
||||
* already set in the $_SESSION array in order to redirect to the
|
||||
* correct page.
|
||||
*
|
||||
* @task Make redirect page with session variable.
|
||||
*/
|
||||
public function api_auth() {
|
||||
session_start();
|
||||
|
||||
|
|
12
src/application/hooks/DisplayHook.php
Normal file
12
src/application/hooks/DisplayHook.php
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
// This hook is necessary in order to run php unit tests
|
||||
// against the codeigniter framework.
|
||||
class DisplayHook {
|
||||
public function captureOutput() {
|
||||
$this->CI =& get_instance();
|
||||
$output = $this->CI->output->get_output();
|
||||
if (ENVIRONMENT != 'testing') {
|
||||
echo $output;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,8 @@
|
|||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
define('EMAIL_HEADER_MIME_VERSION', 'MIME-Version: 1.0' . "\r\n");
|
||||
define('EMAIL_HEADER_CONTENT_TYPE', 'Content-type: text/html; charset=utf-8' . "\r\n");
|
||||
|
||||
/**
|
||||
* This library handles all the notification email deliveries
|
||||
* on the system.
|
||||
|
@ -8,11 +11,11 @@
|
|||
* during the execution of the class methods.
|
||||
*/
|
||||
class Notifications {
|
||||
|
||||
/**
|
||||
* Class Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// @task Define some vars and constants
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -87,15 +90,31 @@ class Notifications {
|
|||
$from_name = $CI->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 {
|
|||
</html>';
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ class Appointments_Model extends CI_Model {
|
|||
return $appointment_id;
|
||||
|
||||
} catch (Exception $exc) {
|
||||
echo $exc->getTraceAsString();
|
||||
echo $exc->getMessage() . '<br/><pre>' . $exc->getTraceAsString() . '</pre>';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Providers_Model extends CI_Model {
|
||||
/**
|
||||
* Class Constructor
|
||||
|
@ -31,6 +32,27 @@ class Providers_Model extends CI_Model {
|
|||
return $this->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 */
|
24
src/application/models/roles_model.php
Normal file
24
src/application/models/roles_model.php
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Roles_Model extends CI_Model {
|
||||
/**
|
||||
* Class Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the record id of a particular role.
|
||||
*
|
||||
* @param string $role_slug The selected role slug. Slugs are
|
||||
* defined in the "application/config/constants.php" file.
|
||||
* @return int Returns the database id of the roles record.
|
||||
*/
|
||||
public function get_role_id($role_slug) {
|
||||
return $this->db->get_where('ea_roles', array('slug' => $role_slug))->row()->id;
|
||||
}
|
||||
}
|
||||
|
||||
/* End of file roles_model.php */
|
||||
/* Location: ./application/models/roles_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.
|
||||
*
|
||||
|
|
|
@ -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.');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
|
|
63
src/assets/js/general_functions.js
Normal file
63
src/assets/js/general_functions.js
Normal file
|
@ -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 = "<No Title Given>";
|
||||
}
|
||||
|
||||
if (message == undefined || message == "") {
|
||||
message = "<No Message Given>";
|
||||
}
|
||||
|
||||
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(
|
||||
"<div id='message_box' title='" + title + "'>" +
|
||||
"<p>" + message + "</p>" +
|
||||
"</div>"
|
||||
);
|
||||
|
||||
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();
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
132
test/AppointmentsModelTest.php
Normal file
132
test/AppointmentsModelTest.php
Normal file
|
@ -0,0 +1,132 @@
|
|||
<?php
|
||||
class AppointmentsModelTest extends PHPUnit_Framework_TestCase {
|
||||
private $CI;
|
||||
private $id_users_provider;
|
||||
private $id_users_customer;
|
||||
private $id_services;
|
||||
|
||||
public function setUp() {
|
||||
$this->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 */
|
212
test/bootstrap.php
Normal file
212
test/bootstrap.php
Normal file
|
@ -0,0 +1,212 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
*---------------------------------------------------------------
|
||||
* APPLICATION ENVIRONMENT
|
||||
*---------------------------------------------------------------
|
||||
*
|
||||
* You can load different configurations depending on your
|
||||
* current environment. Setting the environment also influences
|
||||
* things like logging and error reporting.
|
||||
*
|
||||
* This can be set to anything, but default usage is:
|
||||
*
|
||||
* development
|
||||
* testing
|
||||
* production
|
||||
*
|
||||
* NOTE: If you change these, also change the error_reporting() code below
|
||||
*
|
||||
*/
|
||||
define('ENVIRONMENT', 'testing');
|
||||
/*
|
||||
*---------------------------------------------------------------
|
||||
* ERROR REPORTING
|
||||
*---------------------------------------------------------------
|
||||
*
|
||||
* Different environments will require different levels of error reporting.
|
||||
* By default development will show errors but testing and live will hide them.
|
||||
*/
|
||||
|
||||
if (defined('ENVIRONMENT'))
|
||||
{
|
||||
switch (ENVIRONMENT)
|
||||
{
|
||||
case 'development':
|
||||
error_reporting(E_ALL);
|
||||
break;
|
||||
|
||||
case 'testing':
|
||||
case 'production':
|
||||
error_reporting(0);
|
||||
break;
|
||||
|
||||
default:
|
||||
exit('The application environment is not set correctly.');
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*---------------------------------------------------------------
|
||||
* SYSTEM FOLDER NAME
|
||||
*---------------------------------------------------------------
|
||||
*
|
||||
* This variable must contain the name of your "system" folder.
|
||||
* Include the path if the folder is not in the same directory
|
||||
* as this file.
|
||||
*
|
||||
*/
|
||||
$system_path = '../src/system';
|
||||
|
||||
/*
|
||||
*---------------------------------------------------------------
|
||||
* APPLICATION FOLDER NAME
|
||||
*---------------------------------------------------------------
|
||||
*
|
||||
* If you want this front controller to use a different "application"
|
||||
* folder then the default one you can set its name here. The folder
|
||||
* can also be renamed or relocated anywhere on your server. If
|
||||
* you do, use a full server path. For more info please see the user guide:
|
||||
* http://codeigniter.com/user_guide/general/managing_apps.html
|
||||
*
|
||||
* NO TRAILING SLASH!
|
||||
*
|
||||
*/
|
||||
$application_folder = '../src/application';
|
||||
|
||||
/*
|
||||
* --------------------------------------------------------------------
|
||||
* DEFAULT CONTROLLER
|
||||
* --------------------------------------------------------------------
|
||||
*
|
||||
* Normally you will set your default controller in the routes.php file.
|
||||
* You can, however, force a custom routing by hard-coding a
|
||||
* specific controller class/function here. For most applications, you
|
||||
* WILL NOT set your routing here, but it's an option for those
|
||||
* special instances where you might want to override the standard
|
||||
* routing in a specific front controller that shares a common CI installation.
|
||||
*
|
||||
* IMPORTANT: If you set the routing here, NO OTHER controller will be
|
||||
* callable. In essence, this preference limits your application to ONE
|
||||
* specific controller. Leave the function name blank if you need
|
||||
* to call functions dynamically via the URI.
|
||||
*
|
||||
* Un-comment the $routing array below to use this feature
|
||||
*
|
||||
*/
|
||||
// The directory name, relative to the "controllers" folder. Leave blank
|
||||
// if your controller is not in a sub-folder within the "controllers" folder
|
||||
// $routing['directory'] = '';
|
||||
|
||||
// The controller class file name. Example: Mycontroller
|
||||
// $routing['controller'] = '';
|
||||
|
||||
// The controller function you wish to be called.
|
||||
// $routing['function'] = '';
|
||||
|
||||
|
||||
/*
|
||||
* -------------------------------------------------------------------
|
||||
* CUSTOM CONFIG VALUES
|
||||
* -------------------------------------------------------------------
|
||||
*
|
||||
* The $assign_to_config array below will be passed dynamically to the
|
||||
* config class when initialized. This allows you to set custom config
|
||||
* items or override any default config values found in the config.php file.
|
||||
* This can be handy as it permits you to share one application between
|
||||
* multiple front controller files, with each file containing different
|
||||
* config values.
|
||||
*
|
||||
* Un-comment the $assign_to_config array below to use this feature
|
||||
*
|
||||
*/
|
||||
// $assign_to_config['name_of_config_item'] = 'value of config item';
|
||||
$assign_to_config['uri_protocol'] = 'PATH_INFO'; // This is needed to run tests on netbeans and code igniter.
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// END OF USER CONFIGURABLE SETTINGS. DO NOT EDIT BELOW THIS LINE
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
* ---------------------------------------------------------------
|
||||
* Resolve the system path for increased reliability
|
||||
* ---------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// Set the current directory correctly for CLI requests
|
||||
if (defined('STDIN'))
|
||||
{
|
||||
chdir(dirname(__FILE__));
|
||||
}
|
||||
|
||||
if (realpath($system_path) !== FALSE)
|
||||
{
|
||||
$system_path = realpath($system_path).'/';
|
||||
}
|
||||
|
||||
// ensure there's a trailing slash
|
||||
$system_path = rtrim($system_path, '/').'/';
|
||||
|
||||
// Is the system path correct?
|
||||
if ( ! is_dir($system_path))
|
||||
{
|
||||
exit("Your system folder path does not appear to be set correctly. Please open the following file and correct this: ".pathinfo(__FILE__, PATHINFO_BASENAME));
|
||||
}
|
||||
|
||||
/*
|
||||
* -------------------------------------------------------------------
|
||||
* Now that we know the path, set the main path constants
|
||||
* -------------------------------------------------------------------
|
||||
*/
|
||||
// The name of THIS file
|
||||
define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
|
||||
|
||||
// The PHP file extension
|
||||
// this global constant is deprecated.
|
||||
define('EXT', '.php');
|
||||
|
||||
// Path to the system folder
|
||||
define('BASEPATH', str_replace("\\", "/", $system_path));
|
||||
|
||||
// Path to the front controller (this file)
|
||||
define('FCPATH', str_replace(SELF, '', __FILE__));
|
||||
|
||||
// Name of the "system folder"
|
||||
define('SYSDIR', trim(strrchr(trim(BASEPATH, '/'), '/'), '/'));
|
||||
|
||||
|
||||
// The path to the "application" folder
|
||||
if (is_dir($application_folder))
|
||||
{
|
||||
define('APPPATH', $application_folder.'/');
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( ! is_dir(BASEPATH.$application_folder.'/'))
|
||||
{
|
||||
exit("Your application folder path does not appear to be set correctly. Please open the following file and correct this: ".SELF);
|
||||
}
|
||||
|
||||
define('APPPATH', BASEPATH.$application_folder.'/');
|
||||
}
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------
|
||||
* CHECK IF EASY!APPOINTMENTS IS INSTALLED AND CONFIGURED
|
||||
* --------------------------------------------------------------------
|
||||
*/
|
||||
// If not show the installer instead of the main page.
|
||||
|
||||
/*
|
||||
* --------------------------------------------------------------------
|
||||
* LOAD THE BOOTSTRAP FILE
|
||||
* --------------------------------------------------------------------
|
||||
*
|
||||
* And away we go...
|
||||
*
|
||||
*/
|
||||
require_once BASEPATH.'core/CodeIgniter.php';
|
||||
|
||||
/* End of file index.php */
|
||||
/* Location: ./index.php */
|
10
test/phpunit.xml
Normal file
10
test/phpunit.xml
Normal file
|
@ -0,0 +1,10 @@
|
|||
<phpunit bootstrap="bootstrap.php"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="true"
|
||||
stopOnFailure="false"
|
||||
syntaxCheck="true"
|
||||
verbose="true">
|
||||
</phpunit>
|
Loading…
Reference in a new issue