From 151da6c31b326c6819e346ee48954ae83b383920 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Wed, 15 Jan 2014 16:01:39 -0800 Subject: [PATCH] CRM-13889 - Autoformat --- api/v3/Dashboard.php | 9 ++++-- api/v3/DashboardContact.php | 6 ++-- tests/phpunit/api/v3/DashboardContactTest.php | 29 ++++++++++--------- tests/phpunit/api/v3/DashboardTest.php | 15 +++++----- 4 files changed, 33 insertions(+), 26 deletions(-) diff --git a/api/v3/Dashboard.php b/api/v3/Dashboard.php index ae42779036..44545071ad 100644 --- a/api/v3/Dashboard.php +++ b/api/v3/Dashboard.php @@ -52,7 +52,10 @@ function civicrm_api3_dashboard_create($params) { civicrm_api3_verify_one_mandatory($params, NULL, array( - 'name', 'label', 'url', 'fullscreen_url', + 'name', + 'label', + 'url', + 'fullscreen_url', ) ); } @@ -84,8 +87,8 @@ function _civicrm_api3_dashboard_create_spec(&$params) { */ function civicrm_api3_dashboard_get($params) { $bao = new CRM_Core_BAO_Dashboard(); - _civicrm_api3_dao_set_filter($bao, $params, true, 'Dashboard'); - $dashlets = _civicrm_api3_dao_to_array($bao, $params, true,'Dashboard'); + _civicrm_api3_dao_set_filter($bao, $params, TRUE, 'Dashboard'); + $dashlets = _civicrm_api3_dao_to_array($bao, $params, TRUE, 'Dashboard'); return civicrm_api3_create_success($dashlets, $params, 'dashboard', 'get', $bao); } diff --git a/api/v3/DashboardContact.php b/api/v3/DashboardContact.php index 280420f702..fd8337a652 100644 --- a/api/v3/DashboardContact.php +++ b/api/v3/DashboardContact.php @@ -42,7 +42,7 @@ * @param array $params * * @return array - * + * */ function civicrm_api3_dashboard_contact_create($params) { civicrm_api3_verify_one_mandatory($params, @@ -74,7 +74,7 @@ function civicrm_api3_dashboard_contact_get($params) { ) ); $bao = new CRM_Core_BAO_Dashboard(); - $dashboardContact = CRM_Core_BAO_Dashboard::getContactDashlets(TRUE, CRM_Utils_Array::value('contact_id',$params)); + $dashboardContact = CRM_Core_BAO_Dashboard::getContactDashlets(TRUE, CRM_Utils_Array::value('contact_id', $params)); return civicrm_api3_create_success($dashboardContact, $params, 'dashboard_contact', 'get'); } @@ -94,5 +94,5 @@ function _civicrm_api3_dashboard_contact_check_params(&$params) { if (!in_array($dashboard_id, $allDashlets)) { return civicrm_api3_create_error('Invalid Dashboard ID'); } - return null; + return NULL; } \ No newline at end of file diff --git a/tests/phpunit/api/v3/DashboardContactTest.php b/tests/phpunit/api/v3/DashboardContactTest.php index 012a98ec25..f4a27a3c8c 100644 --- a/tests/phpunit/api/v3/DashboardContactTest.php +++ b/tests/phpunit/api/v3/DashboardContactTest.php @@ -27,8 +27,8 @@ require_once 'CiviTest/CiviUnitTestCase.php'; /** * Test APIv3 civicrm_action_schedule functions * - * @package CiviCRM_APIv3 - * @subpackage API_ActionSchedule + * @package CiviCRM_APIv3 + * @subpackage API_ActionSchedule */ class api_v3_DashboardContactTest extends CiviUnitTestCase { @@ -38,6 +38,7 @@ class api_v3_DashboardContactTest extends CiviUnitTestCase { protected $_apiversion = 3; public $_eNoticeCompliant = TRUE; + /** * Test setup for every test * @@ -62,7 +63,7 @@ class api_v3_DashboardContactTest extends CiviUnitTestCase { ); $this->quickCleanup($tablesToTruncate, TRUE); } - + function testDashboardContactCreate() { $dashParams = array( 'version' => 3, @@ -71,21 +72,23 @@ class api_v3_DashboardContactTest extends CiviUnitTestCase { 'url' => 'civicrm/report/list&compid=99&reset=1&snippet=5', 'fullscreen_url' => 'civicrm/report/list&compid=99&reset=1&snippet=5&context=dashletFullscreen', ); - $dashresult = $this->callAPISuccess('dashboard', 'create', $dashParams); - $contact = $this->callAPISuccess('contact', 'create', array( 'first_name' => 'abc1', - 'contact_type' => 'Individual', - 'last_name' => 'xyz1', - 'email' => 'abc@abc.com') - ); - $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']}"); + $dashresult = $this->callAPISuccess('dashboard', 'create', $dashParams); + $contact = $this->callAPISuccess('contact', 'create', array( + 'first_name' => 'abc1', + 'contact_type' => 'Individual', + 'last_name' => 'xyz1', + 'email' => 'abc@abc.com' + ) + ); + $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 = array( 'version' => 3, 'contact_id' => $contact['id'], 'dashboard_id' => $dashresult['id'], 'is_active' => 1, ); - $dashboradContact = $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); + $dashboradContact = $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); } } \ No newline at end of file diff --git a/tests/phpunit/api/v3/DashboardTest.php b/tests/phpunit/api/v3/DashboardTest.php index baba27c2b1..c85fe680c5 100644 --- a/tests/phpunit/api/v3/DashboardTest.php +++ b/tests/phpunit/api/v3/DashboardTest.php @@ -27,8 +27,8 @@ require_once 'CiviTest/CiviUnitTestCase.php'; /** * Test APIv3 civicrm_action_schedule functions * - * @package CiviCRM_APIv3 - * @subpackage API_ActionSchedule + * @package CiviCRM_APIv3 + * @subpackage API_ActionSchedule */ class api_v3_DashboardTest extends CiviUnitTestCase { @@ -38,14 +38,15 @@ class api_v3_DashboardTest extends CiviUnitTestCase { protected $_apiversion = 3; public $_eNoticeCompliant = TRUE; + /** * Test setup for every test * * Connect to the database, truncate the tables that will be used * and redirect stdin to a temporary file - */ + */ public function setUp() { - // Connect to the database + // Connect to the database parent::setUp(); } @@ -63,7 +64,7 @@ class api_v3_DashboardTest extends CiviUnitTestCase { } function testDashboardCreate() { - $oldCount = CRM_Core_DAO::singleValueQuery('select count(*) from civicrm_dashboard'); + $oldCount = CRM_Core_DAO::singleValueQuery('select count(*) from civicrm_dashboard'); $params = array( 'version' => 3, 'label' => 'New Dashlet element', @@ -75,8 +76,8 @@ class api_v3_DashboardTest extends CiviUnitTestCase { $this->assertTrue(is_numeric($dashboard['id']), "In line " . __LINE__); $this->assertTrue($dashboard['id'] > 0, "In line " . __LINE__); $newCount = CRM_Core_DAO::singleValueQuery('select count(*) from civicrm_dashboard'); - $this->assertEquals($oldCount+1, $newCount); - $this->DashboardDelete($dashboard['id'],$oldCount); + $this->assertEquals($oldCount + 1, $newCount); + $this->DashboardDelete($dashboard['id'], $oldCount); } function DashboardDelete($id, $oldCount) { -- 2.25.1