<?php /** * Unit_test Class * * Created on 2011. 11. 16. * @author 불의회상 <hoksi2k@hanmail.net> * @package library * @subpackage controllers * @version 1.0 */ class Unit_test_lib extends CI_Controller { function __construct() { parent::__construct(); $this->load->library('unit_test'); } function index() { $this->load->library('unit_test'); $this->_view(); } function template() { $this->load->library('unit_test'); $template = "{rows}<div>{item} : {result}<br/></div>\n{/rows}"; $this->unit->set_template($template); $this->_view(); } function _view() { // 단위 테스트 설정 $test = 1 + 1; $expected_result = 2; $test_name = 'Adds one plus one'; // 단위 테스트 실행 $data['unit_test'] = $this->unit->run($test, $expected_result, $test_name); // Stric Mode On(데이터형과 값을 동시에 검사) $this->unit->use_strict(TRUE); $data['strict_on'] = $this->unit->run(1, TRUE); // Stric Mode Off(Default, 데이터형과 값을 동시에 검사) $this->unit->use_strict(FALSE); $data['strict_off'] = $this->unit->run(1, TRUE); // 단위 테스트 비활성화 $this->unit->active(FALSE); $data['unit_test_off'] = $this->unit->run('a', TRUE); // 단위 테스트 활성화 $this->unit->active(TRUE); $data['unit_test_on'] = $this->unit->run('a', TRUE); // 테스트 결과 표시 설정 $this->unit->set_test_items(array('test_name', 'result')); $data['test_items'] = $this->unit->run('a', TRUE); $this->load->view('unit_test_lib_sample', $data); } }
<?php $this->load->view('inc/header')?> <table class="tablesorter" border="0" cellpadding="0" cellspacing="1"> <thead> <tr> <th style="text-align:center" colspan="2">Unit Test Class</th> </tr> </thead> <tr> <td colspan="2"> <input type="button" value="Default Template" onclick="document.location.href='<?=site_url('unit_test_lib')?>'" /> <input type="button" value="Custom Template" onclick="document.location.href='<?=site_url('unit_test_lib/template')?>'" /> </td> </tr> <thead> <tr> <th style="text-align:center" width="20%">테스트명</th> <th width="80%">값</th> </tr> </thead> <tr> <td>Adds one plus one</td> <td><?php echo $unit_test?></td> </tr> <tr> <td>Strict On</td> <td><?php echo $strict_on?></td> </tr> <tr> <td>Strict Off</td> <td><?php echo $strict_off?></td> </tr> <tr> <td>Unit Test On</td> <td><?php echo $unit_test_on?></td> </tr> <tr> <td>Unit Test Off</td> <td><?php echo $unit_test_off?></td> </tr> <tr> <td>Unit Test Items Set</td> <td><?php echo $test_items?></td> </tr> </table> <?php $this->load->view('inc/footer')?>
© Copyright by hoksi(Page rendered in 0.0068 seconds)