Commit 92915c55 authored by totten's avatar totten

INFRA-132 - tests/ - PHPStorm cleanup

parent 242bd179
......@@ -183,12 +183,13 @@ class CRM_Batch_Form_EntryTest extends CiviUnitTestCase {
$this->assertEquals(2, $result['count']);
foreach ($result['values'] as $contribution) {
$this->assertEquals($this->callAPISuccess('line_item', 'getvalue', array(
'contribution_id' => $contribution['id'],
'return' => 'line_total',
'contribution_id' => $contribution['id'],
'return' => 'line_total',
)), $contribution['total_amount']);
}
}
/**
* Data provider for test process membership
* @return array
......@@ -202,7 +203,7 @@ class CRM_Batch_Form_EntryTest extends CiviUnitTestCase {
1 => $this->_contactID,
2 => $this->_contactID2,
3 => $this->_contactID3,
),
),
'field' => array(
1 => array(
'membership_type' => array(0 => $this->_orgContactID, 1 => $this->_membershipTypeID),
......@@ -218,35 +219,35 @@ class CRM_Batch_Form_EntryTest extends CiviUnitTestCase {
'check_number' => NULL,
'contribution_status_id' => 1,
),
2 => array(
'membership_type' => array(0 => $this->_orgContactID, 1 => $this->_membershipTypeID),
'join_date' => '07/03/2013',
'membership_start_date' => '02/03/2013',
'membership_end_date' => NULL,
'membership_source' => NULL,
'financial_type' => 2,
'total_amount' => 1,
'receive_date' => '07/17/2013',
'receive_date_time' => NULL,
'payment_instrument' => NULL,
'check_number' => NULL,
'contribution_status_id' => 1,
),
2 => array(
'membership_type' => array(0 => $this->_orgContactID, 1 => $this->_membershipTypeID),
'join_date' => '07/03/2013',
'membership_start_date' => '02/03/2013',
'membership_end_date' => NULL,
'membership_source' => NULL,
'financial_type' => 2,
'total_amount' => 1,
'receive_date' => '07/17/2013',
'receive_date_time' => NULL,
'payment_instrument' => NULL,
'check_number' => NULL,
'contribution_status_id' => 1,
),
// no join date, coded end date
3 => array(
'membership_type' => array(0 => $this->_orgContactID, 1 => $this->_membershipTypeID),
'join_date' => NULL,
'membership_start_date' => NULL,
'membership_end_date' => '2013-12-01',
'membership_source' => NULL,
'financial_type' => 2,
'total_amount' => 1,
'receive_date' => '07/17/2013',
'receive_date_time' => NULL,
'payment_instrument' => NULL,
'check_number' => NULL,
'contribution_status_id' => 1,
),
3 => array(
'membership_type' => array(0 => $this->_orgContactID, 1 => $this->_membershipTypeID),
'join_date' => NULL,
'membership_start_date' => NULL,
'membership_end_date' => '2013-12-01',
'membership_source' => NULL,
'financial_type' => 2,
'total_amount' => 1,
'receive_date' => '07/17/2013',
'receive_date_time' => NULL,
'payment_instrument' => NULL,
'check_number' => NULL,
'contribution_status_id' => 1,
),
),
'actualBatchTotal' => 0,
......
......@@ -45,9 +45,9 @@ class CRM_Bridge_OG_DrupalTest extends CiviUnitTestCase {
*/
public function testACLRoleDeleteFunctionality() {
$optionGroup = civicrm_api('OptionGroup', 'Get', array(
'version' => 3,
'name' => 'acl_role',
'api.OptionValue.Create' =>
'version' => 3,
'name' => 'acl_role',
'api.OptionValue.Create' =>
array(
array(
'label' => 'OG',
......@@ -60,7 +60,7 @@ class CRM_Bridge_OG_DrupalTest extends CiviUnitTestCase {
'description' => 'OG Sync Group ACL :1969:',
),
),
));
));
$getOptionGroupParams = array('version' => 3, 'option_group_id' => $optionGroup['id']);
$originalCount = civicrm_api('OptionValue', 'GetCount', $getOptionGroupParams);
$params = array('source' => 'OG Sync Group ACL :1969:');
......
......@@ -92,12 +92,12 @@ class CRM_Contact_BAO_ContactType_ContactSearchTest extends CiviUnitTestCase {
public function testSearchWithType() {
// for type:Individual
$params = array('contact_type' => 'Individual', 'version' => 3);
$result = civicrm_api('contact', 'get', $params);
$params = array('contact_type' => 'Individual', 'version' => 3);
$result = civicrm_api('contact', 'get', $params);
$individual = $result['values'][$this->individual];
$individual = $result['values'][$this->individual];
$indiviStudent = $result['values'][$this->indiviStudent];
$indiviParent = $result['values'][$this->indiviParent];
$indiviParent = $result['values'][$this->indiviParent];
//asserts for type:Individual
$this->assertEquals($individual['contact_id'], $this->individual, 'In line ' . __LINE__);
......@@ -156,8 +156,8 @@ class CRM_Contact_BAO_ContactType_ContactSearchTest extends CiviUnitTestCase {
public function testSearchWithSubype() {
// for subtype:Student
$params = array('contact_sub_type' => $this->student, 'version' => 3);
$result = civicrm_api('contact', 'get', $params);
$params = array('contact_sub_type' => $this->student, 'version' => 3);
$result = civicrm_api('contact', 'get', $params);
$indiviStudent = $result['values'][$this->indiviStudent];
......@@ -203,8 +203,8 @@ class CRM_Contact_BAO_ContactType_ContactSearchTest extends CiviUnitTestCase {
public function testSearchWithTypeSubype() {
// for type:individual subtype:Student
$params = array('contact_sub_type' => $this->student, 'version' => 3);
$result = civicrm_api('contact', 'get', $params);
$params = array('contact_sub_type' => $this->student, 'version' => 3);
$result = civicrm_api('contact', 'get', $params);
$indiviStudent = $result['values'][$this->indiviStudent];
......@@ -248,8 +248,8 @@ class CRM_Contact_BAO_ContactType_ContactSearchTest extends CiviUnitTestCase {
*/
public function testSearchWithInvalidData() {
// for invalid type
$params = array('contact_type' => 'Invalid' . CRM_Core_DAO::VALUE_SEPARATOR . 'Invalid', 'version' => 3);
$result = civicrm_api('contact', 'get', $params);
$params = array('contact_type' => 'Invalid' . CRM_Core_DAO::VALUE_SEPARATOR . 'Invalid', 'version' => 3);
$result = civicrm_api('contact', 'get', $params);
$this->assertEquals(empty($result['values']), TRUE, 'In line ' . __LINE__);
// for invalid subtype
......@@ -280,8 +280,8 @@ class CRM_Contact_BAO_ContactType_ContactSearchTest extends CiviUnitTestCase {
// for type:Individual subtype:Sponsor
$defaults = array();
$params = array('contact_type' => 'Individual' . CRM_Core_DAO::VALUE_SEPARATOR . $this->sponsor, 'version' => 3);
$result = civicrm_api('contact', 'get', $params);
$params = array('contact_type' => 'Individual' . CRM_Core_DAO::VALUE_SEPARATOR . $this->sponsor, 'version' => 3);
$result = civicrm_api('contact', 'get', $params);
$this->assertEquals(empty($result['values']), TRUE, 'In line ' . __LINE__);
// for type:Orgaization subtype:Parent
......
......@@ -72,7 +72,8 @@ DELETE FROM civicrm_contact_type
try {
$contact = CRM_Contact_BAO_Contact::add($params);
}
catch(Exception$expected) {}
catch (Exception$expected) {
}
$this->assertEquals($contact->first_name, 'Anne', 'In line ' . __LINE__);
$this->assertEquals($contact->contact_type, 'Individual', 'In line ' . __LINE__);
CRM_Contact_BAO_Contact::deleteContact($contact->id);
......@@ -85,7 +86,8 @@ DELETE FROM civicrm_contact_type
try {
$contact = CRM_Contact_BAO_Contact::add($params);
}
catch(Exception$expected) {}
catch (Exception$expected) {
}
$this->assertEquals($contact->organization_name, 'Compumentor', 'In line ' . __LINE__);
$this->assertEquals($contact->contact_type, 'Organization', 'In line ' . __LINE__);
CRM_Contact_BAO_Contact::deleteContact($contact->id);
......@@ -98,7 +100,8 @@ DELETE FROM civicrm_contact_type
try {
$contact = CRM_Contact_BAO_Contact::add($params);
}
catch(Exception$expected) {}
catch (Exception$expected) {
}
$this->assertEquals($contact->household_name, 'John Does home', 'In line ' . __LINE__);
$this->assertEquals($contact->contact_type, 'Household', 'In line ' . __LINE__);
CRM_Contact_BAO_Contact::deleteContact($contact->id);
......@@ -113,7 +116,8 @@ DELETE FROM civicrm_contact_type
try {
$contact = CRM_Contact_BAO_Contact::add($params);
}
catch(Exception$expected) {}
catch (Exception$expected) {
}
$this->assertEquals($contact->first_name, 'Bill', 'In line ' . __LINE__);
$this->assertEquals($contact->contact_type, 'Individual', 'In line ' . __LINE__);
$this->assertEquals(str_replace(CRM_Core_DAO::VALUE_SEPARATOR, '', $contact->contact_sub_type), $this->student, 'In line ' . __LINE__);
......@@ -128,7 +132,8 @@ DELETE FROM civicrm_contact_type
try {
$contact = CRM_Contact_BAO_Contact::add($params);
}
catch(Exception$expected) {}
catch (Exception$expected) {
}
$this->assertEquals($contact->organization_name, 'Conservation Corp', 'In line ' . __LINE__);
$this->assertEquals($contact->contact_type, 'Organization', 'In line ' . __LINE__);
$this->assertEquals(str_replace(CRM_Core_DAO::VALUE_SEPARATOR, '', $contact->contact_sub_type), $this->sponsor, 'In line ' . __LINE__);
......@@ -148,7 +153,8 @@ DELETE FROM civicrm_contact_type
try {
$contact = CRM_Contact_BAO_Contact::add($params);
}
catch(Exception$expected) {}
catch (Exception$expected) {
}
$updateParams = array(
'contact_sub_type' => $this->student,
'contact_type' => 'Individual',
......@@ -157,7 +163,8 @@ DELETE FROM civicrm_contact_type
try {
$updatedContact = CRM_Contact_BAO_Contact::add($updateParams);
}
catch(Exception$expected) {}
catch (Exception$expected) {
}
$this->assertEquals($updatedContact->id, $contact->id, 'In line ' . __LINE__);
$this->assertEquals($updatedContact->contact_type, 'Individual', 'In line ' . __LINE__);
$this->assertEquals(str_replace(CRM_Core_DAO::VALUE_SEPARATOR, '', $updatedContact->contact_sub_type), $this->student, 'In line ' . __LINE__);
......@@ -170,7 +177,8 @@ DELETE FROM civicrm_contact_type
try {
$contact = CRM_Contact_BAO_Contact::add($params);
}
catch(Exception$expected) {}
catch (Exception$expected) {
}
$updateParams = array(
'contact_sub_type' => $this->sponsor,
......@@ -180,7 +188,8 @@ DELETE FROM civicrm_contact_type
try {
$updatedContact = CRM_Contact_BAO_Contact::add($updateParams);
}
catch(Exception$expected) {}
catch (Exception$expected) {
}
$this->assertEquals($updatedContact->id, $contact->id, 'In line ' . __LINE__);
$this->assertEquals($updatedContact->contact_type, 'Organization', 'In line ' . __LINE__);
$this->assertEquals(str_replace(CRM_Core_DAO::VALUE_SEPARATOR, '', $updatedContact->contact_sub_type), $this->sponsor, 'In line ' . __LINE__);
......@@ -201,7 +210,8 @@ DELETE FROM civicrm_contact_type
try {
$contact = CRM_Contact_BAO_Contact::add($params);
}
catch(Exception$expected) {}
catch (Exception$expected) {
}
$updateParams = array(
'contact_sub_type' => $this->parent,
......@@ -211,7 +221,8 @@ DELETE FROM civicrm_contact_type
try {
$updatedContact = CRM_Contact_BAO_Contact::add($updateParams);
}
catch(Exception$expected) {}
catch (Exception$expected) {
}
$this->assertEquals($updatedContact->id, $contact->id, 'In line ' . __LINE__);
$this->assertEquals($updatedContact->contact_type, 'Individual', 'In line ' . __LINE__);
$this->assertEquals(str_replace(CRM_Core_DAO::VALUE_SEPARATOR, '', $updatedContact->contact_sub_type), $this->parent, 'In line ' . __LINE__);
......@@ -225,7 +236,8 @@ DELETE FROM civicrm_contact_type
try {
$contact = CRM_Contact_BAO_Contact::add($params);
}
catch(Exception$expected) {}
catch (Exception$expected) {
}
$updateParams = array(
'contact_sub_type' => $this->team,
......@@ -235,7 +247,8 @@ DELETE FROM civicrm_contact_type
try {
$updatedContact = CRM_Contact_BAO_Contact::add($updateParams);
}
catch(Exception$expected) {}
catch (Exception$expected) {
}
$this->assertEquals($updatedContact->id, $contact->id, 'In line ' . __LINE__);
$this->assertEquals($updatedContact->contact_type, 'Organization', 'In line ' . __LINE__);
......@@ -251,7 +264,8 @@ DELETE FROM civicrm_contact_type
try {
$contact = CRM_Contact_BAO_Contact::add($params);
}
catch(Exception$expected) {}
catch (Exception$expected) {
}
$updateParams = array(
'contact_sub_type' => NULL,
......@@ -261,7 +275,8 @@ DELETE FROM civicrm_contact_type
try {
$updatedContact = CRM_Contact_BAO_Contact::add($updateParams);
}
catch(Exception$expected) {}
catch (Exception$expected) {
}
$this->assertEquals($updatedContact->id, $contact->id, 'In line ' . __LINE__);
$this->assertEquals($updatedContact->contact_type, 'Individual', 'In line ' . __LINE__);
......
......@@ -162,8 +162,8 @@ DELETE FROM civicrm_contact_type
'contact_sub_type_b' => $this->parent,
);
$relTypeIds = array();
$relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams, $relTypeIds);
$params = array(
$relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams, $relTypeIds);
$params = array(
'relationship_type_id' => $relType->id . '_a_b',
'contact_check' => array($this->indivi_student => 1),
);
......@@ -189,8 +189,8 @@ DELETE FROM civicrm_contact_type
'contact_type_b' => 'Individual',
);
$relTypeIds = array();
$relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams, $relTypeIds);
$params = array(
$relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams, $relTypeIds);
$params = array(
'relationship_type_id' => $relType->id . '_a_b',
'contact_check' => array($this->individual => 1),
);
......@@ -214,8 +214,8 @@ DELETE FROM civicrm_contact_type
'contact_sub_type_b' => 'Sponser',
);
$relTypeIds = array();
$relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams, $relTypeIds);
$params = array(
$relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams, $relTypeIds);
$params = array(
'relationship_type_id' => $relType->id . '_a_b',
'contact_check' => array($this->individual => 1),
);
......@@ -242,8 +242,8 @@ DELETE FROM civicrm_contact_type
'contact_sub_type_b' => $this->parent,
);
$relTypeIds = array();
$relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams, $relTypeIds);
$params = array(
$relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams, $relTypeIds);
$params = array(
'relationship_type_id' => $relType->id . '_a_b',
'is_active' => 1,
'contact_check' => array($this->indivi_parent => $this->indivi_parent),
......@@ -270,8 +270,8 @@ DELETE FROM civicrm_contact_type
'contact_type_b' => 'Individual',
);
$relTypeIds = array();
$relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams, $relTypeIds);
$params = array(
$relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams, $relTypeIds);
$params = array(
'relationship_type_id' => $relType->id . '_a_b',
'is_active' => 1,
'contact_check' => array($this->indivi_student => 1),
......@@ -295,8 +295,8 @@ DELETE FROM civicrm_contact_type
'contact_sub_type_b' => $this->sponsor,
);
$relTypeIds = array();
$relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams, $relTypeIds);
$params = array(
$relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams, $relTypeIds);
$params = array(
'relationship_type_id' => $relType->id . '_a_b',
'is_active' => 1,
'contact_check' => array($this->organization_sponsor => 1),
......
......@@ -86,7 +86,11 @@ class CRM_Contact_BAO_GroupContactCacheTest extends CiviUnitTestCase {
$this->assertAPISuccess($result);
CRM_Contact_BAO_GroupContactCache::load($group, TRUE);
$this->assertCacheMatches(
array(/* deceased[0], */ $deceased[1]->id, $deceased[2]->id, $living[0]->id),
array(/* deceased[0], */
$deceased[1]->id,
$deceased[2]->id,
$living[0]->id
),
$group->id
);
}
......@@ -146,7 +150,10 @@ class CRM_Contact_BAO_GroupContactCacheTest extends CiviUnitTestCase {
// Assert $c1 not in $parent
CRM_Contact_BAO_GroupContactCache::load($parent, TRUE);
$this->assertCacheMatches(
array(/* deceased[0], */ $deceased[1]->id, $deceased[2]->id),
array(/* deceased[0], */
$deceased[1]->id,
$deceased[2]->id
),
$parent->id
);
......
......@@ -137,8 +137,8 @@ class CRM_Contact_BAO_GroupContactTest extends CiviUnitTestCase {
'group' => array($parentGroup->id => 1),
'version' => 3,
);
$result = civicrm_api('contact', 'get', $searchParams);
$validContactIds = array($parentContact, $childContact);
$result = civicrm_api('contact', 'get', $searchParams);
$validContactIds = array($parentContact, $childContact);
$resultContactIds = array();
foreach ($result['values'] as $k => $v) {
$resultContactIds[] = $v['contact_id'];
......
......@@ -123,7 +123,6 @@ class CRM_Contact_BAO_GroupTest extends CiviUnitTestCase {
*
* SET @groupID = x;
* SELECT mapping_id FROM civicrm_group g LEFT JOIN civicrm_saved_search s ON saved_search_id = s.id WHERE g.id = @groupID INTO @mappingID;
* SELECT * FROM civicrm_mapping WHERE id = @mappingID;
* SELECT * FROM civicrm_mapping_field WHERE mapping_id = @mappingID;
* SELECT * FROM civicrm_saved_search WHERE mapping_id = @mappingID;
......
......@@ -43,13 +43,13 @@ class CRM_Contact_BAO_QueryTest extends CiviUnitTestCase {
);
$params = CRM_Contact_BAO_Query::convertFormValues($fv);
$obj = new CRM_Contact_BAO_Query($params);
$obj = new CRM_Contact_BAO_Query($params);
// let's set useGroupBy=true since we are listing contacts here who might belong to
// more than one group / tag / notes etc.
$obj->_useGroupBy = TRUE;
$dao = $obj->searchQuery();
$dao = $obj->searchQuery();
$contacts = array();
while ($dao->fetch()) {
......@@ -68,7 +68,11 @@ class CRM_Contact_BAO_QueryTest extends CiviUnitTestCase {
public function testSearchProfileHomeCityCRM14263() {
$contactID = $this->individualCreate();
CRM_Core_Config::singleton()->defaultSearchProfileID = 1;
$this->callAPISuccess('address', 'create', array('contact_id' => $contactID, 'city' => 'Cool City', 'location_type_id' => 1));
$this->callAPISuccess('address', 'create', array(
'contact_id' => $contactID,
'city' => 'Cool City',
'location_type_id' => 1
));
$params = array(
0 => array(
0 => 'city-1',
......@@ -106,7 +110,11 @@ class CRM_Contact_BAO_QueryTest extends CiviUnitTestCase {
public function testSearchProfileHomeCityNoResultsCRM14263() {
$contactID = $this->individualCreate();
CRM_Core_Config::singleton()->defaultSearchProfileID = 1;
$this->callAPISuccess('address', 'create', array('contact_id' => $contactID, 'city' => 'Cool City', 'location_type_id' => 1));
$this->callAPISuccess('address', 'create', array(
'contact_id' => $contactID,
'city' => 'Cool City',
'location_type_id' => 1
));
$params = array(
0 => array(
0 => 'city-1',
......@@ -136,6 +144,7 @@ class CRM_Contact_BAO_QueryTest extends CiviUnitTestCase {
}
}
/**
* CRM-14263 search builder failure with search profile & address in criteria
* We are retrieving primary here - checking the actual sql seems super prescriptive - but since the massive query object has
......@@ -144,28 +153,32 @@ class CRM_Contact_BAO_QueryTest extends CiviUnitTestCase {
public function testSearchProfilePrimaryCityCRM14263() {
$contactID = $this->individualCreate();
CRM_Core_Config::singleton()->defaultSearchProfileID = 1;
$this->callAPISuccess('address', 'create', array('contact_id' => $contactID, 'city' => 'Cool City', 'location_type_id' => 1));
$this->callAPISuccess('address', 'create', array(
'contact_id' => $contactID,
'city' => 'Cool City',
'location_type_id' => 1
));
$params = array(
0 => array(
0 => 'city',
1 => '=',
2 => 'Cool City',
3 => 1,
4 => 0,
),
);
0 => array(
0 => 'city',
1 => '=',
2 => 'Cool City',
3 => 1,
4 => 0,
),
);
$returnProperties = array(
'contact_type' => 1,
'contact_sub_type' => 1,
'sort_name' => 1,
);
'contact_type' => 1,
'contact_sub_type' => 1,
'sort_name' => 1,
);
$expectedSQL = "SELECT contact_a.id as contact_id, contact_a.contact_type as `contact_type`, contact_a.contact_sub_type as `contact_sub_type`, contact_a.sort_name as `sort_name`, civicrm_address.id as address_id, civicrm_address.city as `city` FROM civicrm_contact contact_a LEFT JOIN civicrm_address ON ( contact_a.id = civicrm_address.contact_id AND civicrm_address.is_primary = 1 ) WHERE ( ( LOWER(civicrm_address.city) = 'cool city' ) ) AND (contact_a.is_deleted = 0) ORDER BY contact_a.sort_name asc, contact_a.id ";
$queryObj = new CRM_Contact_BAO_Query($params, $returnProperties);
try {
$this->assertEquals($expectedSQL, $queryObj->searchQuery(0, 0, NULL,
FALSE, FALSE,
FALSE, FALSE,
TRUE));
FALSE, FALSE,
FALSE, FALSE,
TRUE));
}
catch (PEAR_Exception $e) {
$err = $e->getCause();
......
......@@ -53,51 +53,94 @@ class CRM_Contact_BAO_QueryTestDataProvider implements Iterator {
array(
'fv' => array('group' => array('3' => 1)),
'id' => array(
'17', '18', '19', '20', '21',
'22', '23', '24',