diff --git a/core/legacy/Navbar.php b/core/legacy/Navbar.php index a9676942d..789222182 100644 --- a/core/legacy/Navbar.php +++ b/core/legacy/Navbar.php @@ -4,6 +4,7 @@ namespace SuiteCRM\Core\Legacy; use RuntimeException; use TabController; +use GroupedTabStructure; /** * Class Navbar @@ -26,6 +27,19 @@ class Navbar extends LegacyHandler throw new RuntimeException('Running legacy entry point failed'); } + + public function getGroupedNavTabs(): array + { + if ($this->runLegacyEntryPoint()) { + global $moduleList; + require LEGACY_PATH . 'include/GroupedTabs/GroupedTabStructure.php'; + + return (new GroupedTabStructure())->get_tab_structure($moduleList); + } + + throw new RuntimeException('Running legacy entry point failed'); + } + /** * @return array */ diff --git a/tests/unit/phpunit/legacy/NavbarTest.php b/tests/unit/phpunit/legacy/NavbarTest.php index 7dec9723b..2eca885f9 100644 --- a/tests/unit/phpunit/legacy/NavbarTest.php +++ b/tests/unit/phpunit/legacy/NavbarTest.php @@ -103,4 +103,63 @@ final class NavbarTest extends TestCase $this->navbar->getNonGroupedNavTabs() ); } + + public function testGroupNavTabs(): void + { + $expected = [ + 'Sales' => [ + 'modules' => [ + 'Home' => 'Home', + 'Accounts' => 'Accounts', + 'Contacts' => 'Contacts', + 'Opportunities' => 'Opportunities', + 'Leads' => 'Leads' + ] + ], + 'Marketing' => [ + 'modules' => [ + 'Home' => 'Home', + 'Accounts' => 'Accounts', + 'Contacts' => 'Contacts', + 'Leads' => 'Leads', + 'Campaigns' => 'Campaigns', + 'Prospects' => 'Targets', + 'ProspectLists' => 'Targets - Lists' + ] + ], + 'Support' => [ + 'modules' => [ + 'Home' => 'Home', + 'Accounts' => 'Accounts', + 'Contacts' => 'Contacts', + 'Cases' => 'Cases', + 'Bugs' => 'Bugs' + ] + ], + 'Activities' => [ + 'modules' => [ + 'Home' => 'Home', + 'Calendar' => 'Calendar', + 'Calls' => 'Calls', + 'Meetings' => 'Meetings', + 'Emails' => 'Emails', + 'Tasks' => 'Tasks', + 'Notes' => 'Notes' + ] + ], + 'Collaboration' => [ + 'modules' => [ + 'Home' => 'Home', + 'Emails' => 'Emails', + 'Documents' => 'Documents', + 'Project' => 'Projects' + ] + ] + ]; + + $this->assertSame( + $expected, + $this->navbar->getGroupedNavTabs() + ); + } }