<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
public $_entity = 'Job';
public $_params = array();
- function setUp() {
+ public function setUp() {
parent::setUp();
+ $this->useTransaction(TRUE);
$this->_params = array(
'sequential' => 1,
'name' => 'API_Test_Job',
);
}
- function tearDown() {
- $this->quickCleanup(array('civicrm_job', 'civicrm_action_log', 'civicrm_action_schedule'));
- $this->quickCleanUpFinancialEntities();
- CRM_Utils_Hook::singleton()->reset();
- parent::tearDown();
- }
-
/**
* Check with no name
*/
- function testCreateWithoutName() {
+ public function testCreateWithoutName() {
$params = array(
- 'is_active' => 1, );
+ 'is_active' => 1,
+ );
$result = $this->callAPIFailure('job', 'create', $params,
'Mandatory key(s) missing from params array: run_frequency, name, api_entity, api_action'
);
/**
* Create job with an invalid "run_frequency" value
*/
- function testCreateWithInvalidFrequency() {
+ public function testCreateWithInvalidFrequency() {
$params = array(
'sequential' => 1,
'name' => 'API_Test_Job',
/**
* Create job
*/
- function testCreate() {
+ public function testCreate() {
$result = $this->callAPIAndDocument('job', 'create', $this->_params, __FUNCTION__, __FILE__);
$this->assertNotNull($result['values'][0]['id'], 'in line ' . __LINE__);
/**
* Check with empty array
*/
- function testDeleteEmpty() {
+ public function testDeleteEmpty() {
$params = array();
$result = $this->callAPIFailure('job', 'delete', $params);
}
/**
* Check with No array
*/
- function testDeleteParamsNotArray() {
+ public function testDeleteParamsNotArray() {
$result = $this->callAPIFailure('job', 'delete', 'string');
}
/**
* Check if required fields are not passed
*/
- function testDeleteWithoutRequired() {
+ public function testDeleteWithoutRequired() {
$params = array(
'name' => 'API_Test_PP',
'title' => 'API Test Payment Processor',
/**
* Check with incorrect required fields
*/
- function testDeleteWithIncorrectData() {
+ public function testDeleteWithIncorrectData() {
$params = array(
- 'id' => 'abcd', );
+ 'id' => 'abcd',
+ );
$result = $this->callAPIFailure('job', 'delete', $params);
}
/**
* Check job delete
*/
- function testDelete() {
+ public function testDelete() {
$createResult = $this->callAPISuccess('job', 'create', $this->_params);
- $params = array('id' => $createResult['id'],);
+ $params = array('id' => $createResult['id']);
$result = $this->callAPIAndDocument('job', 'delete', $params, __FUNCTION__, __FILE__);
$this->assertAPIDeleted($this->_entity, $createResult['id']);
}
/**
-
- public function testCallUpdateGreetingMissingParams() {
- $result = $this->callAPISuccess($this->_entity, 'update_greeting', array('gt' => 1));
- $this->assertEquals('Mandatory key(s) missing from params array: ct', $result['error_message']);
- }
-
- public function testCallUpdateGreetingIncorrectParams() {
- $result = $this->callAPISuccess($this->_entity, 'update_greeting', array('gt' => 1, 'ct' => 'djkfhdskjfhds'));
- $this->assertEquals('ct `djkfhdskjfhds` is not valid.', $result['error_message']);
- }
-/*
- * Note that this test is about tesing the metadata / calling of the function & doesn't test the success of the called function
- */
+ *
+ * public function testCallUpdateGreetingMissingParams() {
+ * $result = $this->callAPISuccess($this->_entity, 'update_greeting', array('gt' => 1));
+ * $this->assertEquals('Mandatory key(s) missing from params array: ct', $result['error_message']);
+ * }
+ *
+ * public function testCallUpdateGreetingIncorrectParams() {
+ * $result = $this->callAPISuccess($this->_entity, 'update_greeting', array('gt' => 1, 'ct' => 'djkfhdskjfhds'));
+ * $this->assertEquals('ct `djkfhdskjfhds` is not valid.', $result['error_message']);
+ * }
+ * /*
+ * Note that this test is about tesing the metadata / calling of the function & doesn't test the success of the called function
+ */
public function testCallUpdateGreetingSuccess() {
- $result = $this->callAPISuccess($this->_entity, 'update_greeting', array('gt' => 'postal_greeting', 'ct' => 'Individual'));
- }
+ $result = $this->callAPISuccess($this->_entity, 'update_greeting', array(
+ 'gt' => 'postal_greeting',
+ 'ct' => 'Individual',
+ ));
+ }
public function testCallUpdateGreetingCommaSeparatedParamsSuccess() {
$gt = 'postal_greeting,email_greeting,addressee';
$membershipTypeID = $this->membershipTypeCreate();
$this->membershipStatusCreate();
$createTotal = 30;
- for($i = 1; $i <= $createTotal; $i++) {
+ for ($i = 1; $i <= $createTotal; $i++) {
$contactID = $this->individualCreate();
$groupID = $this->groupCreate(array('name' => $i, 'title' => $i));
$result = $this->callAPISuccess('action_schedule', 'create', array(
'group_id' => $groupID,
'limit_to' => FALSE,
));
- $this->callAPISuccess('group_contact', 'create', array('contact_id' => $contactID, 'status' => 'Added', 'group_id' => $groupID));
+ $this->callAPISuccess('group_contact', 'create', array(
+ 'contact_id' => $contactID,
+ 'status' => 'Added',
+ 'group_id' => $groupID,
+ ));
}
$result = $this->callAPISuccess('job', 'send_reminder', array());
$successfulCronCount = CRM_Core_DAO::singleValueQuery("SELECT count(*) FROM civicrm_action_log");
$this->membershipStatusCreate();
$createTotal = 3;
$groupID = $this->groupCreate(array('name' => 'Texan drawlers', 'title' => 'a...'));
- for($i = 1; $i <= $createTotal; $i++) {
+ for ($i = 1; $i <= $createTotal; $i++) {
$contactID = $this->individualCreate();
- if($i == 2) {
+ if ($i == 2) {
$theChosenOneID = $contactID;
}
- if($i < 3) {
- $this->callAPISuccess('group_contact', 'create', array('contact_id' => $contactID, 'status' => 'Added', 'group_id' => $groupID));
+ if ($i < 3) {
+ $this->callAPISuccess('group_contact', 'create', array(
+ 'contact_id' => $contactID,
+ 'status' => 'Added',
+ 'group_id' => $groupID,
+ ));
}
- if($i > 1) {
+ if ($i > 1) {
$this->callAPISuccess('membership', 'create', array(
- 'contact_id' => $contactID,
- 'membership_type_id' => $membershipTypeID,
- 'join_date' => '+ 1 hour',
+ 'contact_id' => $contactID,
+ 'membership_type_id' => $membershipTypeID,
+ 'join_date' => '+ 1 hour',
)
);
}
$individualID = $this->individualCreate();
$orgID = $this->organizationCreate();
CRM_Utils_Hook_UnitTests::singleton()->setHook('civicrm_pre', array($this, 'hookPreRelationship'));
- $relationshipTypeID = $this->callAPISuccess('relationship_type', 'getvalue', array('return' => 'id', 'name_a_b' => 'Employee of'));
+ $relationshipTypeID = $this->callAPISuccess('relationship_type', 'getvalue', array(
+ 'return' => 'id',
+ 'name_a_b' => 'Employee of',
+ ));
$result = $this->callAPISuccess('relationship', 'create', array(
'relationship_type_id' => $relationshipTypeID,
'contact_id_a' => $individualID,
* @param int $id
* @param array $params
*/
- function hookPreRelationship($op, $objectName, $id, &$params ) {
- if($op == 'delete') {
+ public function hookPreRelationship($op, $objectName, $id, &$params) {
+ if ($op == 'delete') {
return;
}
- if($params['is_active']) {
+ if ($params['is_active']) {
$params['description'] = 'Hooked';
}
else {
}
}
}
-