/** * @dataProvider formProvider */ public function testCheckForm($username = '', $password = '', $verifycode = '', $err = '', $ajax_status = '', $alter_mes = '', $warnings_key = '') { $this->CI = set_controller('ajax/login'); $this->CI->session->set_userdata('auth_code', $this->app_authcode); $_GET['username'] = $username; $_GET['password'] = $password; $_GET['verifycode'] = $verifycode; $_GET['err'] = $err; // init $this->CI->ajax->warnings = array(); $this->CI->ajax->errors = array(); $this->CI->ajax->successes = array(); // ob 忽略输出 ob_start(); $result = $this->CI->check_form(); ob_end_clean(); $status = $this->CI->ajax->status_code; $mes = ''; if (count($this->CI->ajax->warnings) != 0) { $mes = $this->CI->ajax->warnings[$warnings_key]; } // error mes path if (count($this->CI->ajax->errors) != 0) { $mes = $this->CI->ajax->errors[$warnings_key]; } // error mes path if (count($this->CI->ajax->successes) != 0) { $mes = $this->CI->ajax->successes[$warnings_key]; } // 断言 $this->assertEquals($mes, $alter_mes); $this->assertEquals($status, $ajax_status); }
public function testAfterReg() { $this->CI = set_controller('ajax/register'); //全局变量 侵入 $data_success_with_invite = array('phone' => '18810556559', 'password' => '123456', 'smsCode' => '123456', 'verifycode' => '1234', 'invite_uid' => '2'); //全局变量 侵入 foreach ($data_success_with_invite as $key => $value) { $_GET[$key] = $value; } // 图片验证码 1234 $this->CI->session->set_userdata('auth_code', $this->authcode); // 短信验证码 123456 $this->CI->session->set_userdata('smsCode', $this->smscode); // 引入 safe_md5(),用于校验 cookie 中的md5 $this->CI->load->helper('string'); $_COOKIE['phone_send'] = safe_md5($data_success_with_invite['phone']); // init $this->CI->ajax->warnings = array(); $this->CI->ajax->errors = array(); $this->CI->ajax->successes = array(); // ob 忽略输出 // ob_start(); $this->CI->do_reg(); ob_end_clean(); $status = $this->CI->ajax->status_code; $mes = ''; $this->assertEquals(200, $status); }
/** * setUp function. * * @access public * @return void */ public function __construct() { parent::__construct(); // Set the tested controller $this->_ci =& set_controller('welcome'); $this->_ci->router->class = 'welcome'; }
public function setUp() { parent::setUp(); $this->CI = set_controller('ums'); $this->dbfixt('razor_channel_product'); $this->dbfixt('razor_event_defination'); }
/** * Setup PHPUnit & load any required dependencies * @covers Ajax::__construct */ public function setUp() { // Set the tested controller $this->CI = set_controller('ajax'); parent::tearDown(); parent::setUp(); $this->CI->load->model('narrative_model'); }
public function testImg() { $this->CI = set_controller('index'); $authcode = '1234'; $this->CI->session->set_userdata('auth_code', $authcode); $result = $this->_lib_authcode->check($authcode); $this->assertEquals($result, TRUE); }
public function index() { $this->CI = set_controller('unit_testing'); $this->CI->usertesting(); // Fetch the buffered output $out = output(); // Check if the content is OK $this->assertSame(0, preg_match('/(error|notice)/i', $out)); // echo $this->unit->report(); }
public function testIndex() { // igone error ob_start(); $this->CI = set_controller('index'); ob_end_clean(); // Call the controllers method $result = $this->CI->test(); // $this->_controller->test(); // // var_dump($result); // // Check if the content is OK $this->assertEquals('1', '1'); }
public function testIsLoginAndDoReg() { $_COOKIE['uid'] = '1'; $_COOKIE['keep_code'] = '123123'; // igone error ob_start(); $this->CI = set_controller('ajax/register'); ob_end_clean(); // $this->CI->do_reg(); $this->CI->lang->load('regANDlogin', 'chinese'); // 断言 $this->assertEquals($this->CI->ajax->errors['register_errors'], $this->CI->lang->line('reg_user_status_is_login')); $this->assertEquals(400, $this->CI->ajax->status_code); }
public function test_CI_Unit_Test_Class() { $test_path = APPPATH . 'controllers'; $test_folder = 'tests'; $has_failed = FALSE; foreach (glob("{$test_path}/{$test_folder}/*.php") as $filename) { $filename = basename($filename, '.php'); $this->CI = set_controller("{$test_folder}/{$filename}"); echo "\nCI Unit Testing Class: {$test_folder}/{$filename}\n"; if ($this->_run_ci_unit_test() === FALSE) { $has_failed = TRUE; } } if ($has_failed) { $this->fail(); } }
/** * @dataProvider regFormProvider */ public function testRegWithOutLogin($input_data, $expect_status, $mes_key, $expect_message) { // ob 忽略输出 // ob_start(); $this->CI = set_controller('ajax/register'); // ob_end_clean(); $this->CI->session->set_userdata('LOGINuser_id', ''); //全局变量 侵入 foreach ($input_data as $key => $value) { $_GET[$key] = $value; } // 图片验证码 1234 $this->CI->session->set_userdata('auth_code', $this->authcode); // 短信验证码 123456 $this->CI->session->set_userdata('smsCode', $this->smscode); // 引入 safe_md5(),用于校验 cookie 中的md5 $this->CI->load->helper('string'); $_COOKIE['phone_send'] = safe_md5($input_data['phone']); // init $this->CI->ajax->warnings = array(); $this->CI->ajax->errors = array(); $this->CI->ajax->successes = array(); // ob 忽略输出 // ob_start(); $this->CI->do_reg(); // ob_end_clean(); $status = $this->CI->ajax->status_code; $mes = ''; if (count($this->CI->ajax->errors) != 0) { $mes = $this->CI->ajax->errors[$mes_key]; } if (count($this->CI->ajax->successes) != 0) { $mes = $this->CI->ajax->successes[$mes_key]; } // 断言 $this->assertEquals($expect_status, $status); $this->assertEquals($expect_message, $mes); }
function __construct() { $this->CI =& set_controller('MY_Controller'); $this->CI->load->library('Spyc'); }
function setUp() { $this->CI = set_controller('welcome'); }
protected function setUp() { $this->CI =& set_controller(); $this->CI->load->library('Spyc'); }
} // The path to CIUnit if (is_dir($ciunit_folder)) { define('CIUPATH', $ciunit_folder . '/'); } else { if (!is_dir(APPPATH . 'third_party/' . $ciunit_folder)) { exit("Your CIUnit folder path does not appear to be set correctly. Please open the following file and correct this: " . SELF); } define('CIUPATH', APPPATH . 'third_party/' . $ciunit_folder); } // The path to the Tests folder define('TESTSPATH', realpath($tests_folder) . '/'); /* * -------------------------------------------------------------------- * LOAD THE BOOTSTRAP FILE * -------------------------------------------------------------------- * * And away we go... * */ // Load the CIUnit CodeIgniter Core require_once CIUPATH . 'core/CodeIgniter.php'; // Load the CIUnit Framework require_once CIUPATH . 'libraries/CIUnit.php'; //=== and off we go === $CI =& set_controller('CIU_Controller', CIUPATH . 'core/'); $CI->load->add_package_path(CIUPATH); CIUnit::$spyc = new Spyc(); require_once CIUPATH . 'libraries/Fixture.php'; $CI->fixture = new Fixture(); CIUnit::$fixture =& $CI->fixture;
public function setUp() { parent::setUp(); $this->CI = set_controller('twiml'); }
public function setUp() { // Set the tested controller $this->CI = set_controller('admin/dashboard'); }
function &get_controller() { return CIUnit::get_controller(); } /** * retrieves the cached output from the output class * and resets it */ function output() { return CIUnit::$controller->output->pop_output(); } /** * retrieves the cached template vars from the loader class (stored here for assignment to views) * and resets them */ function viewvars() { if (isset(CIUnit::$controller->load->_ci_cached_vars)) { $out = CIUnit::$controller->load->_ci_cached_vars; CIUnit::$controller->load->_ci_cached_vars = array(); return $out; } return array(); } //=== and off we go === $CI =& set_controller(); // $CI->load->library('fooStack/Spyc'); // CIUnit::$spyc = &$CI->spyc; $CI->load->library('fooStack/Fixture'); CIUnit::$fixture =& $CI->fixture;
function __construct() { $this->CI =& set_controller('CI_Controller'); $this->CI->load->database(); }
public function setUp() { // Set the tested controller $this->CI = set_controller('kqavos'); }
public function setUp() { // Set the tested controller $this->CI = set_controller('welcome'); }
function testDifferentControllers() { $default_controller =& set_controller('Controller_fixt', TESTSPATH . 'fixtures/'); $second_controller =& set_controller('Controller_fixt2', TESTSPATH . 'fixtures/'); $default_controller =& set_controller('Controller_fixt', TESTSPATH . 'fixtures/'); $this->assertEquals('Controller_fixt', get_class($default_controller)); $this->assertEquals('Controller_fixt2', get_class($second_controller)); }
public function setUp() { // Set the tested controller $this->CI = set_controller('apis/event'); }