Merge pull request #9187 from sqweets/ExportHeadersRelationships
[civicrm-core.git] / tests / phpunit / api / v3 / DashboardTest.php
index eb496ddd9e4eac2ce3b2d1cc463f464156d211c6..bbc33cbb424ee7151918c71827288b954061c2c9 100644 (file)
  *   <http://www.gnu.org/licenses/>.
  */
 
-/**
- *  Include class definitions
- */
-require_once 'CiviTest/CiviUnitTestCase.php';
-
 /**
  *  Test APIv3 civicrm_action_schedule functions
  *
  * @package CiviCRM_APIv3
  * @subpackage API_ActionSchedule
+ * @group headless
  */
 class api_v3_DashboardTest extends CiviUnitTestCase {
   protected $_params;
@@ -37,7 +33,7 @@ class api_v3_DashboardTest extends CiviUnitTestCase {
   protected $_apiversion = 3;
 
   /**
-   * Test setup for every test
+   * Test setup for every test.
    *
    * Connect to the database, truncate the tables that will be used
    * and redirect stdin to a temporary file
@@ -51,11 +47,10 @@ class api_v3_DashboardTest extends CiviUnitTestCase {
   public function testDashboardCreate() {
     $oldCount = CRM_Core_DAO::singleValueQuery('select count(*) from civicrm_dashboard');
     $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',
+      'url' => 'civicrm/report/list&reset=1&compid=99',
+      'fullscreen_url' => 'civicrm/report/list&compid=99&reset=1&context=dashletFullscreen',
     );
     $dashboard = $this->callAPISuccess('dashboard', 'create', $params);
     $this->assertTrue(is_numeric($dashboard['id']), "In line " . __LINE__);
@@ -63,6 +58,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(
+      '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);
   }
 
   /**
@@ -71,7 +84,6 @@ class api_v3_DashboardTest extends CiviUnitTestCase {
    */
   public function DashboardDelete($id, $oldCount) {
     $params = array(
-      'version' => 3,
       'id' => $id,
     );
     $dashboardget = $this->callAPISuccess('dashboard', 'get', $params);