|
@@ 330-365 (lines=36) @@
|
| 327 |
|
); |
| 328 |
|
} |
| 329 |
|
|
| 330 |
|
public function testGetChildrenAsULMinNodeCountWithFilters() { |
| 331 |
|
$obj1 = $this->objFromFixture('HierarchyTest_Object', 'obj1'); |
| 332 |
|
$obj2 = $this->objFromFixture('HierarchyTest_Object', 'obj2'); |
| 333 |
|
$obj2a = $this->objFromFixture('HierarchyTest_Object', 'obj2a'); |
| 334 |
|
$obj2aa = $this->objFromFixture('HierarchyTest_Object', 'obj2aa'); |
| 335 |
|
|
| 336 |
|
// Set low enough that it should fit all search matches without lazy loading |
| 337 |
|
$nodeCountThreshold = 3; |
| 338 |
|
|
| 339 |
|
$root = new HierarchyTest_Object(); |
| 340 |
|
|
| 341 |
|
// Includes nodes by filter regardless of minNodeCount restrictions |
| 342 |
|
$root->setMarkingFilterFunction(function($record) use($obj2, $obj2a, $obj2aa) { |
| 343 |
|
// Results need to include parent hierarchy, even if we just want to |
| 344 |
|
// match the innermost node. |
| 345 |
|
return in_array($record->ID, array($obj2->ID, $obj2a->ID, $obj2aa->ID)); |
| 346 |
|
}); |
| 347 |
|
$root->markPartialTree($nodeCountThreshold); |
| 348 |
|
|
| 349 |
|
$html = $root->getChildrenAsUL( |
| 350 |
|
"", |
| 351 |
|
'"<li id=\"" . $child->ID . "\">" . $child->Title', |
| 352 |
|
null, |
| 353 |
|
true, // limit to marked |
| 354 |
|
"AllChildrenIncludingDeleted", |
| 355 |
|
"numChildren", |
| 356 |
|
true, |
| 357 |
|
$nodeCountThreshold |
| 358 |
|
); |
| 359 |
|
$this->assertTreeNotContains($html, array($obj1), |
| 360 |
|
'Does not contain root elements which dont match the filter' |
| 361 |
|
); |
| 362 |
|
$this->assertTreeContains($html, array($obj2, $obj2a, $obj2aa), |
| 363 |
|
'Contains non-root elements which match the filter' |
| 364 |
|
); |
| 365 |
|
} |
| 366 |
|
|
| 367 |
|
public function testGetChildrenAsULHardLimitsNodes() { |
| 368 |
|
$obj1 = $this->objFromFixture('HierarchyTest_Object', 'obj1'); |
|
@@ 367-402 (lines=36) @@
|
| 364 |
|
); |
| 365 |
|
} |
| 366 |
|
|
| 367 |
|
public function testGetChildrenAsULHardLimitsNodes() { |
| 368 |
|
$obj1 = $this->objFromFixture('HierarchyTest_Object', 'obj1'); |
| 369 |
|
$obj2 = $this->objFromFixture('HierarchyTest_Object', 'obj2'); |
| 370 |
|
$obj2a = $this->objFromFixture('HierarchyTest_Object', 'obj2a'); |
| 371 |
|
$obj2aa = $this->objFromFixture('HierarchyTest_Object', 'obj2aa'); |
| 372 |
|
|
| 373 |
|
// Set low enough that it should fit all search matches without lazy loading |
| 374 |
|
$nodeCountThreshold = 3; |
| 375 |
|
|
| 376 |
|
$root = new HierarchyTest_Object(); |
| 377 |
|
|
| 378 |
|
// Includes nodes by filter regardless of minNodeCount restrictions |
| 379 |
|
$root->setMarkingFilterFunction(function($record) use($obj2, $obj2a, $obj2aa) { |
| 380 |
|
// Results need to include parent hierarchy, even if we just want to |
| 381 |
|
// match the innermost node. |
| 382 |
|
return in_array($record->ID, array($obj2->ID, $obj2a->ID, $obj2aa->ID)); |
| 383 |
|
}); |
| 384 |
|
$root->markPartialTree($nodeCountThreshold); |
| 385 |
|
|
| 386 |
|
$html = $root->getChildrenAsUL( |
| 387 |
|
"", |
| 388 |
|
'"<li id=\"" . $child->ID . "\">" . $child->Title', |
| 389 |
|
null, |
| 390 |
|
true, // limit to marked |
| 391 |
|
"AllChildrenIncludingDeleted", |
| 392 |
|
"numChildren", |
| 393 |
|
true, |
| 394 |
|
$nodeCountThreshold |
| 395 |
|
); |
| 396 |
|
$this->assertTreeNotContains($html, array($obj1), |
| 397 |
|
'Does not contain root elements which dont match the filter' |
| 398 |
|
); |
| 399 |
|
$this->assertTreeContains($html, array($obj2, $obj2a, $obj2aa), |
| 400 |
|
'Contains non-root elements which match the filter' |
| 401 |
|
); |
| 402 |
|
} |
| 403 |
|
|
| 404 |
|
public function testGetChildrenAsULNodeThresholdLeaf() { |
| 405 |
|
$obj1 = $this->objFromFixture('HierarchyTest_Object', 'obj1'); |