Commit | Line | Data |
---|---|---|
15d9b3ae N |
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 | * Include class definitions | |
24 | */ | |
25 | require_once 'CiviTest/CiviUnitTestCase.php'; | |
26 | ||
27 | /** | |
28 | * Test APIv3 civicrm_action_schedule functions | |
29 | * | |
151da6c3 TO |
30 | * @package CiviCRM_APIv3 |
31 | * @subpackage API_ActionSchedule | |
15d9b3ae | 32 | */ |
15d9b3ae N |
33 | class api_v3_DashboardContactTest extends CiviUnitTestCase { |
34 | protected $_params; | |
35 | protected $_params2; | |
dcf56200 | 36 | protected $_entity = 'dashboard_contact'; |
15d9b3ae N |
37 | protected $_apiversion = 3; |
38 | ||
15d9b3ae N |
39 | /** |
40 | * Test setup for every test | |
41 | * | |
42 | * Connect to the database, truncate the tables that will be used | |
43 | * and redirect stdin to a temporary file | |
44 | */ | |
45 | public function setUp() { | |
46 | // Connect to the database | |
47 | parent::setUp(); | |
ce062e01 | 48 | $this->useTransaction(TRUE); |
15d9b3ae | 49 | } |
151da6c3 | 50 | |
00be9182 | 51 | public function testDashboardContactCreate() { |
15d9b3ae N |
52 | $dashParams = array( |
53 | 'version' => 3, | |
54 | 'label' => 'New Dashlet element', | |
55 | 'name' => 'New Dashlet element', | |
56 | 'url' => 'civicrm/report/list&compid=99&reset=1&snippet=5', | |
57 | 'fullscreen_url' => 'civicrm/report/list&compid=99&reset=1&snippet=5&context=dashletFullscreen', | |
58 | ); | |
151da6c3 TO |
59 | $dashresult = $this->callAPISuccess('dashboard', 'create', $dashParams); |
60 | $contact = $this->callAPISuccess('contact', 'create', array( | |
61 | 'first_name' => 'abc1', | |
62 | 'contact_type' => 'Individual', | |
63 | 'last_name' => 'xyz1', | |
21dfd5f5 | 64 | 'email' => 'abc@abc.com', |
151da6c3 TO |
65 | ) |
66 | ); | |
67 | $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']}"); | |
15d9b3ae N |
68 | $params = array( |
69 | 'version' => 3, | |
70 | 'contact_id' => $contact['id'], | |
71 | 'dashboard_id' => $dashresult['id'], | |
72 | 'is_active' => 1, | |
73 | ); | |
151da6c3 TO |
74 | $dashboradContact = $this->callAPISuccess('dashboard_contact', 'create', $params); |
75 | $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']}"); | |
76 | $this->assertEquals($oldCount + 1, $newCount); | |
15d9b3ae | 77 | } |
96025800 | 78 | |
4b2694ae | 79 | } |