Code Duplication    Length = 40-41 lines in 2 locations

tests/model/HierarchyTest.php 2 locations

@@ 451-490 (lines=40) @@
448
	 * This test checks that deleted ('archived') child pages don't set a css class on the parent
449
	 * node that makes it look like it has children
450
	 */
451
	public function testGetChildrenAsULNodeDeletedOnLive() {
452
		$obj2 = $this->objFromFixture('HierarchyTest_Object', 'obj2');
453
		$obj2a = $this->objFromFixture('HierarchyTest_Object', 'obj2a');
454
		$obj2aa = $this->objFromFixture('HierarchyTest_Object', 'obj2aa');
455
		$obj2ab = $this->objFromFixture('HierarchyTest_Object', 'obj2b');
456
457
		// delete all children under obj2
458
		$obj2a->delete();
459
		$obj2aa->delete();
460
		$obj2ab->delete();
461
		// Don't pre-load all children
462
		$nodeCountThreshold = 1;
463
464
		$childrenMethod = 'AllChildren';
465
		$numChildrenMethod = 'numChildren';
466
467
		$root = new HierarchyTest_Object();
468
		$root->markPartialTree($nodeCountThreshold, null, $childrenMethod, $numChildrenMethod);
469
470
		// As in LeftAndMain::getSiteTreeFor() but simpler and more to the point for testing purposes
471
		$titleFn = function(&$child, $numChildrenMethod="") {
472
			return '<li class="' . $child->markingClasses($numChildrenMethod).
473
				'" id="' . $child->ID . '">"' . $child->Title;
474
		};
475
476
		$html = $root->getChildrenAsUL(
477
			"",
478
			$titleFn,
479
			null,
480
			true, // limit to marked
481
			$childrenMethod,
482
			$numChildrenMethod,
483
			true,
484
			$nodeCountThreshold
485
		);
486
487
		// Get the class attribute from the $obj2 node in the sitetree, class 'jstree-leaf' means it's a leaf node
488
		$nodeClass = $this->getNodeClassFromTree($html, $obj2);
489
		$this->assertEquals('jstree-leaf closed', $nodeClass, 'object2 should not have children in the sitetree');
490
	}
491
492
	/**
493
	 * This test checks that deleted ('archived') child pages _do_ set a css class on the parent
@@ 496-536 (lines=41) @@
493
	 * This test checks that deleted ('archived') child pages _do_ set a css class on the parent
494
	 * node that makes it look like it has children when getting all children including deleted
495
	 */
496
	public function testGetChildrenAsULNodeDeletedOnStage() {
497
		$obj2 = $this->objFromFixture('HierarchyTest_Object', 'obj2');
498
		$obj2a = $this->objFromFixture('HierarchyTest_Object', 'obj2a');
499
		$obj2aa = $this->objFromFixture('HierarchyTest_Object', 'obj2aa');
500
		$obj2ab = $this->objFromFixture('HierarchyTest_Object', 'obj2b');
501
502
		// delete all children under obj2
503
		$obj2a->delete();
504
		$obj2aa->delete();
505
		$obj2ab->delete();
506
		// Don't pre-load all children
507
		$nodeCountThreshold = 1;
508
509
		$childrenMethod = 'AllChildrenIncludingDeleted';
510
		$numChildrenMethod = 'numHistoricalChildren';
511
512
		$root = new HierarchyTest_Object();
513
		$root->markPartialTree($nodeCountThreshold, null, $childrenMethod, $numChildrenMethod);
514
515
		// As in LeftAndMain::getSiteTreeFor() but simpler and more to the point for testing purposes
516
		$titleFn = function(&$child, $numChildrenMethod="") {
517
			return '<li class="' . $child->markingClasses($numChildrenMethod).
518
				'" id="' . $child->ID . '">"' . $child->Title;
519
		};
520
521
		$html = $root->getChildrenAsUL(
522
			"",
523
			$titleFn,
524
			null,
525
			true, // limit to marked
526
			$childrenMethod,
527
			$numChildrenMethod,
528
			true,
529
			$nodeCountThreshold
530
		);
531
532
		// Get the class attribute from the $obj2 node in the sitetree
533
		$nodeClass = $this->getNodeClassFromTree($html, $obj2);
534
		// Object2 can now be expanded
535
		$this->assertEquals('unexpanded jstree-closed closed', $nodeClass, 'obj2 should have children in the sitetree');
536
	}
537
538
	public function testNoHideFromHeirarchy() {
539
		$obj4 = $this->objFromFixture('HierarchyHideTest_Object', 'obj4');