[REF] Update subtypeInfo function to leverage getAllContactTypes
[civicrm-core.git] / tests / phpunit / CRM / Contact / BAO / ContactType / ContactTypeTest.php
index daf1209e542990deb42d20216f9c37ddfffaadb2..e726e82524b4edbf93750c1448e2ca21881c802f 100644 (file)
@@ -42,7 +42,7 @@ class CRM_Contact_BAO_ContactType_ContactTypeTest extends CiviUnitTestCase {
       'parent_id:name' => 'Household',
       'is_active' => 1,
     ];
-    $this->ids['ContactType'][] = ContactType::create()->setValues($params)->execute()->first()['id'];
+    $this->ids['ContactType'][] = (int) ContactType::create()->setValues($params)->execute()->first()['id'];
   }
 
   /**
@@ -66,19 +66,24 @@ class CRM_Contact_BAO_ContactType_ContactTypeTest extends CiviUnitTestCase {
     // check for type:Individual
     $result = CRM_Contact_BAO_ContactType::subTypes('Individual');
     $this->assertEquals(array_keys($this->getExpectedContactSubTypes('Individual')), $result);
+    $this->assertEquals($this->getExpectedContactSubTypes('Individual'), CRM_Contact_BAO_ContactType::subTypeInfo('Individual'));
 
     // check for type:Organization
     $result = CRM_Contact_BAO_ContactType::subTypes('Organization');
     $this->assertEquals(array_keys($this->getExpectedContactSubTypes('Organization')), $result);
+    $this->assertEquals($this->getExpectedContactSubTypes('Organization'), CRM_Contact_BAO_ContactType::subTypeInfo('Organization'));
 
     // check for type:Household
     $result = CRM_Contact_BAO_ContactType::subTypes('Household');
     $this->assertEquals(array_keys($this->getExpectedContactSubTypes('Household')), $result);
+    $this->assertEquals($this->getExpectedContactSubTypes('Household'), CRM_Contact_BAO_ContactType::subTypeInfo('Household'));
 
     // check for all contact types
     $result = CRM_Contact_BAO_ContactType::subTypes();
     $subtypes = array_keys($this->getExpectedAllSubtypes());
     $this->assertEquals(sort($subtypes), sort($result));
+    $this->assertEquals($this->getExpectedAllSubtypes(), CRM_Contact_BAO_ContactType::subTypeInfo());
+
   }
 
   /**
@@ -108,14 +113,16 @@ class CRM_Contact_BAO_ContactType_ContactTypeTest extends CiviUnitTestCase {
     $this->assertEquals($expected, $activeTypes);
     $allTypes = CRM_Contact_BAO_ContactType::contactTypeInfo(TRUE);
     $expected['blah'] = [
-      'is_active' => 0,
+      'is_active' => FALSE,
       'name' => 'blah',
       'label' => 'blah blah',
       'id' => $createdType['id'],
       'parent_id' => 1,
-      'is_reserved' => 0,
+      'is_reserved' => FALSE,
       'parent' => 'Individual',
       'parent_label' => 'Individual',
+      'description' => NULL,
+      'image_URL' => NULL,
     ];
     $this->assertEquals($expected, $allTypes);
   }
@@ -132,123 +139,156 @@ class CRM_Contact_BAO_ContactType_ContactTypeTest extends CiviUnitTestCase {
           'id' => '1',
           'name' => 'Individual',
           'label' => 'Individual',
-          'is_active' => '1',
-          'is_reserved' => '1',
+          'is_active' => TRUE,
+          'is_reserved' => TRUE,
+          'description' => NULL,
+          'parent_id' => NULL,
+          'parent' => NULL,
+          'parent_label' => NULL,
+          'image_URL' => NULL,
         ],
       'Household' =>
         [
           'id' => '2',
           'name' => 'Household',
           'label' => 'Household',
-          'is_active' => '1',
-          'is_reserved' => '1',
+          'is_active' => TRUE,
+          'is_reserved' => TRUE,
+          'description' => NULL,
+          'parent_id' => NULL,
+          'parent' => NULL,
+          'parent_label' => NULL,
+          'image_URL' => NULL,
         ],
       'Organization' =>
         [
           'id' => '3',
           'name' => 'Organization',
           'label' => 'Organization',
-          'is_active' => '1',
-          'is_reserved' => '1',
+          'is_active' => TRUE,
+          'is_reserved' => TRUE,
+          'description' => NULL,
+          'parent_id' => NULL,
+          'parent' => NULL,
+          'parent_label' => NULL,
+          'image_URL' => NULL,
         ],
       'Student' =>
         [
-          'id' => '4',
+          'id' => 4,
           'name' => 'Student',
           'label' => 'Student',
-          'parent_id' => '1',
+          'parent_id' => 1,
           'is_active' => '1',
-          'is_reserved' => '0',
+          'is_reserved' => FALSE,
+          'description' => NULL,
           'parent' => 'Individual',
           'parent_label' => 'Individual',
+          'image_URL' => NULL,
         ],
       'Parent' =>
         [
-          'id' => '5',
+          'id' => 5,
           'name' => 'Parent',
           'label' => 'Parent',
-          'parent_id' => '1',
-          'is_active' => '1',
-          'is_reserved' => '0',
+          'parent_id' => 1,
+          'is_active' => TRUE,
+          'is_reserved' => FALSE,
+          'description' => NULL,
           'parent' => 'Individual',
           'parent_label' => 'Individual',
+          'image_URL' => NULL,
         ],
       'Staff' =>
         [
-          'id' => '6',
+          'id' => 6,
           'name' => 'Staff',
           'label' => 'Staff',
-          'parent_id' => '1',
-          'is_active' => '1',
-          'is_reserved' => '0',
+          'parent_id' => 1,
+          'is_active' => TRUE,
+          'is_reserved' => FALSE,
+          'description' => NULL,
           'parent' => 'Individual',
           'parent_label' => 'Individual',
+          'image_URL' => NULL,
         ],
       'Team' =>
         [
-          'id' => '7',
+          'id' => 7,
           'name' => 'Team',
           'label' => 'Team',
-          'parent_id' => '3',
-          'is_active' => '1',
-          'is_reserved' => '0',
+          'parent_id' => 3,
+          'is_active' => TRUE,
+          'is_reserved' => FALSE,
+          'description' => NULL,
           'parent' => 'Organization',
           'parent_label' => 'Organization',
+          'image_URL' => NULL,
         ],
       'Sponsor' =>
         [
-          'id' => '8',
+          'id' => 8,
           'name' => 'Sponsor',
           'label' => 'Sponsor',
-          'parent_id' => '3',
-          'is_active' => '1',
-          'is_reserved' => '0',
+          'parent_id' => 3,
+          'is_active' => TRUE,
+          'is_reserved' => FALSE,
+          'description' => NULL,
           'parent' => 'Organization',
           'parent_label' => 'Organization',
+          'image_URL' => NULL,
         ],
       'sub1_individual' =>
         [
           'id' => $this->ids['ContactType'][0],
           'name' => 'sub1_individual',
           'label' => 'sub1_individual',
-          'parent_id' => '1',
-          'is_active' => '1',
-          'is_reserved' => '0',
+          'parent_id' => 1,
+          'is_active' => TRUE,
+          'is_reserved' => FALSE,
+          'description' => NULL,
           'parent' => 'Individual',
           'parent_label' => 'Individual',
+          'image_URL' => NULL,
         ],
       'sub2_individual' =>
         [
           'id' => $this->ids['ContactType'][1],
           'name' => 'sub2_individual',
           'label' => 'sub2_individual',
-          'parent_id' => '1',
-          'is_active' => '1',
-          'is_reserved' => '0',
+          'parent_id' => 1,
+          'is_active' => TRUE,
+          'is_reserved' => FALSE,
+          'description' => NULL,
           'parent' => 'Individual',
           'parent_label' => 'Individual',
+          'image_URL' => NULL,
         ],
       'sub_organization' =>
         [
           'id' => $this->ids['ContactType'][2],
           'name' => 'sub_organization',
           'label' => 'sub_organization',
-          'parent_id' => '3',
-          'is_active' => '1',
-          'is_reserved' => '0',
+          'parent_id' => 3,
+          'is_active' => TRUE,
+          'is_reserved' => FALSE,
+          'description' => NULL,
           'parent' => 'Organization',
           'parent_label' => 'Organization',
+          'image_URL' => NULL,
         ],
       'sub_household' =>
         [
           'id' => $this->ids['ContactType'][3],
           'name' => 'sub_household',
           'label' => 'sub_household',
-          'parent_id' => '2',
-          'is_active' => '1',
-          'is_reserved' => '0',
+          'parent_id' => 2,
+          'is_active' => TRUE,
+          'is_reserved' => FALSE,
+          'description' => NULL,
           'parent' => 'Household',
           'parent_label' => 'Household',
+          'image_URL' => NULL,
         ],
     ];
   }