From dfbeefd84856193ade993c925b899e6407a910cd Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 15 Oct 2015 15:56:51 +1300 Subject: [PATCH] CRM-17725 navigation reset duplicating All reports link @colemanw spotted this in QA of CRM-17725 although it doesn't strictly relate --- CRM/Core/BAO/Navigation.php | 2 +- tests/phpunit/CRM/Core/BAO/NavigationTest.php | 27 +++++++++++++++++++ xml/schema/Core/Navigation.xml | 5 ++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/CRM/Core/BAO/Navigation.php b/CRM/Core/BAO/Navigation.php index ca069fc757..b93a74fca7 100644 --- a/CRM/Core/BAO/Navigation.php +++ b/CRM/Core/BAO/Navigation.php @@ -926,7 +926,7 @@ ORDER BY parent_id, weight"; } // Create or update the All Reports link. - self::createOrUpdateReportNavItem('All Reports', 'civicrm/report/list', 'reset=1', $reports_nav->id, 'access CiviReport', $domain_id); + self::createOrUpdateReportNavItem('All Reports', 'civicrm/report/list', 'reset=1', $reports_nav->id, 'access CiviReport', $domain_id, TRUE); } /** diff --git a/tests/phpunit/CRM/Core/BAO/NavigationTest.php b/tests/phpunit/CRM/Core/BAO/NavigationTest.php index 9183de7925..cf47eeedc1 100644 --- a/tests/phpunit/CRM/Core/BAO/NavigationTest.php +++ b/tests/phpunit/CRM/Core/BAO/NavigationTest.php @@ -49,6 +49,22 @@ class CRM_Core_BAO_NavigationTest extends CiviUnitTestCase { $this->assertEquals($reportCount, $this->getCountReportInstances()); } + /** + * Test that All reports link is not stolen. + * + * There are 2 All reports links by default. What we DON'T want to see is them + * both winding up under the Reports menu - since they already exist they should be unchanged + * by rebuilding reports. + */ + public function testNoDuplicateAllReportsLink() { + $existing_links = $this->callAPISuccess('Navigation', 'get', array('label' => 'All Reports', 'sequential' => 1)); + $this->assertNotEquals($existing_links['values'][0]['parent_id'], $existing_links['values'][1]['parent_id']); + CRM_Core_BAO_Navigation::rebuildReportsNavigation(CRM_Core_Config::domainID()); + $new_links = $this->callAPISuccess('Navigation', 'get', array('label' => 'All Reports', 'sequential' => 1)); + $this->assertEquals($existing_links['values'][0]['parent_id'], $new_links['values'][0]['parent_id']); + $this->assertEquals($existing_links['values'][1]['parent_id'], $new_links['values'][1]['parent_id']); + } + /** * Test that an existing report link is rebuilt under it's parent. * @@ -137,6 +153,17 @@ class CRM_Core_BAO_NavigationTest extends CiviUnitTestCase { "SELECT count(*) FROM civicrm_navigation WHERE url LIKE 'civicrm/report/instance/%'"); } + /** + * Get a count of navigation items that match the url. + * @param string $url + * + * @return int + */ + protected function getCountURL($url) { + return CRM_Core_DAO::singleValueQuery( + "SELECT count(*) FROM civicrm_navigation WHERE url ='{$url}'"); + } + /** * Run fixNavigationMenu() on a menu which already has navIDs * everywhere. They should be unchanged. diff --git a/xml/schema/Core/Navigation.xml b/xml/schema/Core/Navigation.xml index 472ef5b31b..cc770f8d17 100644 --- a/xml/schema/Core/Navigation.xml +++ b/xml/schema/Core/Navigation.xml @@ -81,6 +81,11 @@ Navigation parent ID int unsigned Parent navigation item, used for grouping + + civicrm_navigation
+ name + label +
3.0 -- 2.25.1