|
43 | 43 | use Profile_User; |
44 | 44 | use Psr\Log\LogLevel; |
45 | 45 | use User; |
| 46 | +use UserCategory; |
46 | 47 |
|
47 | 48 | class UserTest extends DbTestCase |
48 | 49 | { |
@@ -2506,4 +2507,39 @@ public function testGetFromSSOAndRightRules() |
2506 | 2507 | $this->assertEquals("0", $user->fields["_ldap_rules"]["rules_entities_rights"][0][0]); // entities_id |
2507 | 2508 | $this->assertEquals($admin_profile_id, $user->fields["_ldap_rules"]["rules_entities_rights"][0][1]); // profiles_id |
2508 | 2509 | } |
| 2510 | + |
| 2511 | + /** |
| 2512 | + * The TreeBrowse list is available for users, but user categories are not hierarchical. |
| 2513 | + * This test ensures results can be fetched properly even for flat results. |
| 2514 | + * @return void |
| 2515 | + */ |
| 2516 | + public function testGetTreeCategoryList() |
| 2517 | + { |
| 2518 | + $this->login(); |
| 2519 | + |
| 2520 | + $cat1 = $this->createItem(UserCategory::class, [ |
| 2521 | + 'name' => __FUNCTION__ . '_1', |
| 2522 | + ]); |
| 2523 | + $cat2 = $this->createItem(UserCategory::class, [ |
| 2524 | + 'name' => __FUNCTION__ . '_2', |
| 2525 | + ]); |
| 2526 | + |
| 2527 | + $this->createItem(User::class, [ |
| 2528 | + 'name' => __FUNCTION__ . '_cat1', |
| 2529 | + 'usercategories_id' => $cat1->getID(), |
| 2530 | + ]); |
| 2531 | + $this->createItem(User::class, [ |
| 2532 | + 'name' => __FUNCTION__ . '_cat2', |
| 2533 | + 'usercategories_id' => $cat2->getID(), |
| 2534 | + ]); |
| 2535 | + |
| 2536 | + $tree = User::getTreeCategoryList(User::class, [ |
| 2537 | + 'itemtype' => User::class, |
| 2538 | + 'browse' => 1, |
| 2539 | + 'export_all' => true, |
| 2540 | + ]); |
| 2541 | + $this->assertCount(3, $tree); |
| 2542 | + $this->assertStringStartsWith(__FUNCTION__ . '_1', $tree[1]['title']); |
| 2543 | + $this->assertStringStartsWith(__FUNCTION__ . '_2', $tree[0]['title']); |
| 2544 | + } |
2509 | 2545 | } |
0 commit comments