From 32dafeecb2516c6d4c4c3a2d2898c4fc7d4b6cc1 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Fri, 22 Aug 2014 21:43:35 +1200 Subject: [PATCH] CRM-15168 add line-in-the-sand title test --- .../phpunit/api/v3/SyntaxConformanceTest.php | 78 ++++++++++++++++++- 1 file changed, 77 insertions(+), 1 deletion(-) diff --git a/tests/phpunit/api/v3/SyntaxConformanceTest.php b/tests/phpunit/api/v3/SyntaxConformanceTest.php index 13dc3b441b..71f90e5b7f 100644 --- a/tests/phpunit/api/v3/SyntaxConformanceTest.php +++ b/tests/phpunit/api/v3/SyntaxConformanceTest.php @@ -159,6 +159,12 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { return static::entities(static::toBeSkipped_delete(TRUE)); } + /** + * @return array + */ + public static function entities_getfields() { + return static::entities(static::toBeSkipped_getfields(TRUE)); + } /** * @return array */ @@ -250,6 +256,39 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { return $entities; } + /** + * @param bool $sequential + * + * @return array + * @todo add metadata for ALL these entities + */ + public static function toBeSkipped_getfields($sequential = FALSE) { + $entitiesWithMetadataNotYetFixed = array('Acl', 'AclRole', 'ActionSchedule', 'ActivityType', + 'ContributionPage', + 'ContactType', 'ContributionSoft', 'Country', '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', + 'SmsProvider', 'UFField'); + if ($sequential === TRUE) { + return $entitiesWithMetadataNotYetFixed ; + } + $entities = array(); + foreach ($entitiesWithMetadataNotYetFixed as $e) { + $entities[] = array($e); + } + return $entities; + } /** * Generate list of entities to test for get by id functions * @param boolean $sequential @@ -1100,6 +1139,44 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { ); } + /** + * Create two entities and make sure delete action only deletes one! + * + * @dataProvider entities_getfields + * + */ + public function testGetfieldsHasTitle($entity) { + $entities = $this->getEntitiesSupportingCustomFields(); + 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']); + } + + foreach ($fields['values'] as $fieldName => $fieldSpec) { + $this->assertArrayHasKey('title', $fieldSpec, "no title for $entity - $fieldName"); + $this->assertNotEmpty($fieldSpec['title']); + } + + if (!empty($ids)) { + $this->customFieldDelete($ids['custom_field_id']); + $this->customGroupDelete($ids['custom_group_id']); + } + } + + /** + * @return array + */ + public function getEntitiesSupportingCustomFields() { + $entities = self::custom_data_entities_get(); + $returnEntities = array(); + foreach ($entities as $entityArray) { + $returnEntities[] = $entityArray[0]; + } + return $returnEntities; + } /** * @param $entityName * @param int $count @@ -1274,5 +1351,4 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { 1 => array($eventId, 'Integer') )); } - } -- 2.25.1