From 61ef23bdf5f8fe41726e0b2420bf1ae18e2114ae Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Sun, 4 May 2014 20:14:39 -0700 Subject: [PATCH] ignore system_log in update single test as updating logs doesn't make sense --- api/v3/Job.php | 10 +--------- api/v3/SystemLog.php | 3 ++- tests/phpunit/api/v3/NoteTest.php | 3 +-- tests/phpunit/api/v3/SyntaxConformanceTest.php | 1 + tests/phpunit/api/v3/SystemTest.php | 15 ++++++++++++++- tests/phpunit/api/v3/TagTest.php | 2 +- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/api/v3/Job.php b/api/v3/Job.php index cb8bbfac73..1b8452128b 100644 --- a/api/v3/Job.php +++ b/api/v3/Job.php @@ -98,15 +98,7 @@ function civicrm_api3_job_get($params) { * @access public */ function civicrm_api3_job_delete($params) { - if ($params['id'] != NULL && !CRM_Utils_Rule::integer($params['id'])) { - return civicrm_api3_create_error('Invalid value for job ID'); - } - - $result = CRM_Core_BAO_Job::del($params['id']); - if (!$result) { - return civicrm_api3_create_error('Could not delete job'); - } - return civicrm_api3_create_success($result, $params, 'job', 'delete'); + _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params); } /** diff --git a/api/v3/SystemLog.php b/api/v3/SystemLog.php index 3faebbaa4b..b61843def2 100644 --- a/api/v3/SystemLog.php +++ b/api/v3/SystemLog.php @@ -64,7 +64,8 @@ function civicrm_api3_system_log_create($params) { * @return array */ function _civicrm_api3_system_log_create_spec(&$params) { - return _civicrm_api3_system_log_spec($params); + require_once('api/v3/System.php'); + _civicrm_api3_system_log_spec($params); } /** diff --git a/tests/phpunit/api/v3/NoteTest.php b/tests/phpunit/api/v3/NoteTest.php index 005c41846c..493337cdba 100644 --- a/tests/phpunit/api/v3/NoteTest.php +++ b/tests/phpunit/api/v3/NoteTest.php @@ -153,8 +153,7 @@ class api_v3_NoteTest extends CiviUnitTestCase { $this->assertEquals($result['values'][$result['id']]['note'], 'Hello!!! m testing Note', 'in line ' . __LINE__); $this->assertEquals(date('Y-m-d', strtotime($this->_params['modified_date'])), date('Y-m-d', strtotime($result['values'][$result['id']]['modified_date'])), 'in line ' . __LINE__); - $this->assertArrayHasKey('id', $result, 'in line ' . __LINE__); - $this->assertAPISuccess($result, 'in line ' . __LINE__); + $this->assertArrayHasKey('id', $result); $note = array( 'id' => $result['id'], ); $this->noteDelete($note); diff --git a/tests/phpunit/api/v3/SyntaxConformanceTest.php b/tests/phpunit/api/v3/SyntaxConformanceTest.php index e0eb54a8e9..de89aff96a 100644 --- a/tests/phpunit/api/v3/SyntaxConformanceTest.php +++ b/tests/phpunit/api/v3/SyntaxConformanceTest.php @@ -271,6 +271,7 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { 'MailSettings', 'Setting', 'MailingContact', + 'SystemLog' //skip this because it doesn't make sense to update logs ); if ($sequential === TRUE) { return $entitiesWithout; diff --git a/tests/phpunit/api/v3/SystemTest.php b/tests/phpunit/api/v3/SystemTest.php index 4071bd38c3..3e04fc5bf7 100644 --- a/tests/phpunit/api/v3/SystemTest.php +++ b/tests/phpunit/api/v3/SystemTest.php @@ -88,7 +88,9 @@ class api_v3_SystemTest extends CiviUnitTestCase { * * @access protected */ - protected function tearDown() {} + protected function tearDown() { + $this->quickCleanup(array('civicrm_system_log')); + } ///////////////// civicrm_domain_get methods @@ -122,4 +124,15 @@ class api_v3_SystemTest extends CiviUnitTestCase { $this->assertEquals($result['message'], 'We wish you a merry Christmas'); $this->assertEquals($result['level'], 'info'); } + + /** + * Test system log function + */ + function testSystemLogNoLevel() { + $this->callAPISuccess('system', 'log', array( 'message' => 'We wish you a merry Christmas')); + $result = $this->callAPISuccess('SystemLog', 'getsingle', array('sequential' => 1, 'message' => array('LIKE' => '%Chris%'))); + $this->assertEquals($result['message'], 'We wish you a merry Christmas'); + $this->assertEquals($result['level'], 'info'); + $this->callAPISuccess('system_log', 'create', array('message' => 'msg')); + } } diff --git a/tests/phpunit/api/v3/TagTest.php b/tests/phpunit/api/v3/TagTest.php index e88ef17865..6d2685ce2e 100644 --- a/tests/phpunit/api/v3/TagTest.php +++ b/tests/phpunit/api/v3/TagTest.php @@ -130,7 +130,7 @@ class api_v3_TagTest extends CiviUnitTestCase { 'description' => 'Outside undie-wearers', ); $result = $this->callAPIAndDocument('tag', 'create', $params, __FUNCTION__, __FILE__); - $this->assertNotNull($result['id'], 'In line ' . __LINE__); + $this->assertNotNull($result['id']); $params['used_for'] = 'civicrm_contact'; $this->getAndCheck($params, $result['id'], 'tag'); } -- 2.25.1