|
@@ 400-439 (lines=40) @@
|
| 397 |
|
* This test checks that deleted ('archived') child pages don't set a css class on the parent |
| 398 |
|
* node that makes it look like it has children |
| 399 |
|
*/ |
| 400 |
|
public function testGetChildrenAsULNodeDeletedOnLive() { |
| 401 |
|
$obj2 = $this->objFromFixture('HierarchyTest_Object', 'obj2'); |
| 402 |
|
$obj2a = $this->objFromFixture('HierarchyTest_Object', 'obj2a'); |
| 403 |
|
$obj2aa = $this->objFromFixture('HierarchyTest_Object', 'obj2aa'); |
| 404 |
|
$obj2ab = $this->objFromFixture('HierarchyTest_Object', 'obj2b'); |
| 405 |
|
|
| 406 |
|
// delete all children under obj2 |
| 407 |
|
$obj2a->delete(); |
| 408 |
|
$obj2aa->delete(); |
| 409 |
|
$obj2ab->delete(); |
| 410 |
|
// Don't pre-load all children |
| 411 |
|
$nodeCountThreshold = 1; |
| 412 |
|
|
| 413 |
|
$childrenMethod = 'AllChildren'; |
| 414 |
|
$numChildrenMethod = 'numChildren'; |
| 415 |
|
|
| 416 |
|
$root = new HierarchyTest_Object(); |
| 417 |
|
$root->markPartialTree($nodeCountThreshold, null, $childrenMethod, $numChildrenMethod); |
| 418 |
|
|
| 419 |
|
// As in LeftAndMain::getSiteTreeFor() but simpler and more to the point for testing purposes |
| 420 |
|
$titleFn = function(&$child, $numChildrenMethod="") { |
| 421 |
|
return '<li class="' . $child->markingClasses($numChildrenMethod). |
| 422 |
|
'" id="' . $child->ID . '">"' . $child->Title; |
| 423 |
|
}; |
| 424 |
|
|
| 425 |
|
$html = $root->getChildrenAsUL( |
| 426 |
|
"", |
| 427 |
|
$titleFn, |
| 428 |
|
null, |
| 429 |
|
true, // limit to marked |
| 430 |
|
$childrenMethod, |
| 431 |
|
$numChildrenMethod, |
| 432 |
|
true, |
| 433 |
|
$nodeCountThreshold |
| 434 |
|
); |
| 435 |
|
|
| 436 |
|
// Get the class attribute from the $obj2 node in the sitetree, class 'jstree-leaf' means it's a leaf node |
| 437 |
|
$nodeClass = $this->getNodeClassFromTree($html, $obj2); |
| 438 |
|
$this->assertEquals('jstree-leaf closed', $nodeClass, 'object2 should not have children in the sitetree'); |
| 439 |
|
} |
| 440 |
|
|
| 441 |
|
/** |
| 442 |
|
* This test checks that deleted ('archived') child pages _do_ set a css class on the parent |
|
@@ 445-485 (lines=41) @@
|
| 442 |
|
* This test checks that deleted ('archived') child pages _do_ set a css class on the parent |
| 443 |
|
* node that makes it look like it has children when getting all children including deleted |
| 444 |
|
*/ |
| 445 |
|
public function testGetChildrenAsULNodeDeletedOnStage() { |
| 446 |
|
$obj2 = $this->objFromFixture('HierarchyTest_Object', 'obj2'); |
| 447 |
|
$obj2a = $this->objFromFixture('HierarchyTest_Object', 'obj2a'); |
| 448 |
|
$obj2aa = $this->objFromFixture('HierarchyTest_Object', 'obj2aa'); |
| 449 |
|
$obj2ab = $this->objFromFixture('HierarchyTest_Object', 'obj2b'); |
| 450 |
|
|
| 451 |
|
// delete all children under obj2 |
| 452 |
|
$obj2a->delete(); |
| 453 |
|
$obj2aa->delete(); |
| 454 |
|
$obj2ab->delete(); |
| 455 |
|
// Don't pre-load all children |
| 456 |
|
$nodeCountThreshold = 1; |
| 457 |
|
|
| 458 |
|
$childrenMethod = 'AllChildrenIncludingDeleted'; |
| 459 |
|
$numChildrenMethod = 'numHistoricalChildren'; |
| 460 |
|
|
| 461 |
|
$root = new HierarchyTest_Object(); |
| 462 |
|
$root->markPartialTree($nodeCountThreshold, null, $childrenMethod, $numChildrenMethod); |
| 463 |
|
|
| 464 |
|
// As in LeftAndMain::getSiteTreeFor() but simpler and more to the point for testing purposes |
| 465 |
|
$titleFn = function(&$child, $numChildrenMethod="") { |
| 466 |
|
return '<li class="' . $child->markingClasses($numChildrenMethod). |
| 467 |
|
'" id="' . $child->ID . '">"' . $child->Title; |
| 468 |
|
}; |
| 469 |
|
|
| 470 |
|
$html = $root->getChildrenAsUL( |
| 471 |
|
"", |
| 472 |
|
$titleFn, |
| 473 |
|
null, |
| 474 |
|
true, // limit to marked |
| 475 |
|
$childrenMethod, |
| 476 |
|
$numChildrenMethod, |
| 477 |
|
true, |
| 478 |
|
$nodeCountThreshold |
| 479 |
|
); |
| 480 |
|
|
| 481 |
|
// Get the class attribute from the $obj2 node in the sitetree |
| 482 |
|
$nodeClass = $this->getNodeClassFromTree($html, $obj2); |
| 483 |
|
// Object2 can now be expanded |
| 484 |
|
$this->assertEquals('unexpanded jstree-closed closed', $nodeClass, 'obj2 should have children in the sitetree'); |
| 485 |
|
} |
| 486 |
|
|
| 487 |
|
public function testNoHideFromHeirarchy() { |
| 488 |
|
$obj4 = $this->objFromFixture('HierarchyHideTest_Object', 'obj4'); |