Merge pull request #2102 from eileenmcnaughton/CRM-13744
[civicrm-core.git] / tests / phpunit / api / v3 / ActionScheduleTest.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 * Include class definitions
24 */
25 require_once 'CiviTest/CiviUnitTestCase.php';
26
27
28 /**
29 * Test APIv3 civicrm_action_schedule functions
30 *
31 * @package CiviCRM_APIv3
32 * @subpackage API_ActionSchedule
33 */
34
35 class api_v3_ActionScheduleTest extends CiviUnitTestCase {
36 protected $_params;
37 protected $_params2;
38 protected $_entity = 'action_schedule';
39 protected $_apiversion = 3;
40
41 public $_eNoticeCompliant = TRUE;
42 /**
43 * Test setup for every test
44 *
45 * Connect to the database, truncate the tables that will be used
46 * and redirect stdin to a temporary file
47 */
48 public function setUp() {
49 // Connect to the database
50 parent::setUp();
51
52 }
53
54 /**
55 * Tears down the fixture, for example, closes a network connection.
56 * This method is called after a test is executed.
57 *
58 * @access protected
59 */
60 function tearDown() {
61 $tablesToTruncate = array(
62 'civicrm_action_schedule',
63 );
64 $this->quickCleanup($tablesToTruncate, TRUE);
65 }
66
67
68 function testActionScheduleCreate() {
69
70 $oldCount = CRM_Core_DAO::singleValueQuery('select count(*) from civicrm_action_schedule');
71 $params = array(
72 'title' => 'simpleAction',
73 'entity_value' => '46',
74 );
75
76 $actionSchedule = $this->callAPISuccess('action_schedule', 'create', $params);
77 $this->assertTrue(is_numeric($actionSchedule['id']), "In line " . __LINE__);
78 $this->assertTrue($actionSchedule['id'] > 0, "In line " . __LINE__);
79 $newCount = CRM_Core_DAO::singleValueQuery('select count(*) from civicrm_action_schedule');
80 $this->assertEquals($oldCount+1, $newCount);
81
82 }
83
84
85 }