mirror of
https://github.com/e107inc/e107.git
synced 2025-08-19 12:51:52 +02:00
Expanded admin-ui search query test.
This commit is contained in:
@@ -4904,9 +4904,9 @@ class e_admin_controller_ui extends e_admin_controller
|
|||||||
* @param mixed $qryField Specific query field(s) to filter.
|
* @param mixed $qryField Specific query field(s) to filter.
|
||||||
* @param mixed $isfilter Determines if a specific filter is applied.
|
* @param mixed $isfilter Determines if a specific filter is applied.
|
||||||
* @param mixed $handleAction Custom action handler for the search process.
|
* @param mixed $handleAction Custom action handler for the search process.
|
||||||
* @return void
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function _modifyListQrySearch(string|null $listQry, string $searchTerm, string $filterOptions, string $tablePath, string $tableFrom, string $primaryName, $raw, $orderField, $qryAsc, $forceFrom, int $qryFrom, $forceTo, int $perPage, $qryField, $isfilter, $handleAction)
|
public function _modifyListQrySearch(string|null $listQry, string $searchTerm, string $filterOptions, string $tablePath, string $tableFrom, string|null $primaryName, $raw, $orderField, $qryAsc, $forceFrom, int $qryFrom, $forceTo, int $perPage, $qryField, $isfilter, $handleAction)
|
||||||
{
|
{
|
||||||
$generateTest = false;
|
$generateTest = false;
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
@@ -4962,9 +4962,6 @@ class e_admin_controller_ui extends e_admin_controller
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(E107_DEBUG_LEVEL == E107_DBG_SQLQUERIES)
|
if(E107_DEBUG_LEVEL == E107_DBG_SQLQUERIES)
|
||||||
{
|
{
|
||||||
e107::getMessage()->addDebug('searchQuery: <b>' . $searchQuery . '</b>');
|
e107::getMessage()->addDebug('searchQuery: <b>' . $searchQuery . '</b>');
|
||||||
|
@@ -0,0 +1,203 @@
|
|||||||
|
{
|
||||||
|
"uri": "\/e107v2\/e107_admin\/banlist.php?searchquery=125.125.125.125+&filter_options=&etrigger_filter=etrigger_filter",
|
||||||
|
"methodInvocation": {
|
||||||
|
"listQry": "SELECT * FROM `#banlist` WHERE banlist_bantype != 100 ",
|
||||||
|
"searchTerm": "125.125.125.125",
|
||||||
|
"filterOptions": "",
|
||||||
|
"tablePath": "`#banlist`.",
|
||||||
|
"tableFrom": "`#banlist`",
|
||||||
|
"primaryName": "banlist_id",
|
||||||
|
"raw": false,
|
||||||
|
"orderField": null,
|
||||||
|
"qryAsc": null,
|
||||||
|
"forceFrom": false,
|
||||||
|
"qryFrom": 0,
|
||||||
|
"forceTo": false,
|
||||||
|
"perPage": 10,
|
||||||
|
"qryField": null,
|
||||||
|
"isfilter": false,
|
||||||
|
"handleAction": "List"
|
||||||
|
},
|
||||||
|
"preProcessedData": {
|
||||||
|
"fields": {
|
||||||
|
"checkboxes": {
|
||||||
|
"title": "",
|
||||||
|
"type": null,
|
||||||
|
"data": null,
|
||||||
|
"width": "5%",
|
||||||
|
"thclass": "center",
|
||||||
|
"forced": "1",
|
||||||
|
"class": "center",
|
||||||
|
"toggle": "e-multiselect",
|
||||||
|
"table": "banlist",
|
||||||
|
"alias": "",
|
||||||
|
"field": "checkboxes",
|
||||||
|
"__tableField": "`#banlist`.checkboxes",
|
||||||
|
"__tableFrom": "`#banlist`.checkboxes"
|
||||||
|
},
|
||||||
|
"banlist_id": {
|
||||||
|
"title": "ID",
|
||||||
|
"data": "int",
|
||||||
|
"width": "5%",
|
||||||
|
"help": "",
|
||||||
|
"readParms": "",
|
||||||
|
"writeParms": "",
|
||||||
|
"class": "left",
|
||||||
|
"thclass": "left",
|
||||||
|
"table": "banlist",
|
||||||
|
"alias": "",
|
||||||
|
"field": "banlist_id",
|
||||||
|
"__tableField": "`#banlist`.banlist_id",
|
||||||
|
"__tableFrom": "`#banlist`.banlist_id"
|
||||||
|
},
|
||||||
|
"banlist_ip": {
|
||||||
|
"title": "IP \/ Email",
|
||||||
|
"type": "method",
|
||||||
|
"data": "str",
|
||||||
|
"width": "auto",
|
||||||
|
"help": "",
|
||||||
|
"readParms": "",
|
||||||
|
"writeParms": [],
|
||||||
|
"class": "left",
|
||||||
|
"thclass": "left",
|
||||||
|
"table": "banlist",
|
||||||
|
"alias": "",
|
||||||
|
"field": "banlist_ip",
|
||||||
|
"__tableField": "`#banlist`.banlist_ip",
|
||||||
|
"__tableFrom": "`#banlist`.banlist_ip"
|
||||||
|
},
|
||||||
|
"banlist_bantype": {
|
||||||
|
"title": "Type",
|
||||||
|
"type": "method",
|
||||||
|
"data": "str",
|
||||||
|
"width": "auto",
|
||||||
|
"filter": true,
|
||||||
|
"help": "",
|
||||||
|
"readParms": "",
|
||||||
|
"writeParms": "",
|
||||||
|
"class": "left",
|
||||||
|
"thclass": "left",
|
||||||
|
"table": "banlist",
|
||||||
|
"alias": "",
|
||||||
|
"field": "banlist_bantype",
|
||||||
|
"__tableField": "`#banlist`.banlist_bantype",
|
||||||
|
"__tableFrom": "`#banlist`.banlist_bantype"
|
||||||
|
},
|
||||||
|
"banlist_datestamp": {
|
||||||
|
"title": "Date stamp",
|
||||||
|
"type": "datestamp",
|
||||||
|
"data": "int",
|
||||||
|
"width": "auto",
|
||||||
|
"filter": true,
|
||||||
|
"help": "",
|
||||||
|
"readParms": "",
|
||||||
|
"writeParms": "auto=1&hidden=1&readonly=1",
|
||||||
|
"class": "left",
|
||||||
|
"thclass": "left",
|
||||||
|
"table": "banlist",
|
||||||
|
"alias": "",
|
||||||
|
"field": "banlist_datestamp",
|
||||||
|
"__tableField": "`#banlist`.banlist_datestamp",
|
||||||
|
"__tableFrom": "`#banlist`.banlist_datestamp"
|
||||||
|
},
|
||||||
|
"banlist_banexpires": {
|
||||||
|
"title": "Expires",
|
||||||
|
"type": "method",
|
||||||
|
"data": "int",
|
||||||
|
"inline": true,
|
||||||
|
"width": "auto",
|
||||||
|
"batch": true,
|
||||||
|
"filter": true,
|
||||||
|
"help": "",
|
||||||
|
"readParms": "",
|
||||||
|
"writeParms": "",
|
||||||
|
"class": "left",
|
||||||
|
"thclass": "left",
|
||||||
|
"table": "banlist",
|
||||||
|
"alias": "",
|
||||||
|
"field": "banlist_banexpires",
|
||||||
|
"__tableField": "`#banlist`.banlist_banexpires",
|
||||||
|
"__tableFrom": "`#banlist`.banlist_banexpires"
|
||||||
|
},
|
||||||
|
"banlist_admin": {
|
||||||
|
"title": "Admin",
|
||||||
|
"type": "text",
|
||||||
|
"data": "int",
|
||||||
|
"noedit": true,
|
||||||
|
"width": "auto",
|
||||||
|
"help": "",
|
||||||
|
"readParms": "",
|
||||||
|
"writeParms": "",
|
||||||
|
"class": "center",
|
||||||
|
"thclass": "center",
|
||||||
|
"table": "banlist",
|
||||||
|
"alias": "",
|
||||||
|
"field": "banlist_admin",
|
||||||
|
"__tableField": "`#banlist`.banlist_admin",
|
||||||
|
"__tableFrom": "`#banlist`.banlist_admin"
|
||||||
|
},
|
||||||
|
"banlist_reason": {
|
||||||
|
"title": "Reason",
|
||||||
|
"type": "text",
|
||||||
|
"data": "str",
|
||||||
|
"inline": true,
|
||||||
|
"width": "auto",
|
||||||
|
"help": "",
|
||||||
|
"readParms": "constant=1",
|
||||||
|
"writeParms": {
|
||||||
|
"size": "xxlarge"
|
||||||
|
},
|
||||||
|
"class": "left",
|
||||||
|
"thclass": "left",
|
||||||
|
"table": "banlist",
|
||||||
|
"alias": "",
|
||||||
|
"field": "banlist_reason",
|
||||||
|
"__tableField": "`#banlist`.banlist_reason",
|
||||||
|
"__tableFrom": "`#banlist`.banlist_reason"
|
||||||
|
},
|
||||||
|
"banlist_notes": {
|
||||||
|
"title": "Notes",
|
||||||
|
"type": "text",
|
||||||
|
"data": "str",
|
||||||
|
"inline": true,
|
||||||
|
"width": "auto",
|
||||||
|
"help": "",
|
||||||
|
"readParms": "",
|
||||||
|
"writeParms": {
|
||||||
|
"size": "xxlarge"
|
||||||
|
},
|
||||||
|
"class": "left",
|
||||||
|
"thclass": "left",
|
||||||
|
"table": "banlist",
|
||||||
|
"alias": "",
|
||||||
|
"field": "banlist_notes",
|
||||||
|
"__tableField": "`#banlist`.banlist_notes",
|
||||||
|
"__tableFrom": "`#banlist`.banlist_notes"
|
||||||
|
},
|
||||||
|
"options": {
|
||||||
|
"title": "Options",
|
||||||
|
"type": "",
|
||||||
|
"data": "",
|
||||||
|
"width": "10%",
|
||||||
|
"thclass": "center last",
|
||||||
|
"class": "center last",
|
||||||
|
"forced": "1",
|
||||||
|
"table": "banlist",
|
||||||
|
"alias": "",
|
||||||
|
"field": "options",
|
||||||
|
"__tableField": "`#banlist`.options",
|
||||||
|
"__tableFrom": "`#banlist`.options"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"joinData": [],
|
||||||
|
"listOrder": "banlist_datestamp DESC"
|
||||||
|
},
|
||||||
|
"intermediateStates": {
|
||||||
|
"searchTerm": "125.125.125.125",
|
||||||
|
"searchQuery": "125.125.125.125",
|
||||||
|
"searchFilter": [],
|
||||||
|
"listQry": "SELECT * FROM `#banlist` WHERE banlist_bantype != 100 ",
|
||||||
|
"listQryBeforeFinal": "SELECT * FROM `#banlist` WHERE banlist_bantype != 100 "
|
||||||
|
},
|
||||||
|
"expected": "SELECT * FROM `#banlist` WHERE banlist_bantype != 100 AND ( banlist_ip = '125.125.125.125' OR banlist_ip LIKE '%0000:0000:0000:0000:0000:ffff:7d7d:7d7d%' OR `#banlist`.banlist_bantype LIKE '%125.125.125.125%' OR `#banlist`.banlist_reason LIKE '%125.125.125.125%' OR `#banlist`.banlist_notes LIKE '%125.125.125.125%' ) ORDER BY banlist_datestamp DESC LIMIT 0, 10"
|
||||||
|
}
|
@@ -13,7 +13,7 @@
|
|||||||
class e_admin_controller_uiTest extends \Codeception\Test\Unit
|
class e_admin_controller_uiTest extends \Codeception\Test\Unit
|
||||||
{
|
{
|
||||||
|
|
||||||
/** @var e_admin_controller_ui */
|
/** @var e_admin_ui */
|
||||||
protected $ui;
|
protected $ui;
|
||||||
protected $req;
|
protected $req;
|
||||||
|
|
||||||
@@ -31,6 +31,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function testJoinAlias()
|
public function testJoinAlias()
|
||||||
{
|
{
|
||||||
// Simple Join --------------
|
// Simple Join --------------
|
||||||
@@ -155,7 +157,45 @@
|
|||||||
$expected = "SELECT u.* FROM `#user` WHERE 1 AND ( u.user_name LIKE '%burt's%' OR u.user_login LIKE '%burt's%' OR u.user_phone LIKE '%burt's%' ) LIMIT 0, 10";
|
$expected = "SELECT u.* FROM `#user` WHERE 1 AND ( u.user_name LIKE '%burt's%' OR u.user_login LIKE '%burt's%' OR u.user_phone LIKE '%burt's%' ) LIMIT 0, 10";
|
||||||
$this::assertSame($expected, $result);
|
$this::assertSame($expected, $result);
|
||||||
|
|
||||||
|
// Raw mode.
|
||||||
|
$result = $this->ui->_modifyListQrySearch($listQry, "burt's", $filterOptions, $tablePath, $tableFrom, $primaryName, true, $orderField, $qryAsc, $forceFrom, $qryFrom, $forceTo, $perPage, $qryField, $isfilter, $handleAction);
|
||||||
|
$expected = array ( 'joinWhere' =>
|
||||||
|
array (
|
||||||
|
),
|
||||||
|
'filter' =>
|
||||||
|
array (
|
||||||
|
0 => 'u.user_name LIKE \'%burt's%\'',
|
||||||
|
1 => 'u.user_login LIKE \'%burt's%\'',
|
||||||
|
2 => 'u.user_phone LIKE \'%burt's%\'',
|
||||||
|
),
|
||||||
|
'listQrySql' =>
|
||||||
|
array (
|
||||||
|
),
|
||||||
|
'filterFrom' =>
|
||||||
|
array (
|
||||||
|
),
|
||||||
|
'search' =>
|
||||||
|
array (
|
||||||
|
),
|
||||||
|
'tableFromName' => '`#user`',
|
||||||
|
'tableFrom' =>
|
||||||
|
array (
|
||||||
|
0 => '`#user`.*',
|
||||||
|
),
|
||||||
|
'joinsFrom' =>
|
||||||
|
array (
|
||||||
|
),
|
||||||
|
'joins' =>
|
||||||
|
array (
|
||||||
|
),
|
||||||
|
'groupField' => '',
|
||||||
|
'orderField' => '',
|
||||||
|
'orderType' => 'ASC',
|
||||||
|
'limitFrom' => 0,
|
||||||
|
'limitTo' => 10,
|
||||||
|
);
|
||||||
|
|
||||||
|
$this::assertSame($expected, $result);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -212,6 +252,26 @@
|
|||||||
|
|
||||||
public function test_ModifyListQrySearch_FromJsonFiles()
|
public function test_ModifyListQrySearch_FromJsonFiles()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// For Banlist test.
|
||||||
|
|
||||||
|
$this->ui->handleListBanlistIpSearch = function($srch)
|
||||||
|
{
|
||||||
|
$ret = array(
|
||||||
|
"banlist_ip = '".$srch."'"
|
||||||
|
);
|
||||||
|
|
||||||
|
if($ip6 = e107::getIPHandler()->ipEncode($srch,true))
|
||||||
|
{
|
||||||
|
$ip = str_replace('x', '', $ip6);
|
||||||
|
$ret[] = "banlist_ip LIKE '%".$ip."%'";
|
||||||
|
}
|
||||||
|
|
||||||
|
return implode(" OR ",$ret);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// The directory where the JSON files are stored
|
// The directory where the JSON files are stored
|
||||||
$directory = e_BASE . "e107_tests/tests/_data/e_admin_ui/_modifyListQrySearch/";
|
$directory = e_BASE . "e107_tests/tests/_data/e_admin_ui/_modifyListQrySearch/";
|
||||||
if (!is_dir($directory))
|
if (!is_dir($directory))
|
||||||
@@ -256,6 +316,8 @@
|
|||||||
$preProcessedData = $data['preProcessedData'];
|
$preProcessedData = $data['preProcessedData'];
|
||||||
$expected = $data['expected'];
|
$expected = $data['expected'];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Verify fields are present in the JSON
|
// Verify fields are present in the JSON
|
||||||
if (empty($preProcessedData['fields']))
|
if (empty($preProcessedData['fields']))
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user