From 76f8723656a2ba7cc3116b4f8c27b1a58d122125 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Fri, 20 Mar 2020 10:19:59 -0400 Subject: [PATCH] APIv4 - Add Dashboard & DashboardContact entities --- Civi/Api4/Dashboard.php | 37 +++++++++++++++++++ Civi/Api4/DashboardContact.php | 33 +++++++++++++++++ tests/phpunit/api/v3/DashboardContactTest.php | 11 ++++-- tests/phpunit/api/v3/DashboardTest.php | 25 ++++++++----- 4 files changed, 93 insertions(+), 13 deletions(-) create mode 100644 Civi/Api4/Dashboard.php create mode 100644 Civi/Api4/DashboardContact.php diff --git a/Civi/Api4/Dashboard.php b/Civi/Api4/Dashboard.php new file mode 100644 index 0000000000..5b406dac07 --- /dev/null +++ b/Civi/Api4/Dashboard.php @@ -0,0 +1,37 @@ +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); } diff --git a/tests/phpunit/api/v3/DashboardTest.php b/tests/phpunit/api/v3/DashboardTest.php index 17546619bb..3a21ceff8d 100644 --- a/tests/phpunit/api/v3/DashboardTest.php +++ b/tests/phpunit/api/v3/DashboardTest.php @@ -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', -- 2.25.1