1 <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2
3 /**
4 * Unit testing driver.
5 *
6 * This driver handles all the unit testing of the application.
7 * Custom methods (test categories) can be created in order to
8 * use different test groups on each testing
9 */
10 class Unit_tests extends CI_Driver_Library {
11 public $CI;
12 public $valid_drivers;
13
14 /**
15 * Class Constructor
16 */
17 public function __construct() {
18 $this->CI =& get_instance();
19 // Add more subclasses to the following array to expand
20 // the unit testing classes.
21 $this->valid_drivers = array(
22 'Unit_tests_appointments_model',
23 'Unit_tests_customers_model',
24 'Unit_tests_providers_model',
25 'Unit_tests_services_model',
26 'Unit_tests_settings_model',
27 'Unit_tests_admins_model',
28 'Unit_tests_secretaries_model'
29 );
30 }
31
32 /**
33 * Run all the available tests of the system.
34 *
35 * If a new group of tests is added, it should be also added in
36 * this method, in order to be executed when all the tests need to
37 * be run.
38 */
39 public function run_all_tests() {
40 $this->run_model_tests(false);
41 $this->run_library_tests(false);
42 $this->CI->output->append_output($this->CI->unit->report());
43 }
44
45 ///////////////////////////////////////////////////////////////////////////
46 // UNIT TEST GROUPS
47 ///////////////////////////////////////////////////////////////////////////
48 /**
49 * Run all the models tests.
50 *
51 * @param bool $output_report Determines wether the test report
52 * will be outputted.
53 */
54 public function run_model_tests($output_report = true) {
55 $this->appointments_model->run_all();
56 $this->customers_model->run_all();
57 $this->settings_model->run_all();
58 $this->providers_model->run_all();
59 $this->services_model->run_all();
60 $this->admins_model->run_all();
61 $this->secretaries_model->run_all();
62
63 if ($output_report) {
64 $this->CI->output->append_output($this->CI->unit->report());
65 }
66 }
67
68 /**
69 * Run all the library tests.
70 *
71 * @param bool $output_report Determines wether the test
72 * report will be outputted.
73 */
74 public function run_library_tests($output_report = true) {
75 // No tests for libraries at the moment.
76 if ($output_report) {
77 $this->CI->output->append_output($this->CI->unit->report());
78 }
79 }
80 }