From: Seamus Lee Date: Thu, 11 Aug 2016 04:50:32 +0000 (+1000) Subject: CRM-19217 Ensure that is_active is set to 1 by default when creating dashboards via api X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=3f14cb2407877be3c802a2c5c51e980aa6356c73;p=civicrm-core.git CRM-19217 Ensure that is_active is set to 1 by default when creating dashboards via api --- diff --git a/api/v3/Dashboard.php b/api/v3/Dashboard.php index 3593b541f4..904fc837cf 100644 --- a/api/v3/Dashboard.php +++ b/api/v3/Dashboard.php @@ -61,6 +61,7 @@ function civicrm_api3_dashboard_create($params) { * array of parameters determined by getfields. */ function _civicrm_api3_dashboard_create_spec(&$params) { + $params['is_active']['api.default'] = 1; unset($params['version']); } diff --git a/tests/phpunit/api/v3/DashboardTest.php b/tests/phpunit/api/v3/DashboardTest.php index 183a5584af..13f41fcbd2 100644 --- a/tests/phpunit/api/v3/DashboardTest.php +++ b/tests/phpunit/api/v3/DashboardTest.php @@ -59,6 +59,24 @@ class api_v3_DashboardTest extends CiviUnitTestCase { $newCount = CRM_Core_DAO::singleValueQuery('select count(*) from civicrm_dashboard'); $this->assertEquals($oldCount + 1, $newCount); $this->DashboardDelete($dashboard['id'], $oldCount); + $this->assertEquals($dashboard['values'][$dashboard['id']]['is_active'], 1); + } + + /** + * CRM-19217. + * Ensure that where is_active is specifically set to 0 is_active returns 0. + */ + public function testDashboardCreateNotActive() { + $params = array( + 'version' => 3, + 'label' => 'New Dashlet element', + 'name' => 'New Dashlet element', + 'url' => 'civicrm/report/list&reset=1&compid=99&snippet=5', + 'fullscreen_url' => 'civicrm/report/list&compid=99&reset=1&snippet=5&context=dashletFullscreen', + 'is_active' => 0, + ); + $dashboard = $this->callAPISuccess('dashboard', 'create', $params); + $this->assertEquals($dashboard['values'][$dashboard['id']]['is_active'], 0); } /**