projroot = $projroot;
$this->name = $name;
$this->ext = $ext;
if ( strlen( $ext ) > 0 ) {
$ns = explode( '.' , $name );
$n = array_pop( $ns );
array_push( $ns , $ext , $n );
$path = implode( '/' , $ns );
} else {
//$path = implode( '/' , explode( '.' , $name ) );
$path = $name; //为了支持xx.xx.js类型的文件名而修改 田丽丽
}
// $dir = explode('/',$path);
// if($dir[0]=='dialogs')
// $this->path = $this->projroot . '_test/' . $path . '.html';
// else
$this->path = $this->projroot . '_test/' . $path . '.js';
if ( filesize( $this->path ) < 20 ) {
$this->empty = true;
return;
}
$this->case_id = 'id_case_' . join( '_' , explode( '.' , $name ) );
}
public function print_js( $cov, $release = false )
{
print ''. "\n";
print ''. "\n";
print ''. "\n";
print ''. "\n";
print ''. "\n";
print ''. "\n";
print ''. "\n";
print ''. "\n";
print ''. "\n"; // print '' . "\n";
print ''. "\n";
/* load case source*/
$importurl = "{$this->projroot}_test/tools/br/import.php?f=$this->name";
if ( $cov ) $importurl .= '^&cov=true';
print "\n";
/* load case and case dependents*/
//$ps = explode( '.' , $this->name );
$ps = explode( '/' , $this->name ); //为了支持xx.xx.js类型的文件名而修改 田丽丽
array_pop( $ps );
array_push( $ps , 'tools' );
if ( file_exists( $this->projroot . '_test/' . implode( '/' , $ps ) . '.js' ) ) //没有就不加载了
print '' . "\n";
print '' . "\n";
}
public function print_all_js( $cov, $release = false )
{
print ''. "\n";
print ''. "\n";
print ''. "\n";
print ''. "\n";
print ''. "\n";
print ''. "\n";
print ''. "\n";
print ''. "\n";
print ''. "\n";
print '' . "\n";
/* load case source*/
$importurl = "{$this->projroot}ueditor/ueditor.all.min.js";
print "\n";
/* load case and case dependents*/
//$ps = explode( '.' , $this->name );
$ps = explode( '/' , $this->name ); //为了支持xx.xx.js类型的文件名而修改 田丽丽
array_pop( $ps );
array_push( $ps , 'tools' );
if ( file_exists( $this->projroot . '_test/' . implode( '/' , $ps ) . '.js' ) ) //没有就不加载了
print '' . "\n";
print '' . "\n";
}
public function match( $matcher )
{
if ( $matcher == '*' )
return true;
$len = strlen( $matcher );
/**
* 处理多选分支,有一个成功则成功,filter后面参数使用|切割
* @var Array
*/
$as = explode( ';' , $matcher );
if ($as != false && sizeof( $as ) > 1 ) {
//这里把或的逻辑改成与
foreach ( $as as $matcher1 ) {
if ( $this->match( $matcher1 ) )
return true;
}
return false;
}
$ms = explode( ',' , $matcher );
if ( sizeof( $ms ) > 1 ) {
//这里把或的逻辑改成与
foreach ( $ms as $matcher1 ) {
if ( !$this->match( $matcher1 ) )
return false;
}
return true;
}
/**
* 处理反向选择分支
*/
if ( substr( $matcher , 0 , 1 ) == '!' ) {
$m = substr( $matcher , 1 );
if ( substr( $this->name , 0 , strlen( $m ) ) == $m )
return false;
return true;
}
if ( $len > strlen( $this->name ) ) {
return false;
}
return substr( $this->name , 0 , $len ) == $matcher;
}
public static function listcase( $filter = "*" , $filterRun = '*',$projroot = '../../../' )
{
$srcpath = $projroot . '_src/';
$testpath = $projroot . '_test/';
require_once 'filehelper.php';
$caselist = getSameFile( $srcpath , $testpath , '' );
sort($caselist,SORT_STRING);
foreach ( $caselist as $caseitem ) {
/*将文件名替换为域名方式,替换/为.,移除.js*/
//$name = str_replace( '/' , '.' , substr( $caseitem , 0 , -3 ) );
$name = substr( $caseitem , 0 , -3 ); //为了支持xx.xx.js类型的文件名而修改 田丽丽
$c = new Kiss( $projroot , $name );
if ( $c->empty )
continue;
if ( $c->match( $filterRun ) ) {
$newName = explode( '\\.' , $name );
$newName = $newName[ count( $newName ) - 1 ];
print( "/*过长的时候屏蔽超出20的部分,因为隐藏的处理,所有用例不能直接使用标签a中的innerHTML,而应该使用title*/". $newName . "\n" );
}
}
/**
* 设置在源码路径下没有同名文件对应的测试文件
*/
foreach(Config::$special_Case as $s_caseitem => $s_source){
//取形如 'plugins/config_test.js' 中 'plugins/config_test'部分
$s_newName = str_replace(".js","", $s_caseitem );
print( "". $s_newName . "\n" );
}
}
public static function listSrcOnly( $print = true , $projroot = '../../../' )
{
$srcpath = $projroot . '_src/';
$testpath = $projroot . '_test/';
require_once 'filehelper.php';
$caselist = getSameFile( $srcpath , $testpath , '' );
$srclist = getSrcOnlyFile( $srcpath , $testpath , '' );
$srcList = array();
foreach ( $srclist as $case ) {
if ( in_array( $case , $caselist ) )
continue;
$name = str_replace( '/' , '.' , substr( $case , 0 , -3 ) );
$tag = "" . ( strlen( $name ) > 20 ? substr( $name , 6 )
: $name ) . "";
array_push( $srcList , $tag );
if ( $print )
echo $tag;
}
return $srcList;
}
}
?>