Created
March 20, 2017 04:17
-
-
Save tps2015gh/e35d12b925dd19a5829f5d2eb78a4d17 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
defined('BASEPATH') OR exit('No direct script access allowed'); | |
class MyUnittest10 extends CI_Controller { | |
function __construct() { | |
parent::__construct(); | |
//safeguard_check_controller_construct(); | |
} | |
function index(){ | |
echo "<h1>UnitTest3</h1><ol>"; | |
$this->a1(); | |
$this->a2(); | |
$this->a3(); | |
echo "</ol>"; | |
} | |
function _failon($msg, $require1 = "", $found =""){ | |
if($require1){ | |
return "<li><font color=red><b> Fail on $msg </b> </font>, require <b>'$require1'</b> but found '$found' </li>"; | |
}else{ | |
return "<li><font color=red><b> Fail on $msg </b> </font>"; | |
} | |
} | |
function _okon($msg){ | |
return "<li><font color=blue><b> OK on $msg</b></font></li>"; | |
} | |
function a1(){ | |
$require1 = "reset_pass_hash"; | |
$uf= $this->db->list_fields("app1_user"); | |
$msg = "table user must have field $require1 " ; | |
if( !in_array($require1, $uf)){ | |
echo $this->_failon( $msg , $require1 ); | |
}else{ | |
echo $this->_okon( $msg ); | |
} | |
} | |
function a2(){ | |
$require1 = "reset_pass_hash"; | |
$uf= $this->db->list_fields("app1_admin"); | |
$msg = "table admin must have field $require1 " ; | |
if( !in_array($require1, $uf)){ | |
echo $this->_failon( $msg , "" ); | |
}else{ | |
echo $this->_okon( $msg ); | |
} | |
} // function | |
function a3(){ | |
$q = $this->db->query("select count(*) as c1 from t_user where reset_pass is null "); | |
$r = $q->row(); | |
$c1 = $r->c1; | |
if($c1 == 0 ){ | |
echo $this->_okon( " count (user.reset_pass where null ) must == 0 " ); | |
}else{ | |
echo $this->_failon( " count (user.reset_pass where null ) must == 0 " , " 0 ", $c1 ); | |
} | |
} // function | |
} // class |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment