我正在编写一个简单的测试用例来操纵各种变量组以实现一些特定的结果,但我需要“第三只眼睛”来查看我做错了什么。我没有得到如下所述的预期结果。
Sample Code:
$this->_default['method'] = 'index';
// Input-
// Group one var Option:
$pMethod = 'mission';
$arg1 = 'NULL';
$arg2 = 'NULL';
$arg3 = 'NULL';
// Group two var Option:
$pMethod = 'mission-statements-p_2';;
$arg1 = 'NULL';
$arg2 = 'NULL';
$arg3 = 'NULL';
// Group three var Option:
$pMethod = 'mission';
$arg1 = 'mission-statements-p_2';
$arg2 = 'NULL';
$arg3 = 'NULL';
if ($pMethod && $pMethod !== $this->_default['method'])
{
$find = 'p_';
$pos1 = strpos($pMethod, $find);
$pos2 = strpos($arg1, $find);
if ($pos1 !== false)
{
list($arg1,$arg2)= explode("-p_",$pMethod);
$method = 'page';
$arg1 = !empty($arg1) ? $arg1 : NULL;
$arg2 = !empty($arg2) ? $arg2 : NULL;
$arg3 = NULL;
}
else if ($pos1 === false && $pos2 !== false)
{
list($arg2,$arg3)= explode("-p_",$arg1);
$method = 'page';
$arg1 = $pMethod;
$arg2 = !empty($arg2) ? $arg2 : NULL;
$arg3 = !empty($arg3) ? $arg3 : NULL;
}
}
else
{
$method = $pMethod;
$arg1 = !empty($arg1) ? $arg1 : NULL;
$arg2 = !empty($arg2) ? $arg2 : NULL;
$arg3 = NULL;
}
// The expecting output results should be:
// Group one var Option: no changes
// Group two var Option:
$pMethod = 'page';
$arg1 = 'mission-statements';
$arg2 = 2;
$arg3 = 'NULL';
// Group three var Option:
$pMethod = 'page';
$arg1 = 'mission';
$arg2 = 'mission-statements';
$arg3 = 2;