2013-05-11 13:19:18 +03:00
|
|
|
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
|
|
|
|
class Test extends CI_Controller {
|
|
|
|
/**
|
|
|
|
* Class Constructor
|
|
|
|
*/
|
|
|
|
public function __construct() {
|
|
|
|
parent::__construct();
|
|
|
|
$this->load->driver('Unit_tests');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Run all available unit tests.
|
2013-10-19 13:34:32 +03:00
|
|
|
*
|
|
|
|
* We only test models at the moment. In the future the unit test will be
|
|
|
|
* improved.
|
2013-05-11 13:19:18 +03:00
|
|
|
*/
|
|
|
|
public function index() {
|
2013-10-19 13:34:32 +03:00
|
|
|
// User must be logged in as an admin in order to run the tests.
|
|
|
|
$this->load->library('session');
|
2015-05-21 00:18:27 +03:00
|
|
|
$this->session->set_userdata('dest_url', $this->config->item('base_url') . '/index.php/test');
|
2013-10-19 13:34:32 +03:00
|
|
|
if ($this->session->userdata('role_slug') != DB_SLUG_ADMIN) {
|
2015-05-21 00:18:27 +03:00
|
|
|
header('Location: ' . $this->config->item('base_url') . '/index.php/user/login');
|
2013-10-19 13:34:32 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-01-11 02:07:25 +02:00
|
|
|
if (ENVIRONMENT !== 'development') {
|
|
|
|
$this->output->set_output('Tests are available only at development environment. '
|
|
|
|
. 'Please check your "index.php" file settings.');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-05-11 13:19:18 +03:00
|
|
|
$this->load->view('general/test');
|
|
|
|
$this->unit_tests->run_all_tests();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test only the app models.
|
|
|
|
*/
|
|
|
|
public function models() {
|
2013-10-19 13:34:32 +03:00
|
|
|
//$this->load->view('general/test');
|
|
|
|
//$this->unit_tests->run_model_tests();
|
2013-05-11 13:19:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test only the app libraries.
|
|
|
|
*/
|
|
|
|
public function libraries() {
|
2013-10-19 13:34:32 +03:00
|
|
|
//$this->load->view('general/test');
|
|
|
|
//$this->unit_tests->run_library_tests();
|
2013-05-11 13:19:18 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* End of file test.php */
|
|
|
|
/* Location: ./application/controllers/test.php */
|