3 * File for the TestActionSchedule class
7 * CiviCRM is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Affero General Public License
9 * as published by the Free Software Foundation; either version 3 of
10 * the License, or (at your option) any later version.
12 * CiviCRM is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public
18 * License along with this program. If not, see
19 * <http://www.gnu.org/licenses/>.
23 * Include class definitions
25 require_once 'CiviTest/CiviUnitTestCase.php';
28 * Test APIv3 civicrm_action_schedule functions
30 * @package CiviCRM_APIv3
31 * @subpackage API_ActionSchedule
34 class api_v3_DashboardTest
extends CiviUnitTestCase
{
37 protected $_entity = 'dashboard';
38 protected $_apiversion = 3;
40 public $_eNoticeCompliant = TRUE;
42 * Test setup for every test
44 * Connect to the database, truncate the tables that will be used
45 * and redirect stdin to a temporary file
47 public function setUp() {
48 // Connect to the database
53 * Tears down the fixture, for example, closes a network connection.
54 * This method is called after a test is executed.
59 $tablesToTruncate = array(
62 $this->quickCleanup($tablesToTruncate, TRUE);
65 function testDashboardCreate() {
66 $oldCount = CRM_Core_DAO
::singleValueQuery('select count(*) from civicrm_dashboard');
69 'label' => 'New Dashlet element',
70 'name' => 'New Dashlet element',
71 'url' => 'civicrm/report/list&reset=1&compid=99&snippet=5',
72 'fullscreen_url' => 'civicrm/report/list&compid=99&reset=1&snippet=5&context=dashletFullscreen',
74 $dashboard = $this->callAPISuccess('dashboard', 'create', $params);
75 $this->assertTrue(is_numeric($dashboard['id']), "In line " . __LINE__
);
76 $this->assertTrue($dashboard['id'] > 0, "In line " . __LINE__
);
77 $newCount = CRM_Core_DAO
::singleValueQuery('select count(*) from civicrm_dashboard');
78 $this->assertEquals($oldCount+
1, $newCount);
79 $this->DashboardDelete($dashboard['id'],$oldCount);
82 function DashboardDelete($id, $oldCount) {
87 $dashboardget = $this->callAPISuccess('dashboard', 'get', $params);
88 $this->assertEquals($id, $dashboardget['id']);
89 $dashboard = $this->callAPISuccess('dashboard', 'delete', $params);
90 $newCount = CRM_Core_DAO
::singleValueQuery('select count(*) from civicrm_dashboard');
91 $this->assertEquals($oldCount, $newCount);