From e790a8cbcfc6938f55cc3ae8b6a55950984f572e Mon Sep 17 00:00:00 2001 From: vivekarora Date: Tue, 12 Nov 2013 19:26:20 +0530 Subject: [PATCH] Code review for schedule reminders --- api/v3/ActionSchedule.php | 90 +++++++++++++++++++++ tests/phpunit/api/v3/ActionScheduleTest.php | 85 +++++++++++++++++++ 2 files changed, 175 insertions(+) create mode 100644 api/v3/ActionSchedule.php create mode 100644 tests/phpunit/api/v3/ActionScheduleTest.php diff --git a/api/v3/ActionSchedule.php b/api/v3/ActionSchedule.php new file mode 100644 index 0000000000..37ce6a30a5 --- /dev/null +++ b/api/v3/ActionSchedule.php @@ -0,0 +1,90 @@ +. + */ + +/** + * Include class definitions + */ +require_once 'CiviTest/CiviUnitTestCase.php'; + + +/** + * Test APIv3 civicrm_action_schedule functions + * + * @package CiviCRM_APIv3 + * @subpackage API_ActionSchedule + */ + +class api_v3_ActionScheduleTest extends CiviUnitTestCase { + protected $_params; + protected $_params2; + protected $_entity = 'action_schedule'; + 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 + parent::setUp(); + + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + * + * @access protected + */ + function tearDown() { + $tablesToTruncate = array( + 'civicrm_action_schedule', + ); + $this->quickCleanup($tablesToTruncate, TRUE); + } + + + function testActionScheduleCreate() { + + $oldCount = CRM_Core_DAO::singleValueQuery('select count(*) from civicrm_action_schedule'); + $params = array( + 'title' => 'simpleAction', + 'entity_value' => '46', + ); + + $actionSchedule = $this->callAPISuccess('action_schedule', 'create', $params); + $this->assertTrue(is_numeric($actionSchedule['id']), "In line " . __LINE__); + $this->assertTrue($actionSchedule['id'] > 0, "In line " . __LINE__); + $newCount = CRM_Core_DAO::singleValueQuery('select count(*) from civicrm_action_schedule'); + $this->assertEquals($oldCount+1, $newCount); + + } + + +} -- 2.25.1