CRM-15168 fix test to cope with problems with getactions
[civicrm-core.git] / tests / phpunit / api / v3 / SyntaxConformanceTest.php
index 09cfa08236f4dcfe3e0295eac2b22acb6e822ce2..b79acae7ff86b9452fe1251ea25e8cea87f45021 100644 (file)
@@ -263,21 +263,7 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase {
    * @todo add metadata for ALL these entities
    */
   public static function toBeSkipped_getfields($sequential = FALSE) {
-    $entitiesWithMetadataNotYetFixed = array('ActionSchedule', 'ActivityType',
-      'ContactType', 'ContributionSoft', 'CustomField', 'CustomGroup', 'CustomValue','CustomSearch',
-      'Domain',
-      'Dashboard', 'DashboardContact', 'Extension', 'File', 'FinancialAccount', 'FinancialType',
-      'GroupOrganization', 'GroupNesting',
-      'Im', 'Job', 'LineItem','LocBlock', 'LocationType',
-      'Mailing', 'MailingComponent', 'MailingEventResubscribe', 'MailingEventSubscribe', 'MailingEventUnsubscribe',
-      'MailingEventConfirm', 'MailingGroup',
-      'MailingRecipients', 'MailingJob', 'MailSettings',
-      'MembershipBlock', 'MembershipPayment', 'MessageTemplate',
-      'MembershipType', 'OptionGroup', 'OptionValue', 'MembershipStatus',
-      'ParticipantPayment', 'ParticipantStatusType', 'PledgePayment',
-      'Premium', 'PriceSet', 'PriceFieldValue', 'PriceField', 'PaymentProcessorType', 'PaymentProcessor',
-      'PrintLabel', 'Product', 'ReportTemplate',
-      'Setting',);
+    $entitiesWithMetadataNotYetFixed = array('ReportTemplate', 'CustomSearch');
     if ($sequential === TRUE) {
       return $entitiesWithMetadataNotYetFixed ;
     }
@@ -1148,16 +1134,22 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase {
     if (in_array($entity, $entities)) {
       $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, $entity . 'Test.php');
     }
-    $fields = $this->callAPISuccess($entity, 'getfields', array('action' => 'create'));
-    if (!empty($ids)) {
-      $this->assertArrayHasKey('custom_' . $ids['custom_field_id'], $fields['values']);
-    }
+    $actions =  $this->callAPISuccess($entity, 'getactions', array());
+    foreach ($actions['values'] as $action) {
+      if (substr($action, -7) == '_create'  || substr($action, -4) == '_get' || substr($action, -7) == '_delete') {
+        //getactions can't distinguish between contribution_page.create & contribution_page.create
+        continue;
+      }
+      $fields = $this->callAPISuccess($entity, 'getfields', array('action' => $action));
+      if (!empty($ids) && in_array($action, array('create', 'get'))) {
+        $this->assertArrayHasKey('custom_' . $ids['custom_field_id'], $fields['values']);
+      }
 
-    foreach ($fields['values'] as $fieldName => $fieldSpec) {
-      $this->assertArrayHasKey('title', $fieldSpec, "no title for $entity - $fieldName");
-      $this->assertNotEmpty($fieldSpec['title']);
+      foreach ($fields['values'] as $fieldName => $fieldSpec) {
+        $this->assertArrayHasKey('title', $fieldSpec, "no title for $entity - $fieldName on action $action");
+        $this->assertNotEmpty($fieldSpec['title'], "empty title for $entity - $fieldName");
+      }
     }
-
     if (!empty($ids)) {
       $this->customFieldDelete($ids['custom_field_id']);
       $this->customGroupDelete($ids['custom_group_id']);