Reformat test files for array format
authoreileen <emcnaughton@wikimedia.org>
Wed, 20 Mar 2019 00:47:03 +0000 (13:47 +1300)
committereileen <emcnaughton@wikimedia.org>
Wed, 20 Mar 2019 00:47:03 +0000 (13:47 +1300)
tests/phpunit/CRM/Contact/BAO/ContactType/ContactSearchTest.php
tests/phpunit/CRM/Contact/BAO/ContactType/ContactTest.php
tests/phpunit/CRM/Contact/BAO/ContactType/ContactTypeTest.php
tests/phpunit/CRM/Contact/BAO/ContactType/RelationshipTest.php

index 5e8ca244d3b47db5b1a2ed3510eddfeab6d8b6f8..c22ace62419afc387767efc595d1eae2144a01e0 100644 (file)
@@ -9,78 +9,78 @@ class CRM_Contact_BAO_ContactType_ContactSearchTest extends CiviUnitTestCase {
   public function setUp() {
     parent::setUp();
     $students = 'indivi_student' . substr(sha1(rand()), 0, 7);
-    $params = array(
+    $params = [
       'label' => $students,
       'name' => $students,
       // Individual
       'parent_id' => 1,
       'is_active' => 1,
-    );
+    ];
     CRM_Contact_BAO_ContactType::add($params);
     $this->student = $params['name'];
 
     $parents = 'indivi_parent' . substr(sha1(rand()), 0, 7);
-    $params = array(
+    $params = [
       'label' => $parents,
       'name' => $parents,
       // Individual
       'parent_id' => 1,
       'is_active' => 1,
-    );
+    ];
     CRM_Contact_BAO_ContactType::add($params);
     $this->parent = $params['name'];
 
     $orgs = 'org_sponsor' . substr(sha1(rand()), 0, 7);
-    $params = array(
+    $params = [
       'label' => $orgs,
       'name' => $orgs,
       // Organization
       'parent_id' => 3,
       'is_active' => 1,
-    );
+    ];
     CRM_Contact_BAO_ContactType::add($params);
     $this->sponsor = $params['name'];
 
-    $this->indiviParams = array(
+    $this->indiviParams = [
       'first_name' => 'Anne',
       'last_name' => 'Grant',
       'contact_type' => 'Individual',
-    );
+    ];
     $this->individual = $this->individualCreate($this->indiviParams);
 
-    $this->individualStudentParams = array(
+    $this->individualStudentParams = [
       'first_name' => 'Bill',
       'last_name' => 'Adams',
       'contact_type' => 'Individual',
       'contact_sub_type' => $this->student,
-    );
+    ];
     $this->individualStudent = $this->individualCreate($this->individualStudentParams);
 
-    $this->indiviParentParams = array(
+    $this->indiviParentParams = [
       'first_name' => 'Alen',
       'last_name' => 'Adams',
       'contact_type' => 'Individual',
       'contact_sub_type' => $this->parent,
-    );
+    ];
     $this->indiviParent = $this->individualCreate($this->indiviParentParams);
 
-    $this->organizationParams = array(
+    $this->organizationParams = [
       'organization_name' => 'Compumentor',
       'contact_type' => 'Organization',
-    );
+    ];
     $this->organization = $this->organizationCreate($this->organizationParams);
 
-    $this->orgSponsorParams = array(
+    $this->orgSponsorParams = [
       'organization_name' => 'Conservation Corp',
       'contact_type' => 'Organization',
       'contact_sub_type' => $this->sponsor,
-    );
+    ];
     $this->orgSponsor = $this->organizationCreate($this->orgSponsorParams);
 
-    $this->householdParams = array(
+    $this->householdParams = [
       'household_name' => "John Doe's home",
       'contact_type' => 'Household',
-    );
+    ];
     $this->household = $this->householdCreate($this->householdParams);
   }
 
@@ -92,7 +92,7 @@ class CRM_Contact_BAO_ContactType_ContactSearchTest extends CiviUnitTestCase {
   public function testSearchWithType() {
 
     // for type:Individual
-    $params = array('contact_type' => 'Individual', 'version' => 3);
+    $params = ['contact_type' => 'Individual', 'version' => 3];
     $result = civicrm_api('contact', 'get', $params);
 
     $individual = $result['values'][$this->individual];
@@ -118,7 +118,7 @@ class CRM_Contact_BAO_ContactType_ContactSearchTest extends CiviUnitTestCase {
     $this->assertEquals(end($indiviParent['contact_sub_type']), $this->indiviParentParams['contact_sub_type']);
 
     // for type:Organization
-    $params = array('contact_type' => 'Organization', 'version' => 3);
+    $params = ['contact_type' => 'Organization', 'version' => 3];
     $result = civicrm_api('contact', 'get', $params);
 
     $organization = $result['values'][$this->organization];
@@ -137,7 +137,7 @@ class CRM_Contact_BAO_ContactType_ContactSearchTest extends CiviUnitTestCase {
     $this->assertEquals(end($orgSponsor['contact_sub_type']), $this->orgSponsorParams['contact_sub_type']);
 
     // for type:Household
-    $params = array('contact_type' => 'Household', 'version' => 3);
+    $params = ['contact_type' => 'Household', 'version' => 3];
     $result = civicrm_api('contact', 'get', $params);
 
     $household = $result['values'][$this->household];
@@ -157,7 +157,7 @@ class CRM_Contact_BAO_ContactType_ContactSearchTest extends CiviUnitTestCase {
   public function testSearchWithSubype() {
 
     // for subtype:Student
-    $params = array('contact_sub_type' => $this->student, 'version' => 3);
+    $params = ['contact_sub_type' => $this->student, 'version' => 3];
     $result = civicrm_api('contact', 'get', $params);
 
     $individualStudent = $result['values'][$this->individualStudent];
@@ -177,7 +177,7 @@ class CRM_Contact_BAO_ContactType_ContactSearchTest extends CiviUnitTestCase {
     $this->assertNotContains($this->household, $result['values']);
 
     // for subtype:Sponsor
-    $params = array('contact_sub_type' => $this->sponsor, 'version' => 3);
+    $params = ['contact_sub_type' => $this->sponsor, 'version' => 3];
     $result = civicrm_api('contact', 'get', $params);
 
     $orgSponsor = $result['values'][$this->orgSponsor];
@@ -205,7 +205,7 @@ 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);
+    $params = ['contact_sub_type' => $this->student, 'version' => 3];
     $result = civicrm_api('contact', 'get', $params);
 
     $individualStudent = $result['values'][$this->individualStudent];
@@ -225,7 +225,7 @@ class CRM_Contact_BAO_ContactType_ContactSearchTest extends CiviUnitTestCase {
     $this->assertNotContains($this->household, $result['values']);
 
     // for type:Organization subtype:Sponsor
-    $params = array('contact_sub_type' => $this->sponsor, 'version' => 3);
+    $params = ['contact_sub_type' => $this->sponsor, 'version' => 3];
     $result = civicrm_api('contact', 'get', $params);
 
     $orgSponsor = $result['values'][$this->orgSponsor];
@@ -250,27 +250,39 @@ 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);
+    $params = [
+      'contact_type' => 'Invalid' . CRM_Core_DAO::VALUE_SEPARATOR . 'Invalid',
+      'version' => 3,
+    ];
     $result = civicrm_api('contact', 'get', $params);
     $this->assertEquals(empty($result['values']), TRUE);
 
     // for invalid subtype
-    $params = array('contact_sub_type' => 'Invalid', 'version' => 3);
+    $params = ['contact_sub_type' => 'Invalid', 'version' => 3];
     $result = civicrm_api('contact', 'get', $params);
     $this->assertEquals(empty($result['values']), TRUE);
 
     // for invalid contact type as well as subtype
-    $params = array('contact_type' => 'Invalid' . CRM_Core_DAO::VALUE_SEPARATOR . 'Invalid', 'version' => 3);
+    $params = [
+      'contact_type' => 'Invalid' . CRM_Core_DAO::VALUE_SEPARATOR . 'Invalid',
+      'version' => 3,
+    ];
     $result = civicrm_api('contact', 'get', $params);
     $this->assertEquals(empty($result['values']), TRUE);
 
     // for valid type and invalid subtype
-    $params = array('contact_type' => 'Individual' . CRM_Core_DAO::VALUE_SEPARATOR . 'Invalid', 'version' => 3);
+    $params = [
+      'contact_type' => 'Individual' . CRM_Core_DAO::VALUE_SEPARATOR . 'Invalid',
+      'version' => 3,
+    ];
     $result = civicrm_api('contact', 'get', $params);
     $this->assertEquals(empty($result['values']), TRUE);
 
     // for invalid type and valid subtype
-    $params = array('contact_type' => 'Invalid' . CRM_Core_DAO::VALUE_SEPARATOR . 'indivi_student', 'version' => 3);
+    $params = [
+      'contact_type' => 'Invalid' . CRM_Core_DAO::VALUE_SEPARATOR . 'indivi_student',
+      'version' => 3,
+    ];
     $result = civicrm_api('contact', 'get', $params);
     $this->assertEquals(empty($result['values']), TRUE);
   }
@@ -281,23 +293,35 @@ class CRM_Contact_BAO_ContactType_ContactSearchTest extends CiviUnitTestCase {
   public function testSearchWithWrongdData() {
 
     // for type:Individual subtype:Sponsor
-    $defaults = array();
-    $params = array('contact_type' => 'Individual' . CRM_Core_DAO::VALUE_SEPARATOR . $this->sponsor, 'version' => 3);
+    $defaults = [];
+    $params = [
+      'contact_type' => 'Individual' . CRM_Core_DAO::VALUE_SEPARATOR . $this->sponsor,
+      'version' => 3,
+    ];
     $result = civicrm_api('contact', 'get', $params);
     $this->assertEquals(empty($result['values']), TRUE);
 
     // for type:Orgaization subtype:Parent
-    $params = array('contact_type' => 'Orgaization' . CRM_Core_DAO::VALUE_SEPARATOR . $this->parent, 'version' => 3);
+    $params = [
+      'contact_type' => 'Orgaization' . CRM_Core_DAO::VALUE_SEPARATOR . $this->parent,
+      'version' => 3,
+    ];
     $result = civicrm_api('contact', 'get', $params, $defaults);
     $this->assertEquals(empty($result['values']), TRUE);
 
     // for type:Household subtype:Sponsor
-    $params = array('contact_type' => 'Household' . CRM_Core_DAO::VALUE_SEPARATOR . $this->sponsor, 'version' => 3);
+    $params = [
+      'contact_type' => 'Household' . CRM_Core_DAO::VALUE_SEPARATOR . $this->sponsor,
+      'version' => 3,
+    ];
     $result = civicrm_api('contact', 'get', $params, $defaults);
     $this->assertEquals(empty($result['values']), TRUE);
 
     // for type:Household subtype:Student
-    $params = array('contact_type' => 'Household' . CRM_Core_DAO::VALUE_SEPARATOR . $this->student, 'version' => 3);
+    $params = [
+      'contact_type' => 'Household' . CRM_Core_DAO::VALUE_SEPARATOR . $this->student,
+      'version' => 3,
+    ];
     $result = civicrm_api('contact', 'get', $params, $defaults);
     $this->assertEquals(empty($result['values']), TRUE);
   }
index 03d908155df8a7537ff75e4ec7284d7ec140ad43..73a15ab8433e592f920e8a48562e522005a3feba 100644 (file)
@@ -9,49 +9,49 @@ class CRM_Contact_BAO_ContactType_ContactTest extends CiviUnitTestCase {
   public function setUp() {
     parent::setUp();
 
-    $params = array(
+    $params = [
       'label' => 'indiv_student',
       'name' => 'indiv_student',
       // Individual
       'parent_id' => 1,
       'is_active' => 1,
-    );
+    ];
     $result = CRM_Contact_BAO_ContactType::add($params);
     $this->student = $params['name'];
 
-    $params = array(
+    $params = [
       'label' => 'indiv_parent',
       'name' => 'indiv_parent',
       // Individual
       'parent_id' => 1,
       'is_active' => 1,
-    );
+    ];
     $result = CRM_Contact_BAO_ContactType::add($params);
     $this->parent = $params['name'];
 
-    $params = array(
+    $params = [
       'label' => 'org_sponsor',
       'name' => 'org_sponsor',
       // Organization
       'parent_id' => 3,
       'is_active' => 1,
-    );
+    ];
     $result = CRM_Contact_BAO_ContactType::add($params);
     $this->sponsor = $params['name'];
 
-    $params = array(
+    $params = [
       'label' => 'org_team',
       'name' => 'org_team',
       // Organization
       'parent_id' => 3,
       'is_active' => 1,
-    );
+    ];
     $result = CRM_Contact_BAO_ContactType::add($params);
     $this->team = $params['name'];
   }
 
   public function tearDown() {
-    $this->quickCleanup(array('civicrm_contact'));
+    $this->quickCleanup(['civicrm_contact']);
     $query = "
 DELETE FROM civicrm_contact_type
       WHERE name IN ('{$this->student}','{$this->parent}','{$this->sponsor}', '{$this->team}');";
@@ -65,11 +65,11 @@ DELETE FROM civicrm_contact_type
    */
   public function testCreateContact() {
     //check for Type:Individual
-    $params = array(
+    $params = [
       'first_name' => 'Anne',
       'last_name' => 'Grant',
       'contact_type' => 'Individual',
-    );
+    ];
     try {
       $contact = CRM_Contact_BAO_Contact::add($params);
     }
@@ -80,10 +80,10 @@ DELETE FROM civicrm_contact_type
     CRM_Contact_BAO_Contact::deleteContact($contact->id);
 
     //check for Type:Organization
-    $params = array(
+    $params = [
       'organization_name' => 'Compumentor',
       'contact_type' => 'Organization',
-    );
+    ];
     try {
       $contact = CRM_Contact_BAO_Contact::add($params);
     }
@@ -94,10 +94,10 @@ DELETE FROM civicrm_contact_type
     CRM_Contact_BAO_Contact::deleteContact($contact->id);
 
     //check for Type:Household
-    $params = array(
+    $params = [
       'household_name' => 'John Does home',
       'contact_type' => 'Household',
-    );
+    ];
     try {
       $contact = CRM_Contact_BAO_Contact::add($params);
     }
@@ -108,12 +108,12 @@ DELETE FROM civicrm_contact_type
     CRM_Contact_BAO_Contact::deleteContact($contact->id);
 
     //check for Type:Individual, Subtype:Student
-    $params = array(
+    $params = [
       'first_name' => 'Bill',
       'last_name' => 'Adams',
       'contact_type' => 'Individual',
       'contact_sub_type' => $this->student,
-    );
+    ];
     try {
       $contact = CRM_Contact_BAO_Contact::add($params);
     }
@@ -125,11 +125,11 @@ DELETE FROM civicrm_contact_type
     CRM_Contact_BAO_Contact::deleteContact($contact->id);
 
     //check for Type:Organization, Subtype:Sponsor
-    $params = array(
+    $params = [
       'organization_name' => 'Conservation Corp',
       'contact_type' => 'Organization',
       'contact_sub_type' => $this->sponsor,
-    );
+    ];
     try {
       $contact = CRM_Contact_BAO_Contact::add($params);
     }
@@ -147,21 +147,21 @@ DELETE FROM civicrm_contact_type
    * Success expected.
    */
   public function testUpdateContactNoSubtypeToValid() {
-    $params = array(
+    $params = [
       'first_name' => 'Anne',
       'last_name' => 'Grant',
       'contact_type' => 'Individual',
-    );
+    ];
     try {
       $contact = CRM_Contact_BAO_Contact::add($params);
     }
     catch (Exception$expected) {
     }
-    $updateParams = array(
+    $updateParams = [
       'contact_sub_type' => $this->student,
       'contact_type' => 'Individual',
       'contact_id' => $contact->id,
-    );
+    ];
     try {
       $updatedContact = CRM_Contact_BAO_Contact::add($updateParams);
     }
@@ -172,21 +172,21 @@ DELETE FROM civicrm_contact_type
     $this->assertEquals(str_replace(CRM_Core_DAO::VALUE_SEPARATOR, '', $updatedContact->contact_sub_type), $this->student);
     CRM_Contact_BAO_Contact::deleteContact($contact->id);
 
-    $params = array(
+    $params = [
       'organization_name' => 'Compumentor',
       'contact_type' => 'Organization',
-    );
+    ];
     try {
       $contact = CRM_Contact_BAO_Contact::add($params);
     }
     catch (Exception$expected) {
     }
 
-    $updateParams = array(
+    $updateParams = [
       'contact_sub_type' => $this->sponsor,
       'contact_type' => 'Organization',
       'contact_id' => $contact->id,
-    );
+    ];
     try {
       $updatedContact = CRM_Contact_BAO_Contact::add($updateParams);
     }
@@ -203,23 +203,23 @@ DELETE FROM civicrm_contact_type
    * success expected
    */
   public function testUpdateContactSubtype() {
-    $params = array(
+    $params = [
       'first_name' => 'Anne',
       'last_name' => 'Grant',
       'contact_type' => 'Individual',
       'contact_sub_type' => $this->student,
-    );
+    ];
     try {
       $contact = CRM_Contact_BAO_Contact::add($params);
     }
     catch (Exception$expected) {
     }
 
-    $updateParams = array(
+    $updateParams = [
       'contact_sub_type' => $this->parent,
       'contact_type' => 'Individual',
       'contact_id' => $contact->id,
-    );
+    ];
     try {
       $updatedContact = CRM_Contact_BAO_Contact::add($updateParams);
     }
@@ -230,22 +230,22 @@ DELETE FROM civicrm_contact_type
     $this->assertEquals(str_replace(CRM_Core_DAO::VALUE_SEPARATOR, '', $updatedContact->contact_sub_type), $this->parent);
     CRM_Contact_BAO_Contact::deleteContact($contact->id);
 
-    $params = array(
+    $params = [
       'organization_name' => 'Compumentor',
       'contact_type' => 'Organization',
       'contact_sub_type' => $this->sponsor,
-    );
+    ];
     try {
       $contact = CRM_Contact_BAO_Contact::add($params);
     }
     catch (Exception$expected) {
     }
 
-    $updateParams = array(
+    $updateParams = [
       'contact_sub_type' => $this->team,
       'contact_type' => 'Organization',
       'contact_id' => $contact->id,
-    );
+    ];
     try {
       $updatedContact = CRM_Contact_BAO_Contact::add($updateParams);
     }
@@ -257,23 +257,23 @@ DELETE FROM civicrm_contact_type
     $this->assertEquals(str_replace(CRM_Core_DAO::VALUE_SEPARATOR, '', $updatedContact->contact_sub_type), $this->team);
     CRM_Contact_BAO_Contact::deleteContact($contact->id);
 
-    $params = array(
+    $params = [
       'first_name' => 'Anne',
       'last_name' => 'Grant',
       'contact_type' => 'Individual',
       'contact_sub_type' => $this->student,
-    );
+    ];
     try {
       $contact = CRM_Contact_BAO_Contact::add($params);
     }
     catch (Exception$expected) {
     }
 
-    $updateParams = array(
+    $updateParams = [
       'contact_sub_type' => NULL,
       'contact_type' => 'Individual',
       'contact_id' => $contact->id,
-    );
+    ];
     try {
       $updatedContact = CRM_Contact_BAO_Contact::add($updateParams);
     }
@@ -293,52 +293,55 @@ DELETE FROM civicrm_contact_type
    * Success expected
    */
   public function testCRM19133() {
-    $subtypesToPreserve = array($this->student, $this->parent);
+    $subtypesToPreserve = [$this->student, $this->parent];
 
     // Create custom group that extends student and parent subtype
-    $apiParams = array(
+    $apiParams = [
       'title' => 'custom group',
-      'extends' => array('Individual', $subtypesToPreserve),
+      'extends' => ['Individual', $subtypesToPreserve],
       'is_active' => TRUE,
-    );
+    ];
     $result = civicrm_api3('customGroup', 'create', $apiParams);
     $customGroupId = $result['id'];
 
     // Create desired custom field
-    $apiParams = array(
+    $apiParams = [
       'debug' => 1,
       'custom_group_id' => $result['id'],
       'label' => 'custom field',
       'html_type' => 'Text',
       'data_type' => 'String',
       'is_active' => TRUE,
-    );
+    ];
     $result = civicrm_api3('custom_field', 'create', $apiParams);
     $customFieldId = $result['id'];
 
     // Create contact of subtype parent and student
-    $params = array(
+    $params = [
       'first_name' => 'Anne',
       'last_name' => 'Grant',
       'contact_type' => 'Individual',
-      'contact_sub_type' => array($this->student, $this->parent),
-    );
+      'contact_sub_type' => [$this->student, $this->parent],
+    ];
     $contact = CRM_Contact_BAO_Contact::add($params);
 
     // Record custom value for desired customGroup
-    $this->callAPISuccess('CustomValue', 'create', array('entity_id' => $contact->id, 'custom_' . $customFieldId => 'value 1'));
+    $this->callAPISuccess('CustomValue', 'create', [
+      'entity_id' => $contact->id,
+      'custom_' . $customFieldId => 'value 1',
+    ]);
 
     // Subtype to be removed from customGroup setting
-    $subtypesToBeRemoved = array($this->student);
+    $subtypesToBeRemoved = [$this->student];
     CRM_Contact_BAO_ContactType::deleteCustomRowsOfSubtype($customGroupId, $subtypesToBeRemoved, $subtypesToPreserve);
 
     // Check with correct value to assert that custom data is not deleted
-    $result = $this->callAPISuccess('Contact', 'Get', array('custom_' . $customFieldId => 'value 1'));
+    $result = $this->callAPISuccess('Contact', 'Get', ['custom_' . $customFieldId => 'value 1']);
     $this->assertEquals(1, $result['count']);
     $this->assertEquals($contact->id, $result['id']);
 
     //Check with incorrect custom value that our previous assertion was correct
-    $result = $this->callAPISuccess('Contact', 'Get', array('custom_' . $customFieldId => 'wrong value'));
+    $result = $this->callAPISuccess('Contact', 'Get', ['custom_' . $customFieldId => 'wrong value']);
     $this->assertEquals(0, $result['count']);
   }
 
index 860d3730e539d39d322fc08c7139bf9d39dbd5c6..bb77e8b667ee6dde118f91d6899e285386bb5f2b 100644 (file)
@@ -9,46 +9,46 @@ class CRM_Contact_BAO_ContactType_ContactTypeTest extends CiviUnitTestCase {
   public function setUp() {
     parent::setUp();
     $labelsub1 = 'sub1_individual' . substr(sha1(rand()), 0, 7);
-    $params = array(
+    $params = [
       'label' => $labelsub1,
       'name' => $labelsub1,
       // Individual
       'parent_id' => 1,
       'is_active' => 1,
-    );
+    ];
     $result = CRM_Contact_BAO_ContactType::add($params);
     $this->subTypesIndividual[] = $params['name'];
 
     $labelsub2 = 'sub2_individual' . substr(sha1(rand()), 0, 7);
-    $params = array(
+    $params = [
       'label' => $labelsub2,
       'name' => $labelsub2,
       // Individual
       'parent_id' => 1,
       'is_active' => 1,
-    );
+    ];
     $result = CRM_Contact_BAO_ContactType::add($params);
     $this->subTypesIndividual[] = $params['name'];
 
     $labelsub = 'sub_organization' . substr(sha1(rand()), 0, 7);
-    $params = array(
+    $params = [
       'label' => $labelsub,
       'name' => $labelsub,
       // Organization
       'parent_id' => 3,
       'is_active' => 1,
-    );
+    ];
     $result = CRM_Contact_BAO_ContactType::add($params);
     $this->subTypesOrganization[] = $params['name'];
 
     $labelhousehold = 'sub_household' . substr(sha1(rand()), 0, 7);
-    $params = array(
+    $params = [
       'label' => $labelhousehold,
       'name' => $labelhousehold,
       // Household
       'parent_id' => 2,
       'is_active' => 1,
-    );
+    ];
     $result = CRM_Contact_BAO_ContactType::add($params);
     $this->subTypesHousehold[] = $params['name'];
   }
@@ -60,7 +60,7 @@ class CRM_Contact_BAO_ContactType_ContactTypeTest extends CiviUnitTestCase {
   public function testGetMethods() {
 
     // check all contact types
-    $contactTypes = array('Individual', 'Organization', 'Household');
+    $contactTypes = ['Individual', 'Organization', 'Household'];
     $result = CRM_Contact_BAO_ContactType::contactTypes('Individual');
     foreach ($contactTypes as $type) {
       $this->assertEquals(in_array($type, $result), TRUE);
@@ -121,7 +121,7 @@ class CRM_Contact_BAO_ContactType_ContactTypeTest extends CiviUnitTestCase {
     $result = CRM_Contact_BAO_ContactType::subTypes($params);
     $this->assertEquals(empty($result), TRUE);
 
-    $params = array('invalid');
+    $params = ['invalid'];
     $result = CRM_Contact_BAO_ContactType::subTypes($params);
     $this->assertEquals(empty($result), TRUE);
   }
@@ -132,12 +132,12 @@ class CRM_Contact_BAO_ContactType_ContactTypeTest extends CiviUnitTestCase {
    */
   public function testAdd() {
 
-    $params = array(
+    $params = [
       'label' => 'indiviSubType',
       'name' => 'indiviSubType',
       'parent_id' => 1,
       'is_active' => 1,
-    );
+    ];
     $result = CRM_Contact_BAO_ContactType::add($params);
     $this->assertEquals($result->label, $params['label']);
     $this->assertEquals($result->name, $params['name']);
@@ -145,12 +145,12 @@ class CRM_Contact_BAO_ContactType_ContactTypeTest extends CiviUnitTestCase {
     $this->assertEquals($result->is_active, $params['is_active']);
     CRM_Contact_BAO_ContactType::del($result->id);
 
-    $params = array(
+    $params = [
       'label' => 'householdSubType',
       'name' => 'householdSubType',
       'parent_id' => 2,
       'is_active' => 0,
-    );
+    ];
     $result = CRM_Contact_BAO_ContactType::add($params);
     $this->assertEquals($result->label, $params['label']);
     $this->assertEquals($result->name, $params['name']);
@@ -165,13 +165,13 @@ class CRM_Contact_BAO_ContactType_ContactTypeTest extends CiviUnitTestCase {
   public function testAddInvalid1() {
 
     // parent id does not exist in db
-    $params = array(
+    $params = [
       'label' => 'subType',
       'name' => 'subType',
       // non existent
       'parent_id' => 100,
       'is_active' => 1,
-    );
+    ];
     $result = CRM_Contact_BAO_ContactType::add($params);
     $this->assertEquals($result, NULL);
   }
@@ -179,10 +179,10 @@ class CRM_Contact_BAO_ContactType_ContactTypeTest extends CiviUnitTestCase {
   public function testAddInvalid2() {
 
     // params does not have name and label keys
-    $params = array(
+    $params = [
       'parent_id' => 1,
       'is_active' => 1,
-    );
+    ];
     $result = CRM_Contact_BAO_ContactType::add($params);
     $this->assertEquals($result, NULL);
   }
@@ -190,11 +190,11 @@ class CRM_Contact_BAO_ContactType_ContactTypeTest extends CiviUnitTestCase {
   public function testAddInvalid3() {
 
     // params does not have parent_id
-    $params = array(
+    $params = [
       'label' => 'subType',
       'name' => 'subType',
       'is_active' => 1,
-    );
+    ];
     $result = CRM_Contact_BAO_ContactType::add($params);
     $this->assertEquals($result, NULL, 'In line' . __LINE__);
   }
@@ -205,12 +205,12 @@ class CRM_Contact_BAO_ContactType_ContactTypeTest extends CiviUnitTestCase {
    */
   public function testDel() {
 
-    $params = array(
+    $params = [
       'label' => 'indiviSubType',
       'name' => 'indiviSubType',
       'parent_id' => 1,
       'is_active' => 1,
-    );
+    ];
     $subtype = CRM_Contact_BAO_ContactType::add($params);
 
     $del = CRM_Contact_BAO_ContactType::del($subtype->id);
index 96c6e05649a499ab14bdcd7d3c93ad14f1703a9b..c7cf9da084db54dd6c436339990b70ab425d42db 100644 (file)
@@ -10,76 +10,76 @@ class CRM_Contact_BAO_ContactType_RelationshipTest extends CiviUnitTestCase {
     parent::setUp();
 
     //create contact subtypes
-    $params = array(
+    $params = [
       'label' => 'indivi_student',
       'name' => 'indivi_student',
       // Individual
       'parent_id' => 1,
       'is_active' => 1,
-    );
+    ];
     $result = CRM_Contact_BAO_ContactType::add($params);
     $this->student = $params['name'];
 
-    $params = array(
+    $params = [
       'label' => 'indivi_parent',
       'name' => 'indivi_parent',
       // Individual
       'parent_id' => 1,
       'is_active' => 1,
-    );
+    ];
     $result = CRM_Contact_BAO_ContactType::add($params);
     $this->parent = $params['name'];
 
-    $params = array(
+    $params = [
       'label' => 'org_sponsor',
       'name' => 'org_sponsor',
       // Organization
       'parent_id' => 3,
       'is_active' => 1,
-    );
+    ];
     $result = CRM_Contact_BAO_ContactType::add($params);
     $this->sponsor = $params['name'];
 
     //create contacts
-    $params = array(
+    $params = [
       'first_name' => 'Anne',
       'last_name' => 'Grant',
       'contact_type' => 'Individual',
-    );
+    ];
     $this->individual = $this->individualCreate($params);
 
-    $params = array(
+    $params = [
       'first_name' => 'Bill',
       'last_name' => 'Adams',
       'contact_type' => 'Individual',
       'contact_sub_type' => $this->student,
-    );
+    ];
     $this->indivi_student = $this->individualCreate($params);
 
-    $params = array(
+    $params = [
       'first_name' => 'Alen',
       'last_name' => 'Adams',
       'contact_type' => 'Individual',
       'contact_sub_type' => $this->parent,
-    );
+    ];
     $this->indivi_parent = $this->individualCreate($params);
 
-    $params = array(
+    $params = [
       'organization_name' => 'Compumentor',
       'contact_type' => 'Organization',
-    );
+    ];
     $this->organization = $this->organizationCreate($params);
 
-    $params = array(
+    $params = [
       'organization_name' => 'Conservation Corp',
       'contact_type' => 'Organization',
       'contact_sub_type' => $this->sponsor,
-    );
+    ];
     $this->organization_sponsor = $this->organizationCreate($params);
   }
 
   public function tearDown() {
-    $this->quickCleanup(array('civicrm_contact'));
+    $this->quickCleanup(['civicrm_contact']);
 
     $query = "
 DELETE FROM civicrm_contact_type
@@ -94,13 +94,13 @@ DELETE FROM civicrm_contact_type
    */
   public function testRelationshipTypeAddIndiviParent() {
     //check Individual to Parent RelationshipType
-    $params = array(
+    $params = [
       'name_a_b' => 'indivToparent',
       'name_b_a' => 'parentToindiv',
       'contact_type_a' => 'Individual',
       'contact_type_b' => 'Individual',
       'contact_sub_type_b' => $this->parent,
-    );
+    ];
     $result = CRM_Contact_BAO_RelationshipType::add($params);
     $this->assertEquals($result->name_a_b, 'indivToparent');
     $this->assertEquals($result->contact_type_a, 'Individual');
@@ -111,13 +111,13 @@ DELETE FROM civicrm_contact_type
 
   public function testRelationshipTypeAddSponcorIndivi() {
     //check Sponcor to Individual RelationshipType
-    $params = array(
+    $params = [
       'name_a_b' => 'SponsorToIndiv',
       'name_b_a' => 'IndivToSponsor',
       'contact_type_a' => 'Organization',
       'contact_sub_type_a' => $this->sponsor,
       'contact_type_b' => 'Individual',
-    );
+    ];
     $result = CRM_Contact_BAO_RelationshipType::add($params);
     $this->assertEquals($result->name_a_b, 'SponsorToIndiv');
     $this->assertEquals($result->contact_type_a, 'Organization');
@@ -128,14 +128,14 @@ DELETE FROM civicrm_contact_type
 
   public function testRelationshipTypeAddStudentSponcor() {
     //check Student to Sponcer RelationshipType
-    $params = array(
+    $params = [
       'name_a_b' => 'StudentToSponser',
       'name_b_a' => 'SponsorToStudent',
       'contact_type_a' => 'Individual',
       'contact_sub_type_a' => $this->student,
       'contact_type_b' => 'Organization',
       'contact_sub_type_b' => $this->sponsor,
-    );
+    ];
     $result = CRM_Contact_BAO_RelationshipType::add($params);
     $this->assertEquals($result->name_a_b, 'StudentToSponser');
     $this->assertEquals($result->contact_type_a, 'Individual');
@@ -150,19 +150,19 @@ DELETE FROM civicrm_contact_type
    */
   public function testRelationshipCreateInvalidWithinSameType() {
     //check for Individual to Parent
-    $relTypeParams = array(
+    $relTypeParams = [
       'name_a_b' => 'indivToparent',
       'name_b_a' => 'parentToindiv',
       'contact_type_a' => 'Individual',
       'contact_type_b' => 'Individual',
       'contact_sub_type_b' => $this->parent,
-    );
+    ];
     $relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams);
-    $params = array(
+    $params = [
       'relationship_type_id' => $relType->id . '_a_b',
-      'contact_check' => array($this->indivi_student => 1),
-    );
-    $ids = array('contact' => $this->individual);
+      'contact_check' => [$this->indivi_student => 1],
+    ];
+    $ids = ['contact' => $this->individual];
 
     list($valid, $invalid, $duplicate, $saved, $relationshipIds) = CRM_Contact_BAO_Relationship::legacyCreateMultiple($params, $ids);
 
@@ -176,19 +176,19 @@ DELETE FROM civicrm_contact_type
    */
   public function testRelCreateInvalidWithinDiffTypeSpocorIndivi() {
     //check for Sponcer to Individual
-    $relTypeParams = array(
+    $relTypeParams = [
       'name_a_b' => 'SponsorToIndiv',
       'name_b_a' => 'IndivToSponsor',
       'contact_type_a' => 'Organization',
       'contact_sub_type_a' => $this->sponsor,
       'contact_type_b' => 'Individual',
-    );
+    ];
     $relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams);
-    $params = array(
+    $params = [
       'relationship_type_id' => $relType->id . '_a_b',
-      'contact_check' => array($this->individual => 1),
-    );
-    $ids = array('contact' => $this->indivi_parent);
+      'contact_check' => [$this->individual => 1],
+    ];
+    $ids = ['contact' => $this->indivi_parent];
 
     list($valid, $invalid, $duplicate, $saved, $relationshipIds) = CRM_Contact_BAO_Relationship::legacyCreateMultiple($params, $ids);
 
@@ -199,20 +199,20 @@ DELETE FROM civicrm_contact_type
 
   public function testRelCreateInvalidWithinDiffTypeStudentSponcor() {
     //check for Student to Sponcer
-    $relTypeParams = array(
+    $relTypeParams = [
       'name_a_b' => 'StudentToSponser',
       'name_b_a' => 'SponsorToStudent',
       'contact_type_a' => 'Individual',
       'contact_sub_type_a' => $this->student,
       'contact_type_b' => 'Organization',
       'contact_sub_type_b' => 'Sponser',
-    );
+    ];
     $relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams);
-    $params = array(
+    $params = [
       'relationship_type_id' => $relType->id . '_a_b',
-      'contact_check' => array($this->individual => 1),
-    );
-    $ids = array('contact' => $this->indivi_parent);
+      'contact_check' => [$this->individual => 1],
+    ];
+    $ids = ['contact' => $this->indivi_parent];
 
     list($valid, $invalid, $duplicate, $saved, $relationshipIds) = CRM_Contact_BAO_Relationship::legacyCreateMultiple($params, $ids);
 
@@ -227,20 +227,20 @@ DELETE FROM civicrm_contact_type
    */
   public function testRelationshipCreateWithinSameType() {
     //check for Individual to Parent
-    $relTypeParams = array(
+    $relTypeParams = [
       'name_a_b' => 'indivToparent',
       'name_b_a' => 'parentToindiv',
       'contact_type_a' => 'Individual',
       'contact_type_b' => 'Individual',
       'contact_sub_type_b' => $this->parent,
-    );
+    ];
     $relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams);
-    $params = array(
+    $params = [
       'relationship_type_id' => $relType->id . '_a_b',
       'is_active' => 1,
-      'contact_check' => array($this->indivi_parent => $this->indivi_parent),
-    );
-    $ids = array('contact' => $this->individual);
+      'contact_check' => [$this->indivi_parent => $this->indivi_parent],
+    ];
+    $ids = ['contact' => $this->individual];
     list($valid, $invalid, $duplicate, $saved, $relationshipIds) = CRM_Contact_BAO_Relationship::legacyCreateMultiple($params, $ids);
 
     $this->assertEquals($valid, 1);
@@ -254,20 +254,20 @@ DELETE FROM civicrm_contact_type
    */
   public function testRelCreateWithinDiffTypeSponsorIndivi() {
     //check for Sponcer to Individual
-    $relTypeParams = array(
+    $relTypeParams = [
       'name_a_b' => 'SponsorToIndiv',
       'name_b_a' => 'IndivToSponsor',
       'contact_type_a' => 'Organization',
       'contact_sub_type_a' => $this->sponsor,
       'contact_type_b' => 'Individual',
-    );
+    ];
     $relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams);
-    $params = array(
+    $params = [
       'relationship_type_id' => $relType->id . '_a_b',
       'is_active' => 1,
-      'contact_check' => array($this->indivi_student => 1),
-    );
-    $ids = array('contact' => $this->organization_sponsor);
+      'contact_check' => [$this->indivi_student => 1],
+    ];
+    $ids = ['contact' => $this->organization_sponsor];
     list($valid, $invalid, $duplicate, $saved, $relationshipIds) = CRM_Contact_BAO_Relationship::legacyCreateMultiple($params, $ids);
 
     $this->assertEquals($valid, 1);
@@ -277,21 +277,21 @@ DELETE FROM civicrm_contact_type
 
   public function testRelCreateWithinDiffTypeStudentSponsor() {
     //check for Student to Sponcer
-    $relTypeParams = array(
+    $relTypeParams = [
       'name_a_b' => 'StudentToSponsor',
       'name_b_a' => 'SponsorToStudent',
       'contact_type_a' => 'Individual',
       'contact_sub_type_a' => $this->student,
       'contact_type_b' => 'Organization',
       'contact_sub_type_b' => $this->sponsor,
-    );
+    ];
     $relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams);
-    $params = array(
+    $params = [
       'relationship_type_id' => $relType->id . '_a_b',
       'is_active' => 1,
-      'contact_check' => array($this->organization_sponsor => 1),
-    );
-    $ids = array('contact' => $this->indivi_student);
+      'contact_check' => [$this->organization_sponsor => 1],
+    ];
+    $ids = ['contact' => $this->indivi_student];
     list($valid, $invalid, $duplicate, $saved, $relationshipIds) = CRM_Contact_BAO_Relationship::legacyCreateMultiple($params, $ids);
 
     $this->assertEquals($valid, 1);
@@ -301,12 +301,12 @@ DELETE FROM civicrm_contact_type
 
   public function testGetAnyToAnyRelTypes() {
     // Create an any to any relationship.
-    $relTypeParams = array(
+    $relTypeParams = [
       'name_a_b' => 'MookieIs',
       'name_b_a' => 'MookieOf',
       'contact_type_a' => '',
       'contact_type_b' => '',
-    );
+    ];
     $relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams);
     $indTypes = CRM_Contact_BAO_Relationship::getRelationType('Individual');
     $orgTypes = CRM_Contact_BAO_Relationship::getRelationType('Organization');