CRM-19217 Ensure that is_active is set to 1 by default when creating dashboards via api
authorSeamus Lee <seamuslee001@gmail.com>
Thu, 11 Aug 2016 04:50:32 +0000 (14:50 +1000)
committerSeamus Lee <seamuslee001@gmail.com>
Thu, 11 Aug 2016 04:51:34 +0000 (14:51 +1000)
api/v3/Dashboard.php
tests/phpunit/api/v3/DashboardTest.php

index 3593b541f4f459e4cbbb6ade752cc24e4250ea60..904fc837cfe9e3c1883f69923e1ce49947fec301 100644 (file)
@@ -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']);
 }
 
index 183a5584af065de03171a863b8338045a3b4c40c..13f41fcbd2c0e169d332c7eb4ed666faa6135a1c 100644 (file)
@@ -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);
   }
 
   /**