From e2c44ec0c0a8609b030806b0e9e467994cd6eb8f Mon Sep 17 00:00:00 2001 From: Andrew Hunt Date: Sun, 2 Oct 2016 12:23:23 -0400 Subject: [PATCH] Allow API Navigation.get with parent_id (#9153) * CRM-19437 - Navigation API: allow integer ID as filter for parent_id * CRM-19437 Navigation API: changes after GenCode.php * CRM-19437 Navigation API: test for get by parent --- CRM/Core/DAO/AllCoreTables.data.php | 2 +- CRM/Core/DAO/Navigation.php | 5 +++-- tests/phpunit/api/v3/NavigationTest.php | 17 +++++++++++++++++ xml/schema/Core/Navigation.xml | 3 ++- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/CRM/Core/DAO/AllCoreTables.data.php b/CRM/Core/DAO/AllCoreTables.data.php index 42cd6f37c5..9fe75c6bc4 100644 --- a/CRM/Core/DAO/AllCoreTables.data.php +++ b/CRM/Core/DAO/AllCoreTables.data.php @@ -24,7 +24,7 @@ | see the CiviCRM license FAQ at http://civicrm.org/licensing | +--------------------------------------------------------------------+ */ -// (GenCodeChecksum:2459a2b02aef6013f1bc9de918508e1f) +// (GenCodeChecksum:a21b716e87447ebe26e457f3be1183d8) return array( 'CRM_Core_DAO_AddressFormat' => array( 'name' => 'AddressFormat', diff --git a/CRM/Core/DAO/Navigation.php b/CRM/Core/DAO/Navigation.php index 488c2afc63..6dedda1a44 100644 --- a/CRM/Core/DAO/Navigation.php +++ b/CRM/Core/DAO/Navigation.php @@ -30,7 +30,7 @@ * * Generated from xml/schema/CRM/Core/Navigation.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:28492fb431c3874453b53d0af4e3834a) + * (GenCodeChecksum:54cd16aaee611bffac63ee4fa10787fa) */ require_once 'CRM/Core/DAO.php'; require_once 'CRM/Utils/Type.php'; @@ -212,8 +212,9 @@ class CRM_Core_DAO_Navigation extends CRM_Core_DAO { 'FKClassName' => 'CRM_Core_DAO_Navigation', 'pseudoconstant' => array( 'table' => 'civicrm_navigation', - 'keyColumn' => 'name', + 'keyColumn' => 'id', 'labelColumn' => 'label', + 'nameColumn' => 'name', ) ) , 'is_active' => array( diff --git a/tests/phpunit/api/v3/NavigationTest.php b/tests/phpunit/api/v3/NavigationTest.php index 85c69818b6..bd696990aa 100644 --- a/tests/phpunit/api/v3/NavigationTest.php +++ b/tests/phpunit/api/v3/NavigationTest.php @@ -42,6 +42,23 @@ class api_v3_NavigationTest extends CiviUnitTestCase { $this->callAPISuccess($this->_entity, 'getsingle', array('label' => 'Manage Groups', 'domain_id' => 1)); } + /** + * Test get specifying parent + */ + public function testGetByParent() { + // get by name + $this->callAPISuccess($this->_entity, 'get', array('parentID' => 'Administer', 'domain_id' => 1)); + + $params = array( + 'name' => 'Administer', + 'domain_id' => 1, + 'return' => 'id', + ); + $adminId = $this->callAPISuccess($this->_entity, 'getvalue', $params); + + $this->callAPISuccess($this->_entity, 'get', array('parentID' => $adminId, 'domain_id' => 1)); + } + /** * Test create function. */ diff --git a/xml/schema/Core/Navigation.xml b/xml/schema/Core/Navigation.xml index cc770f8d17..ee9ad5d654 100644 --- a/xml/schema/Core/Navigation.xml +++ b/xml/schema/Core/Navigation.xml @@ -83,7 +83,8 @@ Parent navigation item, used for grouping civicrm_navigation
- name + id + name label
3.0 -- 2.25.1