+ Move unit test from test directory to each module.
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
class datatableTest
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
global $tester;
|
||||
$this->objectModel = $tester->loadModel('datatable');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get field list.
|
||||
*
|
||||
* @param string $module
|
||||
* @param string $method
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function getFieldListTest($module, $method)
|
||||
{
|
||||
$module = zget($this->objectModel->config->datatable->moduleAlias, "$module-$method", $module);
|
||||
$result = $this->objectModel->getFieldList($module);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get save setting field.
|
||||
*
|
||||
* @param string $module
|
||||
* @param string $method
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function getSettingTest($module, $method)
|
||||
{
|
||||
$this->objectModel->app->methodName = $method;
|
||||
$result = $this->objectModel->getSetting($module);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test print table head.
|
||||
*
|
||||
* @param array $data
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function printHeadTest($data)
|
||||
{
|
||||
ob_start();
|
||||
$this->objectModel->printHead($data['cols'], $data['orderBy'], $data['vars'], $data['checkBox']);
|
||||
$head = ob_get_clean();
|
||||
|
||||
$isTh = strpos($head, '<th data-flex') !== false ? true : false;
|
||||
$order = $data['orderBy'] ? (strpos($head, "class='sort-") !== false ? true : false) : true;
|
||||
$vars = $data['vars'] ? (strpos($head, $data['vars']) !== false ? true : false) : true;
|
||||
$check = $data['checkBox'] ? (strpos($head, 'checkbox-primary') !== false ? true : false) : true;
|
||||
$result = ($isTh and $order and $vars and $check) ? true : false;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test set fixed field width.
|
||||
*
|
||||
* @param object $setting
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function setFixedFieldWidthTest($setting)
|
||||
{
|
||||
$result = $this->objectModel->setFixedFieldWidth($setting);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
Executable
+24
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . "/test/lib/init.php";
|
||||
include dirname(__FILE__, 2) . '/datatable.class.php';
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试 datatableModel::getFieldList();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
获取产品模块browse方法自定义列 >> ID
|
||||
获取项目模块browse方法自定义列 >> 项目名称
|
||||
获取执行模块task方法自定义列 >> 70
|
||||
获取测试用例模块browse方法自定义列 >> auto
|
||||
|
||||
*/
|
||||
|
||||
$datatable = new datatableTest();
|
||||
r($datatable->getFieldListTest('product', 'browse')) && p('id:title') && e('ID'); //获取产品模块browse方法自定义列
|
||||
r($datatable->getFieldListTest('project', 'browse')) && p('name:title') && e('项目名称'); //获取项目模块browse方法自定义列
|
||||
r($datatable->getFieldListTest('execution', 'task')) && p('id:width') && e('70'); //获取执行模块task方法自定义列
|
||||
r($datatable->getFieldListTest('testcase', 'browse')) && p('title:width') && e('auto'); //获取测试用例模块browse方法自定义列
|
||||
Executable
+24
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . "/test/lib/init.php";
|
||||
include dirname(__FILE__, 2) . '/datatable.class.php';
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试 datatableModel::getSetting();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
获取产品模块browse方法设置 >> ID
|
||||
获取项目模块browse方法设置 >> 项目名称
|
||||
获取执行模块task方法设置 >> 70
|
||||
获取测试用例模块browse方法设置 >> auto
|
||||
|
||||
*/
|
||||
|
||||
$datatable = new datatableTest();
|
||||
r($datatable->getSettingTest('product', 'browse')) && p('0:title') && e('ID'); //获取产品模块browse方法设置
|
||||
r($datatable->getSettingTest('project', 'browse')) && p('1:title') && e('项目名称'); //获取项目模块browse方法设置
|
||||
r($datatable->getSettingTest('execution', 'task')) && p('0:width') && e('70'); //获取执行模块task方法设置
|
||||
r($datatable->getSettingTest('testcase', 'browse')) && p('2:width') && e('auto'); //获取测试用例模块browse方法设置
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . "/test/lib/init.php";
|
||||
include dirname(__FILE__, 2) . '/datatable.class.php';
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试 datatableModel::printHead();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
获取产品模块browse方法头部html >> 1
|
||||
获取产品模块browse方法头部html带排序 >> 1
|
||||
获取产品模块browse方法头部html带参数 >> 1
|
||||
获取产品模块browse方法头部html带checkbox >> 1
|
||||
|
||||
*/
|
||||
|
||||
$datatable = new datatableTest();
|
||||
$productSetting = $datatable->getSettingTest('product', 'browse');
|
||||
|
||||
$data = array('cols' => $productSetting[0], 'orderBy' => '', 'vars' => '', 'checkBox' => false);
|
||||
$data_order = array('cols' => $productSetting[0], 'orderBy' => 'id_asc', 'vars' => '', 'checkBox' => false);
|
||||
$data_vars = array('cols' => $productSetting[0], 'orderBy' => 'id_asc', 'vars' => 'productID=1', 'checkBox' => false);
|
||||
$data_check = array('cols' => $productSetting[0], 'orderBy' => 'id_asc', 'vars' => 'productID=1', 'checkBox' => true);
|
||||
|
||||
r($datatable->printHeadTest($data)) && p() && e(1); //获取产品模块browse方法头部html
|
||||
r($datatable->printHeadTest($data_order)) && p() && e(1); //获取产品模块browse方法头部html带排序
|
||||
r($datatable->printHeadTest($data_vars)) && p() && e(1); //获取产品模块browse方法头部html带参数
|
||||
r($datatable->printHeadTest($data_check)) && p() && e(1); //获取产品模块browse方法头部html带checkbox
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . "/test/lib/init.php";
|
||||
include dirname(__FILE__, 2) . '/datatable.class.php';
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试 datatableModel::setFixedFieldWidth();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
获取产品模块browse方法设置宽度 >> 550
|
||||
获取项目模块browse方法设置宽度 >> 180
|
||||
获取执行模块browse方法设置宽度 >> 550
|
||||
获取测试用例模块browse方法设置宽度 >> 150
|
||||
|
||||
*/
|
||||
|
||||
$datatable = new datatableTest();
|
||||
$productSetting = $datatable->getSettingTest('product', 'browse');
|
||||
$projectSetting = $datatable->getSettingTest('project', 'browse');
|
||||
$executionSetting = $datatable->getSettingTest('execution', 'task');
|
||||
$testcaseSetting = $datatable->getSettingTest('testcase', 'browse');
|
||||
|
||||
r($datatable->setFixedFieldWidthTest($productSetting)) && p('leftWidth') && e('550'); //获取产品模块browse方法设置宽度
|
||||
r($datatable->setFixedFieldWidthTest($projectSetting)) && p('rightWidth') && e('180'); //获取项目模块browse方法设置宽度
|
||||
r($datatable->setFixedFieldWidthTest($executionSetting)) && p('leftWidth') && e('550'); //获取执行模块browse方法设置宽度
|
||||
r($datatable->setFixedFieldWidthTest($testcaseSetting)) && p('rightWidth') && e('150'); //获取测试用例模块browse方法设置宽度
|
||||
Reference in New Issue
Block a user