profile api test fixes (caching & case on entities)
[civicrm-core.git] / tests / phpunit / api / v3 / ProfileTest.php
index af9e9b6436e5536203624dffb860bdb20d8ee0ef..ee587565257f9ef7d47567aac3042c8566a6ee19 100644 (file)
@@ -39,6 +39,8 @@ require_once 'tests/phpunit/CiviTest/CiviUnitTestCase.php';
 class api_v3_ProfileTest extends CiviUnitTestCase {
   protected $_apiversion;
   protected $_profileID = 0;
+  protected $_membershipTypeID;
+  protected $_contactID;
   function get_info() {
     return array(
       'name' => 'Profile Test',
@@ -54,6 +56,7 @@ class api_v3_ProfileTest extends CiviUnitTestCase {
     $config->countryLimit[1] = 1013;
     $config->stateLimit[1] = 1013;
     $this->createLoggedInUser();
+    $this->_membershipTypeID = $this->membershipTypeCreate();
   }
 
   function tearDown() {
@@ -62,7 +65,10 @@ class api_v3_ProfileTest extends CiviUnitTestCase {
       'civicrm_contact',
       'civicrm_phone',
       'civicrm_address',
+      'civicrm_membership',
+      'civicrm_contribution',
     ), TRUE);
+    $this->callAPISuccess('membership_type', 'delete', array('id' => $this->_membershipTypeID));
     // ok can't be bothered wring an api to do this & truncating is crazy
     CRM_Core_DAO::executeQuery(" DELETE FROM civicrm_uf_group WHERE id IN ($this->_profileID, 26)");
   }
@@ -431,17 +437,14 @@ class api_v3_ProfileTest extends CiviUnitTestCase {
     $profileDetails = $this->callAPISuccess('profile', 'get', $getParams);
 
     foreach ($updateParams as $profileField => $value) {
-      $this->assertEquals($value, CRM_Utils_Array::value($profileField, $profileDetails['values']), "In line " . __LINE__ . " error message: " . "missing/mismatching value for {$profileField}"
+      $this->assertEquals($value, CRM_Utils_Array::value($profileField, $profileDetails['values']), "missing/mismatching value for {$profileField}"
       );
     }
-    unset($updateParams['email-primary']);
-    $updateParams['email-Primary'] = 'my@mail.com';
+    unset($params['email-primary']);
+    $params['email-Primary'] = 'my@mail.com';
     $this->callAPISuccess('profile', 'submit',  $params);
     $profileDetails = $this->callAPISuccess('profile', 'get', $getParams);
-    foreach ($updateParams as $profileField => $value) {
-      $this->assertEquals($value, CRM_Utils_Array::value($profileField, $profileDetails['values']), "In line " . __LINE__ . " error message: " . "missing/mismatching value for {$profileField}"
-      );
-    }
+    $this->assertEquals('my@mail.com', $profileDetails['values']['email-Primary']);
   }
 
   /**
@@ -675,10 +678,10 @@ class api_v3_ProfileTest extends CiviUnitTestCase {
      ), $params
     );
 
-    $contactID = $this->individualCreate($contactParams);
+    $this->_contactID = $this->individualCreate($contactParams);
     $this->_createIndividualProfile();
     // expected result of above created profile with contact Id $contactId
-    $profileData[$contactID] = array(
+    $profileData[$this->_contactID] = array(
       'first_name' => 'abc1',
       'last_name' => 'xyz1',
       'email-primary' => 'abc1.xyz1@yahoo.com',
@@ -783,13 +786,14 @@ class api_v3_ProfileTest extends CiviUnitTestCase {
           'is_required' => 1,
           'visibility' => 'Public Pages and Listings',
           'field_type' => 'Individual',
-          //is_active = 1, is_view  0, weight SHOULD be set by api (& tested), ditto is_reserved 0
+          'label' => 'First Name',
         ),
         array(
           'field_name' => 'last_name',
           'is_required' => 1,
           'visibility' => 'Public Pages and Listings',
           'field_type' => 'Individual',
+          'label' => 'Last Name',
         ),
         array(
           'field_name' => 'email',