Code Duplication    Length = 36-36 lines in 2 locations

tests/model/HierarchyTest.php 2 locations

@@ 279-314 (lines=36) @@
276
		);
277
	}
278
279
	public function testGetChildrenAsULMinNodeCountWithFilters() {
280
		$obj1 = $this->objFromFixture('HierarchyTest_Object', 'obj1');
281
		$obj2 = $this->objFromFixture('HierarchyTest_Object', 'obj2');
282
		$obj2a = $this->objFromFixture('HierarchyTest_Object', 'obj2a');
283
		$obj2aa = $this->objFromFixture('HierarchyTest_Object', 'obj2aa');
284
285
		// Set low enough that it should fit all search matches without lazy loading
286
		$nodeCountThreshold = 3;
287
288
		$root = new HierarchyTest_Object();
289
290
		// Includes nodes by filter regardless of minNodeCount restrictions
291
		$root->setMarkingFilterFunction(function($record) use($obj2, $obj2a, $obj2aa) {
292
			// Results need to include parent hierarchy, even if we just want to
293
			// match the innermost node.
294
			return in_array($record->ID, array($obj2->ID, $obj2a->ID, $obj2aa->ID));
295
		});
296
		$root->markPartialTree($nodeCountThreshold);
297
298
		$html = $root->getChildrenAsUL(
299
			"",
300
			'"<li id=\"" . $child->ID . "\">" . $child->Title',
301
			null,
302
			true, // limit to marked
303
			"AllChildrenIncludingDeleted",
304
			"numChildren",
305
			true,
306
			$nodeCountThreshold
307
		);
308
		$this->assertTreeNotContains($html, array($obj1),
309
			'Does not contain root elements which dont match the filter'
310
		);
311
		$this->assertTreeContains($html, array($obj2, $obj2a, $obj2aa),
312
			'Contains non-root elements which match the filter'
313
		);
314
	}
315
316
	public function testGetChildrenAsULHardLimitsNodes() {
317
		$obj1 = $this->objFromFixture('HierarchyTest_Object', 'obj1');
@@ 316-351 (lines=36) @@
313
		);
314
	}
315
316
	public function testGetChildrenAsULHardLimitsNodes() {
317
		$obj1 = $this->objFromFixture('HierarchyTest_Object', 'obj1');
318
		$obj2 = $this->objFromFixture('HierarchyTest_Object', 'obj2');
319
		$obj2a = $this->objFromFixture('HierarchyTest_Object', 'obj2a');
320
		$obj2aa = $this->objFromFixture('HierarchyTest_Object', 'obj2aa');
321
322
		// Set low enough that it should fit all search matches without lazy loading
323
		$nodeCountThreshold = 3;
324
325
		$root = new HierarchyTest_Object();
326
327
		// Includes nodes by filter regardless of minNodeCount restrictions
328
		$root->setMarkingFilterFunction(function($record) use($obj2, $obj2a, $obj2aa) {
329
			// Results need to include parent hierarchy, even if we just want to
330
			// match the innermost node.
331
			return in_array($record->ID, array($obj2->ID, $obj2a->ID, $obj2aa->ID));
332
		});
333
		$root->markPartialTree($nodeCountThreshold);
334
335
		$html = $root->getChildrenAsUL(
336
			"",
337
			'"<li id=\"" . $child->ID . "\">" . $child->Title',
338
			null,
339
			true, // limit to marked
340
			"AllChildrenIncludingDeleted",
341
			"numChildren",
342
			true,
343
			$nodeCountThreshold
344
		);
345
		$this->assertTreeNotContains($html, array($obj1),
346
			'Does not contain root elements which dont match the filter'
347
		);
348
		$this->assertTreeContains($html, array($obj2, $obj2a, $obj2aa),
349
			'Contains non-root elements which match the filter'
350
		);
351
	}
352
353
	public function testGetChildrenAsULNodeThresholdLeaf() {
354
		$obj1 = $this->objFromFixture('HierarchyTest_Object', 'obj1');