tests/phpunit - Declare `@group headless`
[civicrm-core.git] / tests / phpunit / api / v3 / DashboardContactTest.php
1 <?php
2 /**
3 * File for the TestActionSchedule class
4 *
5 * (PHP 5)
6 *
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.
11 *
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.
16 *
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/>.
20 */
21
22 /**
23 * Test APIv3 civicrm_action_schedule functions
24 *
25 * @package CiviCRM_APIv3
26 * @subpackage API_ActionSchedule
27 * @group headless
28 */
29 class api_v3_DashboardContactTest extends CiviUnitTestCase {
30 protected $_params;
31 protected $_params2;
32 protected $_entity = 'dashboard_contact';
33 protected $_apiversion = 3;
34
35 /**
36 * Test setup for every test.
37 *
38 * Connect to the database, truncate the tables that will be used
39 * and redirect stdin to a temporary file
40 */
41 public function setUp() {
42 // Connect to the database
43 parent::setUp();
44 $this->useTransaction(TRUE);
45 }
46
47 public function testDashboardContactCreate() {
48 $dashParams = array(
49 'version' => 3,
50 'label' => 'New Dashlet element',
51 'name' => 'New Dashlet element',
52 'url' => 'civicrm/report/list&compid=99&reset=1&snippet=5',
53 'fullscreen_url' => 'civicrm/report/list&compid=99&reset=1&snippet=5&context=dashletFullscreen',
54 );
55 $dashresult = $this->callAPISuccess('dashboard', 'create', $dashParams);
56 $contact = $this->callAPISuccess('contact', 'create', array(
57 'first_name' => 'abc1',
58 'contact_type' => 'Individual',
59 'last_name' => 'xyz1',
60 'email' => 'abc@abc.com',
61 )
62 );
63 $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']}");
64 $params = array(
65 'version' => 3,
66 'contact_id' => $contact['id'],
67 'dashboard_id' => $dashresult['id'],
68 'is_active' => 1,
69 );
70 $dashboradContact = $this->callAPISuccess('dashboard_contact', 'create', $params);
71 $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']}");
72 $this->assertEquals($oldCount + 1, $newCount);
73 }
74
75 }