From 226ede244a47a53e3d32a746baf0424c1fd727e1 Mon Sep 17 00:00:00 2001 From: eileen Date: Sat, 22 Jun 2013 19:15:44 +1200 Subject: [PATCH] make event api test e-notice compliant --- tests/phpunit/api/v3/EventTest.php | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/tests/phpunit/api/v3/EventTest.php b/tests/phpunit/api/v3/EventTest.php index d96821f1c0..7dce54a32a 100644 --- a/tests/phpunit/api/v3/EventTest.php +++ b/tests/phpunit/api/v3/EventTest.php @@ -32,7 +32,7 @@ class api_v3_EventTest extends CiviUnitTestCase { protected $_params; protected $_apiversion; protected $_entity; - + public $_eNoticeCompliant = TRUE; function get_info() { return array( 'name' => 'Event Create', @@ -102,7 +102,7 @@ class api_v3_EventTest extends CiviUnitTestCase { $this->events = array(); $this->eventIds = array(); foreach ($params as $event) { - $result = civicrm_api('Event', 'Create', $event); + $result = $this->callAPISuccess('Event', 'Create', $event); $this->_events[] = $result; $this->_eventIds[] = $result['id']; } @@ -143,13 +143,12 @@ class api_v3_EventTest extends CiviUnitTestCase { $params = array( 'event_title' => 'Annual CiviCRM meet', - 'version' => $this->_apiversion, + 'sequential' => TRUE, ); - $result = civicrm_api('event', 'get', $params); - $this->documentMe($params, $result, __FUNCTION__, __FILE__); + $result = $this->callAPIAndDocument('event', 'get', $params, __FUNCTION__, __FILE__); $this->assertEquals(1, $result['count']); - $this->assertEquals($result['values'][0]['id'], $this->_eventIds[0]['id']); + $this->assertEquals($result['values'][0]['id'], $this->_eventIds[0]); } function testGetEventByWrongTitle() { @@ -214,21 +213,18 @@ class api_v3_EventTest extends CiviUnitTestCase { */ function testGetIsCurrent() { $params = array( - 'version' => $this->_apiversion, 'isCurrent' => 1, ); $currentEventParams = array('start_date' => date('Y-m-d', strtotime('+ 1 day')), 'end_date' => date('Y-m-d', strtotime('+ 1 week')), ); $currentEventParams = array_merge($this->_params[1], $currentEventParams); - $currentEvent = civicrm_api('Event', 'Create', $currentEventParams); + $currentEvent = $this->callAPISuccess('Event', 'Create', $currentEventParams); $description = "demonstrates use of is.Current option"; $subfile = "IsCurrentOption"; - $result = civicrm_api('Event', 'Get', $params); - - $this->documentMe($params, $result, __FUNCTION__, __FILE__, $description, $subfile); - $allEvents = civicrm_api('Event', 'Get', array('version' => 3)); - civicrm_api('Event', 'Delete', array('version' => 3, 'id' => $currentEventParams['id'])); + $result = $this->callAPIAndDocument('Event', 'Get', $params, __FUNCTION__, __FILE__, $description, $subfile); + $allEvents = $this->callAPISuccess('Event', 'Get', array('version' => 3)); + $this->callAPISuccess('Event', 'Delete', array('version' => 3, 'id' => $currentEvent['id'])); $this->assertEquals(1, $result['count'], 'confirm only one event found in line ' . __LINE__); $this->assertEquals(3, $allEvents['count'], 'confirm three events exist (ie. two not found) ' . __LINE__); $this->assertEquals($currentEvent['id'], $result['id'], ''); @@ -318,9 +314,7 @@ class api_v3_EventTest extends CiviUnitTestCase { $params = $this->_params[0]; $params['custom_' . $ids['custom_field_id']] = "custom string"; - $result = civicrm_api($this->_entity, 'create', $params); - $this->documentMe($params, $result, __FUNCTION__, __FILE__); - $this->assertNotEquals($result['is_error'], 1, $result['error_message'] . ' in line ' . __LINE__); + $result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__); $check = civicrm_api($this->_entity, 'get', array('version' => 3, 'return.custom_' . $ids['custom_field_id'] => 1, 'id' => $result['id'])); $this->assertEquals("custom string", $check['values'][$check['id']]['custom_' . $ids['custom_field_id']], ' in line ' . __LINE__); -- 2.25.1