Commit 76f87236 authored by colemanw's avatar colemanw

APIv4 - Add Dashboard & DashboardContact entities

parent 95eb4cfc
<?php
/*
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC. All rights reserved. |
| |
| This work is published under the GNU AGPLv3 license with some |
| permitted exceptions and without any warranty. For full license |
| and copyright information, see https://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
* $Id$
*
*/
namespace Civi\Api4;
/**
* Dashboard entity.
*
* A "dashboard" record represents an item that can be displayed on a user's home screen.
* E.g. the "News" or "Getting Started" dashboard items.
*
* Dashboards can also be created from CiviReports, and some extensions provide dashboards as well.
* Displaying an item to a user is done with the `DashboardContact` entity.
*
* @see \Civi\Api4\DashboardContact
* @package Civi\Api4
*/
class Dashboard extends Generic\DAOEntity {
}
<?php
/*
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC. All rights reserved. |
| |
| This work is published under the GNU AGPLv3 license with some |
| permitted exceptions and without any warranty. For full license |
| and copyright information, see https://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
* $Id$
*
*/
namespace Civi\Api4;
/**
* DashboardContact entity.
*
* This places a dashboard item on a user's home screen.
*
* @see \Civi\Api4\Dashboard
* @package Civi\Api4
*/
class DashboardContact extends Generic\DAOEntity {
}
......@@ -44,9 +44,13 @@ class api_v3_DashboardContactTest extends CiviUnitTestCase {
$this->useTransaction(TRUE);
}
public function testDashboardContactCreate() {
/**
* @param int $version
* @dataProvider versionThreeAndFour
*/
public function testDashboardContactCreate($version) {
$this->_apiversion = $version;
$dashParams = [
'version' => 3,
'label' => 'New Dashlet element',
'name' => 'New Dashlet element',
'url' => 'civicrm/report/list&compid=99&reset=1',
......@@ -61,12 +65,11 @@ class api_v3_DashboardContactTest extends CiviUnitTestCase {
]);
$oldCount = CRM_Core_DAO::singleValueQuery("select count(*) from civicrm_dashboard_contact where contact_id = {$contact['id']} AND is_active = 1 AND dashboard_id = {$dashresult['id']}");
$params = [
'version' => 3,
'contact_id' => $contact['id'],
'dashboard_id' => $dashresult['id'],
'is_active' => 1,
];
$dashboradContact = $this->callAPISuccess('dashboard_contact', 'create', $params);
$this->callAPISuccess('dashboard_contact', 'create', $params);
$newCount = CRM_Core_DAO::singleValueQuery("select count(*) from civicrm_dashboard_contact where contact_id = {$contact['id']} AND is_active = 1 AND dashboard_id = {$dashresult['id']}");
$this->assertEquals($oldCount + 1, $newCount);
}
......
......@@ -44,7 +44,12 @@ class api_v3_DashboardTest extends CiviUnitTestCase {
$this->useTransaction(TRUE);
}
public function testDashboardCreate() {
/**
* @param int $version
* @dataProvider versionThreeAndFour
*/
public function testDashboardCreate($version) {
$this->_apiversion = $version;
$oldCount = CRM_Core_DAO::singleValueQuery('select count(*) from civicrm_dashboard');
$params = [
'label' => 'New Dashlet element',
......@@ -62,11 +67,12 @@ class api_v3_DashboardTest extends CiviUnitTestCase {
}
/**
* CRM-19534.
*
* Ensure that Dashboard create works fine for non admins
* CRM-19534. Ensure that Dashboard create works fine for non admins
* @param int $version
* @dataProvider versionThreeAndFour
*/
public function testDashboardCreateByNonAdmins() {
public function testDashboardCreateByNonAdmins($version) {
$this->_apiversion = $version;
$loggedInContactID = $this->createLoggedInUser();
CRM_Core_Config::singleton()->userPermissionClass->permissions = [];
$params = [
......@@ -84,11 +90,12 @@ class api_v3_DashboardTest extends CiviUnitTestCase {
}
/**
* CRM-19217.
*
* Ensure that where is_active is specifically set to 0 is_active returns 0.
* CRM-19217. Ensure that where is_active is specifically set to 0 is_active returns 0.
* @param int $version
* @dataProvider versionThreeAndFour
*/
public function testDashboardCreateNotActive() {
public function testDashboardCreateNotActive($version) {
$this->_apiversion = $version;
$params = [
'label' => 'New Dashlet element',
'name' => 'New Dashlet element',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment