Bug #21821 ยป 0012977.patch
tests/t3lib/matchcondition/t3lib_matchcondition_backend_testcase.php (Arbeitskopie) | ||
---|---|---|
}
|
||
/**
|
||
* Tests whether treeLevel comparison matches when creating new pages.
|
||
* @test
|
||
*/
|
||
public function treeLevelConditionMatchesCurrentPageIdWhileEditingNewPage() {
|
||
$GLOBALS['SOBE'] = $this->getMock('SC_alt_doc', array());
|
||
$GLOBALS['SOBE']->elementsData = array(
|
||
array(
|
||
'table' => 'pages',
|
||
'uid' => 'NEW4adc6021e37e7',
|
||
'pid' => 121,
|
||
'cmd' => 'new',
|
||
'deleteAccess' => 0,
|
||
),
|
||
);
|
||
$GLOBALS['SOBE']->data = array();
|
||
$this->matchCondition->setRootline($this->rootline);
|
||
$this->matchCondition->setPageId(121);
|
||
$this->assertTrue($this->matchCondition->match('[treeLevel = 3]'));
|
||
}
|
||
/**
|
||
* Tests whether treeLevel comparison matches when creating new pages.
|
||
* @test
|
||
*/
|
||
public function treeLevelConditionMatchesCurrentPageIdWhileSavingNewPage() {
|
||
$GLOBALS['SOBE'] = $this->getMock('SC_alt_doc', array());
|
||
$GLOBALS['SOBE']->elementsData = array(
|
||
array(
|
||
'table' => 'pages',
|
||
/// 999 is the uid of the page that was just created
|
||
'uid' => 999,
|
||
'pid' => 121,
|
||
'cmd' => 'edit',
|
||
'deleteAccess' => 1,
|
||
),
|
||
);
|
||
$GLOBALS['SOBE']->data = array(
|
||
'pages' => array(
|
||
'NEW4adc6021e37e7' => array(
|
||
'pid' => 121,
|
||
),
|
||
),
|
||
);
|
||
$this->matchCondition->setRootline($this->rootline);
|
||
$this->matchCondition->setPageId(121);
|
||
$this->assertTrue($this->matchCondition->match('[treeLevel = 3]'));
|
||
}
|
||
/**
|
||
* Tests whether a page Id is found in the previous rootline entries.
|
||
* @test
|
||
*/
|
t3lib/matchcondition/class.t3lib_matchcondition_backend.php (Arbeitskopie) | ||
---|---|---|
}
|
||
break;
|
||
case 'treeLevel':
|
||
// @todo: Behaviour when new page is being created...
|
||
$values = t3lib_div::trimExplode(',', $value, true);
|
||
$treeLevel = count($this->rootline) - 1;
|
||
// If a new page is being edited or saved the treeLevel is higher by one:
|
||
if ($this->isNewPageWithPageId($this->pageId)) {
|
||
$treeLevel += 1;
|
||
}
|
||
foreach ($values as $test) {
|
||
if ($test == $treeLevel) {
|
||
return true;
|