From 92915c5561d7ef4742bd6b46237760d6209141de Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Fri, 9 Jan 2015 19:44:02 -0800 Subject: [PATCH] INFRA-132 - tests/ - PHPStorm cleanup --- tests/phpunit/CRM/Batch/Form/EntryTest.php | 63 +-- tests/phpunit/CRM/Bridge/OG/DrupalTest.php | 8 +- tests/phpunit/CRM/Contact/BAO/ContactTest.php | 108 +++-- .../BAO/ContactType/ContactSearchTest.php | 24 +- .../Contact/BAO/ContactType/ContactTest.php | 45 ++- .../BAO/ContactType/RelationshipTest.php | 24 +- .../CRM/Contact/BAO/GroupContactCacheTest.php | 11 +- .../CRM/Contact/BAO/GroupContactTest.php | 4 +- tests/phpunit/CRM/Contact/BAO/GroupTest.php | 1 - tests/phpunit/CRM/Contact/BAO/QueryTest.php | 53 ++- .../CRM/Contact/BAO/QueryTestDataProvider.php | 73 +++- .../Contact/Form/Search/Custom/GroupTest.php | 16 +- .../Search/Custom/GroupTestDataProvider.php | 213 +++++++--- .../Contribute/BAO/ContributionPageTest.php | 14 +- .../Contribute/BAO/ContributionRecurTest.php | 1 + .../CRM/Contribute/BAO/ContributionTest.php | 22 +- .../Contribute/BAO/ContributionTypeTest.php | 4 +- .../CRM/Contribute/BAO/ManagePremiumsTest.php | 8 +- .../CRM/Core/BAO/ActionScheduleTest.php | 6 +- tests/phpunit/CRM/Core/BAO/AddressTest.php | 16 +- .../phpunit/CRM/Core/BAO/CustomFieldTest.php | 99 ++--- .../phpunit/CRM/Core/BAO/CustomGroupTest.php | 25 +- .../Core/BAO/CustomValueTableMultipleTest.php | 24 +- .../CRM/Core/BAO/CustomValueTableTest.php | 58 +-- .../CRM/Core/BAO/FinancialTrxnTest.php | 6 +- tests/phpunit/CRM/Core/BAO/LocationTest.php | 19 +- .../CRM/Core/BAO/RecurringEntityTest.php | 46 +-- tests/phpunit/CRM/Core/BAO/UFFieldTest.php | 14 +- tests/phpunit/CRM/Core/Config/MailerTest.php | 20 +- tests/phpunit/CRM/Core/DAOTest.php | 30 +- .../phpunit/CRM/Core/ManagedEntitiesTest.php | 4 +- tests/phpunit/CRM/Core/MenuTest.php | 37 +- .../CRM/Core/Payment/AuthorizeNetIPNTest.php | 15 +- .../CRM/Core/Payment/AuthorizeNetTest.php | 54 +-- .../phpunit/CRM/Core/Payment/BaseIPNTest.php | 67 ++-- .../CRM/Core/Payment/PayPalProIPNTest.php | 40 +- tests/phpunit/CRM/Core/PseudoConstantTest.php | 27 +- tests/phpunit/CRM/Core/RegionTest.php | 2 +- tests/phpunit/CRM/Core/ResourcesTest.php | 40 +- .../CRM/Core/Smarty/plugins/CrmScopeTest.php | 10 +- tests/phpunit/CRM/Core/TransactionTest.php | 44 +- tests/phpunit/CRM/Dedupe/DedupeFinderTest.php | 12 +- .../CRM/Event/BAO/AdditionalPaymentTest.php | 6 +- .../CRM/Event/BAO/ParticipantStatusTest.php | 4 +- .../phpunit/CRM/Event/BAO/ParticipantTest.php | 23 +- .../Extension/Container/CollectionTest.php | 11 +- .../CRM/Extension/Manager/ModuleTest.php | 3 +- .../CRM/Extension/Manager/PaymentTest.php | 2 + tests/phpunit/CRM/Extension/ManagerTest.php | 8 +- .../CRM/Financial/BAO/FinancialItemTest.php | 24 +- tests/phpunit/CRM/Group/Page/AjaxTest.php | 32 +- tests/phpunit/CRM/Mailing/BAO/QueryTest.php | 4 +- .../CRM/Mailing/BAO/QueryTestDataProvider.php | 59 +-- .../CRM/Member/BAO/MembershipStatusTest.php | 4 +- .../phpunit/CRM/Member/BAO/MembershipTest.php | 17 +- .../CRM/Member/BAO/MembershipTypeTest.php | 4 +- .../CRM/Member/Form/MembershipTest.php | 124 +++--- .../Member/Import/Parser/MembershipTest.php | 11 +- tests/phpunit/CRM/PCP/BAO/PCPTest.php | 16 +- .../CRM/Pledge/BAO/PledgePaymentTest.php | 24 +- tests/phpunit/CRM/Pledge/BAO/PledgeTest.php | 4 +- tests/phpunit/CRM/Queue/Queue/SqlTest.php | 19 +- tests/phpunit/CRM/Queue/QueueTest.php | 58 +-- tests/phpunit/CRM/Queue/RunnerTest.php | 156 ++++---- .../phpunit/CRM/Utils/API/MatchOptionTest.php | 21 +- .../CRM/Utils/API/ReloadOptionTest.php | 1 + .../phpunit/CRM/Utils/DeprecatedUtilsTest.php | 55 +-- tests/phpunit/CRM/Utils/MailTest.php | 2 +- .../phpunit/CRM/Utils/QueryFormatterTest.php | 147 ++++++- tests/phpunit/CRM/Utils/SQL/InsertTest.php | 12 +- tests/phpunit/CRM/Utils/SQL/SelectTest.php | 14 +- tests/phpunit/Civi/API/KernelTest.php | 3 +- tests/phpunit/Civi/API/RequestTest.php | 16 +- .../Subscriber/DynamicFKAuthorizationTest.php | 14 +- .../Subscriber/TransactionSubscriberTest.php | 40 +- tests/phpunit/CiviTest/CiviDBAssert.php | 2 +- tests/phpunit/CiviTest/CiviMailUtils.php | 3 +- tests/phpunit/CiviTest/CiviReportTestCase.php | 2 +- .../phpunit/CiviTest/CiviSeleniumTestCase.php | 20 +- tests/phpunit/CiviTest/CiviUnitTestCase.php | 68 ++-- tests/phpunit/CiviTest/bootstrap.php | 8 +- .../CiviTest/civicrm.settings.dist.php | 27 +- tests/phpunit/Utils.php | 70 ++-- .../Admin/Form/Setting/LocalizationTest.php | 2 +- .../WebTest/Admin/MoveCustomDataTest.php | 44 +- .../WebTest/Case/ActivityToCaseTest.php | 15 +- tests/phpunit/WebTest/Case/AddCaseTest.php | 14 +- .../phpunit/WebTest/Case/AddCaseTypeTest.php | 9 +- .../WebTest/Case/CaseCustomFieldsTest.php | 33 +- .../WebTest/Case/CaseDashboardTest.php | 7 +- .../WebTest/Contact/AdvanceSearchPaneTest.php | 377 +++++++++--------- .../WebTest/Contact/AdvancedSearchTest.php | 15 +- .../AdvancedSearchedRelatedContactTest.php | 8 +- .../WebTest/Contact/CustomDataAddTest.php | 8 +- .../WebTest/Contact/DupeContactTest.php | 2 +- .../WebTest/Contact/EditContactTest.php | 2 +- .../phpunit/WebTest/Contact/GroupAddTest.php | 4 +- .../WebTest/Contact/InlineFieldsEditTest.php | 2 +- .../WebTest/Contact/MergeContactsTest.php | 3 +- .../WebTest/Contact/ProfileChecksumTest.php | 7 +- .../WebTest/Contribute/AddBatchesTest.php | 3 +- .../Contribute/OfflineContributionTest.php | 2 +- .../OfflineRecurContributionTest.php | 6 +- .../Contribute/OnBehalfOfOrganization.php | 13 +- .../Contribute/OnlineContributionTest.php | 2 +- .../OnlineMultiplePaymentProcessorTest.php | 4 +- .../OnlineRecurContributionTest.php | 2 +- .../UpdateBatchPendingContributionTest.php | 2 +- .../Contribute/UpdateContributionTest.php | 30 +- tests/phpunit/WebTest/Event/AddEventTest.php | 2 +- .../WebTest/Event/AddParticipationTest.php | 34 +- .../phpunit/WebTest/Event/AddPricesetTest.php | 9 +- tests/phpunit/WebTest/Event/PCPAddTest.php | 7 +- .../Export/ExportCiviSeleniumTestCase.php | 6 +- .../Financial/FinancialAccountTest.php | 8 +- .../Financial/FinancialBatchExport.php | 2 +- .../WebTest/Grant/CustomFieldsetTest.php | 10 +- .../WebTest/Import/AddressImportTest.php | 24 +- .../WebTest/Import/AddressParsingTest.php | 4 +- .../WebTest/Import/ContactCustomDataTest.php | 2 +- .../WebTest/Import/ContactSubtypeTest.php | 12 +- tests/phpunit/WebTest/Import/ContactTest.php | 12 +- .../WebTest/Import/ContributionTest.php | 16 +- .../phpunit/WebTest/Import/CustomDataTest.php | 4 +- .../phpunit/WebTest/Import/DateFormatTest.php | 24 +- .../WebTest/Import/DuplicateMatchingTest.php | 12 +- tests/phpunit/WebTest/Import/GroupTest.php | 4 +- .../Import/ImportCiviSeleniumTestCase.php | 7 +- .../WebTest/Import/MatchExternalIdTest.php | 32 +- .../Import/MultipleRelationshipTest.php | 160 ++++---- .../WebTest/Import/ParticipantTest.php | 4 +- tests/phpunit/WebTest/Mailing/MailingTest.php | 145 ++++--- .../Member/BatchUpdateViaProfileTest.php | 10 +- .../Member/DefaultMembershipPricesetTest.php | 36 +- .../WebTest/Member/EditMembershipTest.php | 2 +- .../Member/FixedMembershipTypeTest.php | 50 ++- .../Member/InheritedMembershipTest.php | 11 +- .../Member/OfflineAutoRenewMembershipTest.php | 6 +- .../OfflineMembershipAddPricesetTest.php | 104 ++--- .../Member/OfflineMembershipRenewTest.php | 8 +- .../OnlineAutoRenewMembershipGCTest.php | 3 +- .../Member/OnlineAutoRenewMembershipTest.php | 3 +- .../OnlineMembershipAddPricesetTest.php | 52 +-- .../Member/SeperateMembershipPaymentTest.php | 12 +- .../WebTest/Member/StandaloneAddTest.php | 4 +- .../WebTest/Pledge/ContactContextAddTest.php | 4 +- .../ContactContextPledgePaymentAddTest.php | 12 +- tests/phpunit/WebTest/Profile/DedupeTest.php | 7 +- .../Profile/MultiRecordProfileAddTest.php | 7 +- .../WebTest/Profile/ProfileAddTest.php | 8 +- .../WebTest/Profile/ProfileCountryState.php | 6 +- .../WebTest/Report/LoggingReportTest.php | 88 +++- tests/phpunit/api/v3/ACLPermissionTest.php | 16 +- tests/phpunit/api/v3/APIStandardsTest.php | 1 - tests/phpunit/api/v3/APITest.php | 1 + tests/phpunit/api/v3/ActionScheduleTest.php | 6 +- tests/phpunit/api/v3/ActivityTest.php | 120 ++++-- tests/phpunit/api/v3/ActivityTypeTest.php | 1 - tests/phpunit/api/v3/AddressTest.php | 20 +- tests/phpunit/api/v3/AttachmentTest.php | 2 +- tests/phpunit/api/v3/CRM11793Test.php | 1 + tests/phpunit/api/v3/CaseTest.php | 20 +- tests/phpunit/api/v3/ContactTest.php | 114 +++--- tests/phpunit/api/v3/ContactTypeTest.php | 5 +- tests/phpunit/api/v3/ContributionPageTest.php | 38 +- .../phpunit/api/v3/ContributionRecurTest.php | 2 - tests/phpunit/api/v3/ContributionSoftTest.php | 8 +- tests/phpunit/api/v3/ContributionTest.php | 94 ++--- tests/phpunit/api/v3/CustomFieldTest.php | 37 +- tests/phpunit/api/v3/CustomGroupTest.php | 9 +- .../api/v3/CustomValueContactTypeTest.php | 29 +- tests/phpunit/api/v3/CustomValueTest.php | 65 +-- tests/phpunit/api/v3/DashboardContactTest.php | 1 - tests/phpunit/api/v3/DashboardTest.php | 1 - tests/phpunit/api/v3/EntityTagTest.php | 26 +- tests/phpunit/api/v3/EventTest.php | 85 ++-- tests/phpunit/api/v3/GrantTest.php | 25 +- tests/phpunit/api/v3/GroupContactTest.php | 15 +- tests/phpunit/api/v3/GroupNestingTest.php | 18 +- .../phpunit/api/v3/GroupOrganizationTest.php | 24 +- tests/phpunit/api/v3/GroupTest.php | 1 - tests/phpunit/api/v3/ImTest.php | 8 +- .../phpunit/api/v3/JobProcessMailingTest.php | 7 +- tests/phpunit/api/v3/JobTest.php | 28 +- tests/phpunit/api/v3/MailSettingsTest.php | 4 +- tests/phpunit/api/v3/MailingABTest.php | 30 +- tests/phpunit/api/v3/MailingTest.php | 91 ++++- .../phpunit/api/v3/MembershipPaymentTest.php | 2 +- tests/phpunit/api/v3/MembershipStatusTest.php | 6 +- tests/phpunit/api/v3/MembershipTypeTest.php | 24 +- tests/phpunit/api/v3/NoteTest.php | 21 +- tests/phpunit/api/v3/OptionGroupTest.php | 25 +- tests/phpunit/api/v3/OptionValueTest.php | 14 +- .../phpunit/api/v3/ParticipantPaymentTest.php | 94 +++-- tests/phpunit/api/v3/ParticipantTest.php | 70 ++-- .../api/v3/PaymentProcessorTypeTest.php | 23 +- tests/phpunit/api/v3/PledgePaymentTest.php | 7 +- tests/phpunit/api/v3/PledgeTest.php | 37 +- tests/phpunit/api/v3/PriceFieldTest.php | 10 +- tests/phpunit/api/v3/PriceFieldValueTest.php | 17 +- tests/phpunit/api/v3/PriceSetTest.php | 3 +- tests/phpunit/api/v3/ProductTest.php | 46 +-- tests/phpunit/api/v3/ProfileTest.php | 156 +++++--- tests/phpunit/api/v3/RelationshipTest.php | 8 +- tests/phpunit/api/v3/RelationshipTypeTest.php | 4 +- tests/phpunit/api/v3/ReportTemplateTest.php | 40 +- tests/phpunit/api/v3/SurveyTest.php | 13 +- .../phpunit/api/v3/SyntaxConformanceTest.php | 145 +++++-- tests/phpunit/api/v3/SystemTest.php | 6 +- tests/phpunit/api/v3/TagTest.php | 7 +- .../api/v3/TaxContributionPageTest.php | 9 +- tests/phpunit/api/v3/UFFieldTest.php | 1 + tests/phpunit/api/v3/UFGroupTest.php | 7 +- tests/phpunit/api/v3/UFJoinTest.php | 20 +- tests/phpunit/api/v3/UFMatchTest.php | 15 +- tests/phpunit/api/v3/UtilsTest.php | 31 +- tests/phpunit/api/v3/WebsiteTest.php | 15 +- .../phpunit/api/v3/settings/test.setting.php | 2 +- 218 files changed, 3566 insertions(+), 2399 deletions(-) diff --git a/tests/phpunit/CRM/Batch/Form/EntryTest.php b/tests/phpunit/CRM/Batch/Form/EntryTest.php index 734ce89f05..53c2d8d319 100644 --- a/tests/phpunit/CRM/Batch/Form/EntryTest.php +++ b/tests/phpunit/CRM/Batch/Form/EntryTest.php @@ -183,12 +183,13 @@ class CRM_Batch_Form_EntryTest extends CiviUnitTestCase { $this->assertEquals(2, $result['count']); foreach ($result['values'] as $contribution) { $this->assertEquals($this->callAPISuccess('line_item', 'getvalue', array( - 'contribution_id' => $contribution['id'], - 'return' => 'line_total', + 'contribution_id' => $contribution['id'], + 'return' => 'line_total', )), $contribution['total_amount']); } } + /** * Data provider for test process membership * @return array @@ -202,7 +203,7 @@ class CRM_Batch_Form_EntryTest extends CiviUnitTestCase { 1 => $this->_contactID, 2 => $this->_contactID2, 3 => $this->_contactID3, - ), + ), 'field' => array( 1 => array( 'membership_type' => array(0 => $this->_orgContactID, 1 => $this->_membershipTypeID), @@ -218,35 +219,35 @@ class CRM_Batch_Form_EntryTest extends CiviUnitTestCase { 'check_number' => NULL, 'contribution_status_id' => 1, ), - 2 => array( - 'membership_type' => array(0 => $this->_orgContactID, 1 => $this->_membershipTypeID), - 'join_date' => '07/03/2013', - 'membership_start_date' => '02/03/2013', - 'membership_end_date' => NULL, - 'membership_source' => NULL, - 'financial_type' => 2, - 'total_amount' => 1, - 'receive_date' => '07/17/2013', - 'receive_date_time' => NULL, - 'payment_instrument' => NULL, - 'check_number' => NULL, - 'contribution_status_id' => 1, - ), + 2 => array( + 'membership_type' => array(0 => $this->_orgContactID, 1 => $this->_membershipTypeID), + 'join_date' => '07/03/2013', + 'membership_start_date' => '02/03/2013', + 'membership_end_date' => NULL, + 'membership_source' => NULL, + 'financial_type' => 2, + 'total_amount' => 1, + 'receive_date' => '07/17/2013', + 'receive_date_time' => NULL, + 'payment_instrument' => NULL, + 'check_number' => NULL, + 'contribution_status_id' => 1, + ), // no join date, coded end date - 3 => array( - 'membership_type' => array(0 => $this->_orgContactID, 1 => $this->_membershipTypeID), - 'join_date' => NULL, - 'membership_start_date' => NULL, - 'membership_end_date' => '2013-12-01', - 'membership_source' => NULL, - 'financial_type' => 2, - 'total_amount' => 1, - 'receive_date' => '07/17/2013', - 'receive_date_time' => NULL, - 'payment_instrument' => NULL, - 'check_number' => NULL, - 'contribution_status_id' => 1, - ), + 3 => array( + 'membership_type' => array(0 => $this->_orgContactID, 1 => $this->_membershipTypeID), + 'join_date' => NULL, + 'membership_start_date' => NULL, + 'membership_end_date' => '2013-12-01', + 'membership_source' => NULL, + 'financial_type' => 2, + 'total_amount' => 1, + 'receive_date' => '07/17/2013', + 'receive_date_time' => NULL, + 'payment_instrument' => NULL, + 'check_number' => NULL, + 'contribution_status_id' => 1, + ), ), 'actualBatchTotal' => 0, diff --git a/tests/phpunit/CRM/Bridge/OG/DrupalTest.php b/tests/phpunit/CRM/Bridge/OG/DrupalTest.php index e2125f7263..09f083bd1b 100644 --- a/tests/phpunit/CRM/Bridge/OG/DrupalTest.php +++ b/tests/phpunit/CRM/Bridge/OG/DrupalTest.php @@ -45,9 +45,9 @@ class CRM_Bridge_OG_DrupalTest extends CiviUnitTestCase { */ public function testACLRoleDeleteFunctionality() { $optionGroup = civicrm_api('OptionGroup', 'Get', array( - 'version' => 3, - 'name' => 'acl_role', - 'api.OptionValue.Create' => + 'version' => 3, + 'name' => 'acl_role', + 'api.OptionValue.Create' => array( array( 'label' => 'OG', @@ -60,7 +60,7 @@ class CRM_Bridge_OG_DrupalTest extends CiviUnitTestCase { 'description' => 'OG Sync Group ACL :1969:', ), ), - )); + )); $getOptionGroupParams = array('version' => 3, 'option_group_id' => $optionGroup['id']); $originalCount = civicrm_api('OptionValue', 'GetCount', $getOptionGroupParams); $params = array('source' => 'OG Sync Group ACL :1969:'); diff --git a/tests/phpunit/CRM/Contact/BAO/ContactTest.php b/tests/phpunit/CRM/Contact/BAO/ContactTest.php index 3667e4df71..192482f65c 100644 --- a/tests/phpunit/CRM/Contact/BAO/ContactTest.php +++ b/tests/phpunit/CRM/Contact/BAO/ContactTest.php @@ -30,8 +30,8 @@ class CRM_Contact_BAO_ContactTest extends CiviUnitTestCase { */ public function testAddWithNames() { $firstName = 'Shane'; - $lastName = 'Whatson'; - $params = array( + $lastName = 'Whatson'; + $params = array( 'first_name' => $firstName, 'last_name' => $lastName, 'contact_type' => 'Individual', @@ -221,8 +221,8 @@ class CRM_Contact_BAO_ContactTest extends CiviUnitTestCase { */ public function testAddWithAllContactTypes() { $firstName = 'Bill'; - $lastName = 'Adams'; - $params = array( + $lastName = 'Adams'; + $params = array( 'first_name' => $firstName, 'last_name' => $lastName, 'contact_type' => 'Individual', @@ -332,7 +332,7 @@ class CRM_Contact_BAO_ContactTest extends CiviUnitTestCase { 'is_primary' => 1, ); $compareParams = array( - 'street_address' => CRM_Utils_Array::value('street_address', $params['address'][1]), + 'street_address' => CRM_Utils_Array::value('street_address', $params['address'][1]), 'supplemental_address_1' => CRM_Utils_Array::value('supplemental_address_1', $params['address'][1] ), @@ -360,7 +360,7 @@ class CRM_Contact_BAO_ContactTest extends CiviUnitTestCase { //Now check DB for IM $compareParams = array( - 'name' => CRM_Utils_Array::value('name', $params['im'][1]), + 'name' => CRM_Utils_Array::value('name', $params['im'][1]), 'provider_id' => CRM_Utils_Array::value('provider_id', $params['im'][1]), ); $this->assertDBCompareValues('CRM_Core_DAO_IM', $searchParams, $compareParams); @@ -561,8 +561,8 @@ class CRM_Contact_BAO_ContactTest extends CiviUnitTestCase { CRM_Contact_BAO_Contact_Utils::createCurrentEmployerRelationship($contactId, $orgContact->id); //retrieve the contact values from database. - $values = array(); - $searchParams = array('contact_id' => $contactId); + $values = array(); + $searchParams = array('contact_id' => $contactId); $retrieveContact = CRM_Contact_BAO_Contact::retrieve($searchParams, $values); //Now check $retrieveContact is object of contact DAO.. @@ -823,7 +823,7 @@ class CRM_Contact_BAO_ContactTest extends CiviUnitTestCase { ); $dbPrefComm = explode(CRM_Core_DAO::VALUE_SEPARATOR, - CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $contactId, 'preferred_communication_method', 'id', TRUE) + CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $contactId, 'preferred_communication_method', 'id', TRUE) ); $checkPrefComm = array(); foreach ($dbPrefComm as $key => $value) { @@ -840,7 +840,7 @@ class CRM_Contact_BAO_ContactTest extends CiviUnitTestCase { 'is_primary' => 1, ); $compareParams = array( - 'street_address' => CRM_Utils_Array::value('street_address-Primary', $profileParams), + 'street_address' => CRM_Utils_Array::value('street_address-Primary', $profileParams), 'supplemental_address_1' => CRM_Utils_Array::value('supplemental_address_1-Primary', $profileParams), 'supplemental_address_2' => CRM_Utils_Array::value('supplemental_address_2-Primary', $profileParams), 'city' => CRM_Utils_Array::value('city-Primary', $profileParams), @@ -858,7 +858,7 @@ class CRM_Contact_BAO_ContactTest extends CiviUnitTestCase { //Now check DB for IM $compareParams = array( - 'name' => CRM_Utils_Array::value('im-Primary', $profileParams), + 'name' => CRM_Utils_Array::value('im-Primary', $profileParams), 'provider_id' => CRM_Utils_Array::value('im-Primary-provider_id', $profileParams), ); $this->assertDBCompareValues('CRM_Core_DAO_IM', $searchParams, $compareParams); @@ -883,7 +883,7 @@ class CRM_Contact_BAO_ContactTest extends CiviUnitTestCase { $this->assertDBCompareValues('CRM_Core_DAO_Phone', $searchParams, $compareParams); //get the value of relationship - $values = array(); + $values = array(); $searchParams = array('contact_id' => $contactId); $relationship = CRM_Contact_BAO_Relationship::getValues($searchParams, $values); //Now check values of Relationship Count. @@ -1027,7 +1027,7 @@ class CRM_Contact_BAO_ContactTest extends CiviUnitTestCase { ); $dbPrefComm = explode(CRM_Core_DAO::VALUE_SEPARATOR, - CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $contactId, 'preferred_communication_method', 'id', TRUE) + CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $contactId, 'preferred_communication_method', 'id', TRUE) ); $checkPrefComm = array(); foreach ($dbPrefComm as $key => $value) { @@ -1044,7 +1044,7 @@ class CRM_Contact_BAO_ContactTest extends CiviUnitTestCase { 'is_primary' => 1, ); $compareParams = array( - 'street_address' => CRM_Utils_Array::value('street_address-Primary', $updatePfParams), + 'street_address' => CRM_Utils_Array::value('street_address-Primary', $updatePfParams), 'supplemental_address_1' => CRM_Utils_Array::value('supplemental_address_1-Primary', $updatePfParams), 'supplemental_address_2' => CRM_Utils_Array::value('supplemental_address_2-Primary', $updatePfParams), 'city' => CRM_Utils_Array::value('city-Primary', $updatePfParams), @@ -1062,7 +1062,7 @@ class CRM_Contact_BAO_ContactTest extends CiviUnitTestCase { //Now check DB for IM $compareParams = array( - 'name' => CRM_Utils_Array::value('im-Primary', $updatePfParams), + 'name' => CRM_Utils_Array::value('im-Primary', $updatePfParams), 'provider_id' => CRM_Utils_Array::value('im-Primary-provider_id', $updatePfParams), ); $this->assertDBCompareValues('CRM_Core_DAO_IM', $searchParams, $compareParams); @@ -1086,7 +1086,7 @@ class CRM_Contact_BAO_ContactTest extends CiviUnitTestCase { $this->assertDBCompareValues('CRM_Core_DAO_Phone', $searchParams, $compareParams); //get the value of relationship - $values = array(); + $values = array(); $searchParams = array('contact_id' => $contactId); $relationship = CRM_Contact_BAO_Relationship::getValues($searchParams, $values); //Now check values of Relationship Count. @@ -1427,15 +1427,15 @@ class CRM_Contact_BAO_ContactTest extends CiviUnitTestCase { public function testTimestamps_contact() { $test = $this; $this->_testTimestamps(array( - 'UPDATE' => function ($contactId) use ($test) { - $params = array( + 'UPDATE' => function ($contactId) use ($test) { + $params = array( 'first_name' => 'Testing', 'contact_type' => 'Individual', 'contact_id' => $contactId, ); - $contact = CRM_Contact_BAO_Contact::add($params); - $test->assertInstanceOf('CRM_Contact_DAO_Contact', $contact, 'Check for created object'); - }, + $contact = CRM_Contact_BAO_Contact::add($params); + $test->assertInstanceOf('CRM_Contact_DAO_Contact', $contact, 'Check for created object'); + }, )); } @@ -1445,33 +1445,31 @@ class CRM_Contact_BAO_ContactTest extends CiviUnitTestCase { public function testTimestamps_email() { $test = $this; $this->_testTimestamps(array( - 'INSERT' => function ($contactId) use ($test) { - $params = array( + 'INSERT' => function ($contactId) use ($test) { + $params = array( 'email' => 'ex-1@example.com', 'is_primary' => 1, 'location_type_id' => 1, 'contact_id' => $contactId, ); - CRM_Core_BAO_Email::add($params); - $test->assertDBQuery('ex-1@example.com', + CRM_Core_BAO_Email::add($params); + $test->assertDBQuery('ex-1@example.com', 'SELECT email FROM civicrm_email WHERE contact_id = %1 ORDER BY id DESC LIMIT 1', array(1 => array($contactId, 'Integer')) ); - }, - - 'UPDATE' => function ($contactId) use ($test) { - CRM_Core_DAO::executeQuery( + }, + 'UPDATE' => function ($contactId) use ($test) { + CRM_Core_DAO::executeQuery( 'UPDATE civicrm_email SET email = "ex-2@example.com" WHERE contact_id = %1', array(1 => array($contactId, 'Integer')) ); - }, - - 'DELETE' => function ($contactId) use ($test) { - CRM_Core_DAO::executeQuery( + }, + 'DELETE' => function ($contactId) use ($test) { + CRM_Core_DAO::executeQuery( 'DELETE FROM civicrm_email WHERE contact_id = %1', array(1 => array($contactId, 'Integer')) ); - }, + }, )); } @@ -1481,33 +1479,31 @@ class CRM_Contact_BAO_ContactTest extends CiviUnitTestCase { public function testTimestamps_phone() { $test = $this; $this->_testTimestamps(array( - 'INSERT' => function ($contactId) use ($test) { - $params = array( + 'INSERT' => function ($contactId) use ($test) { + $params = array( 'phone' => '202-555-1000', 'is_primary' => 1, 'location_type_id' => 1, 'contact_id' => $contactId, ); - CRM_Core_BAO_Phone::add($params); - $test->assertDBQuery('202-555-1000', + CRM_Core_BAO_Phone::add($params); + $test->assertDBQuery('202-555-1000', 'SELECT phone FROM civicrm_phone WHERE contact_id = %1 ORDER BY id DESC LIMIT 1', array(1 => array($contactId, 'Integer')) ); - }, - - 'UPDATE' => function ($contactId) use ($test) { - CRM_Core_DAO::executeQuery( + }, + 'UPDATE' => function ($contactId) use ($test) { + CRM_Core_DAO::executeQuery( 'UPDATE civicrm_phone SET phone = "202-555-2000" WHERE contact_id = %1', array(1 => array($contactId, 'Integer')) ); - }, - - 'DELETE' => function ($contactId) use ($test) { - CRM_Core_DAO::executeQuery( + }, + 'DELETE' => function ($contactId) use ($test) { + CRM_Core_DAO::executeQuery( 'DELETE FROM civicrm_phone WHERE contact_id = %1', array(1 => array($contactId, 'Integer')) ); - }, + }, )); } @@ -1527,24 +1523,24 @@ class CRM_Contact_BAO_ContactTest extends CiviUnitTestCase { $customField = $customField['values'][$customField['id']]; $test = $this; $this->_testTimestamps(array( - 'INSERT' => function ($contactId) use ($test, $customGroup, $customField) { - $result = civicrm_api3('contact', 'create', array( + 'INSERT' => function ($contactId) use ($test, $customGroup, $customField) { + $result = civicrm_api3('contact', 'create', array( 'contact_id' => $contactId, 'custom_' . $customField['id'] => 'test-1', )); - }, - 'UPDATE' => function ($contactId) use ($test, $customGroup, $customField) { - CRM_Core_DAO::executeQuery( + }, + 'UPDATE' => function ($contactId) use ($test, $customGroup, $customField) { + CRM_Core_DAO::executeQuery( "UPDATE {$customGroup->table_name} SET {$customField['column_name']} = 'test-2' WHERE entity_id = %1", array(1 => array($contactId, 'Integer')) ); - }, - 'DELETE' => function ($contactId) use ($test, $customGroup, $customField) { - CRM_Core_DAO::executeQuery( + }, + 'DELETE' => function ($contactId) use ($test, $customGroup, $customField) { + CRM_Core_DAO::executeQuery( "DELETE FROM {$customGroup->table_name} WHERE entity_id = %1", array(1 => array($contactId, 'Integer')) ); - }, + }, )); Custom::deleteGroup($customGroup); diff --git a/tests/phpunit/CRM/Contact/BAO/ContactType/ContactSearchTest.php b/tests/phpunit/CRM/Contact/BAO/ContactType/ContactSearchTest.php index 603e07c416..3e795f6a07 100644 --- a/tests/phpunit/CRM/Contact/BAO/ContactType/ContactSearchTest.php +++ b/tests/phpunit/CRM/Contact/BAO/ContactType/ContactSearchTest.php @@ -92,12 +92,12 @@ class CRM_Contact_BAO_ContactType_ContactSearchTest extends CiviUnitTestCase { public function testSearchWithType() { // for type:Individual - $params = array('contact_type' => 'Individual', 'version' => 3); - $result = civicrm_api('contact', 'get', $params); + $params = array('contact_type' => 'Individual', 'version' => 3); + $result = civicrm_api('contact', 'get', $params); - $individual = $result['values'][$this->individual]; + $individual = $result['values'][$this->individual]; $indiviStudent = $result['values'][$this->indiviStudent]; - $indiviParent = $result['values'][$this->indiviParent]; + $indiviParent = $result['values'][$this->indiviParent]; //asserts for type:Individual $this->assertEquals($individual['contact_id'], $this->individual, 'In line ' . __LINE__); @@ -156,8 +156,8 @@ class CRM_Contact_BAO_ContactType_ContactSearchTest extends CiviUnitTestCase { public function testSearchWithSubype() { // for subtype:Student - $params = array('contact_sub_type' => $this->student, 'version' => 3); - $result = civicrm_api('contact', 'get', $params); + $params = array('contact_sub_type' => $this->student, 'version' => 3); + $result = civicrm_api('contact', 'get', $params); $indiviStudent = $result['values'][$this->indiviStudent]; @@ -203,8 +203,8 @@ 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); - $result = civicrm_api('contact', 'get', $params); + $params = array('contact_sub_type' => $this->student, 'version' => 3); + $result = civicrm_api('contact', 'get', $params); $indiviStudent = $result['values'][$this->indiviStudent]; @@ -248,8 +248,8 @@ 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); - $result = civicrm_api('contact', 'get', $params); + $params = array('contact_type' => 'Invalid' . CRM_Core_DAO::VALUE_SEPARATOR . 'Invalid', 'version' => 3); + $result = civicrm_api('contact', 'get', $params); $this->assertEquals(empty($result['values']), TRUE, 'In line ' . __LINE__); // for invalid subtype @@ -280,8 +280,8 @@ class CRM_Contact_BAO_ContactType_ContactSearchTest extends CiviUnitTestCase { // for type:Individual subtype:Sponsor $defaults = array(); - $params = array('contact_type' => 'Individual' . CRM_Core_DAO::VALUE_SEPARATOR . $this->sponsor, 'version' => 3); - $result = civicrm_api('contact', 'get', $params); + $params = array('contact_type' => 'Individual' . CRM_Core_DAO::VALUE_SEPARATOR . $this->sponsor, 'version' => 3); + $result = civicrm_api('contact', 'get', $params); $this->assertEquals(empty($result['values']), TRUE, 'In line ' . __LINE__); // for type:Orgaization subtype:Parent diff --git a/tests/phpunit/CRM/Contact/BAO/ContactType/ContactTest.php b/tests/phpunit/CRM/Contact/BAO/ContactType/ContactTest.php index 5e8ad5619e..e9ea6a4fdc 100644 --- a/tests/phpunit/CRM/Contact/BAO/ContactType/ContactTest.php +++ b/tests/phpunit/CRM/Contact/BAO/ContactType/ContactTest.php @@ -72,7 +72,8 @@ DELETE FROM civicrm_contact_type try { $contact = CRM_Contact_BAO_Contact::add($params); } - catch(Exception$expected) {} + catch (Exception$expected) { + } $this->assertEquals($contact->first_name, 'Anne', 'In line ' . __LINE__); $this->assertEquals($contact->contact_type, 'Individual', 'In line ' . __LINE__); CRM_Contact_BAO_Contact::deleteContact($contact->id); @@ -85,7 +86,8 @@ DELETE FROM civicrm_contact_type try { $contact = CRM_Contact_BAO_Contact::add($params); } - catch(Exception$expected) {} + catch (Exception$expected) { + } $this->assertEquals($contact->organization_name, 'Compumentor', 'In line ' . __LINE__); $this->assertEquals($contact->contact_type, 'Organization', 'In line ' . __LINE__); CRM_Contact_BAO_Contact::deleteContact($contact->id); @@ -98,7 +100,8 @@ DELETE FROM civicrm_contact_type try { $contact = CRM_Contact_BAO_Contact::add($params); } - catch(Exception$expected) {} + catch (Exception$expected) { + } $this->assertEquals($contact->household_name, 'John Does home', 'In line ' . __LINE__); $this->assertEquals($contact->contact_type, 'Household', 'In line ' . __LINE__); CRM_Contact_BAO_Contact::deleteContact($contact->id); @@ -113,7 +116,8 @@ DELETE FROM civicrm_contact_type try { $contact = CRM_Contact_BAO_Contact::add($params); } - catch(Exception$expected) {} + catch (Exception$expected) { + } $this->assertEquals($contact->first_name, 'Bill', 'In line ' . __LINE__); $this->assertEquals($contact->contact_type, 'Individual', 'In line ' . __LINE__); $this->assertEquals(str_replace(CRM_Core_DAO::VALUE_SEPARATOR, '', $contact->contact_sub_type), $this->student, 'In line ' . __LINE__); @@ -128,7 +132,8 @@ DELETE FROM civicrm_contact_type try { $contact = CRM_Contact_BAO_Contact::add($params); } - catch(Exception$expected) {} + catch (Exception$expected) { + } $this->assertEquals($contact->organization_name, 'Conservation Corp', 'In line ' . __LINE__); $this->assertEquals($contact->contact_type, 'Organization', 'In line ' . __LINE__); $this->assertEquals(str_replace(CRM_Core_DAO::VALUE_SEPARATOR, '', $contact->contact_sub_type), $this->sponsor, 'In line ' . __LINE__); @@ -148,7 +153,8 @@ DELETE FROM civicrm_contact_type try { $contact = CRM_Contact_BAO_Contact::add($params); } - catch(Exception$expected) {} + catch (Exception$expected) { + } $updateParams = array( 'contact_sub_type' => $this->student, 'contact_type' => 'Individual', @@ -157,7 +163,8 @@ DELETE FROM civicrm_contact_type try { $updatedContact = CRM_Contact_BAO_Contact::add($updateParams); } - catch(Exception$expected) {} + catch (Exception$expected) { + } $this->assertEquals($updatedContact->id, $contact->id, 'In line ' . __LINE__); $this->assertEquals($updatedContact->contact_type, 'Individual', 'In line ' . __LINE__); $this->assertEquals(str_replace(CRM_Core_DAO::VALUE_SEPARATOR, '', $updatedContact->contact_sub_type), $this->student, 'In line ' . __LINE__); @@ -170,7 +177,8 @@ DELETE FROM civicrm_contact_type try { $contact = CRM_Contact_BAO_Contact::add($params); } - catch(Exception$expected) {} + catch (Exception$expected) { + } $updateParams = array( 'contact_sub_type' => $this->sponsor, @@ -180,7 +188,8 @@ DELETE FROM civicrm_contact_type try { $updatedContact = CRM_Contact_BAO_Contact::add($updateParams); } - catch(Exception$expected) {} + catch (Exception$expected) { + } $this->assertEquals($updatedContact->id, $contact->id, 'In line ' . __LINE__); $this->assertEquals($updatedContact->contact_type, 'Organization', 'In line ' . __LINE__); $this->assertEquals(str_replace(CRM_Core_DAO::VALUE_SEPARATOR, '', $updatedContact->contact_sub_type), $this->sponsor, 'In line ' . __LINE__); @@ -201,7 +210,8 @@ DELETE FROM civicrm_contact_type try { $contact = CRM_Contact_BAO_Contact::add($params); } - catch(Exception$expected) {} + catch (Exception$expected) { + } $updateParams = array( 'contact_sub_type' => $this->parent, @@ -211,7 +221,8 @@ DELETE FROM civicrm_contact_type try { $updatedContact = CRM_Contact_BAO_Contact::add($updateParams); } - catch(Exception$expected) {} + catch (Exception$expected) { + } $this->assertEquals($updatedContact->id, $contact->id, 'In line ' . __LINE__); $this->assertEquals($updatedContact->contact_type, 'Individual', 'In line ' . __LINE__); $this->assertEquals(str_replace(CRM_Core_DAO::VALUE_SEPARATOR, '', $updatedContact->contact_sub_type), $this->parent, 'In line ' . __LINE__); @@ -225,7 +236,8 @@ DELETE FROM civicrm_contact_type try { $contact = CRM_Contact_BAO_Contact::add($params); } - catch(Exception$expected) {} + catch (Exception$expected) { + } $updateParams = array( 'contact_sub_type' => $this->team, @@ -235,7 +247,8 @@ DELETE FROM civicrm_contact_type try { $updatedContact = CRM_Contact_BAO_Contact::add($updateParams); } - catch(Exception$expected) {} + catch (Exception$expected) { + } $this->assertEquals($updatedContact->id, $contact->id, 'In line ' . __LINE__); $this->assertEquals($updatedContact->contact_type, 'Organization', 'In line ' . __LINE__); @@ -251,7 +264,8 @@ DELETE FROM civicrm_contact_type try { $contact = CRM_Contact_BAO_Contact::add($params); } - catch(Exception$expected) {} + catch (Exception$expected) { + } $updateParams = array( 'contact_sub_type' => NULL, @@ -261,7 +275,8 @@ DELETE FROM civicrm_contact_type try { $updatedContact = CRM_Contact_BAO_Contact::add($updateParams); } - catch(Exception$expected) {} + catch (Exception$expected) { + } $this->assertEquals($updatedContact->id, $contact->id, 'In line ' . __LINE__); $this->assertEquals($updatedContact->contact_type, 'Individual', 'In line ' . __LINE__); diff --git a/tests/phpunit/CRM/Contact/BAO/ContactType/RelationshipTest.php b/tests/phpunit/CRM/Contact/BAO/ContactType/RelationshipTest.php index 0b2c19607d..de1c994975 100644 --- a/tests/phpunit/CRM/Contact/BAO/ContactType/RelationshipTest.php +++ b/tests/phpunit/CRM/Contact/BAO/ContactType/RelationshipTest.php @@ -162,8 +162,8 @@ DELETE FROM civicrm_contact_type 'contact_sub_type_b' => $this->parent, ); $relTypeIds = array(); - $relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams, $relTypeIds); - $params = array( + $relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams, $relTypeIds); + $params = array( 'relationship_type_id' => $relType->id . '_a_b', 'contact_check' => array($this->indivi_student => 1), ); @@ -189,8 +189,8 @@ DELETE FROM civicrm_contact_type 'contact_type_b' => 'Individual', ); $relTypeIds = array(); - $relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams, $relTypeIds); - $params = array( + $relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams, $relTypeIds); + $params = array( 'relationship_type_id' => $relType->id . '_a_b', 'contact_check' => array($this->individual => 1), ); @@ -214,8 +214,8 @@ DELETE FROM civicrm_contact_type 'contact_sub_type_b' => 'Sponser', ); $relTypeIds = array(); - $relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams, $relTypeIds); - $params = array( + $relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams, $relTypeIds); + $params = array( 'relationship_type_id' => $relType->id . '_a_b', 'contact_check' => array($this->individual => 1), ); @@ -242,8 +242,8 @@ DELETE FROM civicrm_contact_type 'contact_sub_type_b' => $this->parent, ); $relTypeIds = array(); - $relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams, $relTypeIds); - $params = array( + $relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams, $relTypeIds); + $params = array( 'relationship_type_id' => $relType->id . '_a_b', 'is_active' => 1, 'contact_check' => array($this->indivi_parent => $this->indivi_parent), @@ -270,8 +270,8 @@ DELETE FROM civicrm_contact_type 'contact_type_b' => 'Individual', ); $relTypeIds = array(); - $relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams, $relTypeIds); - $params = array( + $relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams, $relTypeIds); + $params = array( 'relationship_type_id' => $relType->id . '_a_b', 'is_active' => 1, 'contact_check' => array($this->indivi_student => 1), @@ -295,8 +295,8 @@ DELETE FROM civicrm_contact_type 'contact_sub_type_b' => $this->sponsor, ); $relTypeIds = array(); - $relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams, $relTypeIds); - $params = array( + $relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams, $relTypeIds); + $params = array( 'relationship_type_id' => $relType->id . '_a_b', 'is_active' => 1, 'contact_check' => array($this->organization_sponsor => 1), diff --git a/tests/phpunit/CRM/Contact/BAO/GroupContactCacheTest.php b/tests/phpunit/CRM/Contact/BAO/GroupContactCacheTest.php index 10c28081e9..76561d3ede 100644 --- a/tests/phpunit/CRM/Contact/BAO/GroupContactCacheTest.php +++ b/tests/phpunit/CRM/Contact/BAO/GroupContactCacheTest.php @@ -86,7 +86,11 @@ class CRM_Contact_BAO_GroupContactCacheTest extends CiviUnitTestCase { $this->assertAPISuccess($result); CRM_Contact_BAO_GroupContactCache::load($group, TRUE); $this->assertCacheMatches( - array(/* deceased[0], */ $deceased[1]->id, $deceased[2]->id, $living[0]->id), + array(/* deceased[0], */ + $deceased[1]->id, + $deceased[2]->id, + $living[0]->id + ), $group->id ); } @@ -146,7 +150,10 @@ class CRM_Contact_BAO_GroupContactCacheTest extends CiviUnitTestCase { // Assert $c1 not in $parent CRM_Contact_BAO_GroupContactCache::load($parent, TRUE); $this->assertCacheMatches( - array(/* deceased[0], */ $deceased[1]->id, $deceased[2]->id), + array(/* deceased[0], */ + $deceased[1]->id, + $deceased[2]->id + ), $parent->id ); diff --git a/tests/phpunit/CRM/Contact/BAO/GroupContactTest.php b/tests/phpunit/CRM/Contact/BAO/GroupContactTest.php index 19a0ec7772..c76a9dafec 100644 --- a/tests/phpunit/CRM/Contact/BAO/GroupContactTest.php +++ b/tests/phpunit/CRM/Contact/BAO/GroupContactTest.php @@ -137,8 +137,8 @@ class CRM_Contact_BAO_GroupContactTest extends CiviUnitTestCase { 'group' => array($parentGroup->id => 1), 'version' => 3, ); - $result = civicrm_api('contact', 'get', $searchParams); - $validContactIds = array($parentContact, $childContact); + $result = civicrm_api('contact', 'get', $searchParams); + $validContactIds = array($parentContact, $childContact); $resultContactIds = array(); foreach ($result['values'] as $k => $v) { $resultContactIds[] = $v['contact_id']; diff --git a/tests/phpunit/CRM/Contact/BAO/GroupTest.php b/tests/phpunit/CRM/Contact/BAO/GroupTest.php index 9ebc6ab1b1..52021b4b4b 100644 --- a/tests/phpunit/CRM/Contact/BAO/GroupTest.php +++ b/tests/phpunit/CRM/Contact/BAO/GroupTest.php @@ -123,7 +123,6 @@ class CRM_Contact_BAO_GroupTest extends CiviUnitTestCase { * * SET @groupID = x; * SELECT mapping_id FROM civicrm_group g LEFT JOIN civicrm_saved_search s ON saved_search_id = s.id WHERE g.id = @groupID INTO @mappingID; - * SELECT * FROM civicrm_mapping WHERE id = @mappingID; * SELECT * FROM civicrm_mapping_field WHERE mapping_id = @mappingID; * SELECT * FROM civicrm_saved_search WHERE mapping_id = @mappingID; diff --git a/tests/phpunit/CRM/Contact/BAO/QueryTest.php b/tests/phpunit/CRM/Contact/BAO/QueryTest.php index e4fb4130fe..0e240b3500 100644 --- a/tests/phpunit/CRM/Contact/BAO/QueryTest.php +++ b/tests/phpunit/CRM/Contact/BAO/QueryTest.php @@ -43,13 +43,13 @@ class CRM_Contact_BAO_QueryTest extends CiviUnitTestCase { ); $params = CRM_Contact_BAO_Query::convertFormValues($fv); - $obj = new CRM_Contact_BAO_Query($params); + $obj = new CRM_Contact_BAO_Query($params); // let's set useGroupBy=true since we are listing contacts here who might belong to // more than one group / tag / notes etc. $obj->_useGroupBy = TRUE; - $dao = $obj->searchQuery(); + $dao = $obj->searchQuery(); $contacts = array(); while ($dao->fetch()) { @@ -68,7 +68,11 @@ class CRM_Contact_BAO_QueryTest extends CiviUnitTestCase { public function testSearchProfileHomeCityCRM14263() { $contactID = $this->individualCreate(); CRM_Core_Config::singleton()->defaultSearchProfileID = 1; - $this->callAPISuccess('address', 'create', array('contact_id' => $contactID, 'city' => 'Cool City', 'location_type_id' => 1)); + $this->callAPISuccess('address', 'create', array( + 'contact_id' => $contactID, + 'city' => 'Cool City', + 'location_type_id' => 1 + )); $params = array( 0 => array( 0 => 'city-1', @@ -106,7 +110,11 @@ class CRM_Contact_BAO_QueryTest extends CiviUnitTestCase { public function testSearchProfileHomeCityNoResultsCRM14263() { $contactID = $this->individualCreate(); CRM_Core_Config::singleton()->defaultSearchProfileID = 1; - $this->callAPISuccess('address', 'create', array('contact_id' => $contactID, 'city' => 'Cool City', 'location_type_id' => 1)); + $this->callAPISuccess('address', 'create', array( + 'contact_id' => $contactID, + 'city' => 'Cool City', + 'location_type_id' => 1 + )); $params = array( 0 => array( 0 => 'city-1', @@ -136,6 +144,7 @@ class CRM_Contact_BAO_QueryTest extends CiviUnitTestCase { } } + /** * CRM-14263 search builder failure with search profile & address in criteria * We are retrieving primary here - checking the actual sql seems super prescriptive - but since the massive query object has @@ -144,28 +153,32 @@ class CRM_Contact_BAO_QueryTest extends CiviUnitTestCase { public function testSearchProfilePrimaryCityCRM14263() { $contactID = $this->individualCreate(); CRM_Core_Config::singleton()->defaultSearchProfileID = 1; - $this->callAPISuccess('address', 'create', array('contact_id' => $contactID, 'city' => 'Cool City', 'location_type_id' => 1)); + $this->callAPISuccess('address', 'create', array( + 'contact_id' => $contactID, + 'city' => 'Cool City', + 'location_type_id' => 1 + )); $params = array( - 0 => array( - 0 => 'city', - 1 => '=', - 2 => 'Cool City', - 3 => 1, - 4 => 0, - ), - ); + 0 => array( + 0 => 'city', + 1 => '=', + 2 => 'Cool City', + 3 => 1, + 4 => 0, + ), + ); $returnProperties = array( - 'contact_type' => 1, - 'contact_sub_type' => 1, - 'sort_name' => 1, - ); + 'contact_type' => 1, + 'contact_sub_type' => 1, + 'sort_name' => 1, + ); $expectedSQL = "SELECT contact_a.id as contact_id, contact_a.contact_type as `contact_type`, contact_a.contact_sub_type as `contact_sub_type`, contact_a.sort_name as `sort_name`, civicrm_address.id as address_id, civicrm_address.city as `city` FROM civicrm_contact contact_a LEFT JOIN civicrm_address ON ( contact_a.id = civicrm_address.contact_id AND civicrm_address.is_primary = 1 ) WHERE ( ( LOWER(civicrm_address.city) = 'cool city' ) ) AND (contact_a.is_deleted = 0) ORDER BY contact_a.sort_name asc, contact_a.id "; $queryObj = new CRM_Contact_BAO_Query($params, $returnProperties); try { $this->assertEquals($expectedSQL, $queryObj->searchQuery(0, 0, NULL, - FALSE, FALSE, - FALSE, FALSE, - TRUE)); + FALSE, FALSE, + FALSE, FALSE, + TRUE)); } catch (PEAR_Exception $e) { $err = $e->getCause(); diff --git a/tests/phpunit/CRM/Contact/BAO/QueryTestDataProvider.php b/tests/phpunit/CRM/Contact/BAO/QueryTestDataProvider.php index 35062efcd9..d0defad3e9 100644 --- a/tests/phpunit/CRM/Contact/BAO/QueryTestDataProvider.php +++ b/tests/phpunit/CRM/Contact/BAO/QueryTestDataProvider.php @@ -53,51 +53,94 @@ class CRM_Contact_BAO_QueryTestDataProvider implements Iterator { array( 'fv' => array('group' => array('3' => 1)), 'id' => array( - '17', '18', '19', '20', '21', - '22', '23', '24', + '17', + '18', + '19', + '20', + '21', + '22', + '23', + '24', ), ), // Include static group 5 array( 'fv' => array('group' => array('5' => 1)), 'id' => array( - '13', '14', '15', '16', '21', - '22', '23', '24', + '13', + '14', + '15', + '16', + '21', + '22', + '23', + '24', ), ), // Include static groups 3 and 5 array( 'fv' => array('group' => array('3' => 1, '5' => 1)), 'id' => array( - '13', '14', '15', '16', '17', '18', - '19', '20', '21', '22', '23', '24', + '13', + '14', + '15', + '16', + '17', + '18', + '19', + '20', + '21', + '22', + '23', + '24', ), ), // Include tag 7 array( 'fv' => array('tag' => array('7' => 1)), 'id' => array( - '11', '12', '15', '16', - '19', '20', '23', '24', + '11', + '12', + '15', + '16', + '19', + '20', + '23', + '24', ), ), // Include tag 9 array( 'fv' => array('tag' => array('9' => 1)), 'id' => array( - '10', '12', '14', '16', - '18', '20', '22', '24', + '10', + '12', + '14', + '16', + '18', + '20', + '22', + '24', ), ), // Include tags 7 and 9 array( 'fv' => array('tag' => array('7' => 1, '9' => 1)), 'id' => array( - '10', '11', '12', '14', '15', '16', - '18', '19', '20', '22', '23', '24', + '10', + '11', + '12', + '14', + '15', + '16', + '18', + '19', + '20', + '22', + '23', + '24', ), ), - // gender_id 1 = 'Female' array( 'fv' => array('gender_id' => 1), @@ -128,8 +171,8 @@ class CRM_Contact_BAO_QueryTestDataProvider implements Iterator { */ public function current() { $count = count($this->dataset[$this->i]['id']); - $ids = $this->dataset[$this->i]['id']; - $full = array(); + $ids = $this->dataset[$this->i]['id']; + $full = array(); foreach ($this->dataset[$this->i]['id'] as $key => $value) { $full[] = array( 'contact_id' => $value, diff --git a/tests/phpunit/CRM/Contact/Form/Search/Custom/GroupTest.php b/tests/phpunit/CRM/Contact/Form/Search/Custom/GroupTest.php index 8736550248..e76b78e8cd 100644 --- a/tests/phpunit/CRM/Contact/Form/Search/Custom/GroupTest.php +++ b/tests/phpunit/CRM/Contact/Form/Search/Custom/GroupTest.php @@ -101,10 +101,10 @@ class CRM_Contact_Form_Search_Custom_GroupTest extends CiviUnitTestCase { $dao = CRM_Core_DAO::executeQuery($sql); /** - echo "Count: $count, OBJ: ", $obj->count( ) . "\n"; - while ( $dao->fetch( ) ) { - echo "{$dao->contact_id}, {$dao->contact_type}, {$dao->sort_name}, {$dao->group_names}\n"; - } + * echo "Count: $count, OBJ: ", $obj->count( ) . "\n"; + * while ( $dao->fetch( ) ) { + * echo "{$dao->contact_id}, {$dao->contact_type}, {$dao->sort_name}, {$dao->group_names}\n"; + * } **/ $this->assertEquals($count, $obj->count(), 'In line ' . __LINE__ @@ -176,8 +176,8 @@ class CRM_Contact_Form_Search_Custom_GroupTest extends CiviUnitTestCase { */ public function testColumns() { $formValues = array(); - $obj = new CRM_Contact_Form_Search_Custom_Group($formValues); - $columns = $obj->columns(); + $obj = new CRM_Contact_Form_Search_Custom_Group($formValues); + $columns = $obj->columns(); $this->assertTrue(is_array($columns), 'In line ' . __LINE__); foreach ($columns as $key => $value) { $this->assertTrue(is_string($key), 'In line ' . __LINE__); @@ -208,8 +208,8 @@ class CRM_Contact_Form_Search_Custom_GroupTest extends CiviUnitTestCase { */ public function testTemplateFile() { $formValues = array(); - $obj = new CRM_Contact_Form_Search_Custom_Group($formValues); - $fileName = $obj->templateFile(); + $obj = new CRM_Contact_Form_Search_Custom_Group($formValues); + $fileName = $obj->templateFile(); $this->assertTrue(is_string($fileName), 'In line ' . __LINE__); //FIXME: we would need to search the include path to do the following //$this->assertTrue( file_exists( $fileName ), 'In line ' . __LINE__ ); diff --git a/tests/phpunit/CRM/Contact/Form/Search/Custom/GroupTestDataProvider.php b/tests/phpunit/CRM/Contact/Form/Search/Custom/GroupTestDataProvider.php index 714202a947..26e99f6543 100644 --- a/tests/phpunit/CRM/Contact/Form/Search/Custom/GroupTestDataProvider.php +++ b/tests/phpunit/CRM/Contact/Form/Search/Custom/GroupTestDataProvider.php @@ -50,82 +50,146 @@ class CRM_Contact_Form_Search_Custom_GroupTestDataProvider implements Iterator { private $dataset = array( // Exclude static group 3 array( - 'fv' => array('excludeGroups' => array('3')), + 'fv' => array('excludeGroups' => array('3')), 'id' => array( - '9', '10', '11', '12', '13', '14', - '15', '16', '26', + '9', + '10', + '11', + '12', + '13', + '14', + '15', + '16', + '26', ), ), // Include static group 3 array( - 'fv' => array('includeGroups' => array('3')), + 'fv' => array('includeGroups' => array('3')), 'id' => array( - '17', '18', '19', '20', '21', - '22', '23', '24', '27', '28', + '17', + '18', + '19', + '20', + '21', + '22', + '23', + '24', + '27', + '28', ), ), // Include static group 5 array( - 'fv' => array('includeGroups' => array('5')), + 'fv' => array('includeGroups' => array('5')), 'id' => array( - '13', '14', '15', '16', '21', - '22', '23', '24', + '13', + '14', + '15', + '16', + '21', + '22', + '23', + '24', ), ), // Include static groups 3 and 5 array( - 'fv' => array('includeGroups' => array('3', '5')), + 'fv' => array('includeGroups' => array('3', '5')), 'id' => array( - '13', '14', '15', '16', '17', '18', - '19', '20', '21', '22', '23', '24', - '27', '28', + '13', + '14', + '15', + '16', + '17', + '18', + '19', + '20', + '21', + '22', + '23', + '24', + '27', + '28', ), ), // Include static group 3, exclude static group 5 array( - 'fv' => array( - 'includeGroups' => array('3'), + 'fv' => array( + 'includeGroups' => array('3'), 'excludeGroups' => array('5'), ), 'id' => array('17', '18', '19', '20', '27', '28'), ), // Exclude tag 7 array( - 'fv' => array('excludeTags' => array('7')), + 'fv' => array('excludeTags' => array('7')), 'id' => array( - '9', '10', '13', '14', '17', '18', - '21', '22', '27', + '9', + '10', + '13', + '14', + '17', + '18', + '21', + '22', + '27', ), ), // Include tag 7 array( - 'fv' => array('includeTags' => array('7')), + 'fv' => array('includeTags' => array('7')), 'id' => array( - '11', '12', '15', '16', '19', - '20', '23', '24', '26', '28', + '11', + '12', + '15', + '16', + '19', + '20', + '23', + '24', + '26', + '28', ), ), // Include tag 9 array( - 'fv' => array('includeTags' => array('9')), + 'fv' => array('includeTags' => array('9')), 'id' => array( - '10', '12', '14', '16', '18', - '20', '22', '24', + '10', + '12', + '14', + '16', + '18', + '20', + '22', + '24', ), ), // Include tags 7 and 9 array( - 'fv' => array('includeTags' => array('7', '9')), + 'fv' => array('includeTags' => array('7', '9')), 'id' => array( - '10', '11', '12', '14', '15', '16', - '18', '19', '20', '22', '23', '24', - '26', '28', + '10', + '11', + '12', + '14', + '15', + '16', + '18', + '19', + '20', + '22', + '23', + '24', + '26', + '28', ), ), // Include tag 7, exclude tag 9 array( - 'fv' => array( - 'includeTags' => array('7'), + 'fv' => array( + 'includeTags' => array('7'), 'excludeTags' => array('9'), ), 'id' => array('11', '15', '19', '23', '26', '28'), @@ -138,9 +202,21 @@ class CRM_Contact_Form_Search_Custom_GroupTestDataProvider implements Iterator { 'andOr' => 0, ), 'id' => array( - '11', '12', '15', '16', '17', '18', - '19', '20', '21', '22', '23', '24', - '26', '27', '28', + '11', + '12', + '15', + '16', + '17', + '18', + '19', + '20', + '21', + '22', + '23', + '24', + '26', + '27', + '28', ), ), // Include static group 3, include tag 7 (both) @@ -154,54 +230,85 @@ class CRM_Contact_Form_Search_Custom_GroupTestDataProvider implements Iterator { ), // Include static group 3, exclude tag 7 array( - 'fv' => array( - 'includeGroups' => array('3'), + 'fv' => array( + 'includeGroups' => array('3'), 'excludeTags' => array('7'), ), 'id' => array('17', '18', '21', '22', '27'), ), // Include tag 9, exclude static group 5 array( - 'fv' => array( - 'includeTags' => array('9'), + 'fv' => array( + 'includeTags' => array('9'), 'excludeGroups' => array('5'), ), 'id' => array('10', '12', '18', '20'), ), // Exclude tag 9, exclude static group 5 array( - 'fv' => array( - 'excludeTags' => array('9'), + 'fv' => array( + 'excludeTags' => array('9'), 'excludeGroups' => array('5'), ), 'id' => array( - '9', '11', '17', '19', - '26', '27', '28', + '9', + '11', + '17', + '19', + '26', + '27', + '28', ), ), // Include smart group 6 array( - 'fv' => array('includeGroups' => array('6')), + 'fv' => array('includeGroups' => array('6')), 'id' => array( - '9', '10', '11', '12', '13', '14', - '15', '16', '26', + '9', + '10', + '11', + '12', + '13', + '14', + '15', + '16', + '26', ), ), // Include smart group 4 array( - 'fv' => array('includeGroups' => array('4')), + 'fv' => array('includeGroups' => array('4')), 'id' => array( - '17', '18', '19', '20', '21', - '22', '23', '24', '27', '28', + '17', + '18', + '19', + '20', + '21', + '22', + '23', + '24', + '27', + '28', ), ), // Include smart group 4 and static group 5 array( - 'fv' => array('includeGroups' => array('4', '5')), + 'fv' => array('includeGroups' => array('4', '5')), 'id' => array( - '13', '14', '15', '16', '17', '18', - '19', '20', '21', '22', '23', '24', - '27', '28', + '13', + '14', + '15', + '16', + '17', + '18', + '19', + '20', + '21', + '22', + '23', + '24', + '27', + '28', ), ), ); @@ -219,8 +326,8 @@ class CRM_Contact_Form_Search_Custom_GroupTestDataProvider implements Iterator { */ public function current() { $count = count($this->dataset[$this->i]['id']); - $ids = $this->dataset[$this->i]['id']; - $full = array(); + $ids = $this->dataset[$this->i]['id']; + $full = array(); foreach ($this->dataset[$this->i]['id'] as $key => $value) { $full[] = array( 'contact_id' => $value, diff --git a/tests/phpunit/CRM/Contribute/BAO/ContributionPageTest.php b/tests/phpunit/CRM/Contribute/BAO/ContributionPageTest.php index f95bdc7385..2b150bab1f 100644 --- a/tests/phpunit/CRM/Contribute/BAO/ContributionPageTest.php +++ b/tests/phpunit/CRM/Contribute/BAO/ContributionPageTest.php @@ -88,9 +88,9 @@ class CRM_Contribute_BAO_ContributionPageTest extends CiviUnitTestCase { ); $contributionpage = CRM_Contribute_BAO_ContributionPage::create($params); - $id = $contributionpage->id; - $is_active = 1; - $pageActive = CRM_Contribute_BAO_ContributionPage::setIsActive($id, $is_active); + $id = $contributionpage->id; + $is_active = 1; + $pageActive = CRM_Contribute_BAO_ContributionPage::setIsActive($id, $is_active); $this->assertEquals($pageActive, TRUE, 'Verify financial types record deletion.'); ContributionPage::delete($contributionpage->id); } @@ -108,8 +108,8 @@ class CRM_Contribute_BAO_ContributionPageTest extends CiviUnitTestCase { $contributionpage = CRM_Contribute_BAO_ContributionPage::create($params); - $id = $contributionpage->id; - $values = array(); + $id = $contributionpage->id; + $values = array(); $setValues = CRM_Contribute_BAO_ContributionPage::setValues($id, $values); $this->assertEquals($params['title'], $values['title'], 'Verify contribution title.'); @@ -164,8 +164,8 @@ class CRM_Contribute_BAO_ContributionPageTest extends CiviUnitTestCase { ); $contributionpage = CRM_Contribute_BAO_ContributionPage::create($params); - $id = $contributionpage->id; - $checkRecurring = CRM_Contribute_BAO_ContributionPage::checkRecurPaymentProcessor($id); + $id = $contributionpage->id; + $checkRecurring = CRM_Contribute_BAO_ContributionPage::checkRecurPaymentProcessor($id); $this->assertEquals($checkRecurring, FALSE, 'Check for false return.'); ContributionPage::delete($contributionpage->id); } diff --git a/tests/phpunit/CRM/Contribute/BAO/ContributionRecurTest.php b/tests/phpunit/CRM/Contribute/BAO/ContributionRecurTest.php index 200a02cf94..5cfabc7b75 100644 --- a/tests/phpunit/CRM/Contribute/BAO/ContributionRecurTest.php +++ b/tests/phpunit/CRM/Contribute/BAO/ContributionRecurTest.php @@ -26,6 +26,7 @@ */ require_once 'CiviTest/CiviUnitTestCase.php'; + class CRM_Contribute_BAO_ContributionRecurTest extends CiviUnitTestCase { protected $_params = array(); diff --git a/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php b/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php index fdd1cd2feb..09861b3680 100644 --- a/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php +++ b/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php @@ -52,7 +52,7 @@ class CRM_Contribute_BAO_ContributionTest extends CiviUnitTestCase { $params = array( 'contact_id' => $contactId, 'currency' => 'USD', - 'financial_type_id' => 1, + 'financial_type_id' => 1, 'contribution_status_id' => 1, 'payment_instrument_id' => 1, 'source' => 'STUDENT', @@ -110,7 +110,7 @@ class CRM_Contribute_BAO_ContributionTest extends CiviUnitTestCase { $params = array( 'contact_id' => $contactId, 'currency' => 'USD', - 'financial_type_id' => 1, + 'financial_type_id' => 1, 'contribution_status_id' => 1, 'payment_instrument_id' => 1, 'source' => 'STUDENT', @@ -169,7 +169,7 @@ class CRM_Contribute_BAO_ContributionTest extends CiviUnitTestCase { $params = array( 'contact_id' => $contactId, 'currency' => 'USD', - 'financial_type_id' => 1, + 'financial_type_id' => 1, 'contribution_status_id' => 1, 'payment_instrument_id' => 1, 'source' => 'STUDENT', @@ -203,8 +203,8 @@ class CRM_Contribute_BAO_ContributionTest extends CiviUnitTestCase { */ public function testcreateAndGetHonorContact() { $firstName = 'John_' . substr(sha1(rand()), 0, 7); - $lastName = 'Smith_' . substr(sha1(rand()), 0, 7); - $email = "{$firstName}.{$lastName}@example.com"; + $lastName = 'Smith_' . substr(sha1(rand()), 0, 7); + $email = "{$firstName}.{$lastName}@example.com"; //Get profile id of name honoree_individual used to create profileContact $honoreeProfileId = NULL; @@ -223,8 +223,8 @@ class CRM_Contribute_BAO_ContributionTest extends CiviUnitTestCase { $softParam = array('soft_credit_type_id' => 1); $honoreeContactId = CRM_Contact_BAO_Contact::createProfileContact($params, CRM_Core_DAO::$_nullArray, - NULL, NULL, $honoreeProfileId - ); + NULL, NULL, $honoreeProfileId + ); $this->assertDBCompareValue('CRM_Contact_DAO_Contact', $honoreeContactId, 'first_name', 'id', $firstName, 'Database check for created honor contact record.' @@ -238,7 +238,7 @@ class CRM_Contribute_BAO_ContributionTest extends CiviUnitTestCase { $param = array( 'contact_id' => $contactId, 'currency' => 'USD', - 'financial_type_id' => 4, + 'financial_type_id' => 4, 'contribution_status_id' => 1, 'receive_date' => date('Ymd'), 'total_amount' => 66, @@ -306,7 +306,7 @@ class CRM_Contribute_BAO_ContributionTest extends CiviUnitTestCase { $param = array( 'contact_id' => $contactId, 'currency' => 'USD', - 'financial_type_id' => 1, + 'financial_type_id' => 1, 'contribution_status_id' => 1, 'payment_instrument_id' => 1, 'source' => 'STUDENT', @@ -369,7 +369,7 @@ class CRM_Contribute_BAO_ContributionTest extends CiviUnitTestCase { $param = array( 'contact_id' => $contactId, 'currency' => 'USD', - 'financial_type_id' => 1, + 'financial_type_id' => 1, 'contribution_status_id' => 1, 'payment_instrument_id' => 1, 'source' => 'STUDENT', @@ -425,7 +425,7 @@ class CRM_Contribute_BAO_ContributionTest extends CiviUnitTestCase { $param = array( 'contact_id' => $contactId, 'currency' => 'USD', - 'financial_type_id' => 1, + 'financial_type_id' => 1, 'contribution_status_id' => 1, 'payment_instrument_id' => 1, 'source' => 'STUDENT', diff --git a/tests/phpunit/CRM/Contribute/BAO/ContributionTypeTest.php b/tests/phpunit/CRM/Contribute/BAO/ContributionTypeTest.php index 84baf1f1eb..a881b5b552 100644 --- a/tests/phpunit/CRM/Contribute/BAO/ContributionTypeTest.php +++ b/tests/phpunit/CRM/Contribute/BAO/ContributionTypeTest.php @@ -88,9 +88,9 @@ class CRM_Contribute_BAO_ContributionTypeTest extends CiviUnitTestCase { 'is_deductible' => 0, 'is_active' => 1, ); - $ids = array(); + $ids = array(); $contributionType = CRM_Financial_BAO_FinancialType::add($params, $ids); - $result = CRM_Financial_BAO_FinancialType::setIsActive($contributionType->id, 0); + $result = CRM_Financial_BAO_FinancialType::setIsActive($contributionType->id, 0); $this->assertEquals($result, TRUE, 'Verify financial type record updation for is_active.'); $isActive = $this->assertDBNotNull('CRM_Financial_BAO_FinancialType', $contributionType->id, diff --git a/tests/phpunit/CRM/Contribute/BAO/ManagePremiumsTest.php b/tests/phpunit/CRM/Contribute/BAO/ManagePremiumsTest.php index 6916745d8e..b4c2c4135d 100644 --- a/tests/phpunit/CRM/Contribute/BAO/ManagePremiumsTest.php +++ b/tests/phpunit/CRM/Contribute/BAO/ManagePremiumsTest.php @@ -77,9 +77,9 @@ class CRM_Contribute_BAO_ManagePremiumsTest extends CiviUnitTestCase { ); $product = CRM_Contribute_BAO_ManagePremiums::add($params, $ids); - $params = array('id' => $product->id); + $params = array('id' => $product->id); $default = array(); - $result = CRM_Contribute_BAO_ManagePremiums::retrieve($params, $default); + $result = CRM_Contribute_BAO_ManagePremiums::retrieve($params, $default); $this->assertEquals(empty($result), FALSE, 'Verify products record.'); } @@ -128,9 +128,9 @@ class CRM_Contribute_BAO_ManagePremiumsTest extends CiviUnitTestCase { CRM_Contribute_BAO_ManagePremiums::del($product->id); - $params = array('id' => $product->id); + $params = array('id' => $product->id); $default = array(); - $result = CRM_Contribute_BAO_ManagePremiums::retrieve($params, $defaults); + $result = CRM_Contribute_BAO_ManagePremiums::retrieve($params, $defaults); $this->assertEquals(empty($result), TRUE, 'Verify product record deletion.'); } diff --git a/tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php b/tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php index e92a01a9f6..11cb0b0dd1 100644 --- a/tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php +++ b/tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php @@ -512,7 +512,7 @@ class CRM_Core_BAO_ActionScheduleTest extends CiviUnitTestCase { 'contact_id' => $membership->contact_id, 'email' => 'test-member@example.com', 'location_type_id' => 1, - )); + )); $this->assertAPISuccess($result); $this->callAPISuccess('contact', 'create', array_merge($this->fixtures['contact'], array('contact_id' => $membership->contact_id))); @@ -639,7 +639,7 @@ class CRM_Core_BAO_ActionScheduleTest extends CiviUnitTestCase { $this->callAPISuccess('Email', 'create', array( 'contact_id' => $membership->contact_id, 'email' => 'test-member@example.com', - )); + )); $this->callAPISuccess('contact', 'create', array_merge($this->fixtures['contact'], array('contact_id' => $membership->contact_id))); $actionSchedule = $this->fixtures['sched_membership_end_2week']; @@ -768,6 +768,7 @@ class CRM_Core_BAO_ActionScheduleTest extends CiviUnitTestCase { )); $this->callAPISuccess('custom_group', 'delete', array('id' => $createGroup['id'])); } + /** * Check that limit_to + an empty recipients doesn't sent to multiple contacts */ @@ -801,7 +802,6 @@ class CRM_Core_BAO_ActionScheduleTest extends CiviUnitTestCase { } - public function testContactCustomDate_Anniv() { $group = array( 'title' => 'Test_Group now', diff --git a/tests/phpunit/CRM/Core/BAO/AddressTest.php b/tests/phpunit/CRM/Core/BAO/AddressTest.php index 1884f7ea12..22a15fadab 100644 --- a/tests/phpunit/CRM/Core/BAO/AddressTest.php +++ b/tests/phpunit/CRM/Core/BAO/AddressTest.php @@ -290,8 +290,8 @@ class CRM_Core_BAO_AddressTest extends CiviUnitTestCase { $this->assertEquals($parsedStreetAddress['street_number_suffix'], 'A'); // valid Street address to be parsed ( $locale = 'en_US' ) - $street_address = "54A Excelsior Ave. Apt 1C"; - $locale = 'en_US'; + $street_address = "54A Excelsior Ave. Apt 1C"; + $locale = 'en_US'; $parsedStreetAddress = CRM_Core_BAO_Address::parseStreetAddress($street_address, $locale); $this->assertEquals($parsedStreetAddress['street_name'], 'Excelsior Ave.'); $this->assertEquals($parsedStreetAddress['street_unit'], 'Apt 1C'); @@ -299,8 +299,8 @@ class CRM_Core_BAO_AddressTest extends CiviUnitTestCase { $this->assertEquals($parsedStreetAddress['street_number_suffix'], 'A'); // invalid Street address ( $locale = 'en_US' ) - $street_address = "West St. Apt 1"; - $locale = 'en_US'; + $street_address = "West St. Apt 1"; + $locale = 'en_US'; $parsedStreetAddress = CRM_Core_BAO_Address::parseStreetAddress($street_address, $locale); $this->assertEquals($parsedStreetAddress['street_name'], 'West St.'); $this->assertEquals($parsedStreetAddress['street_unit'], 'Apt 1'); @@ -308,8 +308,8 @@ class CRM_Core_BAO_AddressTest extends CiviUnitTestCase { $this->assertNotContains('street_number_suffix', $parsedStreetAddress); // valid Street address to be parsed ( $locale = 'fr_CA' ) - $street_address = "2-123CA Main St"; - $locale = 'fr_CA'; + $street_address = "2-123CA Main St"; + $locale = 'fr_CA'; $parsedStreetAddress = CRM_Core_BAO_Address::parseStreetAddress($street_address, $locale); $this->assertEquals($parsedStreetAddress['street_name'], 'Main St'); $this->assertEquals($parsedStreetAddress['street_unit'], '2'); @@ -317,8 +317,8 @@ class CRM_Core_BAO_AddressTest extends CiviUnitTestCase { $this->assertEquals($parsedStreetAddress['street_number_suffix'], 'CA'); // invalid Street address ( $locale = 'fr_CA' ) - $street_address = "123 Main St"; - $locale = 'fr_CA'; + $street_address = "123 Main St"; + $locale = 'fr_CA'; $parsedStreetAddress = CRM_Core_BAO_Address::parseStreetAddress($street_address, $locale); $this->assertEquals($parsedStreetAddress['street_name'], 'Main St'); $this->assertEquals($parsedStreetAddress['street_number'], '123'); diff --git a/tests/phpunit/CRM/Core/BAO/CustomFieldTest.php b/tests/phpunit/CRM/Core/BAO/CustomFieldTest.php index 055401a2e5..b2529d2dcb 100644 --- a/tests/phpunit/CRM/Core/BAO/CustomFieldTest.php +++ b/tests/phpunit/CRM/Core/BAO/CustomFieldTest.php @@ -40,7 +40,7 @@ class CRM_Core_BAO_CustomFieldTest extends CiviUnitTestCase { $dbFieldName = $this->assertDBNotNull('CRM_Core_DAO_CustomField', $customFieldID, 'name', 'id', 'Database check for edited CustomField.'); $dbColumnName = $this->assertDBNotNull('CRM_Core_DAO_CustomField', $customFieldID, 'column_name', 'id', 'Database check for edited CustomField.'); $this->assertEquals(strtolower("{$dbFieldName}_{$customFieldID}"), $dbColumnName, - "Column name ends in ID"); + "Column name ends in ID"); Custom::deleteGroup($customGroup); } @@ -60,7 +60,7 @@ class CRM_Core_BAO_CustomFieldTest extends CiviUnitTestCase { ); $dbColumnName = $this->assertDBNotNull('CRM_Core_DAO_CustomField', $customFieldID, 'column_name', 'id', 'Database check for edited CustomField.'); $this->assertEquals($fields['column_name'], $dbColumnName, - "Column name set as specified"); + "Column name set as specified"); Custom::deleteGroup($customGroup); } @@ -172,63 +172,63 @@ class CRM_Core_BAO_CustomFieldTest extends CiviUnitTestCase { $this->assertTrue($countriesByName['Andorra'] > 0); $groups = array( 'A' => Custom::createGroup(array( - 'title' => 'Test_Group A', - 'name' => 'test_group_a', - 'extends' => array('Individual'), - 'style' => 'Inline', - 'is_multiple' => 0, - 'is_active' => 1, - 'version' => 3, - )), + 'title' => 'Test_Group A', + 'name' => 'test_group_a', + 'extends' => array('Individual'), + 'style' => 'Inline', + 'is_multiple' => 0, + 'is_active' => 1, + 'version' => 3, + )), 'B' => Custom::createGroup(array( - 'title' => 'Test_Group B', - 'name' => 'test_group_b', - 'extends' => array('Individual'), - 'style' => 'Inline', - 'is_multiple' => 0, - 'is_active' => 1, - 'version' => 3, - )), + 'title' => 'Test_Group B', + 'name' => 'test_group_b', + 'extends' => array('Individual'), + 'style' => 'Inline', + 'is_multiple' => 0, + 'is_active' => 1, + 'version' => 3, + )), ); $fields = array( 'countryA' => Custom::createField(array(), array( - 'groupId' => $groups['A']->id, - 'label' => 'Country A', - 'dataType' => 'Country', - 'htmlType' => 'Select Country', - )), + 'groupId' => $groups['A']->id, + 'label' => 'Country A', + 'dataType' => 'Country', + 'htmlType' => 'Select Country', + )), 'countryB' => Custom::createField(array(), array( - 'groupId' => $groups['A']->id, - 'label' => 'Country B', - 'dataType' => 'Country', - 'htmlType' => 'Select Country', - )), + 'groupId' => $groups['A']->id, + 'label' => 'Country B', + 'dataType' => 'Country', + 'htmlType' => 'Select Country', + )), 'countryC' => Custom::createField(array(), array( - 'groupId' => $groups['B']->id, - 'label' => 'Country C', - 'dataType' => 'Country', - 'htmlType' => 'Select Country', - )), + 'groupId' => $groups['B']->id, + 'label' => 'Country C', + 'dataType' => 'Country', + 'htmlType' => 'Select Country', + )), ); $contacts = array( 'alice' => Contact::createIndividual(array( - 'first_name' => 'Alice', - 'last_name' => 'Albertson', - 'custom_' . $fields['countryA']->id => $countriesByName['Andorra'], - 'custom_' . $fields['countryB']->id => $countriesByName['Barbados'], - )), + 'first_name' => 'Alice', + 'last_name' => 'Albertson', + 'custom_' . $fields['countryA']->id => $countriesByName['Andorra'], + 'custom_' . $fields['countryB']->id => $countriesByName['Barbados'], + )), 'bob' => Contact::createIndividual(array( - 'first_name' => 'Bob', - 'last_name' => 'Roberts', - 'custom_' . $fields['countryA']->id => $countriesByName['Austria'], - 'custom_' . $fields['countryB']->id => $countriesByName['Bermuda'], - 'custom_' . $fields['countryC']->id => $countriesByName['Chad'], - )), + 'first_name' => 'Bob', + 'last_name' => 'Roberts', + 'custom_' . $fields['countryA']->id => $countriesByName['Austria'], + 'custom_' . $fields['countryB']->id => $countriesByName['Bermuda'], + 'custom_' . $fields['countryC']->id => $countriesByName['Chad'], + )), 'carol' => Contact::createIndividual(array( - 'first_name' => 'Carol', - 'last_name' => 'Carolson', - 'custom_' . $fields['countryC']->id => $countriesByName['Cambodia'], - )), + 'first_name' => 'Carol', + 'last_name' => 'Carolson', + 'custom_' . $fields['countryC']->id => $countriesByName['Cambodia'], + )), ); // Move! @@ -240,7 +240,8 @@ class CRM_Core_BAO_CustomFieldTest extends CiviUnitTestCase { $this->assertDBQuery(1, "SELECT {$fields['countryB']->column_name} FROM {$groups['A']->table_name}"); $this->fail('Expected exception when querying column on wrong table'); } - catch(PEAR_Exception$e) {} + catch (PEAR_Exception$e) { + } $errorScope = NULL; // Alice: Group[B] has fields[countryB], but fields[countryC] did not exist before diff --git a/tests/phpunit/CRM/Core/BAO/CustomGroupTest.php b/tests/phpunit/CRM/Core/BAO/CustomGroupTest.php index a7a8fa572d..f5bfe1d297 100644 --- a/tests/phpunit/CRM/Core/BAO/CustomGroupTest.php +++ b/tests/phpunit/CRM/Core/BAO/CustomGroupTest.php @@ -26,7 +26,6 @@ */ - require_once 'CiviTest/CiviUnitTestCase.php'; require_once 'CiviTest/Contact.php'; require_once 'CiviTest/Custom.php'; @@ -44,10 +43,10 @@ class CRM_Core_BAO_CustomGroupTest extends CiviUnitTestCase { * Test getTree() */ public function testGetTree() { - $params = array(); - $contactId = Contact::createIndividual(); + $params = array(); + $contactId = Contact::createIndividual(); $customGrouptitle = 'My Custom Group'; - $groupParams = array( + $groupParams = array( 'title' => $customGrouptitle, 'name' => 'my_custom_group', 'style' => 'Tab', @@ -67,8 +66,8 @@ class CRM_Core_BAO_CustomGroupTest extends CiviUnitTestCase { ); $customField = Custom::createField($params, $fields); - $formParams = NULL; - $getTree = CRM_Core_BAO_CustomGroup::getTree('Individual', $formParams, $customGroupId); + $formParams = NULL; + $getTree = CRM_Core_BAO_CustomGroup::getTree('Individual', $formParams, $customGroupId); $dbCustomGroupTitle = $this->assertDBNotNull('CRM_Core_DAO_CustomGroup', $customGroupId, 'title', 'id', 'Database check for custom group record.' @@ -119,8 +118,8 @@ class CRM_Core_BAO_CustomGroupTest extends CiviUnitTestCase { $customGroup = Custom::createGroup($groupParams); $customGroupId = $customGroup->id; - $params = array('id' => $customGroupId); - $customGroup = CRM_Core_BAO_CustomGroup::retrieve($params, $dafaults); + $params = array('id' => $customGroupId); + $customGroup = CRM_Core_BAO_CustomGroup::retrieve($params, $dafaults); $dbCustomGroupTitle = $this->assertDBNotNull('CRM_Core_DAO_CustomGroup', $customGroupId, 'title', 'id', 'Database check for custom group record.' ); @@ -422,9 +421,9 @@ class CRM_Core_BAO_CustomGroupTest extends CiviUnitTestCase { } public function testGetActiveGroups() { - $contactId = Contact::createIndividual(); + $contactId = Contact::createIndividual(); $customGrouptitle = 'Test Custom Group'; - $groupParams = array( + $groupParams = array( 'title' => $customGrouptitle, 'name' => 'test_custom_group', 'style' => 'Tab', @@ -476,7 +475,7 @@ class CRM_Core_BAO_CustomGroupTest extends CiviUnitTestCase { 'Database check for custom group record.' ); $this->assertEquals(strtolower("civicrm_value_{$params['name']}_{$customGroup->id}"), $dbCustomGroupTableName, - "The table name should be suffixed with '_ID' unless specified."); + "The table name should be suffixed with '_ID' unless specified."); Custom::deleteGroup($customGroup); } @@ -528,9 +527,9 @@ class CRM_Core_BAO_CustomGroupTest extends CiviUnitTestCase { 'version' => 3, ); - $customGroup = Custom::createGroup($groupParams); + $customGroup = Custom::createGroup($groupParams); $customGroupId = $customGroup->id; - $isEmptyGroup = CRM_Core_BAO_CustomGroup::isGroupEmpty($customGroupId); + $isEmptyGroup = CRM_Core_BAO_CustomGroup::isGroupEmpty($customGroupId); $this->assertEquals($isEmptyGroup, TRUE, 'Check that custom Group is Empty.'); Custom::deleteGroup($customGroup); diff --git a/tests/phpunit/CRM/Core/BAO/CustomValueTableMultipleTest.php b/tests/phpunit/CRM/Core/BAO/CustomValueTableMultipleTest.php index 1cd44c0137..58a409147c 100644 --- a/tests/phpunit/CRM/Core/BAO/CustomValueTableMultipleTest.php +++ b/tests/phpunit/CRM/Core/BAO/CustomValueTableMultipleTest.php @@ -14,10 +14,10 @@ class CRM_Core_BAO_CustomValueTableMultipleTest extends CiviUnitTestCase { } public function testCustomGroupMultipleSingle() { - $params = array(); - $contactID = Contact::createIndividual(); + $params = array(); + $contactID = Contact::createIndividual(); $customGroup = Custom::createGroup($params, 'Individual', TRUE); - $fields = array( + $fields = array( 'groupId' => $customGroup->id, 'dataType' => 'String', 'htmlType' => 'Text', @@ -45,10 +45,10 @@ class CRM_Core_BAO_CustomValueTableMultipleTest extends CiviUnitTestCase { } public function testCustomGroupMultipleDouble() { - $params = array(); - $contactID = Contact::createIndividual(); + $params = array(); + $contactID = Contact::createIndividual(); $customGroup = Custom::createGroup($params, 'Individual', TRUE); - $fields = array( + $fields = array( 'groupId' => $customGroup->id, 'dataType' => 'String', 'htmlType' => 'Text', @@ -78,10 +78,10 @@ class CRM_Core_BAO_CustomValueTableMultipleTest extends CiviUnitTestCase { } public function testCustomGroupMultipleUpdate() { - $params = array(); - $contactID = Contact::createIndividual(); + $params = array(); + $contactID = Contact::createIndividual(); $customGroup = Custom::createGroup($params, 'Individual', TRUE); - $fields = array( + $fields = array( 'groupId' => $customGroup->id, 'dataType' => 'String', 'htmlType' => 'Text', @@ -120,10 +120,10 @@ class CRM_Core_BAO_CustomValueTableMultipleTest extends CiviUnitTestCase { } public function testCustomGroupMultipleOldFormate() { - $params = array(); - $contactID = Contact::createIndividual(); + $params = array(); + $contactID = Contact::createIndividual(); $customGroup = Custom::createGroup($params, 'Individual', TRUE); - $fields = array( + $fields = array( 'groupId' => $customGroup->id, 'dataType' => 'String', 'htmlType' => 'Text', diff --git a/tests/phpunit/CRM/Core/BAO/CustomValueTableTest.php b/tests/phpunit/CRM/Core/BAO/CustomValueTableTest.php index e6daee0692..1c36c0a722 100644 --- a/tests/phpunit/CRM/Core/BAO/CustomValueTableTest.php +++ b/tests/phpunit/CRM/Core/BAO/CustomValueTableTest.php @@ -17,10 +17,10 @@ class CRM_Core_BAO_CustomValueTableTest extends CiviUnitTestCase { * Test store function for country */ public function testStoreCountry() { - $params = array(); - $contactID = Contact::createIndividual(); + $params = array(); + $contactID = Contact::createIndividual(); $customGroup = Custom::createGroup($params, 'Individual'); - $fields = array( + $fields = array( 'groupId' => $customGroup->id, 'dataType' => 'Country', 'htmlType' => 'Select Country', @@ -37,7 +37,8 @@ class CRM_Core_BAO_CustomValueTableTest extends CiviUnitTestCase { 'table_name' => 'civicrm_value_test_group_' . $customGroup->id, 'column_name' => 'test_Country_' . $customField->id, 'file_id' => '', - )); + ) + ); CRM_Core_BAO_CustomValueTable::store($params, 'civicrm_contact', $contactID); // $this->assertDBCompareValue('CRM_Custom_DAO_CustomValue', ) @@ -51,10 +52,10 @@ class CRM_Core_BAO_CustomValueTableTest extends CiviUnitTestCase { * Test store function for file */ public function atestStoreFile() { - $params = array(); - $contactID = Contact::createIndividual(); + $params = array(); + $contactID = Contact::createIndividual(); $customGroup = Custom::createGroup($params, 'Individual'); - $fields = array( + $fields = array( 'groupId' => $customGroup->id, 'dataType' => 'File', 'htmlType' => 'File', @@ -71,7 +72,8 @@ class CRM_Core_BAO_CustomValueTableTest extends CiviUnitTestCase { 'table_name' => 'civicrm_value_test_group_' . $customGroup->id, 'column_name' => 'test_File_' . $customField->id, 'file_id' => 1, - )); + ) + ); CRM_Core_BAO_CustomValueTable::store($params, 'civicrm_contact', $contactID); // $this->assertDBCompareValue('CRM_Custom_DAO_CustomValue', ) @@ -85,10 +87,10 @@ class CRM_Core_BAO_CustomValueTableTest extends CiviUnitTestCase { * Test store function for state province */ public function testStoreStateProvince() { - $params = array(); - $contactID = Contact::createIndividual(); + $params = array(); + $contactID = Contact::createIndividual(); $customGroup = Custom::createGroup($params, 'Individual'); - $fields = array( + $fields = array( 'groupId' => $customGroup->id, 'dataType' => 'StateProvince', 'htmlType' => 'Select State/Province', @@ -105,7 +107,8 @@ class CRM_Core_BAO_CustomValueTableTest extends CiviUnitTestCase { 'table_name' => 'civicrm_value_test_group_' . $customGroup->id, 'column_name' => 'test_StateProvince_' . $customField->id, 'file_id' => 1, - )); + ) + ); CRM_Core_BAO_CustomValueTable::store($params, 'civicrm_contact', $contactID); @@ -118,10 +121,10 @@ class CRM_Core_BAO_CustomValueTableTest extends CiviUnitTestCase { * Test store function for date */ public function testStoreDate() { - $params = array(); - $contactID = Contact::createIndividual(); + $params = array(); + $contactID = Contact::createIndividual(); $customGroup = Custom::createGroup($params, 'Individual'); - $fields = array( + $fields = array( 'groupId' => $customGroup->id, 'dataType' => 'Date', 'htmlType' => 'Select Date', @@ -138,7 +141,8 @@ class CRM_Core_BAO_CustomValueTableTest extends CiviUnitTestCase { 'table_name' => 'civicrm_value_test_group_' . $customGroup->id, 'column_name' => 'test_Date_' . $customField->id, 'file_id' => '', - )); + ) + ); CRM_Core_BAO_CustomValueTable::store($params, 'civicrm_contact', $contactID); // $this->assertDBCompareValue('CRM_Custom_DAO_CustomValue', ) @@ -152,10 +156,10 @@ class CRM_Core_BAO_CustomValueTableTest extends CiviUnitTestCase { * Test store function for rich text editor */ public function testStoreRichTextEditor() { - $params = array(); - $contactID = Contact::createIndividual(); + $params = array(); + $contactID = Contact::createIndividual(); $customGroup = Custom::createGroup($params, 'Individual'); - $fields = array( + $fields = array( 'groupId' => $customGroup->id, 'htmlType' => 'RichTextEditor', 'dataType' => 'Memo', @@ -172,7 +176,8 @@ class CRM_Core_BAO_CustomValueTableTest extends CiviUnitTestCase { 'table_name' => 'civicrm_value_test_group_' . $customGroup->id, 'column_name' => 'test_Memo_' . $customField->id, 'file_id' => '', - )); + ) + ); CRM_Core_BAO_CustomValueTable::store($params, 'civicrm_contact', $contactID); // $this->assertDBCompareValue('CRM_Custom_DAO_CustomValue', ) @@ -187,10 +192,10 @@ class CRM_Core_BAO_CustomValueTableTest extends CiviUnitTestCase { */ public function testgetEntityValues() { - $params = array(); - $contactID = Contact::createIndividual(); + $params = array(); + $contactID = Contact::createIndividual(); $customGroup = Custom::createGroup($params, 'Individual'); - $fields = array( + $fields = array( 'groupId' => $customGroup->id, 'htmlType' => 'RichTextEditor', 'dataType' => 'Memo', @@ -207,7 +212,8 @@ class CRM_Core_BAO_CustomValueTableTest extends CiviUnitTestCase { 'table_name' => 'civicrm_value_test_group_' . $customGroup->id, 'column_name' => 'test_Memo_' . $customField->id, 'file_id' => '', - )); + ) + ); CRM_Core_BAO_CustomValueTable::store($params, 'civicrm_contact', $contactID); // $this->assertDBCompareValue('CRM_Custom_DAO_CustomValue', ) @@ -223,8 +229,8 @@ class CRM_Core_BAO_CustomValueTableTest extends CiviUnitTestCase { } public function testCustomGroupMultiple() { - $params = array(); - $contactID = Contact::createIndividual(); + $params = array(); + $contactID = Contact::createIndividual(); $customGroup = Custom::createGroup($params, 'Individual'); $fields = array( diff --git a/tests/phpunit/CRM/Core/BAO/FinancialTrxnTest.php b/tests/phpunit/CRM/Core/BAO/FinancialTrxnTest.php index 4737d26d4f..3228b7639b 100644 --- a/tests/phpunit/CRM/Core/BAO/FinancialTrxnTest.php +++ b/tests/phpunit/CRM/Core/BAO/FinancialTrxnTest.php @@ -39,10 +39,10 @@ class CRM_Core_BAO_FinancialTrxnTest extends CiviUnitTestCase { * Check method create() */ public function testCreate() { - $contactId = $this->individualCreate(); + $contactId = $this->individualCreate(); $financialTypeId = 1; - $contributionId = $this->contributionCreate($contactId, $financialTypeId); - $params = array( + $contributionId = $this->contributionCreate($contactId, $financialTypeId); + $params = array( 'contribution_id' => $financialTypeId, 'to_financial_account_id' => 1, 'trxn_date' => 20091021184930, diff --git a/tests/phpunit/CRM/Core/BAO/LocationTest.php b/tests/phpunit/CRM/Core/BAO/LocationTest.php index 7378c86453..f4c85311e4 100644 --- a/tests/phpunit/CRM/Core/BAO/LocationTest.php +++ b/tests/phpunit/CRM/Core/BAO/LocationTest.php @@ -44,7 +44,14 @@ class CRM_Core_BAO_LocationTest extends CiviUnitTestCase { public function setUp() { parent::setUp(); - $this->quickCleanup(array('civicrm_contact', 'civicrm_address', 'civicrm_loc_block', 'civicrm_email', 'civicrm_phone', 'civicrm_im')); + $this->quickCleanup(array( + 'civicrm_contact', + 'civicrm_address', + 'civicrm_loc_block', + 'civicrm_email', + 'civicrm_phone', + 'civicrm_im' + )); } /** @@ -292,7 +299,7 @@ class CRM_Core_BAO_LocationTest extends CiviUnitTestCase { //Now check DB for location elements. $searchParams = array( - 'id' => CRM_Utils_Array::value('address_id', $locElementIds), + 'id' => CRM_Utils_Array::value('address_id', $locElementIds), 'location_type_id' => 1, 'is_primary' => 1, ); @@ -310,7 +317,7 @@ class CRM_Core_BAO_LocationTest extends CiviUnitTestCase { $this->assertDBCompareValues('CRM_Core_DAO_Address', $searchParams, $compareParams); $searchParams = array( - 'id' => CRM_Utils_Array::value('email_id', $locElementIds), + 'id' => CRM_Utils_Array::value('email_id', $locElementIds), 'location_type_id' => 1, 'is_primary' => 1, ); @@ -318,7 +325,7 @@ class CRM_Core_BAO_LocationTest extends CiviUnitTestCase { $this->assertDBCompareValues('CRM_Core_DAO_Email', $searchParams, $compareParams); $searchParams = array( - 'id' => CRM_Utils_Array::value('phone_id', $locElementIds), + 'id' => CRM_Utils_Array::value('phone_id', $locElementIds), 'location_type_id' => 1, 'is_primary' => 1, 'phone_type_id' => 1, @@ -327,7 +334,7 @@ class CRM_Core_BAO_LocationTest extends CiviUnitTestCase { $this->assertDBCompareValues('CRM_Core_DAO_Phone', $searchParams, $compareParams); $searchParams = array( - 'id' => CRM_Utils_Array::value('phone_2_id', $locElementIds), + 'id' => CRM_Utils_Array::value('phone_2_id', $locElementIds), 'location_type_id' => 1, 'phone_type_id' => 2, ); @@ -335,7 +342,7 @@ class CRM_Core_BAO_LocationTest extends CiviUnitTestCase { $this->assertDBCompareValues('CRM_Core_DAO_Phone', $searchParams, $compareParams); $searchParams = array( - 'id' => CRM_Utils_Array::value('im_id', $locElementIds), + 'id' => CRM_Utils_Array::value('im_id', $locElementIds), 'location_type_id' => 1, 'is_primary' => 1, ); diff --git a/tests/phpunit/CRM/Core/BAO/RecurringEntityTest.php b/tests/phpunit/CRM/Core/BAO/RecurringEntityTest.php index aaa22cd5f7..8ed8418804 100644 --- a/tests/phpunit/CRM/Core/BAO/RecurringEntityTest.php +++ b/tests/phpunit/CRM/Core/BAO/RecurringEntityTest.php @@ -60,17 +60,17 @@ class CRM_Core_BAO_RecurringEntityTest extends CiviUnitTestCase { $daoActivity->save(); $recursion = new CRM_Core_BAO_RecurringEntity(); - $recursion->entity_id = $daoActivity->id; + $recursion->entity_id = $daoActivity->id; $recursion->entity_table = 'civicrm_activity'; - $recursion->dateColumns = array('activity_date_time'); - $recursion->schedule = array( - 'entity_value' => $daoActivity->id, - 'start_action_date' => $daoActivity->activity_date_time, + $recursion->dateColumns = array('activity_date_time'); + $recursion->schedule = array( + 'entity_value' => $daoActivity->id, + 'start_action_date' => $daoActivity->activity_date_time, 'entity_status' => 'fourth saturday', 'repetition_frequency_unit' => 'month', 'repetition_frequency_interval' => 3, 'start_action_offset' => 5, - 'used_for' => 'activity', + 'used_for' => 'activity', ); $generatedEntities = $recursion->generate(); @@ -117,7 +117,7 @@ class CRM_Core_BAO_RecurringEntityTest extends CiviUnitTestCase { $daoEvent->event_type_id = 3; $daoEvent->is_public = 1; $daoEvent->start_date = date('YmdHis', strtotime('2014-10-26 10:30:00')); - $daoEvent->end_date = date('YmdHis', strtotime('2014-10-28 10:30:00')); + $daoEvent->end_date = date('YmdHis', strtotime('2014-10-28 10:30:00')); $daoEvent->created_date = date('YmdHis'); $daoEvent->is_active = 1; $daoEvent->save(); @@ -134,24 +134,24 @@ class CRM_Core_BAO_RecurringEntityTest extends CiviUnitTestCase { // time to use recursion $recursion = new CRM_Core_BAO_RecurringEntity(); - $recursion->entity_id = $daoEvent->id; + $recursion->entity_id = $daoEvent->id; $recursion->entity_table = 'civicrm_event'; - $recursion->dateColumns = array('start_date'); - $recursion->schedule = array( - 'entity_value' => $daoEvent->id, - 'start_action_date' => $daoEvent->start_date, - 'start_action_condition' => 'monday', - 'repetition_frequency_unit' => 'week', + $recursion->dateColumns = array('start_date'); + $recursion->schedule = array( + 'entity_value' => $daoEvent->id, + 'start_action_date' => $daoEvent->start_date, + 'start_action_condition' => 'monday', + 'repetition_frequency_unit' => 'week', 'repetition_frequency_interval' => 1, - 'start_action_offset' => 4, - 'used_for' => 'event', + 'start_action_offset' => 4, + 'used_for' => 'event', ); $recursion->linkedEntities = array( array( - 'table' => 'civicrm_tell_friend', - 'findCriteria' => array( - 'entity_id' => $recursion->entity_id, + 'table' => 'civicrm_tell_friend', + 'findCriteria' => array( + 'entity_id' => $recursion->entity_id, 'entity_table' => 'civicrm_event', ), 'linkedColumns' => array('entity_id'), @@ -211,22 +211,22 @@ class CRM_Core_BAO_RecurringEntityTest extends CiviUnitTestCase { //Cross check event exists before we test deletion $searchParamsEventBeforeDelete = array( - 'entity_id' => $generatedEntities['civicrm_event'][$key], + 'entity_id' => $generatedEntities['civicrm_event'][$key], 'entity_table' => 'civicrm_event', ); $expectedValuesEventBeforeDelete = array( - 'entity_id' => $generatedEntities['civicrm_event'][$key], + 'entity_id' => $generatedEntities['civicrm_event'][$key], 'entity_table' => 'civicrm_event', ); $this->assertDBCompareValues('CRM_Core_DAO_RecurringEntity', $searchParamsEventBeforeDelete, $expectedValuesEventBeforeDelete); //Cross check event exists before we test deletion $searchParamsTellAFriendBeforeDelete = array( - 'entity_id' => $generatedEntities['civicrm_tell_friend'][$actKey], + 'entity_id' => $generatedEntities['civicrm_tell_friend'][$actKey], 'entity_table' => 'civicrm_tell_friend', ); $expectedValuesTellAFriendBeforeDelete = array( - 'entity_id' => $generatedEntities['civicrm_tell_friend'][$actKey], + 'entity_id' => $generatedEntities['civicrm_tell_friend'][$actKey], 'entity_table' => 'civicrm_tell_friend', ); $this->assertDBCompareValues('CRM_Core_DAO_RecurringEntity', $searchParamsTellAFriendBeforeDelete, $expectedValuesTellAFriendBeforeDelete); diff --git a/tests/phpunit/CRM/Core/BAO/UFFieldTest.php b/tests/phpunit/CRM/Core/BAO/UFFieldTest.php index 278581124a..93a27c1e4b 100644 --- a/tests/phpunit/CRM/Core/BAO/UFFieldTest.php +++ b/tests/phpunit/CRM/Core/BAO/UFFieldTest.php @@ -175,13 +175,13 @@ class CRM_Core_BAO_UFFieldTest extends CiviUnitTestCase { /** * Make sure that the existence of a profile doesn't break listing all fields * - public function testGetAvailable_mixed() { - // FIXME - $this->testGetAvailable_full(); - // $this->testGetAvailable_byGid(); - $this->testGetAvailable_full(); - // $this->testGetAvailable_byGid(); - } // */ + * public function testGetAvailable_mixed() { + * // FIXME + * $this->testGetAvailable_full(); + * // $this->testGetAvailable_byGid(); + * $this->testGetAvailable_full(); + * // $this->testGetAvailable_byGid(); + * } // */ /** * @param array $fields diff --git a/tests/phpunit/CRM/Core/Config/MailerTest.php b/tests/phpunit/CRM/Core/Config/MailerTest.php index 37dd86123a..57cff4d4fd 100644 --- a/tests/phpunit/CRM/Core/Config/MailerTest.php +++ b/tests/phpunit/CRM/Core/Config/MailerTest.php @@ -56,20 +56,20 @@ class CRM_Core_Config_MailerTest extends CiviUnitTestCase { public function testHookAlterMailer() { $test = $this; $mockMailer = new CRM_Utils_FakeObject(array( - 'send' => function ($recipients, $headers, $body) use ($test) { - $test->calls['send']++; - $test->assertEquals(array('to@example.org'), $recipients); - $test->assertEquals('Subject Example', $headers['Subject']); - }, + 'send' => function ($recipients, $headers, $body) use ($test) { + $test->calls['send']++; + $test->assertEquals(array('to@example.org'), $recipients); + $test->assertEquals('Subject Example', $headers['Subject']); + }, )); CRM_Utils_Hook::singleton()->setHook('civicrm_alterMailer', function (&$mailer, $driver, $params) use ($test, $mockMailer) { - $test->calls['civicrm_alterMailer']++; - $test->assertTrue(is_string($driver) && !empty($driver)); - $test->assertTrue(is_array($params)); - $test->assertTrue(is_callable(array($mailer, 'send'))); - $mailer = $mockMailer; + $test->calls['civicrm_alterMailer']++; + $test->assertTrue(is_string($driver) && !empty($driver)); + $test->assertTrue(is_array($params)); + $test->assertTrue(is_callable(array($mailer, 'send'))); + $mailer = $mockMailer; } ); diff --git a/tests/phpunit/CRM/Core/DAOTest.php b/tests/phpunit/CRM/Core/DAOTest.php index 6d4f6efca5..204eb317a0 100644 --- a/tests/phpunit/CRM/Core/DAOTest.php +++ b/tests/phpunit/CRM/Core/DAOTest.php @@ -166,12 +166,30 @@ class CRM_Core_DAOTest extends CiviUnitTestCase { public function sqlNameDataProvider() { return array( array('this is a long string', 30, FALSE, 'this is a long string'), - - array('this is an even longer string which is exactly 60 character', 60, FALSE, 'this is an even longer string which is exactly 60 character'), - array('this is an even longer string which is exactly 60 character', 60, TRUE , 'this is an even longer string which is exactly 60 character'), - - array('this is an even longer string which is a bit more than 60 character', 60, FALSE, 'this is an even longer string which is a bit more than 60 ch'), - array('this is an even longer string which is a bit more than 60 character', 60, TRUE , 'this is an even longer string which is a bit more th_c1cbd519'), + array( + 'this is an even longer string which is exactly 60 character', + 60, + FALSE, + 'this is an even longer string which is exactly 60 character' + ), + array( + 'this is an even longer string which is exactly 60 character', + 60, + TRUE, + 'this is an even longer string which is exactly 60 character' + ), + array( + 'this is an even longer string which is a bit more than 60 character', + 60, + FALSE, + 'this is an even longer string which is a bit more than 60 ch' + ), + array( + 'this is an even longer string which is a bit more than 60 character', + 60, + TRUE, + 'this is an even longer string which is a bit more th_c1cbd519' + ), ); } diff --git a/tests/phpunit/CRM/Core/ManagedEntitiesTest.php b/tests/phpunit/CRM/Core/ManagedEntitiesTest.php index 8b6bc83d14..26ca09c215 100644 --- a/tests/phpunit/CRM/Core/ManagedEntitiesTest.php +++ b/tests/phpunit/CRM/Core/ManagedEntitiesTest.php @@ -218,7 +218,7 @@ class CRM_Core_ManagedEntitiesTest extends CiviUnitTestCase { $this->assertDBQuery(1, 'SELECT count(*) FROM civicrm_option_value WHERE name = "CRM_Example_One_Foo"'); // Override 'getrefcount' ==> The refcount is 1 - $this->adhocProvider->addAction('getrefcount', 'access CiviCRM', function($apiRequest) { + $this->adhocProvider->addAction('getrefcount', 'access CiviCRM', function ($apiRequest) { return civicrm_api3_create_success(array( array( 'name' => 'mock', @@ -238,7 +238,7 @@ class CRM_Core_ManagedEntitiesTest extends CiviUnitTestCase { $this->assertEquals($foo['id'], $foo2['id']); // Override 'getrefcount' ==> The refcount is 0 - $this->adhocProvider->addAction('getrefcount', 'access CiviCRM', function($apiRequest) { + $this->adhocProvider->addAction('getrefcount', 'access CiviCRM', function ($apiRequest) { return civicrm_api3_create_success(array()); }); diff --git a/tests/phpunit/CRM/Core/MenuTest.php b/tests/phpunit/CRM/Core/MenuTest.php index b385bb39d6..7ce665f52a 100644 --- a/tests/phpunit/CRM/Core/MenuTest.php +++ b/tests/phpunit/CRM/Core/MenuTest.php @@ -15,20 +15,29 @@ class CRM_Core_MenuTest extends CiviUnitTestCase { $cases[] = array('addSequence=1', array('addSequence' => '1')); $cases[] = array('attachUpload=1', array('attachUpload' => '1')); $cases[] = array('mode=256', array('mode' => '256')); - $cases[] = array('mode=256,addSequence=1,attachUpload=1', array('mode' => '256', 'addSequence' => '1', 'attachUpload' => 1)); - $cases[] = array('mode=256,urlToSession=a:b:c:d', array( - 'mode' => '256', - 'urlToSession' => array( - array('urlVar' => 'a', 'sessionVar' => 'b', 'type' => 'c', 'default' => 'd'), - ), - )); - $cases[] = array('mode=256,urlToSession=a:b:c:d;z:y:x:w', array( - 'mode' => '256', - 'urlToSession' => array( - array('urlVar' => 'a', 'sessionVar' => 'b', 'type' => 'c', 'default' => 'd'), - array('urlVar' => 'z', 'sessionVar' => 'y', 'type' => 'x', 'default' => 'w'), - ), - )); + $cases[] = array( + 'mode=256,addSequence=1,attachUpload=1', + array('mode' => '256', 'addSequence' => '1', 'attachUpload' => 1) + ); + $cases[] = array( + 'mode=256,urlToSession=a:b:c:d', + array( + 'mode' => '256', + 'urlToSession' => array( + array('urlVar' => 'a', 'sessionVar' => 'b', 'type' => 'c', 'default' => 'd'), + ), + ) + ); + $cases[] = array( + 'mode=256,urlToSession=a:b:c:d;z:y:x:w', + array( + 'mode' => '256', + 'urlToSession' => array( + array('urlVar' => 'a', 'sessionVar' => 'b', 'type' => 'c', 'default' => 'd'), + array('urlVar' => 'z', 'sessionVar' => 'y', 'type' => 'x', 'default' => 'w'), + ), + ) + ); $cases[] = array('url=whiz!;.:#=%/|+bang?', array('url' => 'whiz!;.:#=%/|+bang?')); return $cases; } diff --git a/tests/phpunit/CRM/Core/Payment/AuthorizeNetIPNTest.php b/tests/phpunit/CRM/Core/Payment/AuthorizeNetIPNTest.php index 983faab657..e894ad66a0 100644 --- a/tests/phpunit/CRM/Core/Payment/AuthorizeNetIPNTest.php +++ b/tests/phpunit/CRM/Core/Payment/AuthorizeNetIPNTest.php @@ -49,7 +49,10 @@ class CRM_Core_Payment_AuthorizeNetIPNTest extends CiviUnitTestCase { $this->assertEquals(5, $contributionRecur['contribution_status_id']); $paypalIPN = new CRM_Core_Payment_AuthorizeNetIPN($this->getRecurSubsequentTransaction()); $paypalIPN->main(); - $contribution = $this->callAPISuccess('contribution', 'get', array('contribution_recur_id' => $this->_contributionRecurID, 'sequential' => 1)); + $contribution = $this->callAPISuccess('contribution', 'get', array( + 'contribution_recur_id' => $this->_contributionRecurID, + 'sequential' => 1 + )); $this->assertEquals(2, $contribution['count']); $this->assertEquals('second_one', $contribution['values'][1]['trxn_id']); } @@ -70,11 +73,17 @@ class CRM_Core_Payment_AuthorizeNetIPNTest extends CiviUnitTestCase { $this->assertEquals(5, $contributionRecur['contribution_status_id']); $paypalIPN = new CRM_Core_Payment_AuthorizeNetIPN($this->getRecurSubsequentTransaction()); $paypalIPN->main(); - $contribution = $this->callAPISuccess('contribution', 'get', array('contribution_recur_id' => $this->_contributionRecurID, 'sequential' => 1)); + $contribution = $this->callAPISuccess('contribution', 'get', array( + 'contribution_recur_id' => $this->_contributionRecurID, + 'sequential' => 1 + )); $this->assertEquals(2, $contribution['count']); $this->assertEquals('second_one', $contribution['values'][1]['trxn_id']); $this->callAPISuccessGetSingle('membership_payment', array('contribution_id' => $contribution['values'][1]['id'])); - $this->callAPISuccessGetSingle('line_item', array('contribution_id' => $contribution['values'][1]['id'], 'entity_table' => 'civicrm_membership')); + $this->callAPISuccessGetSingle('line_item', array( + 'contribution_id' => $contribution['values'][1]['id'], + 'entity_table' => 'civicrm_membership' + )); } /** diff --git a/tests/phpunit/CRM/Core/Payment/AuthorizeNetTest.php b/tests/phpunit/CRM/Core/Payment/AuthorizeNetTest.php index d6ace534ee..899c830209 100644 --- a/tests/phpunit/CRM/Core/Payment/AuthorizeNetTest.php +++ b/tests/phpunit/CRM/Core/Payment/AuthorizeNetTest.php @@ -65,24 +65,24 @@ class CRM_Core_Payment_AuthorizeNetTest extends CiviUnitTestCase { * Test works but not both due to some form of caching going on in the SmartySingleton */ public function testCreateSingleNowDated() { - $firstName = 'John_' . substr(sha1(rand()), 0, 7); - $lastName = 'Smith_' . substr(sha1(rand()), 0, 7); + $firstName = 'John_' . substr(sha1(rand()), 0, 7); + $lastName = 'Smith_' . substr(sha1(rand()), 0, 7); $nameParams = array('first_name' => $firstName, 'last_name' => $lastName); - $contactId = $this->individualCreate($nameParams); + $contactId = $this->individualCreate($nameParams); $invoiceID = sha1(rand()); - $amount = rand(100, 1000) . '.00'; + $amount = rand(100, 1000) . '.00'; $contributionRecurParams = array( 'contact_id' => $contactId, - 'amount' => $amount, - 'currency' => 'USD', + 'amount' => $amount, + 'currency' => 'USD', 'frequency_unit' => 'week', 'frequency_interval' => 1, 'installments' => 2, - 'start_date' => date('Ymd'), - 'create_date' => date('Ymd'), - 'invoice_id' => $invoiceID, + 'start_date' => date('Ymd'), + 'create_date' => date('Ymd'), + 'invoice_id' => $invoiceID, 'contribution_status_id' => 2, 'is_test' => 1, 'payment_processor_id' => $this->processorParams->id, @@ -90,14 +90,14 @@ class CRM_Core_Payment_AuthorizeNetTest extends CiviUnitTestCase { $recur = CRM_Contribute_BAO_ContributionRecur::add($contributionRecurParams); $contributionParams = array( - 'contact_id' => $contactId, - 'financial_type_id' => $this->_financialTypeId, + 'contact_id' => $contactId, + 'financial_type_id' => $this->_financialTypeId, 'receive_date' => date('Ymd'), 'total_amount' => $amount, - 'invoice_id' => $invoiceID, - 'currency' => 'USD', + 'invoice_id' => $invoiceID, + 'currency' => 'USD', 'contribution_recur_id' => $recur->id, - 'is_test' => 1, + 'is_test' => 1, 'contribution_status_id' => 2, ); $contribution = CRM_Contribute_BAO_Contribution::add($contributionParams); @@ -198,25 +198,25 @@ class CRM_Core_Payment_AuthorizeNetTest extends CiviUnitTestCase { public function testCreateSinglePostDated() { $start_date = date('Ymd', strtotime("+ 1 week")); - $firstName = 'John_' . substr(sha1(rand()), 0, 7); - $lastName = 'Smith_' . substr(sha1(rand()), 0, 7); + $firstName = 'John_' . substr(sha1(rand()), 0, 7); + $lastName = 'Smith_' . substr(sha1(rand()), 0, 7); $nameParams = array('first_name' => $firstName, 'last_name' => $lastName); - $contactId = $this->individualCreate($nameParams); + $contactId = $this->individualCreate($nameParams); $ids = array('contribution' => NULL); $invoiceID = sha1(rand()); - $amount = rand(100, 1000) . '.00'; + $amount = rand(100, 1000) . '.00'; $contributionRecurParams = array( 'contact_id' => $contactId, - 'amount' => $amount, - 'currency' => 'USD', + 'amount' => $amount, + 'currency' => 'USD', 'frequency_unit' => 'month', 'frequency_interval' => 1, 'installments' => 3, - 'start_date' => $start_date, - 'create_date' => date('Ymd'), - 'invoice_id' => $invoiceID, + 'start_date' => $start_date, + 'create_date' => date('Ymd'), + 'invoice_id' => $invoiceID, 'contribution_status_id' => 2, 'is_test' => 1, 'payment_processor_id' => $this->processorParams->id, @@ -224,12 +224,12 @@ class CRM_Core_Payment_AuthorizeNetTest extends CiviUnitTestCase { $recur = CRM_Contribute_BAO_ContributionRecur::add($contributionRecurParams, $ids); $contributionParams = array( - 'contact_id' => $contactId, - 'financial_type_id' => $this->_financialTypeId, + 'contact_id' => $contactId, + 'financial_type_id' => $this->_financialTypeId, 'receive_date' => $start_date, 'total_amount' => $amount, - 'invoice_id' => $invoiceID, - 'currency' => 'USD', + 'invoice_id' => $invoiceID, + 'currency' => 'USD', 'contribution_recur_id' => $recur->id, 'is_test' => 1, 'contribution_status_id' => 2, diff --git a/tests/phpunit/CRM/Core/Payment/BaseIPNTest.php b/tests/phpunit/CRM/Core/Payment/BaseIPNTest.php index b3d188cc41..6d574effa9 100644 --- a/tests/phpunit/CRM/Core/Payment/BaseIPNTest.php +++ b/tests/phpunit/CRM/Core/Payment/BaseIPNTest.php @@ -85,7 +85,7 @@ class CRM_Core_Payment_BaseIPNTest extends CiviUnitTestCase { $this->_contributionParams = array( 'contact_id' => $this->_contactId, 'version' => 3, - 'financial_type_id' => $this->_contributionTypeId, + 'financial_type_id' => $this->_contributionTypeId, 'recieve_date' => date('Ymd'), 'total_amount' => 150.00, 'invoice_id' => 'c8acb91e080ad7bd8a2adc119c192885', @@ -100,7 +100,7 @@ class CRM_Core_Payment_BaseIPNTest extends CiviUnitTestCase { $contribution = new CRM_Contribute_BAO_Contribution(); $contribution->id = $this->_contributionId; - $contribution->find(true); + $contribution->find(TRUE); $this->objects['contribution'] = $contribution; } @@ -120,10 +120,11 @@ class CRM_Core_Payment_BaseIPNTest extends CiviUnitTestCase { $this->assertFalse(empty($this->objects['membership']), 'in line ' . __LINE__); $this->assertArrayHasKey($this->_membershipTypeID, $this->objects['membership'], 'in line ' . __LINE__); $this->assertTrue(is_a($this->objects['membership'][$this->_membershipTypeID], 'CRM_Member_BAO_Membership')); - $this->assertTrue(is_a($this->objects['contributionType'],'CRM_Financial_BAO_FinancialType')); + $this->assertTrue(is_a($this->objects['contributionType'], 'CRM_Financial_BAO_FinancialType')); $this->assertFalse(empty($this->objects['contributionRecur']), __LINE__); $this->assertFalse(empty($this->objects['paymentProcessor']), __LINE__); } + /** * Test the LoadObjects function with recurring membership data */ @@ -133,8 +134,8 @@ class CRM_Core_Payment_BaseIPNTest extends CiviUnitTestCase { unset($this->ids['membership']); $contribution = new CRM_Contribute_BAO_Contribution(); $contribution->id = $this->_contributionId; - $contribution->find(true); - $contribution->loadRelatedObjects($this->input, $this->ids, FALSE, true); + $contribution->find(TRUE); + $contribution->loadRelatedObjects($this->input, $this->ids, FALSE, TRUE); $this->assertFalse(empty($contribution->_relatedObjects['membership']), 'in line ' . __LINE__); $this->assertArrayHasKey($this->_membershipTypeID, $contribution->_relatedObjects['membership'], 'in line ' . __LINE__); $this->assertTrue(is_a($contribution->_relatedObjects['membership'][$this->_membershipTypeID], 'CRM_Member_BAO_Membership')); @@ -142,6 +143,7 @@ class CRM_Core_Payment_BaseIPNTest extends CiviUnitTestCase { $this->assertFalse(empty($contribution->_relatedObjects['contributionRecur']), __LINE__); $this->assertFalse(empty($contribution->_relatedObjects['paymentProcessor']), __LINE__); } + /** * Test the LoadObjects function with recurring membership data */ @@ -177,7 +179,7 @@ class CRM_Core_Payment_BaseIPNTest extends CiviUnitTestCase { $this->IPN->loadObjects($this->input, $this->ids, $this->objects, FALSE, $this->_processorId); $this->assertFalse(empty($this->objects['participant']), 'in line ' . __LINE__); $this->assertTrue(is_a($this->objects['participant'], 'CRM_Event_BAO_Participant')); - $this->assertTrue(is_a($this->objects['contributionType'],'CRM_Financial_BAO_FinancialType')); + $this->assertTrue(is_a($this->objects['contributionType'], 'CRM_Financial_BAO_FinancialType')); $this->assertFalse(empty($this->objects['event'])); $this->assertTrue(is_a($this->objects['event'], 'CRM_Event_BAO_Event')); $this->assertTrue(is_a($this->objects['contribution'], 'CRM_Contribute_BAO_Contribution')); @@ -192,7 +194,7 @@ class CRM_Core_Payment_BaseIPNTest extends CiviUnitTestCase { $this->IPN->loadObjects($this->input, $this->ids, $this->objects, FALSE, $this->_processorId); $values = array(); $this->assertFalse(empty($this->objects['event'])); - $msg = $this->IPN->sendMail($this->input, $this->ids, $this->objects, $values, False,True); + $msg = $this->IPN->sendMail($this->input, $this->ids, $this->objects, $values, FALSE, TRUE); $this->assertContains('registration has been received and your status has been updated to Attended.', $msg['body']); $this->assertContains('Annual CiviCRM meet', $msg['html']); } @@ -216,13 +218,14 @@ class CRM_Core_Payment_BaseIPNTest extends CiviUnitTestCase { $this->_setUpParticipantObjects(); $values = array(); require_once 'CiviTest/CiviMailUtils.php'; - $mut = new CiviMailUtils($this, true); + $mut = new CiviMailUtils($this, TRUE); $this->IPN->loadObjects($this->input, $this->ids, $this->objects, FALSE, $this->_processorId); $this->IPN->sendMail($this->input, $this->ids, $this->objects, $values, FALSE, FALSE); $mut->checkMailLog(array( - 'Thank you for your participation', - 'Annual CiviCRM meet', - 'Mr. Anthony Anderson II') + 'Thank you for your participation', + 'Annual CiviCRM meet', + 'Mr. Anthony Anderson II' + ) ); $mut->stop(); } @@ -242,7 +245,7 @@ class CRM_Core_Payment_BaseIPNTest extends CiviUnitTestCase { ); $this->quickCleanup($tablesToTruncate, FALSE); require_once 'CiviTest/CiviMailUtils.php'; - $mut = new CiviMailUtils($this, true); + $mut = new CiviMailUtils($this, TRUE); $this->IPN->loadObjects($this->input, $this->ids, $this->objects, FALSE, $this->_processorId); $this->IPN->sendMail($this->input, $this->ids, $this->objects, $values, FALSE, FALSE); $mut->assertMailLogEmpty('no mail should have been send as event set to no confirm'); @@ -256,7 +259,7 @@ class CRM_Core_Payment_BaseIPNTest extends CiviUnitTestCase { $this->_setUpPledgeObjects(); $this->IPN->loadObjects($this->input, $this->ids, $this->objects, FALSE, $this->_processorId); $this->assertFalse(empty($this->objects['pledge_payment'][0]), 'in line ' . __LINE__); - $this->assertTrue(is_a($this->objects['contributionType'],'CRM_Financial_BAO_FinancialType')); + $this->assertTrue(is_a($this->objects['contributionType'], 'CRM_Financial_BAO_FinancialType')); $this->assertTrue(is_a($this->objects['contribution'], 'CRM_Contribute_BAO_Contribution')); $this->assertTrue(is_a($this->objects['pledge_payment'][0], 'CRM_Pledge_BAO_PledgePayment')); $this->assertFalse(empty($this->objects['pledge_payment'][0]->id)); @@ -472,7 +475,7 @@ class CRM_Core_Payment_BaseIPNTest extends CiviUnitTestCase { $this->_membershipTypeID = $this->membershipTypeCreate(); $this->_membershipStatusID = $this->membershipStatusCreate('test status'); } - catch(Exception$e) { + catch (Exception$e) { echo $e->getMessage(); } CRM_Member_PseudoConstant::membershipType($this->_membershipTypeID, TRUE); @@ -494,10 +497,10 @@ class CRM_Core_Payment_BaseIPNTest extends CiviUnitTestCase { $this->_membershipId = $membership['id']; //we'll create membership payment here because to make setup more re-usable civicrm_api('membership_payment', 'create', array( - 'version' => 3, - 'contribution_id' => $this->_contributionId, - 'membership_id' => $this->_membershipId, - )); + 'version' => 3, + 'contribution_id' => $this->_contributionId, + 'membership_id' => $this->_membershipId, + )); $contribution = new CRM_Contribute_BAO_Contribution(); $contribution->id = $this->_contributionId; @@ -528,7 +531,7 @@ class CRM_Core_Payment_BaseIPNTest extends CiviUnitTestCase { 'invoice_id' => 'c8acb91e080ad7bd8a2adc119c192885', 'contribution_status_id' => 2, 'is_test' => 1, - 'financial_type_id' => $this->_contributionTypeId, + 'financial_type_id' => $this->_contributionTypeId, 'version' => 3, 'payment_processor_id' => $this->_processorId, ); @@ -547,15 +550,15 @@ class CRM_Core_Payment_BaseIPNTest extends CiviUnitTestCase { $this->assertAPISuccess($event, 'line ' . __LINE__ . ' set-up of event'); $this->_eventId = $event['id']; $this->_participantId = $this->participantCreate(array( - 'event_id' => $this->_eventId, - 'contact_id' => $this->_contactId, - )); + 'event_id' => $this->_eventId, + 'contact_id' => $this->_contactId, + )); //we'll create membership payment here because to make setup more re-usable $participantPayment = civicrm_api('participant_payment', 'create', array( - 'version' => 3, - 'contribution_id' => $this->_contributionId, - 'participant_id' => $this->_participantId, - )); + 'version' => 3, + 'contribution_id' => $this->_contributionId, + 'participant_id' => $this->_participantId, + )); $this->assertAPISuccess($participantPayment, 'line ' . __LINE__ . ' set-up of event'); $contribution = new CRM_Contribute_BAO_Contribution(); $contribution->id = $this->_contributionId; @@ -581,12 +584,12 @@ class CRM_Core_Payment_BaseIPNTest extends CiviUnitTestCase { $this->_pledgeId = $this->pledgeCreate($this->_contactId); //we'll create membership payment here because to make setup more re-usable $pledgePayment = civicrm_api('pledge_payment', 'create', array( - 'version' => 3, - 'pledge_id' => $this->_pledgeId, - 'contribution_id' => $this->_contributionId, - 'status_id' => 1, - 'actual_amount' => 50, - )); + 'version' => 3, + 'pledge_id' => $this->_pledgeId, + 'contribution_id' => $this->_contributionId, + 'status_id' => 1, + 'actual_amount' => 50, + )); $this->assertAPISuccess($pledgePayment, 'line ' . __LINE__ . ' set-up of pledge payment'); $this->input = array( 'component' => 'contribute', diff --git a/tests/phpunit/CRM/Core/Payment/PayPalProIPNTest.php b/tests/phpunit/CRM/Core/Payment/PayPalProIPNTest.php index 9186a17a1c..4b1e8c7b22 100644 --- a/tests/phpunit/CRM/Core/Payment/PayPalProIPNTest.php +++ b/tests/phpunit/CRM/Core/Payment/PayPalProIPNTest.php @@ -44,10 +44,10 @@ class CRM_Core_Payment_PayPalProIPNTest extends CiviUnitTestCase { $this->_paymentProcessorID = $this->paymentProcessorCreate(); $this->_contactID = $this->individualCreate(); $contributionPage = $this->callAPISuccess('contribution_page', 'create', array( - 'title' => "Test Contribution Page", - 'financial_type_id' => $this->_financialTypeID, - 'currency' => 'USD', - 'payment_processor' => $this->_paymentProcessorID, + 'title' => "Test Contribution Page", + 'financial_type_id' => $this->_financialTypeID, + 'currency' => 'USD', + 'payment_processor' => $this->_paymentProcessorID, ) ); $this->_contributionPageID = $contributionPage['id']; @@ -73,7 +73,10 @@ class CRM_Core_Payment_PayPalProIPNTest extends CiviUnitTestCase { $this->assertEquals(5, $contributionRecur['contribution_status_id']); $paypalIPN = new CRM_Core_Payment_PayPalProIPN($this->getPaypalProRecurSubsequentTransaction()); $paypalIPN->main(); - $contribution = $this->callAPISuccess('contribution', 'get', array('contribution_recur_id' => $this->_contributionRecurID, 'sequential' => 1)); + $contribution = $this->callAPISuccess('contribution', 'get', array( + 'contribution_recur_id' => $this->_contributionRecurID, + 'sequential' => 1 + )); $this->assertEquals(2, $contribution['count']); $this->assertEquals('secondone', $contribution['values'][1]['trxn_id']); } @@ -97,14 +100,24 @@ class CRM_Core_Payment_PayPalProIPNTest extends CiviUnitTestCase { $paypalIPN = new CRM_Core_Payment_PaypalProIPN($this->getPaypalProRecurSubsequentTransaction()); $paypalIPN->main(); $this->assertEquals(strtotime('+ 1 year', strtotime($membershipEndDate)), strtotime($this->callAPISuccessGetValue('membership', array('return' => 'end_date')))); - $contribution = $this->callAPISuccess('contribution', 'get', array('contribution_recur_id' => $this->_contributionRecurID, 'sequential' => 1)); + $contribution = $this->callAPISuccess('contribution', 'get', array( + 'contribution_recur_id' => $this->_contributionRecurID, + 'sequential' => 1 + )); $this->assertEquals(2, $contribution['count']); $this->assertEquals('secondone', $contribution['values'][1]['trxn_id']); - $this->callAPISuccessGetCount('line_item', array('entity_id' => $this->ids['membership'], 'entity_table' => 'civicrm_membership'), 2); - $this->callAPISuccessGetSingle('line_item', array('contribution_id' => $contribution['values'][1]['id'], 'entity_table' => 'civicrm_membership')); + $this->callAPISuccessGetCount('line_item', array( + 'entity_id' => $this->ids['membership'], + 'entity_table' => 'civicrm_membership' + ), 2); + $this->callAPISuccessGetSingle('line_item', array( + 'contribution_id' => $contribution['values'][1]['id'], + 'entity_table' => 'civicrm_membership' + )); $this->callAPISuccessGetSingle('membership_payment', array('contribution_id' => $contribution['values'][1]['id'])); } + /** * CRM-13743 test IPN edge case where the first transaction fails and the second succeeds * We are checking that the created contribution has the same date as IPN says it should @@ -126,7 +139,10 @@ class CRM_Core_Payment_PayPalProIPNTest extends CiviUnitTestCase { $this->assertEquals(2, $contributionRecur['contribution_status_id']); $paypalIPN = new CRM_Core_Payment_PayPalProIPN($this->getPaypalProRecurSubsequentTransaction()); $paypalIPN->main(); - $contribution = $this->callAPISuccess('contribution', 'get', array('contribution_recur_id' => $this->_contributionRecurID, 'sequential' => 1)); + $contribution = $this->callAPISuccess('contribution', 'get', array( + 'contribution_recur_id' => $this->_contributionRecurID, + 'sequential' => 1 + )); $this->assertEquals(1, $contribution['count']); $this->assertEquals('secondone', $contribution['values'][0]['trxn_id']); $this->assertEquals(strtotime('03:59:05 Jul 14, 2013 PDT'), strtotime($contribution['values'][0]['receive_date'])); @@ -136,7 +152,6 @@ class CRM_Core_Payment_PayPalProIPNTest extends CiviUnitTestCase { * Check a payment express IPN call does not throw any errors * At this stage nothing it supposed to happen so it's a pretty blunt test * but at least it should be e-notice free - * The browser interaction will update Paypal express payments * The ipn code redirects POSTs to paypal pro & GETs to paypal std but the * documentation (https://www.paypalobjects.com/webstatic/en_US/developer/docs/pdf/ipnguide.pdf) @@ -156,7 +171,7 @@ class CRM_Core_Payment_PayPalProIPNTest extends CiviUnitTestCase { try { $paypalIPN->main(); } - catch(CRM_Core_Exception $e) { + catch (CRM_Core_Exception $e) { $contribution = $this->callAPISuccess('contribution', 'getsingle', array('id' => $this->_contributionID)); // no change $this->assertEquals(2, $contribution['contribution_status_id']); @@ -274,6 +289,7 @@ class CRM_Core_Payment_PayPalProIPNTest extends CiviUnitTestCase { 'ipn_track_id' => '912e5010eb5a6', ); } + /** */ public function getPaypalProRecurTransaction() { @@ -306,7 +322,7 @@ class CRM_Core_Payment_PayPalProIPNTest extends CiviUnitTestCase { 'mc_gross' => '15.00', 'payment_date' => '03:59:05 Jul 14, 2013 PDT', 'rp_invoice_id' => 'i=' . $this->_invoiceID - . '&m=contribute&c=' + . '&m=contribute&c=' . $this->_contactID . '&r=' . $this->_contributionRecurID . '&b=' . $this->_contributionID . '&p=' . $this->_contributionPageID, diff --git a/tests/phpunit/CRM/Core/PseudoConstantTest.php b/tests/phpunit/CRM/Core/PseudoConstantTest.php index 03b4b26117..eee51b14b7 100644 --- a/tests/phpunit/CRM/Core/PseudoConstantTest.php +++ b/tests/phpunit/CRM/Core/PseudoConstantTest.php @@ -64,12 +64,14 @@ class CRM_Core_PseudoConstantTest extends CiviUnitTestCase { 'html_type' => 'Select', 'data_type' => 'String', 'is_active' => TRUE, - 'option_values' => array(array( - 'label' => 'Foo', - 'value' => 'foo', - 'is_active' => 1, - 'weight' => 0, - )), + 'option_values' => array( + array( + 'label' => 'Foo', + 'value' => 'foo', + 'is_active' => 1, + 'weight' => 0, + ) + ), ); $result = civicrm_api3('custom_field', 'create', $api_params); $customFieldId = $result['id']; @@ -524,7 +526,7 @@ class CRM_Core_PseudoConstantTest extends CiviUnitTestCase { 'sample' => $campaign_name, ), ), - 'CRM_Pledge_DAO_PledgePayment' => array( + 'CRM_Pledge_DAO_PledgePayment' => array( array( 'fieldName' => 'currency', 'sample' => array('USD' => 'US Dollar'), @@ -1085,10 +1087,17 @@ class CRM_Core_PseudoConstantTest extends CiviUnitTestCase { $result = CRM_Contact_DAO_Contact::buildOptions('contact_type'); $this->assertEquals($byName, $result); // But we can also fetch by ID - $result = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'contact_type', array('keyColumn' => 'id', 'labelColumn' => 'name')); + $result = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'contact_type', array( + 'keyColumn' => 'id', + 'labelColumn' => 'name' + )); $this->assertEquals($byId, $result); // Make sure flip param works - $result = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'contact_type', array('keyColumn' => 'id', 'labelColumn' => 'name', 'flip' => TRUE)); + $result = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'contact_type', array( + 'keyColumn' => 'id', + 'labelColumn' => 'name', + 'flip' => TRUE + )); $this->assertEquals(array_flip($byId), $result); } } diff --git a/tests/phpunit/CRM/Core/RegionTest.php b/tests/phpunit/CRM/Core/RegionTest.php index 10e54f9c44..297b63aee1 100644 --- a/tests/phpunit/CRM/Core/RegionTest.php +++ b/tests/phpunit/CRM/Core/RegionTest.php @@ -43,7 +43,7 @@ class CRM_Core_RegionTest extends CiviUnitTestCase { */ public function testOverride() { CRM_Core_Region::instance('testOverride')->update('default', array( - 'disabled' => TRUE, + 'disabled' => TRUE, )); CRM_Core_Region::instance('testOverride')->add(array( 'markup' => 'override
', diff --git a/tests/phpunit/CRM/Core/ResourcesTest.php b/tests/phpunit/CRM/Core/ResourcesTest.php index 177302cd0d..6e9da350d3 100644 --- a/tests/phpunit/CRM/Core/ResourcesTest.php +++ b/tests/phpunit/CRM/Core/ResourcesTest.php @@ -59,7 +59,7 @@ class CRM_Core_ResourcesTest extends CiviUnitTestCase { public function testAddScriptFile() { $this->res ->addScriptFile('com.example.ext', 'foo%20bar.js', 0, 'testAddScriptFile') - ->addScriptFile('com.example.ext', 'foo%20bar.js', 0, 'testAddScriptFile') // extra + ->addScriptFile('com.example.ext', 'foo%20bar.js', 0, 'testAddScriptFile')// extra ->addScriptFile('civicrm', 'foo%20bar.js', 0, 'testAddScriptFile'); $smarty = CRM_Core_Smarty::singleton(); @@ -75,19 +75,19 @@ class CRM_Core_ResourcesTest extends CiviUnitTestCase { * * FIXME: This can't work because the tests run in English and CRM_Core_Resources optimizes * away the English data from $settings['strings'] - public function testAddScriptFile_strings() { - file_put_contents($this->mapper->keyToBasePath('com.example.ext') . '/hello.js', 'alert(ts("Hello world"));'); - $this->res->addScriptFile('com.example.ext', 'hello.js', 0, 'testAddScriptFile_strings'); - $settings = $this->res->getSettings(); - $expected = array('Hello world'); - $this->assertEquals($expected, $settings['strings']); - } + * public function testAddScriptFile_strings() { + * file_put_contents($this->mapper->keyToBasePath('com.example.ext') . '/hello.js', 'alert(ts("Hello world"));'); + * $this->res->addScriptFile('com.example.ext', 'hello.js', 0, 'testAddScriptFile_strings'); + * $settings = $this->res->getSettings(); + * $expected = array('Hello world'); + * $this->assertEquals($expected, $settings['strings']); + * } */ public function testAddScriptURL() { $this->res ->addScriptUrl('/whiz/foo%20bar.js', 0, 'testAddScriptURL') - ->addScriptUrl('/whiz/foo%20bar.js', 0, 'testAddScriptURL') // extra + ->addScriptUrl('/whiz/foo%20bar.js', 0, 'testAddScriptURL')// extra ->addScriptUrl('/whizbang/foo%20bar.js', 0, 'testAddScriptURL'); $smarty = CRM_Core_Smarty::singleton(); @@ -116,7 +116,17 @@ class CRM_Core_ResourcesTest extends CiviUnitTestCase { ->addVars('food', array('fruit' => array('mine' => 'apple', 'ours' => 'banana'))) ->addVars('food', array('fruit' => array('mine' => 'new apple', 'yours' => 'orange'))); $this->assertTreeEquals( - array('vars' => array('food' => array('fruit' => array('yours' => 'orange', 'mine' => 'new apple', 'ours' => 'banana')))), + array( + 'vars' => array( + 'food' => array( + 'fruit' => array( + 'yours' => 'orange', + 'mine' => 'new apple', + 'ours' => 'banana' + ) + ) + ) + ), $this->res->getSettings() ); } @@ -135,10 +145,10 @@ class CRM_Core_ResourcesTest extends CiviUnitTestCase { } public function testAddSettingFactory() { - $this->res->addSettingsFactory(function() { + $this->res->addSettingsFactory(function () { return array('fruit' => array('yours' => 'orange')); }); - $this->res->addSettingsFactory(function() { + $this->res->addSettingsFactory(function () { return array('fruit' => array('mine' => 'apple')); }); @@ -151,7 +161,7 @@ class CRM_Core_ResourcesTest extends CiviUnitTestCase { $this->res->addSetting(array('fruit' => array('mine' => 'apple'))); $muckableValue = array('fruit' => array('yours' => 'orange', 'theirs' => 'apricot')); - $this->res->addSettingsFactory(function() use (&$muckableValue) { + $this->res->addSettingsFactory(function () use (&$muckableValue) { return $muckableValue; }); $actual = $this->res->getSettings(); @@ -185,7 +195,7 @@ class CRM_Core_ResourcesTest extends CiviUnitTestCase { public function testAddStyleFile() { $this->res ->addStyleFile('com.example.ext', 'foo%20bar.css', 0, 'testAddStyleFile') - ->addStyleFile('com.example.ext', 'foo%20bar.css', 0, 'testAddStyleFile') // extra + ->addStyleFile('com.example.ext', 'foo%20bar.css', 0, 'testAddStyleFile')// extra ->addStyleFile('civicrm', 'foo%20bar.css', 0, 'testAddStyleFile'); $smarty = CRM_Core_Smarty::singleton(); @@ -199,7 +209,7 @@ class CRM_Core_ResourcesTest extends CiviUnitTestCase { public function testAddStyleURL() { $this->res ->addStyleUrl('/whiz/foo%20bar.css', 0, 'testAddStyleURL') - ->addStyleUrl('/whiz/foo%20bar.css', 0, 'testAddStyleURL') // extra + ->addStyleUrl('/whiz/foo%20bar.css', 0, 'testAddStyleURL')// extra ->addStyleUrl('/whizbang/foo%20bar.css', 0, 'testAddStyleURL'); $smarty = CRM_Core_Smarty::singleton(); diff --git a/tests/phpunit/CRM/Core/Smarty/plugins/CrmScopeTest.php b/tests/phpunit/CRM/Core/Smarty/plugins/CrmScopeTest.php index d5255c8d2a..379ae8961c 100644 --- a/tests/phpunit/CRM/Core/Smarty/plugins/CrmScopeTest.php +++ b/tests/phpunit/CRM/Core/Smarty/plugins/CrmScopeTest.php @@ -26,9 +26,15 @@ class CRM_Core_Smarty_plugins_CrmScopeTest extends CiviUnitTestCase { $cases[] = array('x=1', '{crmScope x=1}x={$x}{/crmScope}'); $cases[] = array('x=1', '{$x}{crmScope x=1}x={$x}{/crmScope}{$x}'); $cases[] = array('x=1 x=2 x=1', '{crmScope x=1}x={$x} {crmScope x=2}x={$x}{/crmScope} x={$x}{/crmScope}'); - $cases[] = array('x=1 x=2 x=3 x=2 x=1', '{crmScope x=1}x={$x} {crmScope x=2}x={$x} {crmScope x=3}x={$x}{/crmScope} x={$x}{/crmScope} x={$x}{/crmScope}'); + $cases[] = array( + 'x=1 x=2 x=3 x=2 x=1', + '{crmScope x=1}x={$x} {crmScope x=2}x={$x} {crmScope x=3}x={$x}{/crmScope} x={$x}{/crmScope} x={$x}{/crmScope}' + ); $cases[] = array('x=1,y=9', '{crmScope x=1 y=9}x={$x},y={$y}{/crmScope}'); - $cases[] = array('x=1,y=9 x=1,y=8 x=1,y=9', '{crmScope x=1 y=9}x={$x},y={$y} {crmScope y=8}x={$x},y={$y}{/crmScope} x={$x},y={$y}{/crmScope}'); + $cases[] = array( + 'x=1,y=9 x=1,y=8 x=1,y=9', + '{crmScope x=1 y=9}x={$x},y={$y} {crmScope y=8}x={$x},y={$y}{/crmScope} x={$x},y={$y}{/crmScope}' + ); $cases[] = array('x=', 'x={$x}'); return $cases; } diff --git a/tests/phpunit/CRM/Core/TransactionTest.php b/tests/phpunit/CRM/Core/TransactionTest.php index 3154919c13..ee1a551180 100644 --- a/tests/phpunit/CRM/Core/TransactionTest.php +++ b/tests/phpunit/CRM/Core/TransactionTest.php @@ -202,10 +202,22 @@ class CRM_Core_TransactionTest extends CiviUnitTestCase { public function testCallback_commit() { $tx = new CRM_Core_Transaction(); - CRM_Core_Transaction::addCallback(CRM_Core_Transaction::PHASE_PRE_COMMIT, array($this, '_preCommit'), array('qwe', 'rty')); - CRM_Core_Transaction::addCallback(CRM_Core_Transaction::PHASE_POST_COMMIT, array($this, '_postCommit'), array('uio', 'p[]')); - CRM_Core_Transaction::addCallback(CRM_Core_Transaction::PHASE_PRE_ROLLBACK, array($this, '_preRollback'), array('asd', 'fgh')); - CRM_Core_Transaction::addCallback(CRM_Core_Transaction::PHASE_POST_ROLLBACK, array($this, '_postRollback'), array('jkl', ';')); + CRM_Core_Transaction::addCallback(CRM_Core_Transaction::PHASE_PRE_COMMIT, array($this, '_preCommit'), array( + 'qwe', + 'rty' + )); + CRM_Core_Transaction::addCallback(CRM_Core_Transaction::PHASE_POST_COMMIT, array($this, '_postCommit'), array( + 'uio', + 'p[]' + )); + CRM_Core_Transaction::addCallback(CRM_Core_Transaction::PHASE_PRE_ROLLBACK, array( + $this, + '_preRollback' + ), array('asd', 'fgh')); + CRM_Core_Transaction::addCallback(CRM_Core_Transaction::PHASE_POST_ROLLBACK, array( + $this, + '_postRollback' + ), array('jkl', ';')); CRM_Core_DAO::executeQuery('UPDATE civicrm_contact SET id = 100 WHERE id = 100'); @@ -218,10 +230,22 @@ class CRM_Core_TransactionTest extends CiviUnitTestCase { public function testCallback_rollback() { $tx = new CRM_Core_Transaction(); - CRM_Core_Transaction::addCallback(CRM_Core_Transaction::PHASE_PRE_COMMIT, array($this, '_preCommit'), array('ewq', 'ytr')); - CRM_Core_Transaction::addCallback(CRM_Core_Transaction::PHASE_POST_COMMIT, array($this, '_postCommit'), array('oiu', '][p')); - CRM_Core_Transaction::addCallback(CRM_Core_Transaction::PHASE_PRE_ROLLBACK, array($this, '_preRollback'), array('dsa', 'hgf')); - CRM_Core_Transaction::addCallback(CRM_Core_Transaction::PHASE_POST_ROLLBACK, array($this, '_postRollback'), array('lkj', ';')); + CRM_Core_Transaction::addCallback(CRM_Core_Transaction::PHASE_PRE_COMMIT, array($this, '_preCommit'), array( + 'ewq', + 'ytr' + )); + CRM_Core_Transaction::addCallback(CRM_Core_Transaction::PHASE_POST_COMMIT, array($this, '_postCommit'), array( + 'oiu', + '][p' + )); + CRM_Core_Transaction::addCallback(CRM_Core_Transaction::PHASE_PRE_ROLLBACK, array( + $this, + '_preRollback' + ), array('dsa', 'hgf')); + CRM_Core_Transaction::addCallback(CRM_Core_Transaction::PHASE_POST_ROLLBACK, array( + $this, + '_postRollback' + ), array('lkj', ';')); CRM_Core_DAO::executeQuery('UPDATE civicrm_contact SET id = 100 WHERE id = 100'); $tx->rollback(); @@ -241,7 +265,7 @@ class CRM_Core_TransactionTest extends CiviUnitTestCase { */ public function testRun_ok($createStyle, $commitStyle) { $test = $this; - CRM_Core_Transaction::create(TRUE)->run(function($tx) use (&$test, $createStyle, $commitStyle) { + CRM_Core_Transaction::create(TRUE)->run(function ($tx) use (&$test, $createStyle, $commitStyle) { $test->createContactWithTransaction('nest-tx', $createStyle, $commitStyle); $test->assertContactsExistByOffset(array(0 => TRUE)); }); @@ -260,7 +284,7 @@ class CRM_Core_TransactionTest extends CiviUnitTestCase { $test = $this; $e = NULL; // Exception try { - CRM_Core_Transaction::create(TRUE)->run(function($tx) use (&$test, $createStyle, $commitStyle) { + CRM_Core_Transaction::create(TRUE)->run(function ($tx) use (&$test, $createStyle, $commitStyle) { $test->createContactWithTransaction('nest-tx', $createStyle, $commitStyle); $test->assertContactsExistByOffset(array(0 => TRUE)); throw new Exception("Ruh-roh"); diff --git a/tests/phpunit/CRM/Dedupe/DedupeFinderTest.php b/tests/phpunit/CRM/Dedupe/DedupeFinderTest.php index 7c6928507f..adc82e3ac7 100644 --- a/tests/phpunit/CRM/Dedupe/DedupeFinderTest.php +++ b/tests/phpunit/CRM/Dedupe/DedupeFinderTest.php @@ -96,10 +96,10 @@ class CRM_Dedupe_DedupeFinderTest extends CiviUnitTestCase { // verify that all contacts have been created separately $this->assertEquals(count($contactIds), 7, 'Check for number of contacts.'); - $dao = new CRM_Dedupe_DAO_RuleGroup(); + $dao = new CRM_Dedupe_DAO_RuleGroup(); $dao->contact_type = 'Individual'; - $dao->level = 'Fuzzy'; - $dao->is_default = 1; + $dao->level = 'Fuzzy'; + $dao->is_default = 1; $dao->find(TRUE); $foundDupes = CRM_Dedupe_Finder::dupesInGroup($dao->id, $groupId); @@ -198,10 +198,10 @@ class CRM_Dedupe_DedupeFinderTest extends CiviUnitTestCase { // verify that all contacts have been created separately $this->assertEquals(count($contactIds), 7, 'Check for number of contacts.'); - $dao = new CRM_Dedupe_DAO_RuleGroup(); + $dao = new CRM_Dedupe_DAO_RuleGroup(); $dao->contact_type = 'Individual'; - $dao->used = 'General'; - $dao->is_default = 1; + $dao->used = 'General'; + $dao->is_default = 1; $dao->find(TRUE); $fields = array( diff --git a/tests/phpunit/CRM/Event/BAO/AdditionalPaymentTest.php b/tests/phpunit/CRM/Event/BAO/AdditionalPaymentTest.php index ac858e4575..0b2efc55e7 100644 --- a/tests/phpunit/CRM/Event/BAO/AdditionalPaymentTest.php +++ b/tests/phpunit/CRM/Event/BAO/AdditionalPaymentTest.php @@ -26,7 +26,6 @@ */ - require_once 'CiviTest/CiviUnitTestCase.php'; require_once 'CiviTest/Contact.php'; require_once 'CiviTest/Event.php'; @@ -148,7 +147,10 @@ class CRM_Event_BAO_AdditionalPaymentTest extends CiviUnitTestCase { $participant = $this->callAPISuccessGetSingle('participant', array('id' => $participant['id'])); // add participant payment entry - $this->callAPISuccess('participant_payment', 'create', array('participant_id' => $participant['id'], 'contribution_id' => $contributionId)); + $this->callAPISuccess('participant_payment', 'create', array( + 'participant_id' => $participant['id'], + 'contribution_id' => $contributionId + )); // -- processing priceSet using the BAO $lineItem = array(); diff --git a/tests/phpunit/CRM/Event/BAO/ParticipantStatusTest.php b/tests/phpunit/CRM/Event/BAO/ParticipantStatusTest.php index 3b83fba3a7..ceb4991a93 100644 --- a/tests/phpunit/CRM/Event/BAO/ParticipantStatusTest.php +++ b/tests/phpunit/CRM/Event/BAO/ParticipantStatusTest.php @@ -134,8 +134,8 @@ class CRM_Event_BAO_ParticipantStatusTest extends CiviUnitTestCase { $statusType = CRM_Event_BAO_ParticipantStatusType::create($params); // retrieve status type - $retrieveParams = array('id' => $statusType->id); - $default = array(); + $retrieveParams = array('id' => $statusType->id); + $default = array(); $retrieveStatusType = CRM_Event_BAO_ParticipantStatusType::retrieve($retrieveParams, $default); // check on retrieve values diff --git a/tests/phpunit/CRM/Event/BAO/ParticipantTest.php b/tests/phpunit/CRM/Event/BAO/ParticipantTest.php index 2f046b8a99..c0666a8f23 100644 --- a/tests/phpunit/CRM/Event/BAO/ParticipantTest.php +++ b/tests/phpunit/CRM/Event/BAO/ParticipantTest.php @@ -26,7 +26,6 @@ */ - require_once 'CiviTest/CiviUnitTestCase.php'; require_once 'CiviTest/Contact.php'; require_once 'CiviTest/Event.php'; @@ -71,10 +70,10 @@ class CRM_Event_BAO_ParticipantTest extends CiviUnitTestCase { ); $params = array_merge($params, array( - 'id' => $participant->id, - 'role_id' => 2, - 'status_id' => 3, - )); + 'id' => $participant->id, + 'role_id' => 2, + 'status_id' => 3, + )); // Participant Edited $updatedParticipant = CRM_Event_BAO_Participant::add($params); @@ -138,8 +137,8 @@ class CRM_Event_BAO_ParticipantTest extends CiviUnitTestCase { * GetValues() method (checking for behavior when params are empty ) */ public function testgetValuesWithoutValidParams() { - $params = $values = $ids = array(); - $participantId = Participant::create($this->_contactId, $this->_eventId); + $params = $values = $ids = array(); + $participantId = Participant::create($this->_contactId, $this->_eventId); $fetchParticipant = CRM_Event_BAO_Participant::getValues($params, $values, $ids); $this->assertNull($fetchParticipant, 'In line ' . __LINE__); @@ -290,10 +289,10 @@ class CRM_Event_BAO_ParticipantTest extends CiviUnitTestCase { $params = array_merge($params, array( 'id' => $participant->id, - 'role_id' => 2, - 'status_id' => 3, - 'note' => 'Test Event in edit mode is running successfully ....', - )); + 'role_id' => 2, + 'status_id' => 3, + 'note' => 'Test Event in edit mode is running successfully ....', + )); $participant = CRM_Event_BAO_Participant::create($params); @@ -404,7 +403,7 @@ class CRM_Event_BAO_ParticipantTest extends CiviUnitTestCase { ); $values = array(); - $ids = array(); + $ids = array(); $params = array('id' => $participant->id); CRM_Event_BAO_Participant::getValues($params, $values, $ids); diff --git a/tests/phpunit/CRM/Extension/Container/CollectionTest.php b/tests/phpunit/CRM/Extension/Container/CollectionTest.php index df7fe8765e..06b7774b6c 100644 --- a/tests/phpunit/CRM/Extension/Container/CollectionTest.php +++ b/tests/phpunit/CRM/Extension/Container/CollectionTest.php @@ -34,6 +34,7 @@ class CRM_Extension_Container_CollectionTest extends CiviUnitTestCase { // WARNING - NEVER COPY & PASTE $_eNoticeCompliant = FALSE // new test classes should be compliant. public $_eNoticeCompliant = FALSE; + public function setUp() { parent::setUp(); } @@ -49,7 +50,13 @@ class CRM_Extension_Container_CollectionTest extends CiviUnitTestCase { public function testGetKeys() { $c = $this->_createContainer(); - $this->assertEquals(array('test.conflict', 'test.whiz', 'test.whizbang', 'test.foo', 'test.foo.bar'), $c->getKeys()); + $this->assertEquals(array( + 'test.conflict', + 'test.whiz', + 'test.whizbang', + 'test.foo', + 'test.foo.bar' + ), $c->getKeys()); } public function testGetPath() { @@ -136,7 +143,7 @@ class CRM_Extension_Container_CollectionTest extends CiviUnitTestCase { 'resUrl' => 'http://conflict-c', ), )); - $c = new CRM_Extension_Container_Collection($containers, $cache, $cacheKey); + $c = new CRM_Extension_Container_Collection($containers, $cache, $cacheKey); return $c; } } diff --git a/tests/phpunit/CRM/Extension/Manager/ModuleTest.php b/tests/phpunit/CRM/Extension/Manager/ModuleTest.php index af009037d9..5da444ac6e 100644 --- a/tests/phpunit/CRM/Extension/Manager/ModuleTest.php +++ b/tests/phpunit/CRM/Extension/Manager/ModuleTest.php @@ -10,6 +10,7 @@ class CRM_Extension_Manager_ModuleTest extends CiviUnitTestCase { // WARNING - NEVER COPY & PASTE $_eNoticeCompliant = FALSE // new test classes should be compliant. public $_eNoticeCompliant = FALSE; + public function setUp() { parent::setUp(); // $query = "INSERT INTO civicrm_domain ( name, version ) VALUES ( 'domain', 3 )"; @@ -227,7 +228,7 @@ class CRM_Extension_Manager_ModuleTest extends CiviUnitTestCase { foreach ($counts as $key => $expected) { $actual = @$_test_extension_manager_moduletest_counts[$module][$key]; $this->assertEquals($expected, $actual, - sprintf('Expected %d call(s) to hook_civicrm_%s -- found %d', $expected, $key, $actual) + sprintf('Expected %d call(s) to hook_civicrm_%s -- found %d', $expected, $key, $actual) ); } } diff --git a/tests/phpunit/CRM/Extension/Manager/PaymentTest.php b/tests/phpunit/CRM/Extension/Manager/PaymentTest.php index 1f17bd02c4..7ee82cddc3 100644 --- a/tests/phpunit/CRM/Extension/Manager/PaymentTest.php +++ b/tests/phpunit/CRM/Extension/Manager/PaymentTest.php @@ -34,6 +34,7 @@ class CRM_Extension_Manager_PaymentTest extends CiviUnitTestCase { // WARNING - NEVER COPY & PASTE $_eNoticeCompliant = FALSE // new test classes should be compliant. public $_eNoticeCompliant = FALSE; + public function setUp() { parent::setUp(); if (class_exists('test_extension_manager_paymenttest')) { @@ -94,6 +95,7 @@ class CRM_Extension_Manager_PaymentTest extends CiviUnitTestCase { $this->assertDBQuery(1, 'SELECT count(*) FROM civicrm_payment_processor_type WHERE class_name = "test.extension.manager.paymenttest"'); $this->assertDBQuery(1, 'SELECT count(*) FROM civicrm_payment_processor_type WHERE class_name = "test.extension.manager.paymenttest" AND is_active = 1'); } + /** * Install an extension and create a payment processor which uses it. * Attempts to uninstall fail diff --git a/tests/phpunit/CRM/Extension/ManagerTest.php b/tests/phpunit/CRM/Extension/ManagerTest.php index 00070ee907..1c76340863 100644 --- a/tests/phpunit/CRM/Extension/ManagerTest.php +++ b/tests/phpunit/CRM/Extension/ManagerTest.php @@ -275,10 +275,10 @@ class CRM_Extension_ManagerTest extends CiviUnitTestCase { $this->download = $this->_createDownload('test.newextension', 'newextension'); $testingTypeManager - ->expects($this->never()) // no data to replace + ->expects($this->never())// no data to replace ->method('onPreReplace'); $testingTypeManager - ->expects($this->never()) // no data to replace + ->expects($this->never())// no data to replace ->method('onPostReplace'); $manager->replace($this->download); $this->assertEquals('uninstalled', $manager->getStatus('test.newextension')); @@ -302,10 +302,10 @@ class CRM_Extension_ManagerTest extends CiviUnitTestCase { $this->download = $this->_createDownload('test.whiz.bang', 'newextension'); $testingTypeManager - ->expects($this->never()) // no data to replace + ->expects($this->never())// no data to replace ->method('onPreReplace'); $testingTypeManager - ->expects($this->never()) // no data to replace + ->expects($this->never())// no data to replace ->method('onPostReplace'); $manager->replace($this->download); $this->assertEquals('uninstalled', $manager->getStatus('test.whiz.bang')); diff --git a/tests/phpunit/CRM/Financial/BAO/FinancialItemTest.php b/tests/phpunit/CRM/Financial/BAO/FinancialItemTest.php index 6c63954a6b..f917dec769 100755 --- a/tests/phpunit/CRM/Financial/BAO/FinancialItemTest.php +++ b/tests/phpunit/CRM/Financial/BAO/FinancialItemTest.php @@ -42,8 +42,8 @@ class CRM_Financial_BAO_FinancialItemTest extends CiviUnitTestCase { */ public function testAdd() { $firstName = 'Shane'; - $lastName = 'Whatson'; - $params = array( + $lastName = 'Whatson'; + $params = array( 'first_name' => $firstName, 'last_name' => $lastName, 'contact_type' => 'Individual', @@ -56,8 +56,8 @@ class CRM_Financial_BAO_FinancialItemTest extends CiviUnitTestCase { 'contact_id' => $contact->id, 'total_amount' => $price, 'financial_type_id' => 1, - 'is_active' => 1, - 'skipLineItem' => 1, + 'is_active' => 1, + 'skipLineItem' => 1, ); $defaults = array(); @@ -91,8 +91,8 @@ class CRM_Financial_BAO_FinancialItemTest extends CiviUnitTestCase { */ public function testRetrieve() { $firstName = 'Shane'; - $lastName = 'Whatson'; - $params = array( + $lastName = 'Whatson'; + $params = array( 'first_name' => $firstName, 'last_name' => $lastName, 'contact_type' => 'Individual', @@ -104,8 +104,8 @@ class CRM_Financial_BAO_FinancialItemTest extends CiviUnitTestCase { 'contact_id' => $contact->id, 'total_amount' => $price, 'financial_type_id' => 1, - 'is_active' => 1, - 'skipLineItem' => 1, + 'is_active' => 1, + 'skipLineItem' => 1, ); $defaults = array(); @@ -138,8 +138,8 @@ class CRM_Financial_BAO_FinancialItemTest extends CiviUnitTestCase { */ public function testCreate() { $firstName = 'Shane'; - $lastName = 'Whatson'; - $params = array( + $lastName = 'Whatson'; + $params = array( 'first_name' => $firstName, 'last_name' => $lastName, 'contact_type' => 'Individual', @@ -151,8 +151,8 @@ class CRM_Financial_BAO_FinancialItemTest extends CiviUnitTestCase { 'contact_id' => $contact->id, 'total_amount' => $price, 'financial_type_id' => 1, - 'is_active' => 1, - 'skipLineItem' => 1, + 'is_active' => 1, + 'skipLineItem' => 1, ); $defaults = array(); diff --git a/tests/phpunit/CRM/Group/Page/AjaxTest.php b/tests/phpunit/CRM/Group/Page/AjaxTest.php index 91348ff92b..0aa6e64bb7 100644 --- a/tests/phpunit/CRM/Group/Page/AjaxTest.php +++ b/tests/phpunit/CRM/Group/Page/AjaxTest.php @@ -34,8 +34,16 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { ); $this->hookClass = CRM_Utils_Hook::singleton(); $this->createLoggedInUser(); - $this->_permissionedDisabledGroup = $this->groupCreate(array('title' => 'pick-me-disabled', 'is_active' => 0, 'name' => 'pick-me-disabled')); - $this->_permissionedGroup = $this->groupCreate(array('title' => 'pick-me-active', 'is_active' => 1, 'name' => 'pick-me-active')); + $this->_permissionedDisabledGroup = $this->groupCreate(array( + 'title' => 'pick-me-disabled', + 'is_active' => 0, + 'name' => 'pick-me-disabled' + )); + $this->_permissionedGroup = $this->groupCreate(array( + 'title' => 'pick-me-active', + 'is_active' => 1, + 'name' => 'pick-me-active' + )); $this->groupCreate(array('title' => 'not-me-disabled', 'is_active' => 0, 'name' => 'not-me-disabled')); $this->groupCreate(array('title' => 'not-me-active', 'is_active' => 1, 'name' => 'not-me-active')); } @@ -69,6 +77,7 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { global $_REQUEST; $_REQUEST = $this->_params; } + /** * Retrieve groups as 'view all contacts' */ @@ -103,6 +112,7 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { list($groups, $total) = CRM_Group_Page_AJAX::getGroupList(); $this->assertEquals(0, $total); } + /** * Retrieve groups as 'edit all contacts' */ @@ -188,6 +198,7 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { $this->assertEquals(0, count($groups)); $this->assertEquals(0, $total, 'Total returned should be accurate based on permissions'); } + /** * Retrieve groups as 'view all contacts' */ @@ -198,6 +209,7 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { $this->assertEquals(0, count($groups)); $this->assertEquals(0, $total, 'Total returned should be accurate based on permissions'); } + /** * Retrieve groups as 'view all contacts' */ @@ -242,7 +254,7 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { $this->assertEquals(0, $total, 'Total returned should be accurate based on permissions'); } - public function testTraditionalACL () { + public function testTraditionalACL() { $this->setupACL(); list($groups, $total) = CRM_Group_Page_AJAX::getGroupList(); $this->assertEquals(1, count($groups), 'Returned groups should exclude disabled by default'); @@ -250,7 +262,7 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { $this->assertEquals('pick-me-active', $groups[2]['group_name']); } - public function testTraditionalACLNotFoundTitle () { + public function testTraditionalACLNotFoundTitle() { $this->_params['title'] = 'n'; $this->setupACL(); list($groups, $total) = CRM_Group_Page_AJAX::getGroupList(); @@ -258,7 +270,7 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { $this->assertEquals(0, $total, 'Total needs to be set correctly'); } - public function testTraditionalACLFoundTitle () { + public function testTraditionalACLFoundTitle() { $this->_params['title'] = 'p'; $this->setupACL(); list($groups, $total) = CRM_Group_Page_AJAX::getGroupList(); @@ -268,7 +280,7 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { $this->assertEquals('pick-me-disabled', $groups[1]['group_name']); } - public function testTraditionalACLDisabled () { + public function testTraditionalACLDisabled() { $this->_params['status'] = 2; $this->setupACL(); list($groups, $total) = CRM_Group_Page_AJAX::getGroupList(); @@ -277,7 +289,7 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { $this->assertEquals('pick-me-disabled', $groups[1]['group_name']); } - public function testTraditionalACLDisabledFoundTitle () { + public function testTraditionalACLDisabledFoundTitle() { $this->_params['status'] = 2; $this->_params['title'] = 'p'; $this->setupACL(); @@ -287,7 +299,7 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { $this->assertEquals('pick-me-disabled', $groups[1]['group_name']); } - public function testTraditionalACLDisabledNotFoundTitle () { + public function testTraditionalACLDisabledNotFoundTitle() { $this->_params['status'] = 2; $this->_params['title'] = 'n'; $this->setupACL(); @@ -296,7 +308,7 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { $this->assertEquals(0, $total, 'Total needs to be set correctly'); } - public function testTraditionalACLEnabled () { + public function testTraditionalACLEnabled() { $this->_params['status'] = 1; $this->setupACL(); list($groups, $total) = CRM_Group_Page_AJAX::getGroupList(); @@ -305,7 +317,7 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { $this->assertEquals('pick-me-active', $groups[2]['group_name']); } - public function testTraditionalACLAll () { + public function testTraditionalACLAll() { $this->_params['status'] = 3; $this->setupACL(); list($groups, $total) = CRM_Group_Page_AJAX::getGroupList(); diff --git a/tests/phpunit/CRM/Mailing/BAO/QueryTest.php b/tests/phpunit/CRM/Mailing/BAO/QueryTest.php index d79e9d22e1..488aff6aa5 100644 --- a/tests/phpunit/CRM/Mailing/BAO/QueryTest.php +++ b/tests/phpunit/CRM/Mailing/BAO/QueryTest.php @@ -49,12 +49,12 @@ class CRM_Mailing_BAO_QueryTest extends CiviUnitTestCase { ); $params = CRM_Contact_BAO_Query::convertFormValues($fv); - $obj = new CRM_Contact_BAO_Query($params); + $obj = new CRM_Contact_BAO_Query($params); // let's set useGroupBy=true, to prevent duplicate records $obj->_useGroupBy = TRUE; - $dao = $obj->searchQuery(); + $dao = $obj->searchQuery(); $contacts = array(); while ($dao->fetch()) { diff --git a/tests/phpunit/CRM/Mailing/BAO/QueryTestDataProvider.php b/tests/phpunit/CRM/Mailing/BAO/QueryTestDataProvider.php index ee809168f8..0a26e40e63 100644 --- a/tests/phpunit/CRM/Mailing/BAO/QueryTestDataProvider.php +++ b/tests/phpunit/CRM/Mailing/BAO/QueryTestDataProvider.php @@ -1,4 +1,5 @@ array('mailing_name' => 'First%', 'mailing_open_status' => 'Y'), + 'fv' => array('mailing_name' => 'First%', 'mailing_open_status' => 'Y'), 'id' => array(109, 110, 111, 112), ), array( - 'fv' => array('mailing_name' => 'First%', 'mailing_open_status' => 'N'), + 'fv' => array('mailing_name' => 'First%', 'mailing_open_status' => 'N'), 'id' => array(102, 103, 104, 105, 108), ), /*bounce*/ array( 'fv' => array( - 'mailing_name' => 'First%', - 'mailing_delivery_status' - => 'N'), + 'mailing_name' => 'First%', + 'mailing_delivery_status' + => 'N' + ), 'id' => array(105), ), /*bounce*/ array( 'fv' => array( - 'mailing_name' => 'First%', - 'mailing_delivery_status' - => 'Y'), + 'mailing_name' => 'First%', + 'mailing_delivery_status' + => 'Y' + ), 'id' => array(102, 103, 104, 108, 109, 110, 111, 112), ), array( - 'fv' => array('mailing_name' => 'First%', 'mailing_reply_status' => 'Y'), + 'fv' => array('mailing_name' => 'First%', 'mailing_reply_status' => 'Y'), 'id' => array(103, 108, 110, 112), ), array( - 'fv' => array('mailing_name' => 'First%', 'mailing_reply_status' => 'N'), + 'fv' => array('mailing_name' => 'First%', 'mailing_reply_status' => 'N'), 'id' => array(102, 104, 105, 109, 111), ), array( - 'fv' => array('mailing_name' => 'First%', 'mailing_click_status' => 'Y'), + 'fv' => array('mailing_name' => 'First%', 'mailing_click_status' => 'Y'), 'id' => array(104, 108, 111, 112), ), array( - 'fv' => array('mailing_name' => 'First%', 'mailing_click_status' => 'N'), + 'fv' => array('mailing_name' => 'First%', 'mailing_click_status' => 'N'), 'id' => array(102, 103, 105, 109, 110), ), /*bounce*/ array( 'fv' => array( - 'mailing_name' => 'Second%', - 'mailing_delivery_status' - => 'N'), + 'mailing_name' => 'Second%', + 'mailing_delivery_status' + => 'N' + ), 'id' => array(), ), /*bounce*/ array( 'fv' => array( - 'mailing_name' => 'Second%', - 'mailing_delivery_status' - => 'Y'), + 'mailing_name' => 'Second%', + 'mailing_delivery_status' + => 'Y' + ), 'id' => array(102, 103, 104, 108, 109, 110, 111, 112), ), array( - 'fv' => array('mailing_name' => 'Second%', 'mailing_reply_status' => 'Y'), + 'fv' => array('mailing_name' => 'Second%', 'mailing_reply_status' => 'Y'), 'id' => array(103), ), array( - 'fv' => array('mailing_name' => 'Second%', 'mailing_click_status' => 'Y'), + 'fv' => array('mailing_name' => 'Second%', 'mailing_click_status' => 'Y'), 'id' => array(104), ), array( - 'fv' => array('mailing_name' => 'Second%', 'mailing_click_status' => 'N'), + 'fv' => array('mailing_name' => 'Second%', 'mailing_click_status' => 'N'), 'id' => array(102, 103, 108, 109, 110, 111, 112), ), array( - 'fv' => array('mailing_date_high' => '2011-05-25', 'mailing_open_status' => 'Y'), + 'fv' => array('mailing_date_high' => '2011-05-25', 'mailing_open_status' => 'Y'), 'id' => array(109, 110, 111, 112), ), array( - 'fv' => array('mailing_date_high' => '2011-05-25', 'mailing_open_status' => 'N'), + 'fv' => array('mailing_date_high' => '2011-05-25', 'mailing_open_status' => 'N'), 'id' => array(102, 103, 104, 105, 108), ), array( - 'fv' => array('mailing_date_low' => '2011-05-26', 'mailing_open_status' => 'Y'), + 'fv' => array('mailing_date_low' => '2011-05-26', 'mailing_open_status' => 'Y'), 'id' => array(102), ), array( - 'fv' => array('mailing_date_low' => '2011-05-26', 'mailing_open_status' => 'N'), + 'fv' => array('mailing_date_low' => '2011-05-26', 'mailing_open_status' => 'N'), 'id' => array(103, 104, 108, 109, 110, 111, 112), ), ); @@ -117,8 +122,8 @@ class CRM_Mailing_BAO_QueryTestDataProvider implements Iterator { */ public function current() { $count = count($this->dataset[$this->i]['id']); - $ids = $this->dataset[$this->i]['id']; - $full = array(); + $ids = $this->dataset[$this->i]['id']; + $full = array(); foreach ($this->dataset[$this->i]['id'] as $key => $value) { $full[] = array( 'contact_id' => $value, diff --git a/tests/phpunit/CRM/Member/BAO/MembershipStatusTest.php b/tests/phpunit/CRM/Member/BAO/MembershipStatusTest.php index 1a03171ea2..461211f168 100644 --- a/tests/phpunit/CRM/Member/BAO/MembershipStatusTest.php +++ b/tests/phpunit/CRM/Member/BAO/MembershipStatusTest.php @@ -63,8 +63,8 @@ class CRM_Member_BAO_MembershipStatusTest extends CiviUnitTestCase { ); $membershipStatus = CRM_Member_BAO_MembershipStatus::add($params); - $defaults = array(); - $result = CRM_Member_BAO_MembershipStatus::retrieve($params, $defaults); + $defaults = array(); + $result = CRM_Member_BAO_MembershipStatus::retrieve($params, $defaults); $this->assertEquals($result->name, 'testStatus', 'Verify membership status name.'); CRM_Member_BAO_MembershipStatus::del($membershipStatus->id); } diff --git a/tests/phpunit/CRM/Member/BAO/MembershipTest.php b/tests/phpunit/CRM/Member/BAO/MembershipTest.php index 285a484dee..6766f00165 100644 --- a/tests/phpunit/CRM/Member/BAO/MembershipTest.php +++ b/tests/phpunit/CRM/Member/BAO/MembershipTest.php @@ -354,6 +354,7 @@ class CRM_Member_BAO_MembershipTest extends CiviUnitTestCase { $this->membershipDelete($membershipId); Contact::delete($contactId); } + /** * Get membership joins/renewals * for a specified membership @@ -488,8 +489,8 @@ class CRM_Member_BAO_MembershipTest extends CiviUnitTestCase { */ public function testRenewMembership() { $contactId = Contact::createIndividual(); - $joinDate = $startDate = date("Ymd", strtotime(date("Ymd") . " -6 month")); - $endDate = date("Ymd", strtotime($joinDate . " +1 year -1 day")); + $joinDate = $startDate = date("Ymd", strtotime(date("Ymd") . " -6 month")); + $endDate = date("Ymd", strtotime($joinDate . " +1 year -1 day")); $params = array( 'contact_id' => $contactId, 'membership_type_id' => $this->_membershipTypeID, @@ -500,8 +501,8 @@ class CRM_Member_BAO_MembershipTest extends CiviUnitTestCase { 'is_override' => 1, 'status_id' => $this->_membershipStatusID, ); - $ids = array(); - $membership = CRM_Member_BAO_Membership::create($params, $ids); + $ids = array(); + $membership = CRM_Member_BAO_Membership::create($params, $ids); $membershipId = $this->assertDBNotNull('CRM_Member_BAO_Membership', $contactId, 'id', 'contact_id', 'Database check for created membership.' ); @@ -549,11 +550,11 @@ class CRM_Member_BAO_MembershipTest extends CiviUnitTestCase { * Renew stale membership */ public function testStaleMembership() { - $statusId = 3; + $statusId = 3; $contactId = Contact::createIndividual(); - $joinDate = $startDate = date("Ymd", strtotime(date("Ymd") . " -1 year -15 days")); - $endDate = date("Ymd", strtotime($joinDate . " +1 year -1 day")); - $params = array( + $joinDate = $startDate = date("Ymd", strtotime(date("Ymd") . " -1 year -15 days")); + $endDate = date("Ymd", strtotime($joinDate . " +1 year -1 day")); + $params = array( 'contact_id' => $contactId, 'membership_type_id' => $this->_membershipTypeID, 'join_date' => $joinDate, diff --git a/tests/phpunit/CRM/Member/BAO/MembershipTypeTest.php b/tests/phpunit/CRM/Member/BAO/MembershipTypeTest.php index 97350b4a17..502233b3cc 100644 --- a/tests/phpunit/CRM/Member/BAO/MembershipTypeTest.php +++ b/tests/phpunit/CRM/Member/BAO/MembershipTypeTest.php @@ -113,9 +113,9 @@ class CRM_Member_BAO_MembershipTypeTest extends CiviUnitTestCase { ); $membershipType = CRM_Member_BAO_MembershipType::add($params, $ids); - $params = array('name' => 'General'); + $params = array('name' => 'General'); $default = array(); - $result = CRM_Member_BAO_MembershipType::retrieve($params, $default); + $result = CRM_Member_BAO_MembershipType::retrieve($params, $default); $this->assertEquals($result->name, 'General', 'Verify membership type name.'); $this->membershipTypeDelete(array('id' => $membershipType->id)); } diff --git a/tests/phpunit/CRM/Member/Form/MembershipTest.php b/tests/phpunit/CRM/Member/Form/MembershipTest.php index 75f82ba965..9be7a535e3 100644 --- a/tests/phpunit/CRM/Member/Form/MembershipTest.php +++ b/tests/phpunit/CRM/Member/Form/MembershipTest.php @@ -222,8 +222,8 @@ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase { 'membership_type_id' => array(), ); $files = array(); - $obj = new CRM_Member_Form_Membership; - $rc = $obj->formRule($params, $files, $obj); + $obj = new CRM_Member_Form_Membership; + $rc = $obj->formRule($params, $files, $obj); $this->assertType('array', $rc, 'In line ' . __LINE__ ); @@ -247,19 +247,19 @@ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase { * membership type */ public function testFormRuleRollingEarlyStart() { - $unixNow = time(); - $ymdNow = date('m/d/Y', $unixNow); + $unixNow = time(); + $ymdNow = date('m/d/Y', $unixNow); $unixYesterday = $unixNow - (24 * 60 * 60); - $ymdYesterday = date('m/d/Y', $unixYesterday); - $params = array( + $ymdYesterday = date('m/d/Y', $unixYesterday); + $params = array( 'join_date' => $ymdNow, 'start_date' => $ymdYesterday, 'end_date' => '', 'membership_type_id' => array('23', '3'), ); $files = array(); - $obj = new CRM_Member_Form_Membership; - $rc = call_user_func(array('CRM_Member_Form_Membership', 'formRule'), + $obj = new CRM_Member_Form_Membership; + $rc = call_user_func(array('CRM_Member_Form_Membership', 'formRule'), $params, $files, $obj ); $this->assertType('array', $rc, @@ -276,19 +276,19 @@ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase { * membership type */ public function testFormRuleRollingEarlyEnd() { - $unixNow = time(); - $ymdNow = date('m/d/Y', $unixNow); + $unixNow = time(); + $ymdNow = date('m/d/Y', $unixNow); $unixYesterday = $unixNow - (24 * 60 * 60); - $ymdYesterday = date('m/d/Y', $unixYesterday); - $params = array( + $ymdYesterday = date('m/d/Y', $unixYesterday); + $params = array( 'join_date' => $ymdNow, 'start_date' => $ymdNow, 'end_date' => $ymdYesterday, 'membership_type_id' => array('23', '3'), ); $files = array(); - $obj = new CRM_Member_Form_Membership; - $rc = $obj->formRule($params, $files, $obj); + $obj = new CRM_Member_Form_Membership; + $rc = $obj->formRule($params, $files, $obj); $this->assertType('array', $rc, 'In line ' . __LINE__ ); @@ -303,19 +303,19 @@ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase { * membership type */ public function testFormRuleRollingEndNoStart() { - $unixNow = time(); - $ymdNow = date('m/d/Y', $unixNow); + $unixNow = time(); + $ymdNow = date('m/d/Y', $unixNow); $unixYearFromNow = $unixNow + (365 * 24 * 60 * 60); - $ymdYearFromNow = date('m/d/Y', $unixYearFromNow); - $params = array( + $ymdYearFromNow = date('m/d/Y', $unixYearFromNow); + $params = array( 'join_date' => $ymdNow, 'start_date' => '', 'end_date' => $ymdYearFromNow, 'membership_type_id' => array('23', '3'), ); $files = array(); - $obj = new CRM_Member_Form_Membership; - $rc = $obj->formRule($params, $files, $obj); + $obj = new CRM_Member_Form_Membership; + $rc = $obj->formRule($params, $files, $obj); $this->assertType('array', $rc, 'In line ' . __LINE__ ); @@ -329,9 +329,9 @@ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase { * that has an end date and a lifetime membership type */ public function testFormRuleRollingLifetimeEnd() { - $unixNow = time(); + $unixNow = time(); $unixYearFromNow = $unixNow + (365 * 24 * 60 * 60); - $params = array( + $params = array( 'join_date' => date('m/d/Y', $unixNow), 'start_date' => date('m/d/Y', $unixNow), 'end_date' => date('m/d/Y', @@ -340,8 +340,8 @@ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase { 'membership_type_id' => array('23', '13'), ); $files = array(); - $obj = new CRM_Member_Form_Membership; - $rc = $obj->formRule($params, $files, $obj); + $obj = new CRM_Member_Form_Membership; + $rc = $obj->formRule($params, $files, $obj); $this->assertType('array', $rc); $this->assertTrue(array_key_exists('status_id', $rc)); } @@ -351,16 +351,16 @@ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase { * that has an override and no status */ public function testFormRuleOverrideNoStatus() { - $unixNow = time(); + $unixNow = time(); $unixYearFromNow = $unixNow + (365 * 24 * 60 * 60); - $params = array( - 'join_date' => date('m/d/Y', $unixNow), + $params = array( + 'join_date' => date('m/d/Y', $unixNow), 'membership_type_id' => array('23', '13'), 'is_override' => TRUE, ); $files = array(); - $obj = new CRM_Member_Form_Membership; - $rc = $obj->formRule($params, $files, $obj); + $obj = new CRM_Member_Form_Membership; + $rc = $obj->formRule($params, $files, $obj); $this->assertType('array', $rc, 'In line ' . __LINE__ ); @@ -374,17 +374,17 @@ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase { * of one month from now and a rolling membership type */ public function testFormRuleRollingJoin1MonthFromNow() { - $unixNow = time(); + $unixNow = time(); $unix1MFmNow = $unixNow + (31 * 24 * 60 * 60); - $params = array( - 'join_date' => date('m/d/Y', $unix1MFmNow), + $params = array( + 'join_date' => date('m/d/Y', $unix1MFmNow), 'start_date' => '', 'end_date' => '', 'membership_type_id' => array('23', '3'), ); $files = array(); - $obj = new CRM_Member_Form_Membership; - $rc = $obj->formRule($params, $files, $obj); + $obj = new CRM_Member_Form_Membership; + $rc = $obj->formRule($params, $files, $obj); // Should have found no valid membership status $this->assertType('array', $rc, @@ -402,14 +402,14 @@ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase { public function testFormRuleRollingJoinToday() { $unixNow = time(); $params = array( - 'join_date' => date('m/d/Y', $unixNow), + 'join_date' => date('m/d/Y', $unixNow), 'start_date' => '', 'end_date' => '', 'membership_type_id' => array('23', '3'), ); $files = array(); - $obj = new CRM_Member_Form_Membership; - $rc = $obj->formRule($params, $files, $obj); + $obj = new CRM_Member_Form_Membership; + $rc = $obj->formRule($params, $files, $obj); // Should have found New membership status $this->assertTrue($rc, 'In line ' . __LINE__); @@ -420,17 +420,17 @@ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase { * of one month ago and a rolling membership type */ public function testFormRuleRollingJoin1MonthAgo() { - $unixNow = time(); + $unixNow = time(); $unix1MAgo = $unixNow - (31 * 24 * 60 * 60); - $params = array( - 'join_date' => date('m/d/Y', $unix1MAgo), + $params = array( + 'join_date' => date('m/d/Y', $unix1MAgo), 'start_date' => '', 'end_date' => '', 'membership_type_id' => array('23', '3'), ); $files = array(); - $obj = new CRM_Member_Form_Membership; - $rc = $obj->formRule($params, $files, $obj); + $obj = new CRM_Member_Form_Membership; + $rc = $obj->formRule($params, $files, $obj); // Should have found New membership status $this->assertTrue($rc, 'In line ' . __LINE__); @@ -441,17 +441,17 @@ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase { * of six months ago and a rolling membership type */ public function testFormRuleRollingJoin6MonthsAgo() { - $unixNow = time(); + $unixNow = time(); $unix6MAgo = $unixNow - (180 * 24 * 60 * 60); - $params = array( - 'join_date' => date('m/d/Y', $unix6MAgo), + $params = array( + 'join_date' => date('m/d/Y', $unix6MAgo), 'start_date' => '', 'end_date' => '', 'membership_type_id' => array('23', '3'), ); $files = array(); - $obj = new CRM_Member_Form_Membership; - $rc = $obj->formRule($params, $files, $obj); + $obj = new CRM_Member_Form_Membership; + $rc = $obj->formRule($params, $files, $obj); // Should have found Current membership status $this->assertTrue($rc, 'In line ' . __LINE__); @@ -462,17 +462,17 @@ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase { * of one year+ ago and a rolling membership type */ public function testFormRuleRollingJoin1YearAgo() { - $unixNow = time(); + $unixNow = time(); $unix1YAgo = $unixNow - (370 * 24 * 60 * 60); - $params = array( - 'join_date' => date('m/d/Y', $unix1YAgo), + $params = array( + 'join_date' => date('m/d/Y', $unix1YAgo), 'start_date' => '', 'end_date' => '', 'membership_type_id' => array('23', '3'), ); $files = array(); - $obj = new CRM_Member_Form_Membership; - $rc = $obj->formRule($params, $files, $obj); + $obj = new CRM_Member_Form_Membership; + $rc = $obj->formRule($params, $files, $obj); // Should have found Grace membership status $this->assertTrue($rc, 'In line ' . __LINE__); @@ -483,17 +483,17 @@ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase { * of two years ago and a rolling membership type */ public function testFormRuleRollingJoin2YearsAgo() { - $unixNow = time(); + $unixNow = time(); $unix2YAgo = $unixNow - (2 * 365 * 24 * 60 * 60); - $params = array( - 'join_date' => date('m/d/Y', $unix2YAgo), + $params = array( + 'join_date' => date('m/d/Y', $unix2YAgo), 'start_date' => '', 'end_date' => '', 'membership_type_id' => array('23', '3'), ); $files = array(); - $obj = new CRM_Member_Form_Membership; - $rc = $obj->formRule($params, $files, $obj); + $obj = new CRM_Member_Form_Membership; + $rc = $obj->formRule($params, $files, $obj); // Should have found Expired membership status $this->assertTrue($rc, 'In line ' . __LINE__); @@ -504,17 +504,17 @@ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase { * of six months ago and a fixed membership type */ public function testFormRuleFixedJoin6MonthsAgo() { - $unixNow = time(); + $unixNow = time(); $unix6MAgo = $unixNow - (180 * 24 * 60 * 60); - $params = array( - 'join_date' => date('m/d/Y', $unix6MAgo), + $params = array( + 'join_date' => date('m/d/Y', $unix6MAgo), 'start_date' => '', 'end_date' => '', 'membership_type_id' => array('23', '7'), ); $files = array(); - $obj = new CRM_Member_Form_Membership; - $rc = $obj->formRule($params, $files, $obj); + $obj = new CRM_Member_Form_Membership; + $rc = $obj->formRule($params, $files, $obj); // Should have found Current membership status $this->assertTrue($rc, 'In line ' . __LINE__); diff --git a/tests/phpunit/CRM/Member/Import/Parser/MembershipTest.php b/tests/phpunit/CRM/Member/Import/Parser/MembershipTest.php index 64e0e5d94c..8e67a619ee 100644 --- a/tests/phpunit/CRM/Member/Import/Parser/MembershipTest.php +++ b/tests/phpunit/CRM/Member/Import/Parser/MembershipTest.php @@ -88,7 +88,12 @@ class CRM_Member_Import_Parser_MembershipTest extends CiviUnitTestCase { * This method is called after a test is executed. */ public function tearDown() { - $tablesToTruncate = array('civicrm_membership', 'civicrm_membership_log', 'civicrm_contribution', 'civicrm_membership_payment'); + $tablesToTruncate = array( + 'civicrm_membership', + 'civicrm_membership_log', + 'civicrm_contribution', + 'civicrm_membership_payment' + ); $this->quickCleanup($tablesToTruncate); $this->relationshipTypeDelete($this->_relationshipTypeId); $this->membershipTypeDelete(array('id' => $this->_membershipTypeID)); @@ -116,8 +121,8 @@ class CRM_Member_Import_Parser_MembershipTest extends CiviUnitTestCase { $params = array( array( 'anthony_anderson@civicrm.org', - $this->_membershipTypeID, - date('Y-m-d'), + $this->_membershipTypeID, + date('Y-m-d'), ), array( $contact2Params['email'], diff --git a/tests/phpunit/CRM/PCP/BAO/PCPTest.php b/tests/phpunit/CRM/PCP/BAO/PCPTest.php index 2109d38c09..14b53fe77b 100644 --- a/tests/phpunit/CRM/PCP/BAO/PCPTest.php +++ b/tests/phpunit/CRM/PCP/BAO/PCPTest.php @@ -120,9 +120,9 @@ class CRM_PCP_BAO_PCPTest extends CiviUnitTestCase { public function testDeletePCP() { - $pcp = CRM_Core_DAO::createTestObject('CRM_PCP_DAO_PCP'); + $pcp = CRM_Core_DAO::createTestObject('CRM_PCP_DAO_PCP'); $pcpId = $pcp->id; - $del = CRM_PCP_BAO_PCP::deleteById($pcpId); + $del = CRM_PCP_BAO_PCP::deleteById($pcpId); $this->assertDBRowNotExist('CRM_PCP_DAO_PCP', $pcpId, 'Database check PCP deleted successfully.' ); @@ -132,9 +132,9 @@ class CRM_PCP_BAO_PCPTest extends CiviUnitTestCase { * Build params */ private function pcpBlockParams() { - $contribPage = CRM_Core_DAO::createTestObject('CRM_Contribute_DAO_ContributionPage'); - $contribPageId = $contribPage->id; - $supporterProfile = CRM_Core_DAO::createTestObject('CRM_Core_DAO_UFGroup'); + $contribPage = CRM_Core_DAO::createTestObject('CRM_Contribute_DAO_ContributionPage'); + $contribPageId = $contribPage->id; + $supporterProfile = CRM_Core_DAO::createTestObject('CRM_Core_DAO_UFGroup'); $supporterProfileId = $supporterProfile->id; $params = array( @@ -156,9 +156,9 @@ class CRM_PCP_BAO_PCPTest extends CiviUnitTestCase { * Build params */ private function pcpParams() { - $contact = CRM_Core_DAO::createTestObject('CRM_Contact_DAO_Contact'); - $contactId = $contact->id; - $contribPage = CRM_Core_DAO::createTestObject('CRM_Contribute_DAO_ContributionPage'); + $contact = CRM_Core_DAO::createTestObject('CRM_Contact_DAO_Contact'); + $contactId = $contact->id; + $contribPage = CRM_Core_DAO::createTestObject('CRM_Contribute_DAO_ContributionPage'); $contribPageId = $contribPage->id; $params = array( diff --git a/tests/phpunit/CRM/Pledge/BAO/PledgePaymentTest.php b/tests/phpunit/CRM/Pledge/BAO/PledgePaymentTest.php index 71891f2718..e66d55bf2d 100644 --- a/tests/phpunit/CRM/Pledge/BAO/PledgePaymentTest.php +++ b/tests/phpunit/CRM/Pledge/BAO/PledgePaymentTest.php @@ -94,9 +94,9 @@ class CRM_Pledge_BAO_PledgePaymentTest extends CiviUnitTestCase { * Retrieve a payment based on a pledge id = 0 */ public function testRetrieveZeroPledeID() { - $payment = CRM_Core_DAO::createTestObject('CRM_Pledge_BAO_PledgePayment'); - $params = array('pledge_id' => 0); - $defaults = array(); + $payment = CRM_Core_DAO::createTestObject('CRM_Pledge_BAO_PledgePayment'); + $params = array('pledge_id' => 0); + $defaults = array(); $paymentid = CRM_Pledge_BAO_PledgePayment::retrieve($params, $defaults); $this->assertEquals(count($paymentid), 0, "Pledge Id must be greater than 0"); @@ -107,9 +107,9 @@ class CRM_Pledge_BAO_PledgePaymentTest extends CiviUnitTestCase { * Retrieve a payment based on a Null pledge id */ public function testRetrieveStringPledgeID() { - $payment = CRM_Core_DAO::createTestObject('CRM_Pledge_BAO_PledgePayment'); - $params = array('pledge_id' => 'Test'); - $defaults = array(); + $payment = CRM_Core_DAO::createTestObject('CRM_Pledge_BAO_PledgePayment'); + $params = array('pledge_id' => 'Test'); + $defaults = array(); $paymentid = CRM_Pledge_BAO_PledgePayment::retrieve($params, $defaults); $this->assertEquals(count($paymentid), 0, "Pledge Id cannot be a string"); @@ -120,10 +120,10 @@ class CRM_Pledge_BAO_PledgePaymentTest extends CiviUnitTestCase { * Test that payment retrieve wrks based on known pledge id */ public function testRetrieveKnownPledgeID() { - $payment = CRM_Core_DAO::createTestObject('CRM_Pledge_BAO_PledgePayment'); - $pledgeId = $payment->pledge_id; - $params = array('pledge_id' => $pledgeId); - $defaults = array(); + $payment = CRM_Core_DAO::createTestObject('CRM_Pledge_BAO_PledgePayment'); + $pledgeId = $payment->pledge_id; + $params = array('pledge_id' => $pledgeId); + $defaults = array(); $paymentid = CRM_Pledge_BAO_PledgePayment::retrieve($params, $defaults); $this->assertEquals(count($paymentid), 1, "Pledge was retrieved"); @@ -154,9 +154,9 @@ class CRM_Pledge_BAO_PledgePaymentTest extends CiviUnitTestCase { * Pass Zero Id for a payment deletion for one pledge */ public function testDeletePaymentsZeroId() { - $payment = CRM_Core_DAO::createTestObject('CRM_Pledge_BAO_PledgePayment'); + $payment = CRM_Core_DAO::createTestObject('CRM_Pledge_BAO_PledgePayment'); $paymentid = CRM_Pledge_BAO_PledgePayment::deletePayments(0); - $result = CRM_Pledge_BAO_Pledge::deletePledge($payment->pledge_id); + $result = CRM_Pledge_BAO_Pledge::deletePledge($payment->pledge_id); } /** diff --git a/tests/phpunit/CRM/Pledge/BAO/PledgeTest.php b/tests/phpunit/CRM/Pledge/BAO/PledgeTest.php index d78063eec2..06f27139bc 100644 --- a/tests/phpunit/CRM/Pledge/BAO/PledgeTest.php +++ b/tests/phpunit/CRM/Pledge/BAO/PledgeTest.php @@ -85,7 +85,7 @@ class CRM_Pledge_BAO_PledgeTest extends CiviUnitTestCase { */ public function testRetrieveZeroPledeID() { $defaults = array(); - $params = array('pledge_id' => 0); + $params = array('pledge_id' => 0); $pledgeId = CRM_Pledge_BAO_Pledge::retrieve($params, $defaults); $this->assertEquals(count($pledgeId), 0, "Pledge Id must be greater than 0"); @@ -96,7 +96,7 @@ class CRM_Pledge_BAO_PledgeTest extends CiviUnitTestCase { */ public function testRetrieveStringPledgeID() { $defaults = array(); - $params = array('pledge_id' => 'random text'); + $params = array('pledge_id' => 'random text'); $pledgeId = CRM_Pledge_BAO_Pledge::retrieve($params, $defaults); $this->assertEquals(count($pledgeId), 0, "Pledge Id must be a string"); diff --git a/tests/phpunit/CRM/Queue/Queue/SqlTest.php b/tests/phpunit/CRM/Queue/Queue/SqlTest.php index 80b1ec9d9a..d85b8e8b0b 100644 --- a/tests/phpunit/CRM/Queue/Queue/SqlTest.php +++ b/tests/phpunit/CRM/Queue/Queue/SqlTest.php @@ -48,7 +48,8 @@ class CRM_Queue_Queue_SqlTest extends CiviUnitTestCase { array( 'type' => 'Sql', 'name' => 'test-queue', - )); + ) + ); return $queueSpecs; } @@ -75,14 +76,14 @@ class CRM_Queue_Queue_SqlTest extends CiviUnitTestCase { $this->assertTrue($this->queue instanceof CRM_Queue_Queue); $this->queue->createItem(array( - 'test-key' => 'a', - )); + 'test-key' => 'a', + )); $this->queue->createItem(array( - 'test-key' => 'b', - )); + 'test-key' => 'b', + )); $this->queue->createItem(array( - 'test-key' => 'c', - )); + 'test-key' => 'c', + )); $this->assertEquals(3, $this->queue->numberOfItems()); $item = $this->queue->claimItem(); @@ -111,8 +112,8 @@ class CRM_Queue_Queue_SqlTest extends CiviUnitTestCase { ) ); $this->queue->createItem(array( - 'test-key' => 'd', - )); + 'test-key' => 'd', + )); $this->assertEquals(4, $this->queue->numberOfItems()); $item = $this->queue->claimItem(); diff --git a/tests/phpunit/CRM/Queue/QueueTest.php b/tests/phpunit/CRM/Queue/QueueTest.php index 40828a3463..ab8d4404de 100644 --- a/tests/phpunit/CRM/Queue/QueueTest.php +++ b/tests/phpunit/CRM/Queue/QueueTest.php @@ -46,12 +46,14 @@ class CRM_Queue_QueueTest extends CiviUnitTestCase { array( 'type' => 'Sql', 'name' => 'test-queue', - )); + ) + ); $queueSpecs[] = array( array( 'type' => 'Memory', 'name' => 'test-queue', - )); + ) + ); return $queueSpecs; } @@ -78,14 +80,14 @@ class CRM_Queue_QueueTest extends CiviUnitTestCase { $this->assertTrue($this->queue instanceof CRM_Queue_Queue); $this->queue->createItem(array( - 'test-key' => 'a', - )); + 'test-key' => 'a', + )); $this->queue->createItem(array( - 'test-key' => 'b', - )); + 'test-key' => 'b', + )); $this->queue->createItem(array( - 'test-key' => 'c', - )); + 'test-key' => 'c', + )); $this->assertEquals(3, $this->queue->numberOfItems()); $item = $this->queue->claimItem(); @@ -98,8 +100,8 @@ class CRM_Queue_QueueTest extends CiviUnitTestCase { $this->queue->deleteItem($item); $this->queue->createItem(array( - 'test-key' => 'd', - )); + 'test-key' => 'd', + )); $this->assertEquals(2, $this->queue->numberOfItems()); $item = $this->queue->claimItem(); @@ -124,8 +126,8 @@ class CRM_Queue_QueueTest extends CiviUnitTestCase { $this->assertTrue($this->queue instanceof CRM_Queue_Queue); $this->queue->createItem(array( - 'test-key' => 'a', - )); + 'test-key' => 'a', + )); $item = $this->queue->claimItem(); $this->assertEquals('a', $item->data['test-key']); @@ -151,8 +153,8 @@ class CRM_Queue_QueueTest extends CiviUnitTestCase { CRM_Utils_Time::setTime('2012-04-01 1:00:00'); $this->queue->createItem(array( - 'test-key' => 'a', - )); + 'test-key' => 'a', + )); $item = $this->queue->claimItem(); $this->assertEquals('a', $item->data['test-key']); @@ -186,8 +188,8 @@ class CRM_Queue_QueueTest extends CiviUnitTestCase { require_once 'CRM/Utils/Time.php'; CRM_Utils_Time::setTime('2012-04-01 1:00:00'); $this->queue->createItem(array( - 'test-key' => 'a', - )); + 'test-key' => 'a', + )); $item = $this->queue->claimItem(); $this->assertEquals('a', $item->data['test-key']); @@ -216,11 +218,11 @@ class CRM_Queue_QueueTest extends CiviUnitTestCase { public function testCreateResetTrue($queueSpec) { $this->queue = $this->queueService->create($queueSpec); $this->queue->createItem(array( - 'test-key' => 'a', - )); + 'test-key' => 'a', + )); $this->queue->createItem(array( - 'test-key' => 'b', - )); + 'test-key' => 'b', + )); $this->assertEquals(2, $this->queue->numberOfItems()); unset($this->queue); @@ -238,11 +240,11 @@ class CRM_Queue_QueueTest extends CiviUnitTestCase { public function testCreateResetFalse($queueSpec) { $this->queue = $this->queueService->create($queueSpec); $this->queue->createItem(array( - 'test-key' => 'a', - )); + 'test-key' => 'a', + )); $this->queue->createItem(array( - 'test-key' => 'b', - )); + 'test-key' => 'b', + )); $this->assertEquals(2, $this->queue->numberOfItems()); unset($this->queue); @@ -262,11 +264,11 @@ class CRM_Queue_QueueTest extends CiviUnitTestCase { public function testLoad($queueSpec) { $this->queue = $this->queueService->create($queueSpec); $this->queue->createItem(array( - 'test-key' => 'a', - )); + 'test-key' => 'a', + )); $this->queue->createItem(array( - 'test-key' => 'b', - )); + 'test-key' => 'b', + )); $this->assertEquals(2, $this->queue->numberOfItems()); unset($this->queue); diff --git a/tests/phpunit/CRM/Queue/RunnerTest.php b/tests/phpunit/CRM/Queue/RunnerTest.php index f00e24d339..e9cede7ab1 100644 --- a/tests/phpunit/CRM/Queue/RunnerTest.php +++ b/tests/phpunit/CRM/Queue/RunnerTest.php @@ -38,9 +38,9 @@ class CRM_Queue_RunnerTest extends CiviUnitTestCase { require_once 'CRM/Queue/Service.php'; $this->queueService = CRM_Queue_Service::singleton(TRUE); $this->queue = $this->queueService->create(array( - 'type' => 'Sql', - 'name' => 'test-queue', - )); + 'type' => 'Sql', + 'name' => 'test-queue', + )); self::$_recordedValues = array(); } @@ -57,26 +57,26 @@ class CRM_Queue_RunnerTest extends CiviUnitTestCase { public function testRunAllNormal() { // prepare a list of tasks with an error in the middle $this->queue->createItem(new CRM_Queue_Task( - array('CRM_Queue_RunnerTest', '_recordValue'), - array('a'), - 'Add "a"' - )); + array('CRM_Queue_RunnerTest', '_recordValue'), + array('a'), + 'Add "a"' + )); $this->queue->createItem(new CRM_Queue_Task( - array('CRM_Queue_RunnerTest', '_recordValue'), - array('b'), - 'Add "b"' - )); + array('CRM_Queue_RunnerTest', '_recordValue'), + array('b'), + 'Add "b"' + )); $this->queue->createItem(new CRM_Queue_Task( - array('CRM_Queue_RunnerTest', '_recordValue'), - array('c'), - 'Add "c"' - )); + array('CRM_Queue_RunnerTest', '_recordValue'), + array('c'), + 'Add "c"' + )); // run the list of tasks $runner = new CRM_Queue_Runner(array( - 'queue' => $this->queue, - 'errorMode' => CRM_Queue_Runner::ERROR_ABORT, - )); + 'queue' => $this->queue, + 'errorMode' => CRM_Queue_Runner::ERROR_ABORT, + )); $this->assertEquals(self::$_recordedValues, array()); $this->assertEquals(3, $this->queue->numberOfItems()); $result = $runner->runAll(); @@ -92,26 +92,26 @@ class CRM_Queue_RunnerTest extends CiviUnitTestCase { public function testRunAll_AddMore() { // prepare a list of tasks with an error in the middle $this->queue->createItem(new CRM_Queue_Task( - array('CRM_Queue_RunnerTest', '_recordValue'), - array('a'), - 'Add "a"' - )); + array('CRM_Queue_RunnerTest', '_recordValue'), + array('a'), + 'Add "a"' + )); $this->queue->createItem(new CRM_Queue_Task( - array('CRM_Queue_RunnerTest', '_enqueueNumbers'), - array(1, 3), - 'Add more' - )); + array('CRM_Queue_RunnerTest', '_enqueueNumbers'), + array(1, 3), + 'Add more' + )); $this->queue->createItem(new CRM_Queue_Task( - array('CRM_Queue_RunnerTest', '_recordValue'), - array('b'), - 'Add "b"' - )); + array('CRM_Queue_RunnerTest', '_recordValue'), + array('b'), + 'Add "b"' + )); // run the list of tasks $runner = new CRM_Queue_Runner(array( - 'queue' => $this->queue, - 'errorMode' => CRM_Queue_Runner::ERROR_ABORT, - )); + 'queue' => $this->queue, + 'errorMode' => CRM_Queue_Runner::ERROR_ABORT, + )); $this->assertEquals(self::$_recordedValues, array()); $this->assertEquals(3, $this->queue->numberOfItems()); $result = $runner->runAll(); @@ -127,26 +127,26 @@ class CRM_Queue_RunnerTest extends CiviUnitTestCase { public function testRunAll_Continue_Exception() { // prepare a list of tasks with an error in the middle $this->queue->createItem(new CRM_Queue_Task( - array('CRM_Queue_RunnerTest', '_recordValue'), - array('a'), - 'Add "a"' - )); + array('CRM_Queue_RunnerTest', '_recordValue'), + array('a'), + 'Add "a"' + )); $this->queue->createItem(new CRM_Queue_Task( - array('CRM_Queue_RunnerTest', '_throwException'), - array('b'), - 'Throw exception' - )); + array('CRM_Queue_RunnerTest', '_throwException'), + array('b'), + 'Throw exception' + )); $this->queue->createItem(new CRM_Queue_Task( - array('CRM_Queue_RunnerTest', '_recordValue'), - array('c'), - 'Add "c"' - )); + array('CRM_Queue_RunnerTest', '_recordValue'), + array('c'), + 'Add "c"' + )); // run the list of tasks $runner = new CRM_Queue_Runner(array( - 'queue' => $this->queue, - 'errorMode' => CRM_Queue_Runner::ERROR_CONTINUE, - )); + 'queue' => $this->queue, + 'errorMode' => CRM_Queue_Runner::ERROR_CONTINUE, + )); $this->assertEquals(self::$_recordedValues, array()); $this->assertEquals(3, $this->queue->numberOfItems()); $result = $runner->runAll(); @@ -163,26 +163,26 @@ class CRM_Queue_RunnerTest extends CiviUnitTestCase { public function testRunAll_Abort_Exception() { // prepare a list of tasks with an error in the middle $this->queue->createItem(new CRM_Queue_Task( - array('CRM_Queue_RunnerTest', '_recordValue'), - array('a'), - 'Add "a"' - )); + array('CRM_Queue_RunnerTest', '_recordValue'), + array('a'), + 'Add "a"' + )); $this->queue->createItem(new CRM_Queue_Task( - array('CRM_Queue_RunnerTest', '_throwException'), - array('b'), - 'Throw exception' - )); + array('CRM_Queue_RunnerTest', '_throwException'), + array('b'), + 'Throw exception' + )); $this->queue->createItem(new CRM_Queue_Task( - array('CRM_Queue_RunnerTest', '_recordValue'), - array('c'), - 'Add "c"' - )); + array('CRM_Queue_RunnerTest', '_recordValue'), + array('c'), + 'Add "c"' + )); // run the list of tasks $runner = new CRM_Queue_Runner(array( - 'queue' => $this->queue, - 'errorMode' => CRM_Queue_Runner::ERROR_ABORT, - )); + 'queue' => $this->queue, + 'errorMode' => CRM_Queue_Runner::ERROR_ABORT, + )); $this->assertEquals(self::$_recordedValues, array()); $this->assertEquals(3, $this->queue->numberOfItems()); $result = $runner->runAll(); @@ -200,26 +200,26 @@ class CRM_Queue_RunnerTest extends CiviUnitTestCase { public function testRunAll_Abort_False() { // prepare a list of tasks with an error in the middle $this->queue->createItem(new CRM_Queue_Task( - array('CRM_Queue_RunnerTest', '_recordValue'), - array('a'), - 'Add "a"' - )); + array('CRM_Queue_RunnerTest', '_recordValue'), + array('a'), + 'Add "a"' + )); $this->queue->createItem(new CRM_Queue_Task( - array('CRM_Queue_RunnerTest', '_returnFalse'), - array(), - 'Return false' - )); + array('CRM_Queue_RunnerTest', '_returnFalse'), + array(), + 'Return false' + )); $this->queue->createItem(new CRM_Queue_Task( - array('CRM_Queue_RunnerTest', '_recordValue'), - array('c'), - 'Add "c"' - )); + array('CRM_Queue_RunnerTest', '_recordValue'), + array('c'), + 'Add "c"' + )); // run the list of tasks $runner = new CRM_Queue_Runner(array( - 'queue' => $this->queue, - 'errorMode' => CRM_Queue_Runner::ERROR_ABORT, - )); + 'queue' => $this->queue, + 'errorMode' => CRM_Queue_Runner::ERROR_ABORT, + )); $this->assertEquals(self::$_recordedValues, array()); $this->assertEquals(3, $this->queue->numberOfItems()); $result = $runner->runAll(); diff --git a/tests/phpunit/CRM/Utils/API/MatchOptionTest.php b/tests/phpunit/CRM/Utils/API/MatchOptionTest.php index 7c5abb0278..a6c2e9a802 100644 --- a/tests/phpunit/CRM/Utils/API/MatchOptionTest.php +++ b/tests/phpunit/CRM/Utils/API/MatchOptionTest.php @@ -1,6 +1,7 @@ 'ignore1@example.com', // 'street_address-1' => 'Irrelevant' 'api.Address.create' => array( - 'location_type_id' => 1, + 'location_type_id' => 1, 'street_address' => '123 Irrelevant Str', 'supplemental_address_1' => 'Room 987', ), @@ -185,7 +186,11 @@ class CRM_Utils_API_MatchOptionTest extends CiviUnitTestCase { 'options' => array('match' => 'location_type_id'), 'values' => array( array('location_type_id' => 1, 'email' => 'j1-a@example.com', 'signature_text' => 'The Dude abides.'), - array('location_type_id' => 2, 'email' => 'j2@example.com', 'signature_text' => 'You know, a lotta ins, a lotta outs, a lotta what-have-yous.'), + array( + 'location_type_id' => 2, + 'email' => 'j2@example.com', + 'signature_text' => 'You know, a lotta ins, a lotta outs, a lotta what-have-yous.' + ), ), ), )); @@ -261,8 +266,16 @@ class CRM_Utils_API_MatchOptionTest extends CiviUnitTestCase { 'api.Address.replace' => array( 'options' => array('match' => 'location_type_id'), 'values' => array( - array('location_type_id' => 1, 'street_address' => 'j1-a Example Ave', 'supplemental_address_1' => 'The Dude abides.'), - array('location_type_id' => 2, 'street_address' => 'j2 Example Ave', 'supplemental_address_1' => 'You know, a lotta ins, a lotta outs, a lotta what-have-yous.'), + array( + 'location_type_id' => 1, + 'street_address' => 'j1-a Example Ave', + 'supplemental_address_1' => 'The Dude abides.' + ), + array( + 'location_type_id' => 2, + 'street_address' => 'j2 Example Ave', + 'supplemental_address_1' => 'You know, a lotta ins, a lotta outs, a lotta what-have-yous.' + ), ), ), )); diff --git a/tests/phpunit/CRM/Utils/API/ReloadOptionTest.php b/tests/phpunit/CRM/Utils/API/ReloadOptionTest.php index 3540d2fa55..ea1b1d91fe 100644 --- a/tests/phpunit/CRM/Utils/API/ReloadOptionTest.php +++ b/tests/phpunit/CRM/Utils/API/ReloadOptionTest.php @@ -1,6 +1,7 @@ quickCleanup($tablesToTruncate); } + /** * Test civicrm_contact_check_params with no contact type */ @@ -39,26 +41,26 @@ class CRM_Utils_DeprecatedUtilsTest extends CiviUnitTestCase { // Insert a row in civicrm_contact creating individual contact $op = new PHPUnit_Extensions_Database_Operation_Insert(); $op->execute($this->_dbconn, - $this->createXMLDataSet( - dirname(__FILE__) . '/../../api/v3/dataset/contact_17.xml' - ) + $this->createXMLDataSet( + dirname(__FILE__) . '/../../api/v3/dataset/contact_17.xml' + ) ); $op->execute($this->_dbconn, - $this->createXMLDataSet( - dirname(__FILE__) . '/../../api/v3/dataset/email_contact_17.xml' - ) + $this->createXMLDataSet( + dirname(__FILE__) . '/../../api/v3/dataset/email_contact_17.xml' + ) ); $params = array( - 'first_name' => 'Test', - 'last_name' => 'Contact', - 'email' => 'TestContact@example.com', - 'contact_type' => 'Individual', + 'first_name' => 'Test', + 'last_name' => 'Contact', + 'email' => 'TestContact@example.com', + 'contact_type' => 'Individual', ); $contact = _civicrm_api3_deprecated_contact_check_params($params, TRUE); $this->assertEquals(1, $contact['is_error']); $this->assertRegexp("/matching contacts.*17/s", - CRM_Utils_Array::value('error_message', $contact) + CRM_Utils_Array::value('error_message', $contact) ); } @@ -71,28 +73,29 @@ class CRM_Utils_DeprecatedUtilsTest extends CiviUnitTestCase { // Insert a row in civicrm_contact creating individual contact $op = new PHPUnit_Extensions_Database_Operation_Insert(); $op->execute($this->_dbconn, - $this->createXMLDataSet( - dirname(__FILE__) . '/../../api/v3/dataset/contact_17.xml' - ) + $this->createXMLDataSet( + dirname(__FILE__) . '/../../api/v3/dataset/contact_17.xml' + ) ); $op->execute($this->_dbconn, - $this->createXMLDataSet( - dirname(__FILE__) . '/../../api/v3/dataset/email_contact_17.xml' - ) + $this->createXMLDataSet( + dirname(__FILE__) . '/../../api/v3/dataset/email_contact_17.xml' + ) ); $params = array( - 'first_name' => 'Test', - 'last_name' => 'Contact', - 'email' => 'TestContact@example.com', - 'contact_type' => 'Individual', + 'first_name' => 'Test', + 'last_name' => 'Contact', + 'email' => 'TestContact@example.com', + 'contact_type' => 'Individual', ); $contact = _civicrm_api3_deprecated_contact_check_params($params, TRUE, TRUE); $this->assertEquals(1, $contact['is_error']); $this->assertRegexp("/matching contacts.*17/s", - $contact['error_message']['message'] + $contact['error_message']['message'] ); } + /** * Test civicrm_contact_check_params with check for required * params and no params diff --git a/tests/phpunit/CRM/Utils/MailTest.php b/tests/phpunit/CRM/Utils/MailTest.php index 671b38d2cf..b3e685b218 100644 --- a/tests/phpunit/CRM/Utils/MailTest.php +++ b/tests/phpunit/CRM/Utils/MailTest.php @@ -18,7 +18,7 @@ class CRM_Utils_MailTest extends CiviUnitTestCase { $values = array( array( - 'name' => "Test User", + 'name' => "Test User", 'email' => "foo@bar.com", 'result' => "Test User ", ), diff --git a/tests/phpunit/CRM/Utils/QueryFormatterTest.php b/tests/phpunit/CRM/Utils/QueryFormatterTest.php index c3f416c70e..574dd79f0a 100644 --- a/tests/phpunit/CRM/Utils/QueryFormatterTest.php +++ b/tests/phpunit/CRM/Utils/QueryFormatterTest.php @@ -10,32 +10,137 @@ class CRM_Utils_QueryFormatterTest extends CiviUnitTestCase { public function dataProvider() { $cases = array(); // array(0=>$inputText, 1=>$language, 2=>$options, 3=>$expectedText) - $cases[] = array('first second', CRM_Utils_QueryFormatter::LANG_SQL_LIKE, CRM_Utils_QueryFormatter::MODE_NONE, '%first second%'); - $cases[] = array('first second', CRM_Utils_QueryFormatter::LANG_SQL_LIKE, CRM_Utils_QueryFormatter::MODE_PHRASE, '%first second%'); - $cases[] = array('first second', CRM_Utils_QueryFormatter::LANG_SQL_LIKE, CRM_Utils_QueryFormatter::MODE_WILDPHRASE, '%first second%'); - $cases[] = array('first second', CRM_Utils_QueryFormatter::LANG_SQL_LIKE, CRM_Utils_QueryFormatter::MODE_WILDWORDS, '%first%second%'); - $cases[] = array('first second', CRM_Utils_QueryFormatter::LANG_SQL_LIKE, CRM_Utils_QueryFormatter::MODE_WILDWORDS_SUFFIX, '%first%second%'); + $cases[] = array( + 'first second', + CRM_Utils_QueryFormatter::LANG_SQL_LIKE, + CRM_Utils_QueryFormatter::MODE_NONE, + '%first second%' + ); + $cases[] = array( + 'first second', + CRM_Utils_QueryFormatter::LANG_SQL_LIKE, + CRM_Utils_QueryFormatter::MODE_PHRASE, + '%first second%' + ); + $cases[] = array( + 'first second', + CRM_Utils_QueryFormatter::LANG_SQL_LIKE, + CRM_Utils_QueryFormatter::MODE_WILDPHRASE, + '%first second%' + ); + $cases[] = array( + 'first second', + CRM_Utils_QueryFormatter::LANG_SQL_LIKE, + CRM_Utils_QueryFormatter::MODE_WILDWORDS, + '%first%second%' + ); + $cases[] = array( + 'first second', + CRM_Utils_QueryFormatter::LANG_SQL_LIKE, + CRM_Utils_QueryFormatter::MODE_WILDWORDS_SUFFIX, + '%first%second%' + ); - $cases[] = array('first second', CRM_Utils_QueryFormatter::LANG_SQL_FTS, CRM_Utils_QueryFormatter::MODE_NONE, 'first second'); - $cases[] = array('first second', CRM_Utils_QueryFormatter::LANG_SQL_FTS, CRM_Utils_QueryFormatter::MODE_PHRASE, '"first second"'); - $cases[] = array('first second', CRM_Utils_QueryFormatter::LANG_SQL_FTS, CRM_Utils_QueryFormatter::MODE_WILDPHRASE, '"*first second*"'); - $cases[] = array('first second', CRM_Utils_QueryFormatter::LANG_SQL_FTS, CRM_Utils_QueryFormatter::MODE_WILDWORDS, '*first* *second*'); - $cases[] = array('first second', CRM_Utils_QueryFormatter::LANG_SQL_FTS, CRM_Utils_QueryFormatter::MODE_WILDWORDS_SUFFIX, 'first* second*'); + $cases[] = array( + 'first second', + CRM_Utils_QueryFormatter::LANG_SQL_FTS, + CRM_Utils_QueryFormatter::MODE_NONE, + 'first second' + ); + $cases[] = array( + 'first second', + CRM_Utils_QueryFormatter::LANG_SQL_FTS, + CRM_Utils_QueryFormatter::MODE_PHRASE, + '"first second"' + ); + $cases[] = array( + 'first second', + CRM_Utils_QueryFormatter::LANG_SQL_FTS, + CRM_Utils_QueryFormatter::MODE_WILDPHRASE, + '"*first second*"' + ); + $cases[] = array( + 'first second', + CRM_Utils_QueryFormatter::LANG_SQL_FTS, + CRM_Utils_QueryFormatter::MODE_WILDWORDS, + '*first* *second*' + ); + $cases[] = array( + 'first second', + CRM_Utils_QueryFormatter::LANG_SQL_FTS, + CRM_Utils_QueryFormatter::MODE_WILDWORDS_SUFFIX, + 'first* second*' + ); - $cases[] = array('first second', CRM_Utils_QueryFormatter::LANG_SQL_FTSBOOL, CRM_Utils_QueryFormatter::MODE_NONE, '+first +second'); - $cases[] = array('first second', CRM_Utils_QueryFormatter::LANG_SQL_FTSBOOL, CRM_Utils_QueryFormatter::MODE_PHRASE, '+"first second"'); - $cases[] = array('first second', CRM_Utils_QueryFormatter::LANG_SQL_FTSBOOL, CRM_Utils_QueryFormatter::MODE_WILDPHRASE, '+"*first second*"'); - $cases[] = array('first second', CRM_Utils_QueryFormatter::LANG_SQL_FTSBOOL, CRM_Utils_QueryFormatter::MODE_WILDWORDS, '+*first* +*second*'); - $cases[] = array('first second', CRM_Utils_QueryFormatter::LANG_SQL_FTSBOOL, CRM_Utils_QueryFormatter::MODE_WILDWORDS_SUFFIX, '+first* +second*'); + $cases[] = array( + 'first second', + CRM_Utils_QueryFormatter::LANG_SQL_FTSBOOL, + CRM_Utils_QueryFormatter::MODE_NONE, + '+first +second' + ); + $cases[] = array( + 'first second', + CRM_Utils_QueryFormatter::LANG_SQL_FTSBOOL, + CRM_Utils_QueryFormatter::MODE_PHRASE, + '+"first second"' + ); + $cases[] = array( + 'first second', + CRM_Utils_QueryFormatter::LANG_SQL_FTSBOOL, + CRM_Utils_QueryFormatter::MODE_WILDPHRASE, + '+"*first second*"' + ); + $cases[] = array( + 'first second', + CRM_Utils_QueryFormatter::LANG_SQL_FTSBOOL, + CRM_Utils_QueryFormatter::MODE_WILDWORDS, + '+*first* +*second*' + ); + $cases[] = array( + 'first second', + CRM_Utils_QueryFormatter::LANG_SQL_FTSBOOL, + CRM_Utils_QueryFormatter::MODE_WILDWORDS_SUFFIX, + '+first* +second*' + ); - $cases[] = array('first second', CRM_Utils_QueryFormatter::LANG_SOLR, CRM_Utils_QueryFormatter::MODE_NONE, 'first second'); - $cases[] = array('first second', CRM_Utils_QueryFormatter::LANG_SOLR, CRM_Utils_QueryFormatter::MODE_PHRASE, '"first second"'); - $cases[] = array('first second', CRM_Utils_QueryFormatter::LANG_SOLR, CRM_Utils_QueryFormatter::MODE_WILDPHRASE, '"*first second*"'); - $cases[] = array('first second', CRM_Utils_QueryFormatter::LANG_SOLR, CRM_Utils_QueryFormatter::MODE_WILDWORDS, '*first* *second*'); - $cases[] = array('first second', CRM_Utils_QueryFormatter::LANG_SOLR, CRM_Utils_QueryFormatter::MODE_WILDWORDS_SUFFIX, 'first* second*'); + $cases[] = array( + 'first second', + CRM_Utils_QueryFormatter::LANG_SOLR, + CRM_Utils_QueryFormatter::MODE_NONE, + 'first second' + ); + $cases[] = array( + 'first second', + CRM_Utils_QueryFormatter::LANG_SOLR, + CRM_Utils_QueryFormatter::MODE_PHRASE, + '"first second"' + ); + $cases[] = array( + 'first second', + CRM_Utils_QueryFormatter::LANG_SOLR, + CRM_Utils_QueryFormatter::MODE_WILDPHRASE, + '"*first second*"' + ); + $cases[] = array( + 'first second', + CRM_Utils_QueryFormatter::LANG_SOLR, + CRM_Utils_QueryFormatter::MODE_WILDWORDS, + '*first* *second*' + ); + $cases[] = array( + 'first second', + CRM_Utils_QueryFormatter::LANG_SOLR, + CRM_Utils_QueryFormatter::MODE_WILDWORDS_SUFFIX, + 'first* second*' + ); // if user supplies wildcards, then ignore mode - foreach (array(CRM_Utils_QueryFormatter::MODE_NONE, CRM_Utils_QueryFormatter::MODE_WILDPHRASE, CRM_Utils_QueryFormatter::MODE_WILDWORDS, CRM_Utils_QueryFormatter::MODE_WILDWORDS_SUFFIX) as $mode) { + foreach (array( + CRM_Utils_QueryFormatter::MODE_NONE, + CRM_Utils_QueryFormatter::MODE_WILDPHRASE, + CRM_Utils_QueryFormatter::MODE_WILDWORDS, + CRM_Utils_QueryFormatter::MODE_WILDWORDS_SUFFIX + ) as $mode) { $cases[] = array('first% second', CRM_Utils_QueryFormatter::LANG_SQL_LIKE, $mode, 'first% second'); $cases[] = array('first% second', CRM_Utils_QueryFormatter::LANG_SQL_FTS, $mode, 'first* second'); $cases[] = array('first% second', CRM_Utils_QueryFormatter::LANG_SQL_FTSBOOL, $mode, '+first* +second'); diff --git a/tests/phpunit/CRM/Utils/SQL/InsertTest.php b/tests/phpunit/CRM/Utils/SQL/InsertTest.php index b0135cd0c5..581183b2c7 100644 --- a/tests/phpunit/CRM/Utils/SQL/InsertTest.php +++ b/tests/phpunit/CRM/Utils/SQL/InsertTest.php @@ -1,9 +1,9 @@ row(array('first' => '1', 'second' => '2')) ->rows(array( - array('second' => '2b', 'first' => '1b'), - array('first' => '1c', 'second' => '2c'), + array('second' => '2b', 'first' => '1b'), + array('first' => '1c', 'second' => '2c'), )) ->row(array('second' => '2d', 'first' => '1d')); $expected = ' diff --git a/tests/phpunit/CRM/Utils/SQL/SelectTest.php b/tests/phpunit/CRM/Utils/SQL/SelectTest.php index bee0798fff..7f1c48902e 100644 --- a/tests/phpunit/CRM/Utils/SQL/SelectTest.php +++ b/tests/phpunit/CRM/Utils/SQL/SelectTest.php @@ -92,13 +92,13 @@ class CRM_Utils_SQL_SelectTest extends CiviUnitTestCase { ->limit(100, 300); $this->assertLike( "SELECT foo.id FROM foo" - . " INNER JOIN rel1_table rel1 ON foo.id = rel1.foo_id" - . " LEFT JOIN rel2_table rel2 ON foo.id = rel2.foo_id " - . " WHERE (foo.type = \"mytype\")" - . " GROUP BY foo.id" - . " HAVING (sum(rel1.stat) > 10)" - . " ORDER BY rel2.whiz" - . " LIMIT 100 OFFSET 300", + . " INNER JOIN rel1_table rel1 ON foo.id = rel1.foo_id" + . " LEFT JOIN rel2_table rel2 ON foo.id = rel2.foo_id " + . " WHERE (foo.type = \"mytype\")" + . " GROUP BY foo.id" + . " HAVING (sum(rel1.stat) > 10)" + . " ORDER BY rel2.whiz" + . " LIMIT 100 OFFSET 300", $select->toSQL() ); } diff --git a/tests/phpunit/Civi/API/KernelTest.php b/tests/phpunit/Civi/API/KernelTest.php index 7b6bfa2e71..0d429b2740 100644 --- a/tests/phpunit/Civi/API/KernelTest.php +++ b/tests/phpunit/Civi/API/KernelTest.php @@ -1,5 +1,6 @@ dispatcher->addListener(Events::RESOLVE, function () { throw new \API_Exception('Oh My God', 'omg', array('the' => 'badzes')); }, Events::W_EARLY); - $this->dispatcher->addListener(Events::EXCEPTION, function(\Civi\API\Event\ExceptionEvent $event) use ($test) { + $this->dispatcher->addListener(Events::EXCEPTION, function (\Civi\API\Event\ExceptionEvent $event) use ($test) { $test->assertEquals('Oh My God', $event->getException()->getMessage()); }); diff --git a/tests/phpunit/Civi/API/RequestTest.php b/tests/phpunit/Civi/API/RequestTest.php index 5c119152a9..f9b7ac1c72 100644 --- a/tests/phpunit/Civi/API/RequestTest.php +++ b/tests/phpunit/Civi/API/RequestTest.php @@ -31,13 +31,25 @@ class RequestTest extends \CiviUnitTestCase { array(), // expectedChains ); $cases[] = array( - array('version' => 4, 'option.limit' => 15, 'option.foo' => array('bar'), 'options' => array('whiz' => 'bang'), 'optionnotreally' => 'data'), // requestParams + array( + 'version' => 4, + 'option.limit' => 15, + 'option.foo' => array('bar'), + 'options' => array('whiz' => 'bang'), + 'optionnotreally' => 'data' + ), // requestParams array('limit' => 15, 'foo' => array('bar'), 'whiz' => 'bang'), // expectedOptions array('optionnotreally' => 'data'), // expectedData array(), // expectedChains ); $cases[] = array( - array('version' => 4, 'return' => array('field1', 'field2'), 'return.field3' => 1, 'return.field4' => 0, 'returnontreally' => 'data'), // requestParams + array( + 'version' => 4, + 'return' => array('field1', 'field2'), + 'return.field3' => 1, + 'return.field4' => 0, + 'returnontreally' => 'data' + ), // requestParams array('return' => array('field1', 'field2', 'field3')), // expectedOptions array('returnontreally' => 'data'), // expectedData array(), // expectedChains diff --git a/tests/phpunit/Civi/API/Subscriber/DynamicFKAuthorizationTest.php b/tests/phpunit/Civi/API/Subscriber/DynamicFKAuthorizationTest.php index 6d13bdf8bd..53933117b7 100644 --- a/tests/phpunit/Civi/API/Subscriber/DynamicFKAuthorizationTest.php +++ b/tests/phpunit/Civi/API/Subscriber/DynamicFKAuthorizationTest.php @@ -146,8 +146,18 @@ class DynamicFKAuthorizationTest extends \CiviUnitTestCase { '/Authorization failed/', ); - $cases[] = array('FakeFile', 'create', array(), "/Mandatory key\\(s\\) missing from params array: 'id' or 'entity_table/"); - $cases[] = array('FakeFile', 'get', array(), "/Mandatory key\\(s\\) missing from params array: 'id' or 'entity_table/"); + $cases[] = array( + 'FakeFile', + 'create', + array(), + "/Mandatory key\\(s\\) missing from params array: 'id' or 'entity_table/" + ); + $cases[] = array( + 'FakeFile', + 'get', + array(), + "/Mandatory key\\(s\\) missing from params array: 'id' or 'entity_table/" + ); $cases[] = array('FakeFile', 'create', array('entity_table' => 'unknown'), '/Unrecognized target entity/'); $cases[] = array('FakeFile', 'get', array('entity_table' => 'unknown'), '/Unrecognized target entity/'); diff --git a/tests/phpunit/Civi/API/Subscriber/TransactionSubscriberTest.php b/tests/phpunit/Civi/API/Subscriber/TransactionSubscriberTest.php index d4c3a83bf4..58d76d6bc4 100644 --- a/tests/phpunit/Civi/API/Subscriber/TransactionSubscriberTest.php +++ b/tests/phpunit/Civi/API/Subscriber/TransactionSubscriberTest.php @@ -27,10 +27,42 @@ class TransactionSubscriberTest extends \CiviUnitTestCase { $r[] = array(3, 'Widget', 'create', array('options' => array('force_rollback' => TRUE)), TRUE, TRUE, TRUE); $r[] = array(3, 'Widget', 'create', array('options' => array('force_rollback' => FALSE)), TRUE, FALSE, FALSE); - $r[] = array(3, 'Widget', 'create', array('is_transactional' => TRUE, 'options' => array('force_rollback' => TRUE)), TRUE, TRUE, TRUE); - $r[] = array(3, 'Widget', 'create', array('is_transactional' => TRUE, 'options' => array('force_rollback' => FALSE)), TRUE, FALSE, FALSE); - $r[] = array(3, 'Widget', 'create', array('is_transactional' => FALSE, 'options' => array('force_rollback' => TRUE)), TRUE, TRUE, TRUE); - $r[] = array(3, 'Widget', 'create', array('is_transactional' => FALSE, 'options' => array('force_rollback' => FALSE)), FALSE, FALSE, FALSE); + $r[] = array( + 3, + 'Widget', + 'create', + array('is_transactional' => TRUE, 'options' => array('force_rollback' => TRUE)), + TRUE, + TRUE, + TRUE + ); + $r[] = array( + 3, + 'Widget', + 'create', + array('is_transactional' => TRUE, 'options' => array('force_rollback' => FALSE)), + TRUE, + FALSE, + FALSE + ); + $r[] = array( + 3, + 'Widget', + 'create', + array('is_transactional' => FALSE, 'options' => array('force_rollback' => TRUE)), + TRUE, + TRUE, + TRUE + ); + $r[] = array( + 3, + 'Widget', + 'create', + array('is_transactional' => FALSE, 'options' => array('force_rollback' => FALSE)), + FALSE, + FALSE, + FALSE + ); $r[] = array(4, 'Widget', 'get', array(), FALSE, FALSE, FALSE); $r[] = array(4, 'Widget', 'create', array(), TRUE, FALSE, FALSE); diff --git a/tests/phpunit/CiviTest/CiviDBAssert.php b/tests/phpunit/CiviTest/CiviDBAssert.php index f521833089..ba415c81e0 100644 --- a/tests/phpunit/CiviTest/CiviDBAssert.php +++ b/tests/phpunit/CiviTest/CiviDBAssert.php @@ -51,7 +51,7 @@ class CiviDBAssert { $testCase->fail('ID not populated. Please fix your assertDBState usage!!!'); } - $object = new $daoName(); + $object = new $daoName(); $object->id = $id; $verifiedCount = 0; diff --git a/tests/phpunit/CiviTest/CiviMailUtils.php b/tests/phpunit/CiviTest/CiviMailUtils.php index 61f0f4602d..73b147297f 100644 --- a/tests/phpunit/CiviTest/CiviMailUtils.php +++ b/tests/phpunit/CiviTest/CiviMailUtils.php @@ -264,8 +264,7 @@ class CiviMailUtils extends PHPUnit_Framework_TestCase { $this->_ut->assertContains($string, $mail, "$string . not found in $mail $prefix"); } foreach ($absentStrings as $string) { - $this->_ut->assertEmpty(strstr($mail, $string), "$string incorrectly found in $mail $prefix"); - ; + $this->_ut->assertEmpty(strstr($mail, $string), "$string incorrectly found in $mail $prefix");; } return $mail; } diff --git a/tests/phpunit/CiviTest/CiviReportTestCase.php b/tests/phpunit/CiviTest/CiviReportTestCase.php index 550c56cd56..6a928d5cc6 100644 --- a/tests/phpunit/CiviTest/CiviReportTestCase.php +++ b/tests/phpunit/CiviTest/CiviReportTestCase.php @@ -140,7 +140,7 @@ class CiviReportTestCase extends CiviUnitTestCase { foreach ($actualCsvArray as $intKey => $strVal) { $rowData = var_export(array( 'expected' => $expectedCsvArray[$intKey], - 'actual' => $actualCsvArray[$intKey], + 'actual' => $actualCsvArray[$intKey], ), TRUE); $this->assertNotNull($expectedCsvArray[$intKey], 'In line ' . __LINE__); $this->assertEquals( diff --git a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php index e67be0b40a..30fa7d25bc 100644 --- a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php +++ b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php @@ -1820,16 +1820,16 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { */ function _testEditFinancialAccount( $editfinancialAccount, - $financialAccountTitle = FALSE, - $financialAccountDescription = FALSE, - $accountingCode = FALSE, - $firstName = FALSE, - $financialAccountType = FALSE, - $taxDeductible = FALSE, - $isActive = TRUE, - $isTax = FALSE, - $taxRate = FALSE, - $isDefault = FALSE + $financialAccountTitle = FALSE, + $financialAccountDescription = FALSE, + $accountingCode = FALSE, + $firstName = FALSE, + $financialAccountType = FALSE, + $taxDeductible = FALSE, + $isActive = TRUE, + $isTax = FALSE, + $taxRate = FALSE, + $isDefault = FALSE ) { if ($firstName) { $this->openCiviPage("admin/financial/financialAccount", "reset=1"); diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index 7151be3ac1..12f4e98906 100755 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -2038,9 +2038,9 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { //have a crack @ deleting it first in the hope this will prevent derailing our tests $this->callAPISuccess('custom_group', 'get', array( - 'title' => $params['title'], - array('api.custom_group.delete' => 1), - )); + 'title' => $params['title'], + array('api.custom_group.delete' => 1), + )); return $this->callAPISuccess('custom_group', 'create', $params); } @@ -2083,24 +2083,24 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { $ids['custom_group_id'] = $customGroup['id']; $customField = $this->customFieldCreate(array( - 'custom_group_id' => $ids['custom_group_id'], - 'label' => 'field_1' . $ids['custom_group_id'], - )); + 'custom_group_id' => $ids['custom_group_id'], + 'label' => 'field_1' . $ids['custom_group_id'], + )); $ids['custom_field_id'][] = $customField['id']; $customField = $this->customFieldCreate(array( - 'custom_group_id' => $ids['custom_group_id'], - 'default_value' => '', - 'label' => 'field_2' . $ids['custom_group_id'], - )); + 'custom_group_id' => $ids['custom_group_id'], + 'default_value' => '', + 'label' => 'field_2' . $ids['custom_group_id'], + )); $ids['custom_field_id'][] = $customField['id']; $customField = $this->customFieldCreate(array( - 'custom_group_id' => $ids['custom_group_id'], - 'default_value' => '', - 'label' => 'field_3' . $ids['custom_group_id'], - )); + 'custom_group_id' => $ids['custom_group_id'], + 'default_value' => '', + 'label' => 'field_3' . $ids['custom_group_id'], + )); $ids['custom_field_id'][] = $customField['id']; return $ids; @@ -3037,24 +3037,24 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) $contributionPriceSet = $this->callAPISuccess('price_set', 'getsingle', array('name' => 'default_contribution_amount')); $firstID = $contributionPriceSet['id']; $this->callAPISuccess('price_set', 'create', array( - 'id' => $contributionPriceSet['id'], - 'is_active' => 0, - 'name' => 'old', - )); + 'id' => $contributionPriceSet['id'], + 'is_active' => 0, + 'name' => 'old', + )); unset($contributionPriceSet['id']); $newPriceSet = $this->callAPISuccess('price_set', 'create', $contributionPriceSet); $priceField = $this->callAPISuccess('price_field', 'getsingle', array( - 'price_set_id' => $firstID, - 'options' => array('limit' => 1), - )); + 'price_set_id' => $firstID, + 'options' => array('limit' => 1), + )); unset($priceField['id']); $priceField['price_set_id'] = $newPriceSet['id']; $newPriceField = $this->callAPISuccess('price_field', 'create', $priceField); $priceFieldValue = $this->callAPISuccess('price_field_value', 'getsingle', array( - 'price_set_id' => $firstID, - 'sequential' => 1, - 'options' => array('limit' => 1), - )); + 'price_set_id' => $firstID, + 'sequential' => 1, + 'options' => array('limit' => 1), + )); unset($priceFieldValue['id']); //create some padding to use up ids @@ -3157,18 +3157,18 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) 'line_total' => 200, 'financial_type_id' => 1, 'price_field_id' => $this->callAPISuccess('price_field', 'getvalue', array( - 'return' => 'id', - 'label' => 'Membership Amount', - )), + 'return' => 'id', + 'label' => 'Membership Amount', + )), 'price_field_value_id' => $this->callAPISuccess('price_field_value', 'getvalue', array( - 'return' => 'id', - 'label' => 'General', - )), + 'return' => 'id', + 'label' => 'General', + )), )); $this->callAPISuccess('membership_payment', 'create', array( - 'contribution_id' => $this->_contributionID, - 'membership_id' => $this->ids['membership'], - )); + 'contribution_id' => $this->_contributionID, + 'membership_id' => $this->ids['membership'], + )); } /** diff --git a/tests/phpunit/CiviTest/bootstrap.php b/tests/phpunit/CiviTest/bootstrap.php index 84640680b4..2ec2354a06 100644 --- a/tests/phpunit/CiviTest/bootstrap.php +++ b/tests/phpunit/CiviTest/bootstrap.php @@ -6,10 +6,10 @@ $tests_dir = $GLOBALS['base_dir'] . DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SE $civi_pkgs_dir = $GLOBALS['base_dir'] . DIRECTORY_SEPARATOR . 'packages'; ini_set('safe_mode', 0); ini_set('include_path', - "{$GLOBALS['base_dir']}" . PATH_SEPARATOR . - "$tests_dir" . PATH_SEPARATOR . - "$civi_pkgs_dir" . PATH_SEPARATOR - . ini_get('include_path')); + "{$GLOBALS['base_dir']}" . PATH_SEPARATOR . + "$tests_dir" . PATH_SEPARATOR . + "$civi_pkgs_dir" . PATH_SEPARATOR + . ini_get('include_path')); # Relying on system timezone setting produces a warning, # doing the following prevents the warning message diff --git a/tests/phpunit/CiviTest/civicrm.settings.dist.php b/tests/phpunit/CiviTest/civicrm.settings.dist.php index 24ed925dd3..e07d5394fe 100644 --- a/tests/phpunit/CiviTest/civicrm.settings.dist.php +++ b/tests/phpunit/CiviTest/civicrm.settings.dist.php @@ -8,8 +8,8 @@ define('CIVICRM_TEST', 1); //--- you shouldn't have to modify anything under this line, but might want to put the compiled templates CIVICRM_TEMPLATE_COMPILEDIR in a different folder than our default location ---------- -if (! defined('CIVICRM_DSN') && ! empty($GLOBALS['mysql_user'])) { - $dbName = ! empty($GLOBALS['mysql_db']) ? $GLOBALS['mysql_db'] : 'civicrm_tests_dev'; +if (!defined('CIVICRM_DSN') && !empty($GLOBALS['mysql_user'])) { + $dbName = !empty($GLOBALS['mysql_db']) ? $GLOBALS['mysql_db'] : 'civicrm_tests_dev'; if (empty($GLOBALS['mysql_pass']) && $GLOBALS['mysql_pass_need_password']) { $GLOBALS['mysql_pass'] = PHPUnit_TextUI_Command::getPassword('Password'); } @@ -55,7 +55,7 @@ $GLOBALS['mysql_db'] = $dsninfo['database']; * Content Management System (CMS) Host: * * CiviCRM can be hosted in either Drupal, Joomla or WordPress. -*/ + */ define('CIVICRM_UF', 'UnitTests'); @@ -122,10 +122,10 @@ define('CIVICRM_MYSQL_STRICT', TRUE); * */ -$include_path = '.' . PATH_SEPARATOR . - $civicrm_root . PATH_SEPARATOR . - $civicrm_root . DIRECTORY_SEPARATOR . 'packages' . PATH_SEPARATOR . - get_include_path(); +$include_path = '.' . PATH_SEPARATOR . + $civicrm_root . PATH_SEPARATOR . + $civicrm_root . DIRECTORY_SEPARATOR . 'packages' . PATH_SEPARATOR . + get_include_path(); set_include_path($include_path); if (function_exists('variable_get') && variable_get('clean_url', '0') != '0') { @@ -140,12 +140,15 @@ ini_set('auto_detect_line_endings', '1'); // make sure the memory_limit is at least 64 MB $memLimitString = trim(ini_get('memory_limit')); -$memLimitUnit = strtolower(substr($memLimitString, -1)); -$memLimit = (int) $memLimitString; +$memLimitUnit = strtolower(substr($memLimitString, -1)); +$memLimit = (int) $memLimitString; switch ($memLimitUnit) { - case 'g': $memLimit *= 1024; - case 'm': $memLimit *= 1024; - case 'k': $memLimit *= 1024; + case 'g': + $memLimit *= 1024; + case 'm': + $memLimit *= 1024; + case 'k': + $memLimit *= 1024; } if ($memLimit >= 0 and $memLimit < 67108864) { ini_set('memory_limit', '64M'); diff --git a/tests/phpunit/Utils.php b/tests/phpunit/Utils.php index 8a6d2c18ab..e1168f64fa 100644 --- a/tests/phpunit/Utils.php +++ b/tests/phpunit/Utils.php @@ -52,7 +52,7 @@ class Utils { array(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => TRUE) ); } - catch(PDOException$e) { + catch (PDOException$e) { echo "Can't connect to MySQL server:" . PHP_EOL . $e->getMessage() . PHP_EOL; exit(1); } @@ -91,40 +91,40 @@ class Utils { } /******* - if ( $this->pdo->errorCode() == 0 ) { - //echo "returning the PDOStmt\n"; - return $stmt; - } - - // operation failed, so output description of where and why - $errorInfo = $this->pdo->errorInfo(); - echo "Oops, can't do query:\n {$query}\n in " - . basename( __FILE__) . " line " . __LINE__.":\n " - . $errorInfo[0] . ": " . $errorInfo[2] . "\n Call stack:\n"; - $backtrace = debug_backtrace(); - $dir_name = dirname( __FILE__ ); - $cwd_len = strlen( $dir_name ) + 1; - foreach ($backtrace as $frame ) { - echo " "; - if ( array_key_exists( 'class', $frame ) ) { - echo " class {$frame['class']}"; - if ( array_key_exists( 'function', $frame ) ) { - echo " method {$frame['function']}"; - } - } - else { - if ( array_key_exists( 'function', $frame ) ) { - echo " function {$frame['function']}"; - } - } - if ( array_key_exists( 'file', $frame ) ) { - echo " file ". substr( $frame['file'], $cwd_len ); - } - if ( array_key_exists( 'line', $frame ) ) { - echo " line {$frame['line']}"; - } - echo "\n"; - } + * if ( $this->pdo->errorCode() == 0 ) { + * //echo "returning the PDOStmt\n"; + * return $stmt; + * } + * + * // operation failed, so output description of where and why + * $errorInfo = $this->pdo->errorInfo(); + * echo "Oops, can't do query:\n {$query}\n in " + * . basename( __FILE__) . " line " . __LINE__.":\n " + * . $errorInfo[0] . ": " . $errorInfo[2] . "\n Call stack:\n"; + * $backtrace = debug_backtrace(); + * $dir_name = dirname( __FILE__ ); + * $cwd_len = strlen( $dir_name ) + 1; + * foreach ($backtrace as $frame ) { + * echo " "; + * if ( array_key_exists( 'class', $frame ) ) { + * echo " class {$frame['class']}"; + * if ( array_key_exists( 'function', $frame ) ) { + * echo " method {$frame['function']}"; + * } + * } + * else { + * if ( array_key_exists( 'function', $frame ) ) { + * echo " function {$frame['function']}"; + * } + * } + * if ( array_key_exists( 'file', $frame ) ) { + * echo " file ". substr( $frame['file'], $cwd_len ); + * } + * if ( array_key_exists( 'line', $frame ) ) { + * echo " line {$frame['line']}"; + * } + * echo "\n"; + * } ******/ return TRUE; } diff --git a/tests/phpunit/WebTest/Admin/Form/Setting/LocalizationTest.php b/tests/phpunit/WebTest/Admin/Form/Setting/LocalizationTest.php index 3d1aa1bc97..55cbe9251f 100644 --- a/tests/phpunit/WebTest/Admin/Form/Setting/LocalizationTest.php +++ b/tests/phpunit/WebTest/Admin/Form/Setting/LocalizationTest.php @@ -54,7 +54,7 @@ class WebTest_Admin_Form_Setting_LocalizationTest extends CiviSeleniumTestCase { try { $this->assertFalse($this->isTextPresent("Your changes have been saved.")); } - catch(PHPUnit_Framework_AssertionFailedError$e) { + catch (PHPUnit_Framework_AssertionFailedError$e) { array_push($this->verificationErrors, $e->toString()); } } diff --git a/tests/phpunit/WebTest/Admin/MoveCustomDataTest.php b/tests/phpunit/WebTest/Admin/MoveCustomDataTest.php index df683f0ee6..2dd7d4a84d 100644 --- a/tests/phpunit/WebTest/Admin/MoveCustomDataTest.php +++ b/tests/phpunit/WebTest/Admin/MoveCustomDataTest.php @@ -38,9 +38,9 @@ class WebTest_Admin_MoveCustomDataTest extends CiviSeleniumTestCase { public function testCreateCustomFields() { $this->webtestLogin(); - $cid_all = $this->_createContact("all_data", "move_custom_data"); + $cid_all = $this->_createContact("all_data", "move_custom_data"); $cid_from_missing = $this->_createContact("source_missing", "move_custom_data"); - $cid_to_missing = $this->_createContact("destination_missing", "move_custom_data"); + $cid_to_missing = $this->_createContact("destination_missing", "move_custom_data"); $from_group_id = $this->_buildCustomFieldSet("source"); CRM_Utils_System::flushCache(); @@ -81,9 +81,14 @@ class WebTest_Admin_MoveCustomDataTest extends CiviSeleniumTestCase { //Make sure that only the appropriate values have changed foreach (array( - $cid_all, $cid_from_missing, $cid_to_missing) as $cid) { + $cid_all, + $cid_from_missing, + $cid_to_missing + ) as $cid) { foreach (array( - 'source', 'destination') as $fieldset) { + 'source', + 'destination' + ) as $fieldset) { foreach ($pre_move_values[$cid][$fieldset] as $id => $value) { if ($id != $field_to_move) { //All fields that were there should still be there @@ -103,8 +108,8 @@ class WebTest_Admin_MoveCustomDataTest extends CiviSeleniumTestCase { $this->openCiviPage('contact/view', "reset=1&cid={$cid_all}"); //load the names of the custom fieldsets - $source = $this->webtest_civicrm_api("CustomGroup", "get", array('id' => $from_group_id)); - $source = $source['values'][$from_group_id]; + $source = $this->webtest_civicrm_api("CustomGroup", "get", array('id' => $from_group_id)); + $source = $source['values'][$from_group_id]; $destination = $this->webtest_civicrm_api("CustomGroup", "get", array('id' => $to_group_id)); $destination = $destination['values'][$to_group_id]; @@ -210,7 +215,7 @@ class WebTest_Admin_MoveCustomDataTest extends CiviSeleniumTestCase { * @return null */ public function _buildCustomFieldset($prefix) { - $group_id = $this->_createCustomGroup($prefix); + $group_id = $this->_createCustomGroup($prefix); $field_ids[] = $this->_addCustomFieldToGroup($group_id, 'Alphanumeric', "CheckBox", $prefix); $field_ids[] = $this->_addCustomFieldToGroup($group_id, 'Alphanumeric', "Radio", $prefix); $field_ids[] = $this->_addCustomFieldToGroup($group_id, 'Alphanumeric', "Text", $prefix); @@ -265,7 +270,18 @@ class WebTest_Admin_MoveCustomDataTest extends CiviSeleniumTestCase { 'alphanumeric' => array( 'id' => 0, 'widgets' => array('Text', 'Select', 'Radio', 'CheckBox', 'Multi-Select'), - 'options' => array('option_01', 'option_02', 'option_03', 'option_04', 'option_05', 'option_06', 'option_07', 'option_08', 'option_09', 'option_10'), + 'options' => array( + 'option_01', + 'option_02', + 'option_03', + 'option_04', + 'option_05', + 'option_06', + 'option_07', + 'option_08', + 'option_09', + 'option_10' + ), ), 'integer' => array( 'id' => 1, @@ -385,7 +401,10 @@ class WebTest_Admin_MoveCustomDataTest extends CiviSeleniumTestCase { $this->waitForText('crm-notification-container', "Custom field '$fieldLabel' has been saved."); //get the custom id of the custom field that was just created - $results = $this->webtest_civicrm_api("CustomField", "get", array('label' => $fieldLabel, 'custom_group_id' => $group_id)); + $results = $this->webtest_civicrm_api("CustomField", "get", array( + 'label' => $fieldLabel, + 'custom_group_id' => $group_id + )); //While there _technically_ could be two fields with the same name, its highly unlikely //so assert that exactly one result is return $this->assertTrue($results['count'] == 1, "Could not uniquely get custom field id"); @@ -429,8 +448,11 @@ class WebTest_Admin_MoveCustomDataTest extends CiviSeleniumTestCase { //Recent (4.0.6+, i think?) versions of the api return this when getting //custom data for a contact. So we do that. $field_ids = array_keys($fields); - $contact = $this->webtest_civicrm_api("Contact", "get", array('contact_id' => $contact_id, 'return.custom_' . $field_ids[0] => 1)); - $group = $this->webtest_civicrm_api("CustomGroup", "get", array('id' => $group_id, 'return.table_name' => 1)); + $contact = $this->webtest_civicrm_api("Contact", "get", array( + 'contact_id' => $contact_id, + 'return.custom_' . $field_ids[0] => 1 + )); + $group = $this->webtest_civicrm_api("CustomGroup", "get", array('id' => $group_id, 'return.table_name' => 1)); //if the contact has not been saved since this fieldset has been creative, //the form uses id = -1. In this case the table pk wont be in the api results diff --git a/tests/phpunit/WebTest/Case/ActivityToCaseTest.php b/tests/phpunit/WebTest/Case/ActivityToCaseTest.php index 01e310ef02..e3d1f94d4f 100644 --- a/tests/phpunit/WebTest/Case/ActivityToCaseTest.php +++ b/tests/phpunit/WebTest/Case/ActivityToCaseTest.php @@ -43,7 +43,12 @@ class WebTest_Case_ActivityToCaseTest extends CiviSeleniumTestCase { $this->enableComponents("CiviCase"); // let's give full CiviCase permissions to demo user (registered user). - $permission = array('edit-2-access-all-cases-and-activities', 'edit-2-access-my-cases-and-activities', 'edit-2-administer-civicase', 'edit-2-delete-in-civicase'); + $permission = array( + 'edit-2-access-all-cases-and-activities', + 'edit-2-access-my-cases-and-activities', + 'edit-2-administer-civicase', + 'edit-2-delete-in-civicase' + ); $this->changePermissions($permission); // Log in as normal user @@ -89,7 +94,12 @@ class WebTest_Case_ActivityToCaseTest extends CiviSeleniumTestCase { $this->enableComponents("CiviCase"); // let's give full CiviCase permissions to demo user (registered user). - $permission = array('edit-2-access-all-cases-and-activities', 'edit-2-access-my-cases-and-activities', 'edit-2-administer-civicase', 'edit-2-delete-in-civicase'); + $permission = array( + 'edit-2-access-all-cases-and-activities', + 'edit-2-access-my-cases-and-activities', + 'edit-2-administer-civicase', + 'edit-2-delete-in-civicase' + ); $this->changePermissions($permission); // Log in as normal user @@ -186,6 +196,7 @@ class WebTest_Case_ActivityToCaseTest extends CiviSeleniumTestCase { ); $this->webtestVerifyTabularData($LinkCaseActivityData); } + /** * @param string $firstName * @param $caseSubject diff --git a/tests/phpunit/WebTest/Case/AddCaseTest.php b/tests/phpunit/WebTest/Case/AddCaseTest.php index a335d94fbb..0ca41a9775 100644 --- a/tests/phpunit/WebTest/Case/AddCaseTest.php +++ b/tests/phpunit/WebTest/Case/AddCaseTest.php @@ -43,7 +43,12 @@ class WebTest_Case_AddCaseTest extends CiviSeleniumTestCase { $this->enableComponents("CiviCase"); // let's give full CiviCase permissions to demo user (registered user). - $permission = array('edit-2-access-all-cases-and-activities', 'edit-2-access-my-cases-and-activities', 'edit-2-administer-civicase', 'edit-2-delete-in-civicase'); + $permission = array( + 'edit-2-access-all-cases-and-activities', + 'edit-2-access-my-cases-and-activities', + 'edit-2-administer-civicase', + 'edit-2-delete-in-civicase' + ); $this->changePermissions($permission); // Log in as normal user @@ -146,7 +151,12 @@ class WebTest_Case_AddCaseTest extends CiviSeleniumTestCase { $this->enableComponents("CiviCase"); // let's give full CiviCase permissions to demo user (registered user). - $permission = array('edit-2-access-all-cases-and-activities', 'edit-2-access-my-cases-and-activities', 'edit-2-administer-civicase', 'edit-2-delete-in-civicase'); + $permission = array( + 'edit-2-access-all-cases-and-activities', + 'edit-2-access-my-cases-and-activities', + 'edit-2-administer-civicase', + 'edit-2-delete-in-civicase' + ); $this->changePermissions($permission); // Log in as normal user diff --git a/tests/phpunit/WebTest/Case/AddCaseTypeTest.php b/tests/phpunit/WebTest/Case/AddCaseTypeTest.php index b2e6811df7..3b32266cfe 100644 --- a/tests/phpunit/WebTest/Case/AddCaseTypeTest.php +++ b/tests/phpunit/WebTest/Case/AddCaseTypeTest.php @@ -46,7 +46,12 @@ class WebTest_Case_AddCaseTypeTest extends CiviSeleniumTestCase { $this->enableComponents("CiviCase"); // let's give full CiviCase permissions to demo user (registered user). - $permission = array('edit-2-access-all-cases-and-activities', 'edit-2-access-my-cases-and-activities', 'edit-2-administer-civicase', 'edit-2-delete-in-civicase'); + $permission = array( + 'edit-2-access-all-cases-and-activities', + 'edit-2-access-my-cases-and-activities', + 'edit-2-administer-civicase', + 'edit-2-delete-in-civicase' + ); $this->changePermissions($permission); // Log in as normal user @@ -127,7 +132,7 @@ class WebTest_Case_AddCaseTypeTest extends CiviSeleniumTestCase { $this->waitForElementPresent('title'); $this->type('title', $editCaseTypeLabel); - $this->select2("xpath=//div[@id='crm-main-content-wrapper']/div/div/form/div/div[4]/table/tfoot/tr/td/span/div/a",'Sibling of', FALSE, TRUE); + $this->select2("xpath=//div[@id='crm-main-content-wrapper']/div/div/form/div/div[4]/table/tfoot/tr/td/span/div/a", 'Sibling of', FALSE, TRUE); $this->click("xpath=//*[@id='crm-main-content-wrapper']/div/div/form/div/div[4]/table/tbody/tr[4]/td[2]/input[@type='checkbox']"); $this->click("xpath=//a[text()='Standard Timeline']"); diff --git a/tests/phpunit/WebTest/Case/CaseCustomFieldsTest.php b/tests/phpunit/WebTest/Case/CaseCustomFieldsTest.php index f47dec00e1..1ca265c8be 100644 --- a/tests/phpunit/WebTest/Case/CaseCustomFieldsTest.php +++ b/tests/phpunit/WebTest/Case/CaseCustomFieldsTest.php @@ -64,7 +64,12 @@ class WebTest_Case_CaseCustomFieldsTest extends CiviSeleniumTestCase { $cusId_3 = 'custom_' . $customId[2] . '_-1'; // let's give full CiviCase permissions. - $permission = array('edit-2-access-all-cases-and-activities', 'edit-2-access-my-cases-and-activities', 'edit-2-administer-civicase', 'edit-2-delete-in-civicase'); + $permission = array( + 'edit-2-access-all-cases-and-activities', + 'edit-2-access-my-cases-and-activities', + 'edit-2-administer-civicase', + 'edit-2-delete-in-civicase' + ); $this->changePermissions($permission); // Log in as normal user @@ -201,7 +206,11 @@ class WebTest_Case_CaseCustomFieldsTest extends CiviSeleniumTestCase { $this->clickLink("_qf_Field_next_new-bottom"); // get id of custom fields - $this->openCiviPage("admin/custom/group/field", array('reset' => 1, 'action' => 'browse', 'gid' => $customGrpId1)); + $this->openCiviPage("admin/custom/group/field", array( + 'reset' => 1, + 'action' => 'browse', + 'gid' => $customGrpId1 + )); $custom1 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr[1]/td[8]/span/a[text()='Edit Field']/@href")); $custom1 = $custom1[1]; array_push($customId, $custom1); @@ -229,7 +238,11 @@ class WebTest_Case_CaseCustomFieldsTest extends CiviSeleniumTestCase { $this->clickLink("_qf_Field_done-bottom"); // get id of custom fields - $this->openCiviPage("admin/custom/group/field", array('reset' => 1, 'action' => 'browse', 'gid' => $customGrpId1)); + $this->openCiviPage("admin/custom/group/field", array( + 'reset' => 1, + 'action' => 'browse', + 'gid' => $customGrpId1 + )); $custom1 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr[1]/td[8]/span/a[text()='Edit Field']/@href")); $custom1 = $custom1[1]; array_push($customId, $custom1); @@ -251,7 +264,12 @@ class WebTest_Case_CaseCustomFieldsTest extends CiviSeleniumTestCase { public function _testDeleteCustomData($customGrpId1, $customId) { // delete all custom data foreach ($customId as $cKey => $cValue) { - $this->openCiviPage("admin/custom/group/field", array('action' => 'delete', 'reset' => '1', 'gid' => $customGrpId1, 'id' => $cValue)); + $this->openCiviPage("admin/custom/group/field", array( + 'action' => 'delete', + 'reset' => '1', + 'gid' => $customGrpId1, + 'id' => $cValue + )); $this->clickLink("_qf_DeleteField_next-bottom"); } @@ -292,7 +310,12 @@ class WebTest_Case_CaseCustomFieldsTest extends CiviSeleniumTestCase { $cusId_2 = 'custom_' . $customId[1] . '_-1'; // let's give full CiviCase permissions. - $permission = array('edit-2-access-all-cases-and-activities', 'edit-2-access-my-cases-and-activities', 'edit-2-administer-civicase', 'edit-2-delete-in-civicase'); + $permission = array( + 'edit-2-access-all-cases-and-activities', + 'edit-2-access-my-cases-and-activities', + 'edit-2-administer-civicase', + 'edit-2-delete-in-civicase' + ); $this->changePermissions($permission); // Log in as normal user diff --git a/tests/phpunit/WebTest/Case/CaseDashboardTest.php b/tests/phpunit/WebTest/Case/CaseDashboardTest.php index a6af037644..c8166af949 100644 --- a/tests/phpunit/WebTest/Case/CaseDashboardTest.php +++ b/tests/phpunit/WebTest/Case/CaseDashboardTest.php @@ -43,7 +43,12 @@ class WebTest_Case_CaseDashboardTest extends CiviSeleniumTestCase { $this->enableComponents("CiviCase"); // let's give full CiviCase permissions to demo user (registered user). - $permission = array('edit-2-access-all-cases-and-activities', 'edit-2-access-my-cases-and-activities', 'edit-2-administer-civicase', 'edit-2-delete-in-civicase'); + $permission = array( + 'edit-2-access-all-cases-and-activities', + 'edit-2-access-my-cases-and-activities', + 'edit-2-administer-civicase', + 'edit-2-delete-in-civicase' + ); $this->changePermissions($permission); // Log in as normal user diff --git a/tests/phpunit/WebTest/Contact/AdvanceSearchPaneTest.php b/tests/phpunit/WebTest/Contact/AdvanceSearchPaneTest.php index 40b7094ae4..35883bb5c0 100644 --- a/tests/phpunit/WebTest/Contact/AdvanceSearchPaneTest.php +++ b/tests/phpunit/WebTest/Contact/AdvanceSearchPaneTest.php @@ -174,221 +174,226 @@ class WebTest_Contact_AdvanceSearchPaneTest extends CiviSeleniumTestCase { if (!isset($_advance_search_panes) || empty($_advance_search_panes)) { $_advance_search_panes = array( 'location' => - array( - 'headerLocator' => 'div#location', - 'bodyLocator' => 'select#country', - 'title' => 'Address Fields', - 'fields' => array( - 'Location Type' => - array( - 'type' => 'multiselect2', - 'locator' => 'location_type', - 'values' => array(array('Home', 'Work')), - ), - 'Country' => - array( - 'type' => 'select', - 'locator' => 'country', - 'values' => array('United States'), - ), - 'State' => - array( - 'type' => 'multiselect2', - 'locator' => 'state_province', - 'values' => array(array('Alabama', 'California', 'New Jersey', 'New York')), - ), + 'headerLocator' => 'div#location', + 'bodyLocator' => 'select#country', + 'title' => 'Address Fields', + 'fields' => + array( + 'Location Type' => + array( + 'type' => 'multiselect2', + 'locator' => 'location_type', + 'values' => array(array('Home', 'Work')), + ), + 'Country' => + array( + 'type' => 'select', + 'locator' => 'country', + 'values' => array('United States'), + ), + 'State' => + array( + 'type' => 'multiselect2', + 'locator' => 'state_province', + 'values' => array(array('Alabama', 'California', 'New Jersey', 'New York')), + ), + ), ), - ), 'custom' => - array( - 'headerLocator' => 'div#custom', - 'bodyLocator' => 'div#constituent_information', - 'title' => 'Custom Data', - 'fields' => array( - 'Marital Status' => - array( - 'type' => 'select', - 'locator' => 'custom_2', - 'values' => array('Single'), - ), + 'headerLocator' => 'div#custom', + 'bodyLocator' => 'div#constituent_information', + 'title' => 'Custom Data', + 'fields' => + array( + 'Marital Status' => + array( + 'type' => 'select', + 'locator' => 'custom_2', + 'values' => array('Single'), + ), + ), ), - ), 'activity' => - array( - 'headerLocator' => 'div#activity', - 'bodyLocator' => 'input#activity_subject', - 'title' => 'Activities', - 'fields' => array( - 'Activity Type' => - array( - 'type' => 'checkbox', - 'values' => array('activity_type_id[6]', 'activity_type_id[3]', 'activity_type_id[5]', 'activity_type_id[7]'), - ), - 'Activity Subject' => - array( - 'type' => 'text', - 'locator' => 'activity_subject', - 'values' => array('Test Subject'), - ), - 'Activity Status' => - array( - 'type' => 'checkbox', - 'values' => array('activity_status[1]', 'activity_status[2]'), - ), + 'headerLocator' => 'div#activity', + 'bodyLocator' => 'input#activity_subject', + 'title' => 'Activities', + 'fields' => + array( + 'Activity Type' => + array( + 'type' => 'checkbox', + 'values' => array( + 'activity_type_id[6]', + 'activity_type_id[3]', + 'activity_type_id[5]', + 'activity_type_id[7]' + ), + ), + 'Activity Subject' => + array( + 'type' => 'text', + 'locator' => 'activity_subject', + 'values' => array('Test Subject'), + ), + 'Activity Status' => + array( + 'type' => 'checkbox', + 'values' => array('activity_status[1]', 'activity_status[2]'), + ), + ), ), - ), 'relationship' => - array( - 'headerLocator' => 'div#relationship', - 'bodyLocator' => 'select#relation_type_id', - 'title' => 'Relationships', - 'fields' => array( - 'Relation Type' => - array( - 'type' => 'select', - 'locator' => 'relation_type_id', - 'values' => array('Employee of'), - ), - 'Relation Target' => - array( - 'type' => 'text', - 'locator' => 'relation_target_name', - 'values' => array('Test Contact'), - ), + 'headerLocator' => 'div#relationship', + 'bodyLocator' => 'select#relation_type_id', + 'title' => 'Relationships', + 'fields' => + array( + 'Relation Type' => + array( + 'type' => 'select', + 'locator' => 'relation_type_id', + 'values' => array('Employee of'), + ), + 'Relation Target' => + array( + 'type' => 'text', + 'locator' => 'relation_target_name', + 'values' => array('Test Contact'), + ), + ), ), - ), 'demographics' => - array( - 'headerLocator' => 'div#demographics', - 'bodyLocator' => 'input#birth_date_low_display', - 'title' => 'Demographics', - 'fields' => array( - 'Birth Date Range' => - array( - 'type' => 'select', - 'locator' => 'birth_date_relative', - 'values' => array('Choose Date Range'), - ), - 'Birth Date from' => - array( - 'type' => 'date', - 'locator' => 'birth_date_low', - 'values' => array('10 September 1980'), - ), - 'Birth Date to' => - array( - 'type' => 'date', - 'locator' => 'birth_date_high', - 'values' => array('10 September 2000'), - ), + 'headerLocator' => 'div#demographics', + 'bodyLocator' => 'input#birth_date_low_display', + 'title' => 'Demographics', + 'fields' => + array( + 'Birth Date Range' => + array( + 'type' => 'select', + 'locator' => 'birth_date_relative', + 'values' => array('Choose Date Range'), + ), + 'Birth Date from' => + array( + 'type' => 'date', + 'locator' => 'birth_date_low', + 'values' => array('10 September 1980'), + ), + 'Birth Date to' => + array( + 'type' => 'date', + 'locator' => 'birth_date_high', + 'values' => array('10 September 2000'), + ), + ), ), - ), 'note' => - array( - 'headerLocator' => 'div#notes', - 'bodyLocator' => 'input#note', - 'title' => 'Notes', - 'fields' => array( - 'note' => - array( - 'type' => 'text', - 'locator' => 'css=div#notes-search input#note', - 'values' => array('Test Note'), - ), + 'headerLocator' => 'div#notes', + 'bodyLocator' => 'input#note', + 'title' => 'Notes', + 'fields' => + array( + 'note' => + array( + 'type' => 'text', + 'locator' => 'css=div#notes-search input#note', + 'values' => array('Test Note'), + ), + ), ), - ), 'change_log' => - array( - 'headerLocator' => 'div#changeLog', - 'bodyLocator' => 'input#changed_by', - 'title' => 'Change Log', - 'fields' => array( - 'Modified By' => - array( - 'type' => 'text', - 'locator' => 'changed_by', - 'values' => array('Test User'), - ), + 'headerLocator' => 'div#changeLog', + 'bodyLocator' => 'input#changed_by', + 'title' => 'Change Log', + 'fields' => + array( + 'Modified By' => + array( + 'type' => 'text', + 'locator' => 'changed_by', + 'values' => array('Test User'), + ), + ), ), - ), 'contribution' => - array( - 'headerLocator' => 'div#CiviContribute', - 'bodyLocator' => 'select#financial_type_id', - 'title' => 'Contributions', - 'fields' => array( - 'Amount from' => - array( - 'type' => 'text', - 'locator' => 'contribution_amount_low', - 'values' => array('10'), - ), - 'Amount to' => - array( - 'type' => 'text', - 'locator' => 'contribution_amount_high', - 'values' => array('1000'), - ), - 'Financial Type' => - - array( - 'type' => 'select', - 'locator' => 'financial_type_id', - 'values' => array('Donation'), - ), - 'Contribution Status' => - array( - 'type' => 'checkbox', - 'values' => array('contribution_status_id[1]', 'contribution_status_id[2]'), - ), + 'headerLocator' => 'div#CiviContribute', + 'bodyLocator' => 'select#financial_type_id', + 'title' => 'Contributions', + 'fields' => + array( + 'Amount from' => + array( + 'type' => 'text', + 'locator' => 'contribution_amount_low', + 'values' => array('10'), + ), + 'Amount to' => + array( + 'type' => 'text', + 'locator' => 'contribution_amount_high', + 'values' => array('1000'), + ), + 'Financial Type' => + + array( + 'type' => 'select', + 'locator' => 'financial_type_id', + 'values' => array('Donation'), + ), + 'Contribution Status' => + array( + 'type' => 'checkbox', + 'values' => array('contribution_status_id[1]', 'contribution_status_id[2]'), + ), + ), ), - ), 'membership' => - array( - 'headerLocator' => 'div#CiviMember', - 'bodyLocator' => 'input#member_source', - 'title' => 'Memberships', - 'fields' => array( - 'Membership Type' => - array( - 'type' => 'checkbox', - 'values' => array('member_membership_type_id[1]', 'member_membership_type_id[2]'), - ), - 'Membership Status' => - array( - 'type' => 'checkbox', - 'values' => array('member_status_id[1]', 'member_status_id[2]'), - ), + 'headerLocator' => 'div#CiviMember', + 'bodyLocator' => 'input#member_source', + 'title' => 'Memberships', + 'fields' => + array( + 'Membership Type' => + array( + 'type' => 'checkbox', + 'values' => array('member_membership_type_id[1]', 'member_membership_type_id[2]'), + ), + 'Membership Status' => + array( + 'type' => 'checkbox', + 'values' => array('member_status_id[1]', 'member_status_id[2]'), + ), + ), ), - ), 'event' => - array( - 'headerLocator' => 'div#CiviEvent', - 'bodyLocator' => 'input#event_id', - 'title' => 'Events', - 'fields' => array( - 'Participant Status' => - array( - 'type' => 'checkbox', - 'values' => array('participant_status_id[1]', 'participant_status_id[2]'), - ), - 'Participant Role' => - array( - 'type' => 'checkbox', - 'values' => array('participant_role_id[1]', 'participant_role_id[2]'), - ), + 'headerLocator' => 'div#CiviEvent', + 'bodyLocator' => 'input#event_id', + 'title' => 'Events', + 'fields' => + array( + 'Participant Status' => + array( + 'type' => 'checkbox', + 'values' => array('participant_status_id[1]', 'participant_status_id[2]'), + ), + 'Participant Role' => + array( + 'type' => 'checkbox', + 'values' => array('participant_role_id[1]', 'participant_role_id[2]'), + ), + ), ), - ), ); } diff --git a/tests/phpunit/WebTest/Contact/AdvancedSearchTest.php b/tests/phpunit/WebTest/Contact/AdvancedSearchTest.php index 708a144d7c..3a470752fe 100644 --- a/tests/phpunit/WebTest/Contact/AdvancedSearchTest.php +++ b/tests/phpunit/WebTest/Contact/AdvancedSearchTest.php @@ -131,7 +131,10 @@ class WebTest_Contact_AdvancedSearchTest extends CiviSeleniumTestCase { 'CiviEvent' => array('participant_fee_amount_high', 'addParticipantSearchDetail'), 'CiviMember' => array('member_end_date_high', 'addMemberSearchDetail'), 'CiviPledge' => array('pledge_frequency_interval', 'addPledgeSearchDetail'), - 'relationship' => array("xpath=//div[@id='relationship']/table/tbody/tr//td/label[text()='Relationship Status']/../label[text()='All']", ''), + 'relationship' => array( + "xpath=//div[@id='relationship']/table/tbody/tr//td/label[text()='Relationship Status']/../label[text()='All']", + '' + ), ); foreach ($searchBlockValues as $block => $blockValues) { @@ -238,7 +241,15 @@ class WebTest_Contact_AdvancedSearchTest extends CiviSeleniumTestCase { $this->clickAjaxLink("location", 'country'); $this->select2("country", "United States", FALSE); $this->waitForElementPresent('state_province'); - $this->multiselect2("state_province", array("Ohio", "New York", "New Mexico", "Connecticut", "Georgia", "New Jersey", "Texas")); + $this->multiselect2("state_province", array( + "Ohio", + "New York", + "New Mexico", + "Connecticut", + "Georgia", + "New Jersey", + "Texas" + )); $this->clickLink("_qf_Advanced_refresh", "xpath=//div[@class='crm-search-results']//table/tbody/tr[1]/td[6]"); $stateBeforeSort = $this->getText("xpath=//div[@class='crm-search-results']//table/tbody/tr[1]/td[6]"); diff --git a/tests/phpunit/WebTest/Contact/AdvancedSearchedRelatedContactTest.php b/tests/phpunit/WebTest/Contact/AdvancedSearchedRelatedContactTest.php index f3dcadacdc..7488f11008 100644 --- a/tests/phpunit/WebTest/Contact/AdvancedSearchedRelatedContactTest.php +++ b/tests/phpunit/WebTest/Contact/AdvancedSearchedRelatedContactTest.php @@ -61,7 +61,7 @@ class WebTest_Contact_AdvancedSearchedRelatedContactTest extends CiviSeleniumTes $eventId = $Id[1]; $params = array( - 'label_a_b' => 'Owner of ' . rand(), + 'label_a_b' => 'Owner of ' . rand(), 'label_b_a' => 'Belongs to ' . rand(), 'contact_type_a' => 'Individual', 'contact_type_b' => 'Individual', @@ -307,12 +307,12 @@ class WebTest_Contact_AdvancedSearchedRelatedContactTest extends CiviSeleniumTes public function testAdvanceSearchForLog() { $this->webtestLogin(); - $Pdate = date('F jS, Y h:i:s A', mktime(0, 0, 0, date('m'), date('d') - 1, date('Y'))); - $Ndate = date('F jS, Y h:i:s A', mktime(0, 0, 0, date('m'), date('d') + 1, date('Y'))); + $Pdate = date('F jS, Y h:i:s A', mktime(0, 0, 0, date('m'), date('d') - 1, date('Y'))); + $Ndate = date('F jS, Y h:i:s A', mktime(0, 0, 0, date('m'), date('d') + 1, date('Y'))); //create a contact and return the contact id $firstNameSoft = "John_" . substr(sha1(rand()), 0, 5); - $lastNameSoft = "Doe_" . substr(sha1(rand()), 0, 5); + $lastNameSoft = "Doe_" . substr(sha1(rand()), 0, 5); $this->webtestAddContact($firstNameSoft, $lastNameSoft); $cid = $this->urlArg('cid'); diff --git a/tests/phpunit/WebTest/Contact/CustomDataAddTest.php b/tests/phpunit/WebTest/Contact/CustomDataAddTest.php index 86420cf64d..48b7154a36 100644 --- a/tests/phpunit/WebTest/Contact/CustomDataAddTest.php +++ b/tests/phpunit/WebTest/Contact/CustomDataAddTest.php @@ -141,8 +141,8 @@ class WebTest_Contact_CustomDataAddTest extends CiviSeleniumTestCase { //fill first name, last name, email id $firstName = 'Ma' . substr(sha1(rand()), 0, 4); - $lastName = 'An' . substr(sha1(rand()), 0, 7); - $emailId = substr(sha1(rand()), 0, 7) . '@web.com'; + $lastName = 'An' . substr(sha1(rand()), 0, 7); + $emailId = substr(sha1(rand()), 0, 7) . '@web.com'; $this->click("first_name"); $this->type("first_name", $firstName); $this->type("last_name", $lastName); @@ -217,8 +217,8 @@ class WebTest_Contact_CustomDataAddTest extends CiviSeleniumTestCase { //fill first name, last name, email id $firstName = 'Ma' . substr(sha1(rand()), 0, 4); - $lastName = 'An' . substr(sha1(rand()), 0, 7); - $emailId = substr(sha1(rand()), 0, 7) . '@web.com'; + $lastName = 'An' . substr(sha1(rand()), 0, 7); + $emailId = substr(sha1(rand()), 0, 7) . '@web.com'; $this->click("first_name"); $this->type("first_name", $firstName); $this->type("last_name", $lastName); diff --git a/tests/phpunit/WebTest/Contact/DupeContactTest.php b/tests/phpunit/WebTest/Contact/DupeContactTest.php index c941b0b988..8b8c58b47d 100644 --- a/tests/phpunit/WebTest/Contact/DupeContactTest.php +++ b/tests/phpunit/WebTest/Contact/DupeContactTest.php @@ -42,7 +42,7 @@ class WebTest_Contact_DupeContactTest extends CiviSeleniumTestCase { $firstName = substr(sha1(rand()), 0, 7); $lastName1 = substr(sha1(rand()), 0, 7); - $email = "{$firstName}@example.com"; + $email = "{$firstName}@example.com"; $lastName2 = substr(sha1(rand()), 0, 7); //contact details section diff --git a/tests/phpunit/WebTest/Contact/EditContactTest.php b/tests/phpunit/WebTest/Contact/EditContactTest.php index b39909663d..7d12b57d9b 100644 --- a/tests/phpunit/WebTest/Contact/EditContactTest.php +++ b/tests/phpunit/WebTest/Contact/EditContactTest.php @@ -40,7 +40,7 @@ class WebTest_Contact_EditContactTest extends CiviSeleniumTestCase { // create contact $firstName = 'WebTest' . substr(sha1(rand()), 0, 7); - $lastName = 'ContactEdit' . substr(sha1(rand()), 0, 7); + $lastName = 'ContactEdit' . substr(sha1(rand()), 0, 7); $this->openCiviPage("contact/add", "reset=1&ct=Individual"); $this->type("first_name", $firstName); $this->type("last_name", $lastName); diff --git a/tests/phpunit/WebTest/Contact/GroupAddTest.php b/tests/phpunit/WebTest/Contact/GroupAddTest.php index 3eb09cb810..d726ad491e 100644 --- a/tests/phpunit/WebTest/Contact/GroupAddTest.php +++ b/tests/phpunit/WebTest/Contact/GroupAddTest.php @@ -233,8 +233,8 @@ class WebTest_Contact_GroupAddTest extends CiviSeleniumTestCase { } /** - * Webtest for add contact to group (CRM-15108) - */ + * Webtest for add contact to group (CRM-15108) + */ public function testAddContactToGroup() { $this->webtestLogin(); $this->openCiviPage("contact/add", "reset=1&ct=Individual"); diff --git a/tests/phpunit/WebTest/Contact/InlineFieldsEditTest.php b/tests/phpunit/WebTest/Contact/InlineFieldsEditTest.php index 38b6f9eebe..9bec1e2f30 100644 --- a/tests/phpunit/WebTest/Contact/InlineFieldsEditTest.php +++ b/tests/phpunit/WebTest/Contact/InlineFieldsEditTest.php @@ -40,7 +40,7 @@ class WebTest_Contact_InlineFieldsEditTest extends CiviSeleniumTestCase { // Add a contact $firstName = 'WebTest' . substr(sha1(rand()), 0, 7); - $lastName = 'InlineFieldsEdit' . substr(sha1(rand()), 0, 7); + $lastName = 'InlineFieldsEdit' . substr(sha1(rand()), 0, 7); $this->webtestAddContact($firstName, $lastName); $contactId = $this->urlArg('cid'); $this->waitForElementPresent('css=.crm-inline-edit-container.crm-edit-ready'); diff --git a/tests/phpunit/WebTest/Contact/MergeContactsTest.php b/tests/phpunit/WebTest/Contact/MergeContactsTest.php index d66cb46c94..a74f608d50 100644 --- a/tests/phpunit/WebTest/Contact/MergeContactsTest.php +++ b/tests/phpunit/WebTest/Contact/MergeContactsTest.php @@ -250,6 +250,7 @@ class WebTest_Contact_MergeContactsTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); $this->assertTrue($this->isTextPresent("Staff, Student")); } + /** * @param string $firstName * @param string $lastName @@ -599,7 +600,7 @@ class WebTest_Contact_MergeContactsTest extends CiviSeleniumTestCase { $this->assertTrue( (bool) preg_match("/^This will run the batch merge process on the listed duplicates. The operation will run in safe mode - only records with no direct data conflicts will be merged. Click OK to proceed if you are sure you wish to run this operation./", $this->getConfirmation() - )); + )); $this->chooseOkOnNextConfirmation(); $this->waitForPageToLoad($this->getTimeoutMsec()); $this->waitForElementPresent('civicrm-footer'); diff --git a/tests/phpunit/WebTest/Contact/ProfileChecksumTest.php b/tests/phpunit/WebTest/Contact/ProfileChecksumTest.php index c0b589084a..ed9d249428 100644 --- a/tests/phpunit/WebTest/Contact/ProfileChecksumTest.php +++ b/tests/phpunit/WebTest/Contact/ProfileChecksumTest.php @@ -103,7 +103,12 @@ class WebTest_Contact_ProfileChecksumTest extends CiviSeleniumTestCase { $profileId = $this->_testCreateContactProfile($fields, $profileName); // Check for profile create/edit permissions. - $permission = array('edit-1-profile-edit', 'edit-1-profile-create', 'edit-1-access-all-custom-data', 'edit-1-edit-all-contacts'); + $permission = array( + 'edit-1-profile-edit', + 'edit-1-profile-create', + 'edit-1-access-all-custom-data', + 'edit-1-edit-all-contacts' + ); $this->changePermissions($permission); // Get checksum of the newly created contact. diff --git a/tests/phpunit/WebTest/Contribute/AddBatchesTest.php b/tests/phpunit/WebTest/Contribute/AddBatchesTest.php index 1e4ebb9a2b..3c8fbbb36a 100644 --- a/tests/phpunit/WebTest/Contribute/AddBatchesTest.php +++ b/tests/phpunit/WebTest/Contribute/AddBatchesTest.php @@ -206,7 +206,8 @@ class WebTest_Contribute_AddBatchesTest extends CiviSeleniumTestCase { if (!empty($data['contact'])) { $pledgeID = CRM_Pledge_BAO_Pledge::getContactPledges($data['contact']['id']); $this->select("open_pledges_{$row}", "value={$pledgeID[0]}"); - $this->click("css=span#{$row}.pledge-adjust-option a");sleep(5); + $this->click("css=span#{$row}.pledge-adjust-option a"); + sleep(5); $this->select("option_type_{$row}", "value=1"); $this->click("css=span#{$row}.pledge-adjust-option a"); $this->type("field_{$row}_total_amount", $data['amount']); diff --git a/tests/phpunit/WebTest/Contribute/OfflineContributionTest.php b/tests/phpunit/WebTest/Contribute/OfflineContributionTest.php index 7d0ce9e8a7..7026dd9f68 100644 --- a/tests/phpunit/WebTest/Contribute/OfflineContributionTest.php +++ b/tests/phpunit/WebTest/Contribute/OfflineContributionTest.php @@ -395,7 +395,7 @@ class WebTest_Contribute_OfflineContributionTest extends CiviSeleniumTestCase { "xpath=//form[@id='Basic']/div[3]/div[1]/div[2]/table/tbody/tr[1]/td[11]/span/a[text()='View']"); $this->clickLink("xpath=//form[@id='Basic']/div[3]/div[1]/div[2]/table/tbody/tr[1]/td[11]/span/a[text()='View']", - 'crm-contact-actions-link', FALSE); + 'crm-contact-actions-link', FALSE); } public function testOnlineContributionWithZeroAmount() { diff --git a/tests/phpunit/WebTest/Contribute/OfflineRecurContributionTest.php b/tests/phpunit/WebTest/Contribute/OfflineRecurContributionTest.php index fd560165e2..c7633a30d5 100644 --- a/tests/phpunit/WebTest/Contribute/OfflineRecurContributionTest.php +++ b/tests/phpunit/WebTest/Contribute/OfflineRecurContributionTest.php @@ -43,9 +43,9 @@ class WebTest_Contribute_OfflineRecurContributionTest extends CiviSeleniumTestCa $this->webtestAddPaymentProcessor($processorName, 'AuthNet'); // create a new contact for whom recurring contribution is to be created - $firstName = 'Jane' . substr(sha1(rand()), 0, 7); + $firstName = 'Jane' . substr(sha1(rand()), 0, 7); $middleName = 'Middle'; - $lastName = 'Recuroff_' . substr(sha1(rand()), 0, 7); + $lastName = 'Recuroff_' . substr(sha1(rand()), 0, 7); $this->webtestAddContact($firstName, $lastName, "{$firstName}@example.com"); $contactName = "$firstName $lastName"; @@ -97,7 +97,7 @@ class WebTest_Contribute_OfflineRecurContributionTest extends CiviSeleniumTestCa // View Recurring Contribution Record $verifyData = array( 'From' => "$contactName", - 'Financial Type' => 'Donation (test)', + 'Financial Type' => 'Donation (test)', 'Total Amount' => 'Installments: 12, Interval: 1 month(s)', 'Contribution Status' => 'Pending : Incomplete Transaction', 'Paid By' => 'Credit Card', diff --git a/tests/phpunit/WebTest/Contribute/OnBehalfOfOrganization.php b/tests/phpunit/WebTest/Contribute/OnBehalfOfOrganization.php index 6ee756dbdd..ade04f9896 100644 --- a/tests/phpunit/WebTest/Contribute/OnBehalfOfOrganization.php +++ b/tests/phpunit/WebTest/Contribute/OnBehalfOfOrganization.php @@ -31,6 +31,7 @@ require_once 'CiviTest/CiviSeleniumTestCase.php'; */ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { protected $pageno = ''; + protected function setUp() { parent::setUp(); } @@ -380,7 +381,11 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { $gid = $this->urlArg('gid'); - $this->openCiviPage('admin/uf/group/field/add', array('action' => 'add', 'reset' => 1, 'gid' => $gid), 'field_name[0]'); + $this->openCiviPage('admin/uf/group/field/add', array( + 'action' => 'add', + 'reset' => 1, + 'gid' => $gid + ), 'field_name[0]'); $this->select('field_name[0]', "value=Membership"); $this->select('field_name[1]', "label={$checkboxFieldLabel} :: {$customGroupTitle}"); $this->click('field_name[1]'); @@ -1369,8 +1374,8 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { // Check confirmation alert. $this->assertTrue((bool) preg_match("/^Are you sure you want to delete this relationship?/", - $this->getConfirmation() - )); + $this->getConfirmation() + )); $this->chooseOkOnNextConfirmation(); $this->waitForPageToLoad($this->getTimeoutMsec()); $this->assertTrue($this->isTextPresent('Selected relationship has been deleted successfully.'), @@ -1505,7 +1510,7 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { //header("Content-Type: image/png"); $im = imagecreate(110, 20) - or die("Cannot Initialize new GD image stream"); + or die("Cannot Initialize new GD image stream"); $background_color = imagecolorallocate($im, 0, 0, 0); $text_color = imagecolorallocate($im, 233, 14, 91); imagestring($im, 1, 5, 5, "On Behalf-Org Logo", $text_color); diff --git a/tests/phpunit/WebTest/Contribute/OnlineContributionTest.php b/tests/phpunit/WebTest/Contribute/OnlineContributionTest.php index 4f0eb82276..49d3d28a39 100644 --- a/tests/phpunit/WebTest/Contribute/OnlineContributionTest.php +++ b/tests/phpunit/WebTest/Contribute/OnlineContributionTest.php @@ -178,7 +178,7 @@ class WebTest_Contribute_OnlineContributionTest extends CiviSeleniumTestCase { } - public function testOnlineContributionWithZeroAmount () { + public function testOnlineContributionWithZeroAmount() { $this->webtestLogin(); // Use default payment processor diff --git a/tests/phpunit/WebTest/Contribute/OnlineMultiplePaymentProcessorTest.php b/tests/phpunit/WebTest/Contribute/OnlineMultiplePaymentProcessorTest.php index f6b7b67cba..3605ea424c 100644 --- a/tests/phpunit/WebTest/Contribute/OnlineMultiplePaymentProcessorTest.php +++ b/tests/phpunit/WebTest/Contribute/OnlineMultiplePaymentProcessorTest.php @@ -194,8 +194,8 @@ class WebTest_Contribute_OnlineMultiplePaymentProcessorTest extends CiviSelenium $this->click("xpath=//div[@id='contributionSearch']/table/tbody/tr[1]/td[11]/span/a[text()='View']"); $this->waitForElementPresent("_qf_ContributionView_cancel-bottom"); $expected = array( - 'From' => "{$firstName} {$lastName}", - 'Financial Type' => 'Donation', + 'From' => "{$firstName} {$lastName}", + 'Financial Type' => 'Donation', 'Contribution Status' => 'Pending : Pay Later', ); $this->webtestVerifyTabularData($expected); diff --git a/tests/phpunit/WebTest/Contribute/OnlineRecurContributionTest.php b/tests/phpunit/WebTest/Contribute/OnlineRecurContributionTest.php index 6b08711fd5..e640784eda 100644 --- a/tests/phpunit/WebTest/Contribute/OnlineRecurContributionTest.php +++ b/tests/phpunit/WebTest/Contribute/OnlineRecurContributionTest.php @@ -140,7 +140,7 @@ class WebTest_Contribute_OnlineRecurContributionTest extends CiviSeleniumTestCas // View Recurring Contribution Record $verifyData = array( 'From' => "$contactName", - 'Financial Type' => 'Donation (test)', + 'Financial Type' => 'Donation (test)', 'Total Amount' => 'Installments: 12, Interval: 1 month(s)', 'Contribution Status' => 'Pending : Incomplete Transaction', 'Paid By' => 'Credit Card', diff --git a/tests/phpunit/WebTest/Contribute/UpdateBatchPendingContributionTest.php b/tests/phpunit/WebTest/Contribute/UpdateBatchPendingContributionTest.php index ad128bf12f..0719b6f164 100644 --- a/tests/phpunit/WebTest/Contribute/UpdateBatchPendingContributionTest.php +++ b/tests/phpunit/WebTest/Contribute/UpdateBatchPendingContributionTest.php @@ -123,7 +123,7 @@ class WebTest_Contribute_UpdateBatchPendingContributionTest extends CiviSelenium $this->click("xpath=//div[@id='contributionSearch']/table[@class='selector row-highlight']/tbody/tr[1]/td[11]/span/a[text()='View']"); $this->waitForElementPresent("_qf_ContributionView_cancel-bottom"); $expected = array( - 'Received Into' => "Deposit Bank Account", + 'Received Into' => "Deposit Bank Account", 'Contribution Status' => "Completed", ); diff --git a/tests/phpunit/WebTest/Contribute/UpdateContributionTest.php b/tests/phpunit/WebTest/Contribute/UpdateContributionTest.php index 4c4067eb77..03ddaf7a1a 100755 --- a/tests/phpunit/WebTest/Contribute/UpdateContributionTest.php +++ b/tests/phpunit/WebTest/Contribute/UpdateContributionTest.php @@ -114,9 +114,9 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase { $from = 'Premiums'; $to = 'Premiums inventory'; $financialType = array( - 'name' => 'Test Financial' . substr(sha1(rand()), 0, 7), - 'is_reserved' => 1, - 'is_deductible' => 1, + 'name' => 'Test Financial' . substr(sha1(rand()), 0, 7), + 'is_reserved' => 1, + 'is_deductible' => 1, ); $this->addeditFinancialType($financialType); $this->waitForElementPresent("xpath=//div[@id='ltype']/div/table/tbody//tr/td[text()='" . $financialType['name'] . "']/../td[7]/span/a[text()='Accounts']"); @@ -185,9 +185,9 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase { $from = 'Premiums'; $to = 'Premiums inventory'; $financialType = array( - 'name' => 'Test Financial' . substr(sha1(rand()), 0, 7), - 'is_reserved' => 1, - 'is_deductible' => 1, + 'name' => 'Test Financial' . substr(sha1(rand()), 0, 7), + 'is_reserved' => 1, + 'is_deductible' => 1, ); $this->addeditFinancialType($financialType); $this->waitForElementPresent("xpath=//div[@id='ltype']/div/table/tbody//tr/td[text()='" . $financialType['name'] . "']/../td[7]/span/a[text()='Accounts']"); @@ -284,8 +284,8 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase { $lineItem = key(CRM_Price_BAO_LineItem::getLineItems($contId, 'contribution')); $search = array('entity_id' => $lineItem); $compare = array( - 'amount' => '100.00', - 'status_id' => 1, + 'amount' => '100.00', + 'status_id' => 1, ); $this->assertDBCompareValues("CRM_Financial_DAO_FinancialItem", $search, $compare); $amount = $this->_getPremiumActualCost($contId, NULL, 'Payment Processor Account', -100.00, "'civicrm_contribution'"); @@ -312,8 +312,8 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase { $this->assertDBCompareValues('CRM_Contribute_DAO_Contribution', $search, $compare); $lineItem = key(CRM_Price_BAO_LineItem::getLineItems($contId, 'contribution')); $itemParams = array( - 'amount' => '-100.00', - 'entity_id' => $lineItem, + 'amount' => '-100.00', + 'entity_id' => $lineItem, ); $defaults = array(); $items = CRM_Financial_BAO_FinancialItem::retrieve($itemParams, $defaults); @@ -345,8 +345,8 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase { $lineItem = key(CRM_Price_BAO_LineItem::getLineItems($contId, 'contribution')); $itemParams = array( - 'amount' => '-100.00', - 'entity_id' => $lineItem, + 'amount' => '-100.00', + 'entity_id' => $lineItem, ); $item1 = $item2 = array(); CRM_Financial_BAO_FinancialItem::retrieve($itemParams, $item1); @@ -489,9 +489,9 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase { $this->click("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='View']"); $expected = array( - 'Financial Type' => 'Donation', - 'Total Amount' => '100.00', - 'Contribution Status' => $status, + 'Financial Type' => 'Donation', + 'Total Amount' => '100.00', + 'Contribution Status' => $status, ); $this->webtestVerifyTabularData($expected); $this->click("_qf_ContributionView_cancel-bottom"); diff --git a/tests/phpunit/WebTest/Event/AddEventTest.php b/tests/phpunit/WebTest/Event/AddEventTest.php index 7937f91222..b592be535d 100644 --- a/tests/phpunit/WebTest/Event/AddEventTest.php +++ b/tests/phpunit/WebTest/Event/AddEventTest.php @@ -764,7 +764,7 @@ class WebTest_Event_AddEventTest extends CiviSeleniumTestCase { $participantEmails = array($primaryParticipant, $secParticipant, $thirdParticipant); $addtlPart = array($secParticipant, $thirdParticipant); $primaryParticipantInfo = - $this->_testOnlineRegistration($registerUrl, 2, $anonymous, FALSE, $participantEmails, "Test Processor"); + $this->_testOnlineRegistration($registerUrl, 2, $anonymous, FALSE, $participantEmails, "Test Processor"); $primaryDisplayName = "{$primaryParticipantInfo['first_name']} {$primaryParticipantInfo['last_name']}"; $this->webtestLogin(); $this->openCiviPage("event/search", "reset=1"); diff --git a/tests/phpunit/WebTest/Event/AddParticipationTest.php b/tests/phpunit/WebTest/Event/AddParticipationTest.php index 442af61096..8a3011e4ed 100644 --- a/tests/phpunit/WebTest/Event/AddParticipationTest.php +++ b/tests/phpunit/WebTest/Event/AddParticipationTest.php @@ -357,10 +357,15 @@ class WebTest_Event_AddParticipationTest extends CiviSeleniumTestCase { $customSets = array( array( - 'entity' => 'ParticipantEventName', - 'subEntity' => 'Fall Fundraiser Dinner', - 'triggerElement' => array('name' => "event_id", 'type' => "select2")), - array('entity' => 'ParticipantRole', 'subEntity' => 'Attendee', 'triggerElement' => array('name' => 'role_id', 'type' => "select")), + 'entity' => 'ParticipantEventName', + 'subEntity' => 'Fall Fundraiser Dinner', + 'triggerElement' => array('name' => "event_id", 'type' => "select2") + ), + array( + 'entity' => 'ParticipantRole', + 'subEntity' => 'Attendee', + 'triggerElement' => array('name' => 'role_id', 'type' => "select") + ), ); $pageUrl = array('url' => "participant/add", 'args' => "reset=1&action=add&context=standalone"); $this->customFieldSetLoadOnTheFlyCheck($customSets, $pageUrl, TRUE); @@ -374,17 +379,20 @@ class WebTest_Event_AddParticipationTest extends CiviSeleniumTestCase { $customSets = array( array( - 'entity' => 'ParticipantEventType', - 'subEntity' => '- Any -', - 'triggerElement' => array('name' => "event_id", 'type' => "select")), + 'entity' => 'ParticipantEventType', + 'subEntity' => '- Any -', + 'triggerElement' => array('name' => "event_id", 'type' => "select") + ), array( - 'entity' => 'ParticipantEventName', - 'subEntity' => '- Any -', - 'triggerElement' => array('name' => "event_id", 'type' => "select")), + 'entity' => 'ParticipantEventName', + 'subEntity' => '- Any -', + 'triggerElement' => array('name' => "event_id", 'type' => "select") + ), array( - 'entity' => 'ParticipantEventName', - 'subEntity' => 'Rain-forest Cup Youth Soccer Tournament', - 'triggerElement' => array('name' => "event_id", 'type' => "select")), + 'entity' => 'ParticipantEventName', + 'subEntity' => 'Rain-forest Cup Youth Soccer Tournament', + 'triggerElement' => array('name' => "event_id", 'type' => "select") + ), array('entity' => 'ParticipantRole', 'subEntity' => '- Any -', 'triggerElement' => array('type' => "checkbox")), array('entity' => 'ParticipantRole', 'subEntity' => 'Volunteer', 'triggerElement' => array('type' => "checkbox")), ); diff --git a/tests/phpunit/WebTest/Event/AddPricesetTest.php b/tests/phpunit/WebTest/Event/AddPricesetTest.php index 48f8a9a740..0da4aba3ef 100644 --- a/tests/phpunit/WebTest/Event/AddPricesetTest.php +++ b/tests/phpunit/WebTest/Event/AddPricesetTest.php @@ -119,7 +119,7 @@ class WebTest_Event_AddPricesetTest extends CiviSeleniumTestCase { case 'Select': $options = array( 1 => array( - 'label' => 'Chicken', + 'label' => 'Chicken', 'amount' => '30.00', 'financial_type_id' => 'Donation', ), @@ -138,11 +138,11 @@ class WebTest_Event_AddPricesetTest extends CiviSeleniumTestCase { case 'Radio': $options = array( 1 => array( - 'label' => 'Yes', + 'label' => 'Yes', 'amount' => '50.00', 'financial_type_id' => 'Donation', - ), + ), 2 => array( 'label' => 'No', 'amount' => '0', @@ -159,7 +159,7 @@ class WebTest_Event_AddPricesetTest extends CiviSeleniumTestCase { case 'CheckBox': $options = array( 1 => array( - 'label' => 'First Night', + 'label' => 'First Night', 'amount' => '15.00', 'financial_type_id' => 'Donation', ), @@ -501,7 +501,6 @@ class WebTest_Event_AddPricesetTest extends CiviSeleniumTestCase { /** * Test to regiter participant for event with - * multiple price fields in price-set * CRM-11986 diff --git a/tests/phpunit/WebTest/Event/PCPAddTest.php b/tests/phpunit/WebTest/Event/PCPAddTest.php index b2d74127e5..6c5bec75fb 100644 --- a/tests/phpunit/WebTest/Event/PCPAddTest.php +++ b/tests/phpunit/WebTest/Event/PCPAddTest.php @@ -37,7 +37,12 @@ class WebTest_Event_PCPAddTest extends CiviSeleniumTestCase { public function testPCPAdd() { //give permissions to anonymous user - $permission = array('edit-1-profile-listings-and-forms', 'edit-1-access-all-custom-data', 'edit-1-register-for-events', 'edit-1-make-online-contributions'); + $permission = array( + 'edit-1-profile-listings-and-forms', + 'edit-1-access-all-custom-data', + 'edit-1-register-for-events', + 'edit-1-make-online-contributions' + ); $this->changePermissions($permission); // Log in as normal user diff --git a/tests/phpunit/WebTest/Export/ExportCiviSeleniumTestCase.php b/tests/phpunit/WebTest/Export/ExportCiviSeleniumTestCase.php index 38290e4bee..764564e4f2 100644 --- a/tests/phpunit/WebTest/Export/ExportCiviSeleniumTestCase.php +++ b/tests/phpunit/WebTest/Export/ExportCiviSeleniumTestCase.php @@ -78,13 +78,13 @@ class ExportCiviSeleniumTestCase extends CiviSeleniumTestCase { * Array of header and rows according to row index. * eg: array( * 1 => array( - // Row index 1 - // column name 'First Name', value 'Jones' + * // Row index 1 + * // column name 'First Name', value 'Jones' * 'First Name' => 'Jones', * 'Last Name' => 'Franklin' * ), * 2 => array( - // Row index 2 + * // Row index 2 * 'First Name' => 'Rajan', * 'Last Name' => 'mayekar' * ), diff --git a/tests/phpunit/WebTest/Financial/FinancialAccountTest.php b/tests/phpunit/WebTest/Financial/FinancialAccountTest.php index 6c2cb67358..2f6772950b 100644 --- a/tests/phpunit/WebTest/Financial/FinancialAccountTest.php +++ b/tests/phpunit/WebTest/Financial/FinancialAccountTest.php @@ -73,10 +73,10 @@ class WebTest_Financial_FinancialAccountTest extends CiviSeleniumTestCase { $this->clickLink("xpath=//table/tbody//tr/td[1]/div[text()='{$financialAccountTitle}']/../../td[9]/span/a[text()='Edit']", '_qf_FinancialAccount_cancel-botttom', FALSE); //Varify Data after Adding new Financial Account $verifyData = array( - 'name' => $financialAccountTitle, + 'name' => $financialAccountTitle, 'description' => $financialAccountDescription, 'accounting_code' => $accountingCode, - 'tax_rate' => $taxRate, + 'tax_rate' => $taxRate, 'is_tax' => 'on', 'is_deductible' => 'off', 'is_default' => 'off', @@ -121,10 +121,10 @@ class WebTest_Financial_FinancialAccountTest extends CiviSeleniumTestCase { $this->clickLink("xpath=//table/tbody//tr/td[1]/div[text()='{$financialAccountTitle}']/../../td[9]/span/a[text()='Edit']", '_qf_FinancialAccount_cancel-botttom', FALSE); $verifyData = array( - 'name' => $financialAccountTitle, + 'name' => $financialAccountTitle, 'description' => $financialAccountDescription, 'accounting_code' => $accountingCode, - 'tax_rate' => $taxRate, + 'tax_rate' => $taxRate, 'is_tax' => 'on', 'is_deductible' => 'off', 'is_default' => 'off', diff --git a/tests/phpunit/WebTest/Financial/FinancialBatchExport.php b/tests/phpunit/WebTest/Financial/FinancialBatchExport.php index 0035fe383b..dcda54489d 100644 --- a/tests/phpunit/WebTest/Financial/FinancialBatchExport.php +++ b/tests/phpunit/WebTest/Financial/FinancialBatchExport.php @@ -41,7 +41,7 @@ class WebTest_Financial_FinancialBatchExport extends CiviSeleniumTestCase { $this->webtestLogin('admin'); $this->openCiviPage("financial/batch", "reset=1&action=add", '_qf_FinancialBatch_next-botttom'); $setTitle = 'Batch ' . substr(sha1(rand()), 0, 7) . date('Y-m-d'); - $setDescription = 'Test Batch Creation'; + $setDescription = 'Test Batch Creation'; $setPaymentInstrument = 'Credit Card'; $numberOfTrxn = '10'; // can be 10, 25, 50, 100 $totalAmt = '1000'; diff --git a/tests/phpunit/WebTest/Grant/CustomFieldsetTest.php b/tests/phpunit/WebTest/Grant/CustomFieldsetTest.php index 18bdc7a9cb..4f9525e295 100644 --- a/tests/phpunit/WebTest/Grant/CustomFieldsetTest.php +++ b/tests/phpunit/WebTest/Grant/CustomFieldsetTest.php @@ -98,11 +98,11 @@ class WebTest_Grant_CustomFieldsetTest extends CiviSeleniumTestCase { // verify tabular data for grant view $this->webtestVerifyTabularData(array( - 'Name' => $contact['display_name'], - 'Grant Status' => 'Approved', - 'Grant Type' => $grantType, - $grantField => '$ 99.99', - ) + 'Name' => $contact['display_name'], + 'Grant Status' => 'Approved', + 'Grant Type' => $grantType, + $grantField => '$ 99.99', + ) ); } diff --git a/tests/phpunit/WebTest/Import/AddressImportTest.php b/tests/phpunit/WebTest/Import/AddressImportTest.php index 9cca856ead..e1d760fef5 100644 --- a/tests/phpunit/WebTest/Import/AddressImportTest.php +++ b/tests/phpunit/WebTest/Import/AddressImportTest.php @@ -89,17 +89,17 @@ class WebTest_Import_AddressImportTest extends ImportCiviSeleniumTestCase { } $rows = array( - 0 => - - array( - 'first_name' => $firstName1, - 'last_name' => 'Anderson', - 'address_1' => 'Add 1', - 'address_2' => 'Add 2', - 'city' => 'Watson', - 'state' => 'NY', - 'country' => 'United States', - ), + 0 => + + array( + 'first_name' => $firstName1, + 'last_name' => 'Anderson', + 'address_1' => 'Add 1', + 'address_2' => 'Add 2', + 'city' => 'Watson', + 'state' => 'NY', + 'country' => 'United States', + ), ); foreach ($customDataParams['rows'][0] as $key => $values) { $rows[0][$key] = $values; @@ -273,7 +273,7 @@ class WebTest_Import_AddressImportTest extends ImportCiviSeleniumTestCase { ), ), 'customFields' => array( - $customField => 'This is a test field', + $customField => 'This is a test field', $customField3 => 'label1', $customField4 => 'label1', $customField5 => 'label1', diff --git a/tests/phpunit/WebTest/Import/AddressParsingTest.php b/tests/phpunit/WebTest/Import/AddressParsingTest.php index e399dbc142..d042d038e4 100644 --- a/tests/phpunit/WebTest/Import/AddressParsingTest.php +++ b/tests/phpunit/WebTest/Import/AddressParsingTest.php @@ -204,7 +204,7 @@ class WebTest_Import_AddressParsingTest extends ImportCiviSeleniumTestCase { $rows = array( array( - 'first_name' => 'A' . substr(sha1(rand()), 0, 7), + 'first_name' => 'A' . substr(sha1(rand()), 0, 7), 'middle_name' => substr(sha1(rand()), 0, 7), 'last_name' => substr(sha1(rand()), 0, 7) . 'and', 'email' => substr(sha1(rand()), 0, 7) . '@example.com', @@ -217,7 +217,7 @@ class WebTest_Import_AddressParsingTest extends ImportCiviSeleniumTestCase { 'country' => 'United States', ), array( - 'first_name' => 'S' . substr(sha1(rand()), 0, 7), + 'first_name' => 'S' . substr(sha1(rand()), 0, 7), 'middle_name' => substr(sha1(rand()), 0, 7), 'last_name' => substr(sha1(rand()), 0, 7) . 'sum', 'email' => substr(sha1(rand()), 0, 7) . '@example.com', diff --git a/tests/phpunit/WebTest/Import/ContactCustomDataTest.php b/tests/phpunit/WebTest/Import/ContactCustomDataTest.php index e5f715d8cc..0ffdbaaffa 100644 --- a/tests/phpunit/WebTest/Import/ContactCustomDataTest.php +++ b/tests/phpunit/WebTest/Import/ContactCustomDataTest.php @@ -122,7 +122,7 @@ class WebTest_Import_ContactCustomDataTest extends ImportCiviSeleniumTestCase { $rows = array( array( - 'first_name' => $firstName1, + 'first_name' => $firstName1, 'last_name' => 'Anderson', "custom_{$customDataParams[0]}" => 'This is a test field', ), diff --git a/tests/phpunit/WebTest/Import/ContactSubtypeTest.php b/tests/phpunit/WebTest/Import/ContactSubtypeTest.php index 52761f2c69..18ed1c3b4b 100644 --- a/tests/phpunit/WebTest/Import/ContactSubtypeTest.php +++ b/tests/phpunit/WebTest/Import/ContactSubtypeTest.php @@ -314,7 +314,7 @@ class WebTest_Import_ContactSubtypeTest extends ImportCiviSeleniumTestCase { $rows = array( array( - 'first_name' => substr(sha1(rand()), 0, 7), + 'first_name' => substr(sha1(rand()), 0, 7), 'middle_name' => substr(sha1(rand()), 0, 7), 'last_name' => 'Anderson', 'email' => substr(sha1(rand()), 0, 7) . '@example.com', @@ -326,7 +326,7 @@ class WebTest_Import_ContactSubtypeTest extends ImportCiviSeleniumTestCase { 'country' => 'United States', ), array( - 'first_name' => substr(sha1(rand()), 0, 7), + 'first_name' => substr(sha1(rand()), 0, 7), 'middle_name' => substr(sha1(rand()), 0, 7), 'last_name' => 'Summerson', 'email' => substr(sha1(rand()), 0, 7) . '@example.com', @@ -362,7 +362,7 @@ class WebTest_Import_ContactSubtypeTest extends ImportCiviSeleniumTestCase { $rows = array( array( - 'organization_name' => 'org_' . substr(sha1(rand()), 0, 7), + 'organization_name' => 'org_' . substr(sha1(rand()), 0, 7), 'email' => substr(sha1(rand()), 0, 7) . '@example.org', 'phone' => '9949912154', 'address_1' => 'Add 1', @@ -372,7 +372,7 @@ class WebTest_Import_ContactSubtypeTest extends ImportCiviSeleniumTestCase { 'country' => 'United States', ), array( - 'organization_name' => 'org_' . substr(sha1(rand()), 0, 7), + 'organization_name' => 'org_' . substr(sha1(rand()), 0, 7), 'email' => substr(sha1(rand()), 0, 7) . '@example.org', 'phone' => '6949412154', 'address_1' => 'Add 1', @@ -406,7 +406,7 @@ class WebTest_Import_ContactSubtypeTest extends ImportCiviSeleniumTestCase { $rows = array( array( - 'household_name' => 'household_' . substr(sha1(rand()), 0, 7), + 'household_name' => 'household_' . substr(sha1(rand()), 0, 7), 'email' => substr(sha1(rand()), 0, 7) . '@example.org', 'phone' => '3949912154', 'address_1' => 'Add 1', @@ -416,7 +416,7 @@ class WebTest_Import_ContactSubtypeTest extends ImportCiviSeleniumTestCase { 'country' => 'United States', ), array( - 'household_name' => 'household_' . substr(sha1(rand()), 0, 7), + 'household_name' => 'household_' . substr(sha1(rand()), 0, 7), 'email' => substr(sha1(rand()), 0, 7) . '@example.org', 'phone' => '5949412154', 'address_1' => 'Add 1', diff --git a/tests/phpunit/WebTest/Import/ContactTest.php b/tests/phpunit/WebTest/Import/ContactTest.php index c2bf05c0d6..d105e06971 100644 --- a/tests/phpunit/WebTest/Import/ContactTest.php +++ b/tests/phpunit/WebTest/Import/ContactTest.php @@ -306,7 +306,7 @@ class WebTest_Import_ContactTest extends ImportCiviSeleniumTestCase { $rows = array( array( - 'first_name' => substr(sha1(rand()), 0, 7), + 'first_name' => substr(sha1(rand()), 0, 7), 'middle_name' => substr(sha1(rand()), 0, 7), 'last_name' => 'Anderson', 'email' => substr(sha1(rand()), 0, 7) . '@example.com', @@ -318,7 +318,7 @@ class WebTest_Import_ContactTest extends ImportCiviSeleniumTestCase { 'country' => 'United States', ), array( - 'first_name' => substr(sha1(rand()), 0, 7), + 'first_name' => substr(sha1(rand()), 0, 7), 'middle_name' => substr(sha1(rand()), 0, 7), 'last_name' => 'Summerson', 'email' => substr(sha1(rand()), 0, 7) . '@example.com', @@ -354,7 +354,7 @@ class WebTest_Import_ContactTest extends ImportCiviSeleniumTestCase { $rows = array( array( - 'organization_name' => 'org_' . substr(sha1(rand()), 0, 7), + 'organization_name' => 'org_' . substr(sha1(rand()), 0, 7), 'email' => substr(sha1(rand()), 0, 7) . '@example.org', 'phone' => '9949912154', 'address_1' => 'Add 1', @@ -364,7 +364,7 @@ class WebTest_Import_ContactTest extends ImportCiviSeleniumTestCase { 'country' => 'United States', ), array( - 'organization_name' => 'org_' . substr(sha1(rand()), 0, 7), + 'organization_name' => 'org_' . substr(sha1(rand()), 0, 7), 'email' => substr(sha1(rand()), 0, 7) . '@example.org', 'phone' => '6949412154', 'address_1' => 'Add 1', @@ -398,7 +398,7 @@ class WebTest_Import_ContactTest extends ImportCiviSeleniumTestCase { $rows = array( array( - 'household_name' => 'household_' . substr(sha1(rand()), 0, 7), + 'household_name' => 'household_' . substr(sha1(rand()), 0, 7), 'email' => substr(sha1(rand()), 0, 7) . '@example.org', 'phone' => '3949912154', 'address_1' => 'Add 1', @@ -408,7 +408,7 @@ class WebTest_Import_ContactTest extends ImportCiviSeleniumTestCase { 'country' => 'United States', ), array( - 'household_name' => 'household_' . substr(sha1(rand()), 0, 7), + 'household_name' => 'household_' . substr(sha1(rand()), 0, 7), 'email' => substr(sha1(rand()), 0, 7) . '@example.org', 'phone' => '5949412154', 'address_1' => 'Add 1', diff --git a/tests/phpunit/WebTest/Import/ContributionTest.php b/tests/phpunit/WebTest/Import/ContributionTest.php index f523a584d4..761a3d35ad 100644 --- a/tests/phpunit/WebTest/Import/ContributionTest.php +++ b/tests/phpunit/WebTest/Import/ContributionTest.php @@ -59,7 +59,7 @@ class WebTest_Import_ContributionTest extends ImportCiviSeleniumTestCase { list($headers, $rows) = $this->_contributionOrganizationCSVData(); $fieldMapper = array( 'mapper[0][0]' => 'organization_name', - 'mapper[2][0]' => 'financial_type', + 'mapper[2][0]' => 'financial_type', 'mapper[4][0]' => 'total_amount', ); $this->importCSVComponent('Contribution', $headers, $rows, 'Organization', 'Insert new contributions', $fieldMapper); @@ -73,7 +73,7 @@ class WebTest_Import_ContributionTest extends ImportCiviSeleniumTestCase { list($headers, $rows) = $this->_contributionHouseholdCSVData(); $fieldMapper = array( 'mapper[0][0]' => 'household_name', - 'mapper[2][0]' => 'financial_type', + 'mapper[2][0]' => 'financial_type', 'mapper[4][0]' => 'total_amount', ); $this->importCSVComponent('Contribution', $headers, $rows, 'Household', 'Insert new contributions', $fieldMapper); @@ -103,14 +103,14 @@ class WebTest_Import_ContributionTest extends ImportCiviSeleniumTestCase { array( 'email' => $email1, 'fee_amount' => '200', - 'financial_type' => 'Donation', + 'financial_type' => 'Donation', 'contribution_status_id' => 'Completed', 'total_amount' => '200', ), array( 'email' => $email2, 'fee_amount' => '400', - 'financial_type' => 'Donation', + 'financial_type' => 'Donation', 'contribution_status_id' => 'Completed', 'total_amount' => '400', ), @@ -141,14 +141,14 @@ class WebTest_Import_ContributionTest extends ImportCiviSeleniumTestCase { array( 'household' => $household1, 'fee_amount' => '200', - 'financial_type' => 'Donation', + 'financial_type' => 'Donation', 'contribution_status_id' => 'Completed', 'total_amount' => '200', ), array( 'household' => $household2, 'fee_amount' => '400', - 'financial_type' => 'Donation', + 'financial_type' => 'Donation', 'contribution_status_id' => 'Completed', 'total_amount' => '400', ), @@ -179,14 +179,14 @@ class WebTest_Import_ContributionTest extends ImportCiviSeleniumTestCase { array( 'organization' => $organization1, 'fee_amount' => '200', - 'financial_type' => 'Donation', + 'financial_type' => 'Donation', 'contribution_status_id' => 'Completed', 'total_amount' => '200', ), array( 'organization' => $organization2, 'fee_amount' => '400', - 'financial_type' => 'Donation', + 'financial_type' => 'Donation', 'contribution_status_id' => 'Completed', 'total_amount' => '400', ), diff --git a/tests/phpunit/WebTest/Import/CustomDataTest.php b/tests/phpunit/WebTest/Import/CustomDataTest.php index 3a76a82b59..144cb846a8 100644 --- a/tests/phpunit/WebTest/Import/CustomDataTest.php +++ b/tests/phpunit/WebTest/Import/CustomDataTest.php @@ -38,8 +38,8 @@ class WebTest_Import_CustomDataTest extends ImportCiviSeleniumTestCase { public function testCustomDataImport() { $this->webtestLogin(); - $firstName1 = 'Ma_' . substr(sha1(rand()), 0, 7); - $firstName2 = 'An_' . substr(sha1(rand()), 0, 7); + $firstName1 = 'Ma_' . substr(sha1(rand()), 0, 7); + $firstName2 = 'An_' . substr(sha1(rand()), 0, 7); $customGroupTitle = 'Custom ' . substr(sha1(rand()), 0, 7); $firstName3 = 'Ma' . substr(sha1(rand()), 0, 4); diff --git a/tests/phpunit/WebTest/Import/DateFormatTest.php b/tests/phpunit/WebTest/Import/DateFormatTest.php index 85ad21d2a0..75f6b0e3b4 100644 --- a/tests/phpunit/WebTest/Import/DateFormatTest.php +++ b/tests/phpunit/WebTest/Import/DateFormatTest.php @@ -173,7 +173,7 @@ class WebTest_Import_DateFormatTest extends ImportCiviSeleniumTestCase { $rows = array( array( - 'first_name' => substr(sha1(rand()), 0, 7), + 'first_name' => substr(sha1(rand()), 0, 7), 'middle_name' => substr(sha1(rand()), 0, 7), 'last_name' => 'Anderson', 'email' => substr(sha1(rand()), 0, 7) . '@example.com', @@ -186,7 +186,7 @@ class WebTest_Import_DateFormatTest extends ImportCiviSeleniumTestCase { 'birth_date' => '1998-12-25', ), array( - 'first_name' => substr(sha1(rand()), 0, 7), + 'first_name' => substr(sha1(rand()), 0, 7), 'middle_name' => substr(sha1(rand()), 0, 7), 'last_name' => 'Summerson', 'email' => substr(sha1(rand()), 0, 7) . '@example.com', @@ -226,7 +226,7 @@ class WebTest_Import_DateFormatTest extends ImportCiviSeleniumTestCase { $rows = array( array( - 'first_name' => substr(sha1(rand()), 0, 7), + 'first_name' => substr(sha1(rand()), 0, 7), 'middle_name' => substr(sha1(rand()), 0, 7), 'last_name' => 'Anderson', 'email' => substr(sha1(rand()), 0, 7) . '@example.com', @@ -239,7 +239,7 @@ class WebTest_Import_DateFormatTest extends ImportCiviSeleniumTestCase { 'birth_date' => '12/23/98', ), array( - 'first_name' => substr(sha1(rand()), 0, 7), + 'first_name' => substr(sha1(rand()), 0, 7), 'middle_name' => substr(sha1(rand()), 0, 7), 'last_name' => 'Summerson', 'email' => substr(sha1(rand()), 0, 7) . '@example.com', @@ -279,7 +279,7 @@ class WebTest_Import_DateFormatTest extends ImportCiviSeleniumTestCase { $rows = array( array( - 'first_name' => substr(sha1(rand()), 0, 7), + 'first_name' => substr(sha1(rand()), 0, 7), 'middle_name' => substr(sha1(rand()), 0, 7), 'last_name' => 'Anderson', 'email' => substr(sha1(rand()), 0, 7) . '@example.com', @@ -292,7 +292,7 @@ class WebTest_Import_DateFormatTest extends ImportCiviSeleniumTestCase { 'birth_date' => '11/12/1995', ), array( - 'first_name' => substr(sha1(rand()), 0, 7), + 'first_name' => substr(sha1(rand()), 0, 7), 'middle_name' => substr(sha1(rand()), 0, 7), 'last_name' => 'Summerson', 'email' => substr(sha1(rand()), 0, 7) . '@example.com', @@ -332,7 +332,7 @@ class WebTest_Import_DateFormatTest extends ImportCiviSeleniumTestCase { $rows = array( array( - 'first_name' => substr(sha1(rand()), 0, 7), + 'first_name' => substr(sha1(rand()), 0, 7), 'middle_name' => substr(sha1(rand()), 0, 7), 'last_name' => 'Anderson', 'email' => substr(sha1(rand()), 0, 7) . '@example.com', @@ -345,7 +345,7 @@ class WebTest_Import_DateFormatTest extends ImportCiviSeleniumTestCase { 'birth_date' => 'December 12, 1998', ), array( - 'first_name' => substr(sha1(rand()), 0, 7), + 'first_name' => substr(sha1(rand()), 0, 7), 'middle_name' => substr(sha1(rand()), 0, 7), 'last_name' => 'Summerson', 'email' => substr(sha1(rand()), 0, 7) . '@example.com', @@ -385,7 +385,7 @@ class WebTest_Import_DateFormatTest extends ImportCiviSeleniumTestCase { $rows = array( array( - 'first_name' => substr(sha1(rand()), 0, 7), + 'first_name' => substr(sha1(rand()), 0, 7), 'middle_name' => substr(sha1(rand()), 0, 7), 'last_name' => 'Anderson', 'email' => substr(sha1(rand()), 0, 7) . '@example.com', @@ -398,7 +398,7 @@ class WebTest_Import_DateFormatTest extends ImportCiviSeleniumTestCase { 'birth_date' => '25/12/98', ), array( - 'first_name' => substr(sha1(rand()), 0, 7), + 'first_name' => substr(sha1(rand()), 0, 7), 'middle_name' => substr(sha1(rand()), 0, 7), 'last_name' => 'Summerson', 'email' => substr(sha1(rand()), 0, 7) . '@example.com', @@ -438,7 +438,7 @@ class WebTest_Import_DateFormatTest extends ImportCiviSeleniumTestCase { $rows = array( array( - 'first_name' => substr(sha1(rand()), 0, 7), + 'first_name' => substr(sha1(rand()), 0, 7), 'middle_name' => substr(sha1(rand()), 0, 7), 'last_name' => 'Anderson', 'email' => substr(sha1(rand()), 0, 7) . '@example.com', @@ -451,7 +451,7 @@ class WebTest_Import_DateFormatTest extends ImportCiviSeleniumTestCase { 'birth_date' => '25/12/1998', ), array( - 'first_name' => substr(sha1(rand()), 0, 7), + 'first_name' => substr(sha1(rand()), 0, 7), 'middle_name' => substr(sha1(rand()), 0, 7), 'last_name' => 'Summerson', 'email' => substr(sha1(rand()), 0, 7) . '@example.com', diff --git a/tests/phpunit/WebTest/Import/DuplicateMatchingTest.php b/tests/phpunit/WebTest/Import/DuplicateMatchingTest.php index 0f62bb6b6d..57032337f3 100644 --- a/tests/phpunit/WebTest/Import/DuplicateMatchingTest.php +++ b/tests/phpunit/WebTest/Import/DuplicateMatchingTest.php @@ -371,7 +371,7 @@ class WebTest_Import_DuplicateMatchingTest extends ImportCiviSeleniumTestCase { $rows = array( array( - 'first_name' => isset($individualFields['first_name']) ? $individualFields['first_name'] : substr(sha1(rand()), 0, 7), + 'first_name' => isset($individualFields['first_name']) ? $individualFields['first_name'] : substr(sha1(rand()), 0, 7), 'middle_name' => isset($individualFields['middle_name']) ? $individualFields['middle_name'] : substr(sha1(rand()), 0, 7), 'last_name' => isset($individualFields['last_name']) ? $individualFields['last_name'] : 'Anderson', 'email' => isset($individualFields['email']) ? $individualFields['email'] : substr(sha1(rand()), 0, 7) . '@example.com', @@ -383,7 +383,7 @@ class WebTest_Import_DuplicateMatchingTest extends ImportCiviSeleniumTestCase { 'country' => 'United States', ), array( - 'first_name' => substr(sha1(rand()), 0, 7), + 'first_name' => substr(sha1(rand()), 0, 7), 'middle_name' => substr(sha1(rand()), 0, 7), 'last_name' => 'Summerson', 'email' => substr(sha1(rand()), 0, 7) . '@example.com', @@ -421,7 +421,7 @@ class WebTest_Import_DuplicateMatchingTest extends ImportCiviSeleniumTestCase { ); $rows = array( array( - 'organization_name' => isset($organizationFields['organization_name']) ? $organizationFields['organization_name'] : 'org_' . substr(sha1(rand()), 0, 7), + 'organization_name' => isset($organizationFields['organization_name']) ? $organizationFields['organization_name'] : 'org_' . substr(sha1(rand()), 0, 7), 'email' => isset($organizationFields['email']) ? $organizationFields['email'] : substr(sha1(rand()), 0, 7) . 'example.org', 'phone' => '9949912154', 'address_1' => 'Add 1', @@ -431,7 +431,7 @@ class WebTest_Import_DuplicateMatchingTest extends ImportCiviSeleniumTestCase { 'country' => 'United States', ), array( - 'organization_name' => 'org_' . substr(sha1(rand()), 0, 7), + 'organization_name' => 'org_' . substr(sha1(rand()), 0, 7), 'email' => substr(sha1(rand()), 0, 7) . '@example.org', 'phone' => '6949412154', 'address_1' => 'Add 1', @@ -468,7 +468,7 @@ class WebTest_Import_DuplicateMatchingTest extends ImportCiviSeleniumTestCase { $rows = array( array( - 'household_name' => isset($householdFields['household_name']) ? $householdFields['household_name'] : 'household_' . substr(sha1(rand()), 0, 7), + 'household_name' => isset($householdFields['household_name']) ? $householdFields['household_name'] : 'household_' . substr(sha1(rand()), 0, 7), 'email' => isset($householdFields['email']) ? $householdFields['email'] : substr(sha1(rand()), 0, 7) . '@example.com', 'phone' => '3949912154', 'address_1' => 'Add 1', @@ -478,7 +478,7 @@ class WebTest_Import_DuplicateMatchingTest extends ImportCiviSeleniumTestCase { 'country' => 'United States', ), array( - 'household_name' => 'household_' . substr(sha1(rand()), 0, 7), + 'household_name' => 'household_' . substr(sha1(rand()), 0, 7), 'email' => substr(sha1(rand()), 0, 7) . '@example.org', 'phone' => '5949412154', 'address_1' => 'Add 1', diff --git a/tests/phpunit/WebTest/Import/GroupTest.php b/tests/phpunit/WebTest/Import/GroupTest.php index 95978a8611..0bfba02b7b 100644 --- a/tests/phpunit/WebTest/Import/GroupTest.php +++ b/tests/phpunit/WebTest/Import/GroupTest.php @@ -112,7 +112,7 @@ class WebTest_Import_GroupTest extends ImportCiviSeleniumTestCase { $rows = array( array( - 'first_name' => substr(sha1(rand()), 0, 7), + 'first_name' => substr(sha1(rand()), 0, 7), 'middle_name' => substr(sha1(rand()), 0, 7), 'last_name' => 'Anderson', 'email' => substr(sha1(rand()), 0, 7) . '@example.com', @@ -124,7 +124,7 @@ class WebTest_Import_GroupTest extends ImportCiviSeleniumTestCase { 'country' => 'United States', ), array( - 'first_name' => substr(sha1(rand()), 0, 7), + 'first_name' => substr(sha1(rand()), 0, 7), 'middle_name' => substr(sha1(rand()), 0, 7), 'last_name' => 'Summerson', 'email' => substr(sha1(rand()), 0, 7) . '@example.com', diff --git a/tests/phpunit/WebTest/Import/ImportCiviSeleniumTestCase.php b/tests/phpunit/WebTest/Import/ImportCiviSeleniumTestCase.php index 3f67491d36..f91dd87ff6 100644 --- a/tests/phpunit/WebTest/Import/ImportCiviSeleniumTestCase.php +++ b/tests/phpunit/WebTest/Import/ImportCiviSeleniumTestCase.php @@ -50,7 +50,6 @@ class ImportCiviSeleniumTestCase extends CiviSeleniumTestCase { * @param array $other * Other parameters. * useMappingName : to reuse mapping - * dateFormat : date format of data * checkMapperHeaders : to override default check mapper headers * saveMapping : save current mapping? @@ -181,7 +180,6 @@ class ImportCiviSeleniumTestCase extends CiviSeleniumTestCase { * @param array $other * Other parameters. * contactSubtype : import for selected Contact Subtype - * useMappingName : to reuse mapping * dateFormat : date format of data * checkMapperHeaders : to override default check mapper headers @@ -418,7 +416,10 @@ class ImportCiviSeleniumTestCase extends CiviSeleniumTestCase { } if (!empty($other['callbackImportSummary']) && is_callable(array( - $this, $other['callbackImportSummary']))) { + $this, + $other['callbackImportSummary'] + )) + ) { $callbackImportSummary = $other['callbackImportSummary']; $this->$callbackImportSummary($originalHeaders, $originalRows, $checkSummary); } diff --git a/tests/phpunit/WebTest/Import/MatchExternalIdTest.php b/tests/phpunit/WebTest/Import/MatchExternalIdTest.php index 36c30890c5..42d6fd3030 100644 --- a/tests/phpunit/WebTest/Import/MatchExternalIdTest.php +++ b/tests/phpunit/WebTest/Import/MatchExternalIdTest.php @@ -81,14 +81,14 @@ class WebTest_Import_MatchExternalIdTest extends ImportCiviSeleniumTestCase { * @return array */ public function _contributionIndividualCSVData() { - $firstName1 = substr(sha1(rand()), 0, 7); - $lastName1 = substr(sha1(rand()), 0, 7); + $firstName1 = substr(sha1(rand()), 0, 7); + $lastName1 = substr(sha1(rand()), 0, 7); $externalId1 = substr(sha1(rand()), 0, 4); $this->_addContact($firstName1, $lastName1, $externalId1); - $firstName2 = substr(sha1(rand()), 0, 7); - $lastName2 = substr(sha1(rand()), 0, 7); + $firstName2 = substr(sha1(rand()), 0, 7); + $lastName2 = substr(sha1(rand()), 0, 7); $externalId2 = substr(sha1(rand()), 0, 4); $this->_addContact($firstName2, $lastName2, $externalId2); @@ -96,7 +96,7 @@ class WebTest_Import_MatchExternalIdTest extends ImportCiviSeleniumTestCase { $headers = array( 'external_identifier' => 'External Identifier', 'fee_amount' => 'Fee Amount', - 'financial_type' => 'Financial Type', + 'financial_type' => 'Financial Type', 'contribution_status_id' => 'Contribution Status', 'total_amount' => 'Total Amount', ); @@ -105,21 +105,21 @@ class WebTest_Import_MatchExternalIdTest extends ImportCiviSeleniumTestCase { array( 'external_identifier' => $externalId1, 'fee_amount' => '200', - 'financial_type' => 'Donation', + 'financial_type' => 'Donation', 'contribution_status_id' => 'Completed', 'total_amount' => '200', ), array( 'external_identifier' => $externalId2, 'fee_amount' => '400', - 'financial_type' => 'Donation', + 'financial_type' => 'Donation', 'contribution_status_id' => 'Completed', 'total_amount' => '400', ), ); $fieldMapper = array( 'mapper[0][0]' => 'external_identifier', - 'mapper[2][0]' => 'financial_type', + 'mapper[2][0]' => 'financial_type', 'mapper[4][0]' => 'total_amount', ); return array($headers, $rows, $fieldMapper); @@ -133,16 +133,16 @@ class WebTest_Import_MatchExternalIdTest extends ImportCiviSeleniumTestCase { public function _memberIndividualCSVData() { $memTypeParams = $this->webtestAddMembershipType(); - $firstName1 = substr(sha1(rand()), 0, 7); - $lastName1 = substr(sha1(rand()), 0, 7); + $firstName1 = substr(sha1(rand()), 0, 7); + $lastName1 = substr(sha1(rand()), 0, 7); $externalId1 = substr(sha1(rand()), 0, 4); $this->_addContact($firstName1, $lastName1, $externalId1); $startDate1 = date('Y-m-d'); $year = date('Y') - 1; - $firstName2 = substr(sha1(rand()), 0, 7); - $lastName2 = substr(sha1(rand()), 0, 7); + $firstName2 = substr(sha1(rand()), 0, 7); + $lastName2 = substr(sha1(rand()), 0, 7); $externalId2 = substr(sha1(rand()), 0, 4); $this->_addContact($firstName2, $lastName2, $externalId2); @@ -182,14 +182,14 @@ class WebTest_Import_MatchExternalIdTest extends ImportCiviSeleniumTestCase { public function _participantIndividualCSVData() { $eventInfo = $this->_addNewEvent(); - $firstName1 = substr(sha1(rand()), 0, 7); - $lastName1 = substr(sha1(rand()), 0, 7); + $firstName1 = substr(sha1(rand()), 0, 7); + $lastName1 = substr(sha1(rand()), 0, 7); $externalId1 = substr(sha1(rand()), 0, 4); $this->_addContact($firstName1, $lastName1, $externalId1); - $firstName2 = substr(sha1(rand()), 0, 7); - $lastName2 = substr(sha1(rand()), 0, 7); + $firstName2 = substr(sha1(rand()), 0, 7); + $lastName2 = substr(sha1(rand()), 0, 7); $externalId2 = substr(sha1(rand()), 0, 4); $this->_addContact($firstName2, $lastName2, $externalId2); diff --git a/tests/phpunit/WebTest/Import/MultipleRelationshipTest.php b/tests/phpunit/WebTest/Import/MultipleRelationshipTest.php index 2e39076118..7bfc7eba8a 100644 --- a/tests/phpunit/WebTest/Import/MultipleRelationshipTest.php +++ b/tests/phpunit/WebTest/Import/MultipleRelationshipTest.php @@ -70,38 +70,38 @@ class WebTest_Import_MultipleRelationshipTest extends ImportCiviSeleniumTestCase 'state' => 'State', 'country' => 'Country', 'contact_relationships' => - array( - '4_a_b' => array( - 'organization_name' => 'Organization Name', - 'organization_email' => 'Organization Email', - 'organization_add' => 'Organization Street Address', - 'organization_city' => 'Organization City', - 'organization_state' => 'Organization State', - 'organization_country' => 'Organization Country', - ), - '7_a_b' => array( - 'household_name' => 'Household Name', - 'household_email' => 'Household Name', - 'household_add' => 'Household Street Address', - 'household_city' => 'Household City', - 'household_state' => 'Household State', - 'household_country' => 'Household Country', - ), - '2_a_b' => array( - 'spouse_f_name' => 'Spouse First Name', - 'spouse_l_name' => 'Spouse Last Name', - 'spouse_email' => 'Spouse Email', - 'spouse_add' => 'Spouse Street Address', - 'spouse_city' => 'Spouse City', - 'spouse_state' => 'Spouse State', - 'spouse_country' => 'Spouse Country', + array( + '4_a_b' => array( + 'organization_name' => 'Organization Name', + 'organization_email' => 'Organization Email', + 'organization_add' => 'Organization Street Address', + 'organization_city' => 'Organization City', + 'organization_state' => 'Organization State', + 'organization_country' => 'Organization Country', + ), + '7_a_b' => array( + 'household_name' => 'Household Name', + 'household_email' => 'Household Name', + 'household_add' => 'Household Street Address', + 'household_city' => 'Household City', + 'household_state' => 'Household State', + 'household_country' => 'Household Country', + ), + '2_a_b' => array( + 'spouse_f_name' => 'Spouse First Name', + 'spouse_l_name' => 'Spouse Last Name', + 'spouse_email' => 'Spouse Email', + 'spouse_add' => 'Spouse Street Address', + 'spouse_city' => 'Spouse City', + 'spouse_state' => 'Spouse State', + 'spouse_country' => 'Spouse Country', + ), ), - ), ); $rows = array( array( - 'first_name' => substr(sha1(rand()), 0, 7), + 'first_name' => substr(sha1(rand()), 0, 7), 'middle_name' => substr(sha1(rand()), 0, 7), 'last_name' => 'Anderson', 'email' => substr(sha1(rand()), 0, 7) . '@example.com', @@ -112,36 +112,36 @@ class WebTest_Import_MultipleRelationshipTest extends ImportCiviSeleniumTestCase 'state' => 'NY', 'country' => 'United States', 'contact_relationships' => - array( - '4_a_b' => array( - 'organization_name' => 'Org ' . substr(sha1(rand()), 0, 7), - 'organization_email' => substr(sha1(rand()), 0, 7) . 'org@example.org', - 'organization_add' => 'Org Street Address', - 'organization_city' => 'Org City', - 'organization_state' => 'NY', - 'organization_country' => 'United States', - ), - '7_a_b' => array( - 'household_name' => 'House ' . substr(sha1(rand()), 0, 7), - 'household_email' => substr(sha1(rand()), 0, 7) . 'house@example.org', - 'household_add' => 'House Street Address', - 'household_city' => 'House City', - 'household_state' => 'NY', - 'household_country' => 'United States', + array( + '4_a_b' => array( + 'organization_name' => 'Org ' . substr(sha1(rand()), 0, 7), + 'organization_email' => substr(sha1(rand()), 0, 7) . 'org@example.org', + 'organization_add' => 'Org Street Address', + 'organization_city' => 'Org City', + 'organization_state' => 'NY', + 'organization_country' => 'United States', + ), + '7_a_b' => array( + 'household_name' => 'House ' . substr(sha1(rand()), 0, 7), + 'household_email' => substr(sha1(rand()), 0, 7) . 'house@example.org', + 'household_add' => 'House Street Address', + 'household_city' => 'House City', + 'household_state' => 'NY', + 'household_country' => 'United States', + ), + '2_a_b' => array( + 'spouse_f_name' => substr(sha1(rand()), 0, 7), + 'spouse_l_name' => substr(sha1(rand()), 0, 7), + 'spouse_email' => substr(sha1(rand()), 0, 7) . 'spouse@example.org', + 'spouse_add' => 'Spouse Street Address', + 'spouse_city' => 'Spouse City', + 'spouse_state' => 'NY', + 'spouse_country' => 'United States', + ), ), - '2_a_b' => array( - 'spouse_f_name' => substr(sha1(rand()), 0, 7), - 'spouse_l_name' => substr(sha1(rand()), 0, 7), - 'spouse_email' => substr(sha1(rand()), 0, 7) . 'spouse@example.org', - 'spouse_add' => 'Spouse Street Address', - 'spouse_city' => 'Spouse City', - 'spouse_state' => 'NY', - 'spouse_country' => 'United States', - ), - ), ), array( - 'first_name' => substr(sha1(rand()), 0, 7), + 'first_name' => substr(sha1(rand()), 0, 7), 'middle_name' => substr(sha1(rand()), 0, 7), 'last_name' => 'Summerson', 'email' => substr(sha1(rand()), 0, 7) . '@example.com', @@ -152,33 +152,33 @@ class WebTest_Import_MultipleRelationshipTest extends ImportCiviSeleniumTestCase 'state' => 'NY', 'country' => 'United States', 'contact_relationships' => - array( - '4_a_b' => array( - 'organization_name' => 'Org ' . substr(sha1(rand()), 0, 7), - 'organization_email' => substr(sha1(rand()), 0, 7) . 'org@example.org', - 'organization_add' => 'Org Street Address', - 'organization_city' => 'Org City', - 'organization_state' => 'NY', - 'organization_country' => 'United States', + array( + '4_a_b' => array( + 'organization_name' => 'Org ' . substr(sha1(rand()), 0, 7), + 'organization_email' => substr(sha1(rand()), 0, 7) . 'org@example.org', + 'organization_add' => 'Org Street Address', + 'organization_city' => 'Org City', + 'organization_state' => 'NY', + 'organization_country' => 'United States', + ), + '7_a_b' => array( + 'household_name' => 'House ' . substr(sha1(rand()), 0, 7), + 'household_email' => substr(sha1(rand()), 0, 7) . 'house@example.org', + 'household_add' => 'House Street Address', + 'household_city' => 'House City', + 'household_state' => 'NY', + 'household_country' => 'United States', + ), + '2_a_b' => array( + 'spouse_f_name' => substr(sha1(rand()), 0, 7), + 'spouse_l_name' => substr(sha1(rand()), 0, 7), + 'spouse_email' => substr(sha1(rand()), 0, 7) . 'spouse@example.org', + 'spouse_add' => 'Spouse Street Address', + 'spouse_city' => 'Spouse City', + 'spouse_state' => 'NY', + 'spouse_country' => 'United States', + ), ), - '7_a_b' => array( - 'household_name' => 'House ' . substr(sha1(rand()), 0, 7), - 'household_email' => substr(sha1(rand()), 0, 7) . 'house@example.org', - 'household_add' => 'House Street Address', - 'household_city' => 'House City', - 'household_state' => 'NY', - 'household_country' => 'United States', - ), - '2_a_b' => array( - 'spouse_f_name' => substr(sha1(rand()), 0, 7), - 'spouse_l_name' => substr(sha1(rand()), 0, 7), - 'spouse_email' => substr(sha1(rand()), 0, 7) . 'spouse@example.org', - 'spouse_add' => 'Spouse Street Address', - 'spouse_city' => 'Spouse City', - 'spouse_state' => 'NY', - 'spouse_country' => 'United States', - ), - ), ), ); // for Employee of relationship diff --git a/tests/phpunit/WebTest/Import/ParticipantTest.php b/tests/phpunit/WebTest/Import/ParticipantTest.php index 9fe59ae662..4b3868001f 100644 --- a/tests/phpunit/WebTest/Import/ParticipantTest.php +++ b/tests/phpunit/WebTest/Import/ParticipantTest.php @@ -259,8 +259,8 @@ class WebTest_Import_ParticipantTest extends ImportCiviSeleniumTestCase { 'event_type_id' => 4, 'payment_processor' => $processorName, 'fee_level' => array( - 'Member' => "250.00", - 'Non-Member' => "325.00", + 'Member' => "250.00", + 'Non-Member' => "325.00", ), ); } diff --git a/tests/phpunit/WebTest/Mailing/MailingTest.php b/tests/phpunit/WebTest/Mailing/MailingTest.php index f820f8accc..9a945dcda0 100644 --- a/tests/phpunit/WebTest/Mailing/MailingTest.php +++ b/tests/phpunit/WebTest/Mailing/MailingTest.php @@ -228,7 +228,10 @@ class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase { $this->webtestLogout(); // build forward url - $forwardUrl = array("mailing/forward", "reset=1&jid={$eventQueue->job_id}&qid={$eventQueue->id}&h={$eventQueue->hash}"); + $forwardUrl = array( + "mailing/forward", + "reset=1&jid={$eventQueue->job_id}&qid={$eventQueue->id}&h={$eventQueue->hash}" + ); $this->openCiviPage($forwardUrl[0], $forwardUrl[1], NULL); $this->type("email_0", substr(sha1(rand()), 0, 7) . '@example.com'); @@ -421,7 +424,17 @@ class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase { // verify successful deliveries $this->verifyText("xpath=//table//tr[td/a[text()='Successful Deliveries']]/descendant::td[2]", preg_quote("1 (100.00%)")); - $summaryInfoLinks = array('Intended Recipients', 'Successful Deliveries', 'Tracked Opens', 'Click-throughs', 'Forwards', 'Replies', 'Bounces', 'Unsubscribe Requests', 'Opt-out Requests'); + $summaryInfoLinks = array( + 'Intended Recipients', + 'Successful Deliveries', + 'Tracked Opens', + 'Click-throughs', + 'Forwards', + 'Replies', + 'Bounces', + 'Unsubscribe Requests', + 'Opt-out Requests' + ); //check for report and adv search links foreach ($summaryInfoLinks as $value) { @@ -438,65 +451,91 @@ class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase { $criteriaCheck = array( 'Intended Recipients' => - array( - 'report' => array('report_name' => 'Mailing Details', 'Mailing' => "Mailing $mailingName Webtest"), - 'search' => array('Mailing Name IN' => "\"Mailing {$mailingName} Webtest"), - ), + array( + 'report' => array('report_name' => 'Mailing Details', 'Mailing' => "Mailing $mailingName Webtest"), + 'search' => array('Mailing Name IN' => "\"Mailing {$mailingName} Webtest"), + ), 'Successful Deliveries' => - array( - 'report' => array( - 'report_name' => 'Mailing Details', - 'Mailing' => "Mailing $mailingName Webtest", - "Delivery Status" => " Successful"), - 'search' => array('Mailing Name IN' => "\"Mailing {$mailingName} Webtest", 'Mailing Delivery -' => "Successful"), - ), + array( + 'report' => array( + 'report_name' => 'Mailing Details', + 'Mailing' => "Mailing $mailingName Webtest", + "Delivery Status" => " Successful" + ), + 'search' => array( + 'Mailing Name IN' => "\"Mailing {$mailingName} Webtest", + 'Mailing Delivery -' => "Successful" + ), + ), 'Tracked Opens' => - array( - 'report' => array('report_name' => 'Mail Opened', 'Mailing' => "Mailing $mailingName Webtest"), - 'search' => array('Mailing Name IN' => "\"Mailing {$mailingName} Webtest", 'Mailing: Trackable Opens -' => "Opened"), - ), + array( + 'report' => array('report_name' => 'Mail Opened', 'Mailing' => "Mailing $mailingName Webtest"), + 'search' => array( + 'Mailing Name IN' => "\"Mailing {$mailingName} Webtest", + 'Mailing: Trackable Opens -' => "Opened" + ), + ), 'Click-throughs' => - array( - 'report' => array('report_name' => 'Mail Clickthroughs', 'Mailing' => "Mailing $mailingName Webtest"), - 'search' => array('Mailing Name IN' => "\"Mailing {$mailingName} Webtest", 'Mailing: Trackable URL Clicks -' => "Clicked"), - ), + array( + 'report' => array('report_name' => 'Mail Clickthroughs', 'Mailing' => "Mailing $mailingName Webtest"), + 'search' => array( + 'Mailing Name IN' => "\"Mailing {$mailingName} Webtest", + 'Mailing: Trackable URL Clicks -' => "Clicked" + ), + ), 'Forwards' => - array( - 'report' => array( - 'report_name' => 'Mailing Details', - 'Mailing' => "Mailing $mailingName Webtest", - 'Forwarded' => 'Is equal to Yes'), - 'search' => array('Mailing Name IN' => "\"Mailing {$mailingName} Webtest", 'Mailing: -' => "Forwards"), - ), + array( + 'report' => array( + 'report_name' => 'Mailing Details', + 'Mailing' => "Mailing $mailingName Webtest", + 'Forwarded' => 'Is equal to Yes' + ), + 'search' => array('Mailing Name IN' => "\"Mailing {$mailingName} Webtest", 'Mailing: -' => "Forwards"), + ), 'Replies' => - array( - 'report' => array( - 'report_name' => 'Mailing Details', - 'Mailing' => "Mailing $mailingName Webtest", - 'Replied' => 'Is equal to Yes'), - 'search' => array('Mailing Name IN' => "\"Mailing {$mailingName} Webtest", 'Mailing: Trackable Replies -' => "Replied"), - ), + array( + 'report' => array( + 'report_name' => 'Mailing Details', + 'Mailing' => "Mailing $mailingName Webtest", + 'Replied' => 'Is equal to Yes' + ), + 'search' => array( + 'Mailing Name IN' => "\"Mailing {$mailingName} Webtest", + 'Mailing: Trackable Replies -' => "Replied" + ), + ), 'Bounces' => - array( - 'report' => array('report_name' => 'Mail Bounces', 'Mailing' => "Mailing $mailingName Webtest"), - 'search' => array('Mailing Name IN' => "\"Mailing {$mailingName} Webtest", 'Mailing Delivery -' => "Bounced"), - ), + array( + 'report' => array('report_name' => 'Mail Bounces', 'Mailing' => "Mailing $mailingName Webtest"), + 'search' => array( + 'Mailing Name IN' => "\"Mailing {$mailingName} Webtest", + 'Mailing Delivery -' => "Bounced" + ), + ), 'Unsubscribe Requests' => - array( - 'report' => array( - 'report_name' => 'Mailing Details', - 'Mailing' => "Mailing $mailingName Webtest", - 'Unsubscribed' => 'Is equal to Yes'), - 'search' => array('Mailing Name IN' => "\"Mailing {$mailingName} Webtest", 'Mailing: -' => "Unsubscribe Requests"), - ), + array( + 'report' => array( + 'report_name' => 'Mailing Details', + 'Mailing' => "Mailing $mailingName Webtest", + 'Unsubscribed' => 'Is equal to Yes' + ), + 'search' => array( + 'Mailing Name IN' => "\"Mailing {$mailingName} Webtest", + 'Mailing: -' => "Unsubscribe Requests" + ), + ), 'Opt-out Requests' => - array( - 'report' => array( - 'report_name' => 'Mailing Details', - 'Mailing' => "Mailing $mailingName Webtest", - 'Opted-out' => 'Is equal to Yes'), - 'search' => array('Mailing Name IN' => "\"Mailing {$mailingName} Webtest", 'Mailing: -' => "Opt-out Requests"), - ), + array( + 'report' => array( + 'report_name' => 'Mailing Details', + 'Mailing' => "Mailing $mailingName Webtest", + 'Opted-out' => 'Is equal to Yes' + ), + 'search' => array( + 'Mailing Name IN' => "\"Mailing {$mailingName} Webtest", + 'Mailing: -' => "Opt-out Requests" + ), + ), ); $this->criteriaCheck($criteriaCheck, $mailingReportUrl); } diff --git a/tests/phpunit/WebTest/Member/BatchUpdateViaProfileTest.php b/tests/phpunit/WebTest/Member/BatchUpdateViaProfileTest.php index 5e35541615..4ae3ab5675 100644 --- a/tests/phpunit/WebTest/Member/BatchUpdateViaProfileTest.php +++ b/tests/phpunit/WebTest/Member/BatchUpdateViaProfileTest.php @@ -46,8 +46,8 @@ class WebTest_Member_BatchUpdateViaProfileTest extends CiviSeleniumTestCase { // Add new individual using Quick Add block on the main page $firstName1 = "John_" . substr(sha1(rand()), 0, 7); - $lastName = "Smith_" . substr(sha1(rand()), 0, 7); - $Name1 = $lastName . ', ' . $firstName1; + $lastName = "Smith_" . substr(sha1(rand()), 0, 7); + $Name1 = $lastName . ', ' . $firstName1; $this->webtestAddContact($firstName1, $lastName, "$firstName1.$lastName@example.com"); // Add membership for this individual @@ -203,7 +203,11 @@ class WebTest_Member_BatchUpdateViaProfileTest extends CiviSeleniumTestCase { $this->waitForText('crm-notification-container', "Your CiviCRM Profile '{$profileTitle}' has been added. You can add fields to this profile now."); $gid = $this->urlArg('gid'); - $this->openCiviPage('admin/uf/group/field/add', array('action' => 'add', 'reset' => 1, 'gid' => $gid), 'field_name[0]'); + $this->openCiviPage('admin/uf/group/field/add', array( + 'action' => 'add', + 'reset' => 1, + 'gid' => $gid + ), 'field_name[0]'); $this->select('field_name[0]', "value=Membership"); $this->select('field_name[1]', "label={$customDataParams[0]} :: {$customDataParams[1]}"); diff --git a/tests/phpunit/WebTest/Member/DefaultMembershipPricesetTest.php b/tests/phpunit/WebTest/Member/DefaultMembershipPricesetTest.php index 54c0252a81..4d3407184f 100755 --- a/tests/phpunit/WebTest/Member/DefaultMembershipPricesetTest.php +++ b/tests/phpunit/WebTest/Member/DefaultMembershipPricesetTest.php @@ -39,11 +39,11 @@ class WebTest_Member_DefaultMembershipPricesetTest extends CiviSeleniumTestCase // Log in using webtestLogin() method $this->webtestLogin(); - $title = substr(sha1(rand()), 0, 7); - $setTitle = "Membership Fees - $title"; - $usedFor = 'Membership'; + $title = substr(sha1(rand()), 0, 7); + $setTitle = "Membership Fees - $title"; + $usedFor = 'Membership'; $contributionType = 'Member Dues'; - $setHelp = 'Select your membership options.'; + $setHelp = 'Select your membership options.'; $this->_testAddSet($setTitle, $usedFor, $contributionType, $setHelp); // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form @@ -64,9 +64,9 @@ class WebTest_Member_DefaultMembershipPricesetTest extends CiviSeleniumTestCase $memPriceSetId = $sid; $membershipContributionPageId = $this->webtestAddContributionPage($hash, $rand, $pageTitle, array($processorName => 'Dummy'), TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, $memPriceSetId, FALSE, NULL, NULL, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE); - $firstName = 'John_' . substr(sha1(rand()), 0, 7); - $lastName = 'Anderson_' . substr(sha1(rand()), 0, 7); - $email = "{$firstName}.{$lastName}@example.com"; + $firstName = 'John_' . substr(sha1(rand()), 0, 7); + $lastName = 'Anderson_' . substr(sha1(rand()), 0, 7); + $email = "{$firstName}.{$lastName}@example.com"; $contactParams = array( 'first_name' => $firstName, 'last_name' => $lastName, @@ -219,19 +219,19 @@ class WebTest_Member_DefaultMembershipPricesetTest extends CiviSeleniumTestCase } elseif (!$defaultPriceSet) { $memTypeParams1 = $this->webtestAddMembershipType(); - $memTypeTitle1 = $memTypeParams1['membership_type']; - $memTypeId1 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td[text()='{$memTypeTitle1}']/../td[12]/span/a[3]@href")); - $memTypeId1 = $memTypeId1[1]; + $memTypeTitle1 = $memTypeParams1['membership_type']; + $memTypeId1 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td[text()='{$memTypeTitle1}']/../td[12]/span/a[3]@href")); + $memTypeId1 = $memTypeId1[1]; $memTypeParams2 = $this->webtestAddMembershipType(); - $memTypeTitle2 = $memTypeParams2['membership_type']; - $memTypeId2 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td[text()='{$memTypeTitle2}']/../td[12]/span/a[3]@href")); - $memTypeId2 = $memTypeId2[1]; + $memTypeTitle2 = $memTypeParams2['membership_type']; + $memTypeId2 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td[text()='{$memTypeTitle2}']/../td[12]/span/a[3]@href")); + $memTypeId2 = $memTypeId2[1]; $memTypeParams3 = $this->webtestAddMembershipType(); - $memTypeTitle3 = $memTypeParams3['membership_type']; - $memTypeId3 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td[text()='{$memTypeTitle3}']/../td[12]/span/a[3]@href")); - $memTypeId3 = $memTypeId3[1]; + $memTypeTitle3 = $memTypeParams3['membership_type']; + $memTypeId3 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td[text()='{$memTypeTitle3}']/../td[12]/span/a[3]@href")); + $memTypeId3 = $memTypeId3[1]; } $this->openCiviPage("admin/price/field", "reset=1&action=add&sid={$sid}"); @@ -246,7 +246,7 @@ class WebTest_Member_DefaultMembershipPricesetTest extends CiviSeleniumTestCase case 'Radio': $options = array( 1 => array( - 'label' => "$memTypeTitle1", + 'label' => "$memTypeTitle1", 'membership_type_id' => $memTypeId1, 'amount' => '100.00', ), @@ -267,7 +267,7 @@ class WebTest_Member_DefaultMembershipPricesetTest extends CiviSeleniumTestCase case 'CheckBox': $options = array( 1 => array( - 'label' => "$memTypeTitle1", + 'label' => "$memTypeTitle1", 'membership_type_id' => $memTypeId1, 'amount' => '100.00', ), diff --git a/tests/phpunit/WebTest/Member/EditMembershipTest.php b/tests/phpunit/WebTest/Member/EditMembershipTest.php index 32a931cf13..ce3cc3ce89 100644 --- a/tests/phpunit/WebTest/Member/EditMembershipTest.php +++ b/tests/phpunit/WebTest/Member/EditMembershipTest.php @@ -69,7 +69,7 @@ class WebTest_Member_EditMembershipTest extends CiviSeleniumTestCase { $this->click("xpath=//div[@id='memberships']//table/tbody/tr[1]/td[9]/span/a[text()='View']"); $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); $expected = array( - 'Membership Type' => $membershipTypes['membership_type'], + 'Membership Type' => $membershipTypes['membership_type'], 'Status' => 'New', 'Source' => 'Membership StandaloneAddTest Webtest', ); diff --git a/tests/phpunit/WebTest/Member/FixedMembershipTypeTest.php b/tests/phpunit/WebTest/Member/FixedMembershipTypeTest.php index 8fc4c06104..3d2c9d0358 100644 --- a/tests/phpunit/WebTest/Member/FixedMembershipTypeTest.php +++ b/tests/phpunit/WebTest/Member/FixedMembershipTypeTest.php @@ -120,10 +120,10 @@ class WebTest_Member_FixedMembershipTypeTest extends CiviSeleniumTestCase { require_once 'CRM/Core/Config.php'; require_once 'CRM/Utils/Array.php'; require_once 'CRM/Utils/Date.php'; - $currentYear = date('Y'); + $currentYear = date('Y'); $currentMonth = date('m'); $previousYear = $currentYear - 1; - $nextYear = $currentYear + 1; + $nextYear = $currentYear + 1; $todayDate = date('Y-m-d'); @@ -138,7 +138,10 @@ class WebTest_Member_FixedMembershipTypeTest extends CiviSeleniumTestCase { $configVars = new CRM_Core_Config_Variables(); foreach (array( - 'joinDate', 'startDate', 'endDate') as $date) { + 'joinDate', + 'startDate', + 'endDate' + ) as $date) { $$date = CRM_Utils_Date::customFormat($$date, $configVars->dateformatFull); } @@ -278,7 +281,7 @@ SELECT end_event_adjust_interval require_once 'CRM/Core/Config.php'; require_once 'CRM/Utils/Array.php'; require_once 'CRM/Utils/Date.php'; - $currentYear = date('Y'); + $currentYear = date('Y'); $currentMonth = date('m'); $previousYear = $currentYear - 1; @@ -294,7 +297,10 @@ SELECT end_event_adjust_interval $endDate = date('Y-m-d', mktime(0, 0, 0, 8, 31, $currentYear + 2)); $configVars = new CRM_Core_Config_Variables(); foreach (array( - 'joinDate', 'startDate', 'endDate') as $date) { + 'joinDate', + 'startDate', + 'endDate' + ) as $date) { $$date = CRM_Utils_Date::customFormat($$date, $configVars->dateformatFull); } @@ -433,17 +439,20 @@ SELECT end_event_adjust_interval require_once 'CRM/Core/Config.php'; require_once 'CRM/Utils/Array.php'; require_once 'CRM/Utils/Date.php'; - $currentYear = date('Y'); + $currentYear = date('Y'); $currentMonth = date('m'); $previousYear = $currentYear - 1; - $nextYear = $currentYear + 1; - $todayDate = date('Y-m-d'); - $joinDate = date('Y-m-d', mktime(0, 0, 0, 11, 15, $currentYear)); - $startDate = date('Y-m-d', mktime(0, 0, 0, 1, 1, $currentYear)); - $endDate = date('Y-m-d', mktime(0, 0, 0, 12, 31, $nextYear)); - $configVars = new CRM_Core_Config_Variables(); + $nextYear = $currentYear + 1; + $todayDate = date('Y-m-d'); + $joinDate = date('Y-m-d', mktime(0, 0, 0, 11, 15, $currentYear)); + $startDate = date('Y-m-d', mktime(0, 0, 0, 1, 1, $currentYear)); + $endDate = date('Y-m-d', mktime(0, 0, 0, 12, 31, $nextYear)); + $configVars = new CRM_Core_Config_Variables(); foreach (array( - 'joinDate', 'startDate', 'endDate') as $date) { + 'joinDate', + 'startDate', + 'endDate' + ) as $date) { $$date = CRM_Utils_Date::customFormat($$date, $configVars->dateformatFull); } @@ -581,20 +590,23 @@ SELECT end_event_adjust_interval require_once 'CRM/Core/Config.php'; require_once 'CRM/Utils/Array.php'; require_once 'CRM/Utils/Date.php'; - $currentYear = date('Y'); + $currentYear = date('Y'); $currentMonth = date('m'); - $nextYear = $currentYear + 1; - $todayDate = date('Y-m-d'); + $nextYear = $currentYear + 1; + $todayDate = date('Y-m-d'); // the member-since date we will type in to membership form $joinDate = date('Y-m-d', mktime(0, 0, 0, 1, 15, $currentYear)); // expected calc'd start and end dates - $startDate = date('Y-m-d', mktime(0, 0, 0, 1, 1, $currentYear)); - $endDate = date('Y-m-d', mktime(0, 0, 0, 12, 31, $currentYear)); + $startDate = date('Y-m-d', mktime(0, 0, 0, 1, 1, $currentYear)); + $endDate = date('Y-m-d', mktime(0, 0, 0, 12, 31, $currentYear)); $configVars = new CRM_Core_Config_Variables(); foreach (array( - 'joinDate', 'startDate', 'endDate') as $date) { + 'joinDate', + 'startDate', + 'endDate' + ) as $date) { $$date = CRM_Utils_Date::customFormat($$date, $configVars->dateformatFull); } diff --git a/tests/phpunit/WebTest/Member/InheritedMembershipTest.php b/tests/phpunit/WebTest/Member/InheritedMembershipTest.php index 78e5327704..54c0f4edba 100644 --- a/tests/phpunit/WebTest/Member/InheritedMembershipTest.php +++ b/tests/phpunit/WebTest/Member/InheritedMembershipTest.php @@ -111,12 +111,15 @@ class WebTest_Member_InheritedMembershipTest extends CiviSeleniumTestCase { $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']"); $this->waitForElementPresent('_qf_MembershipView_cancel-bottom'); - $joinDate = date('Y-m-d'); - $startDate = date('Y-m-d'); - $endDate = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d') - 1, date('Y') + 1)); + $joinDate = date('Y-m-d'); + $startDate = date('Y-m-d'); + $endDate = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d') - 1, date('Y') + 1)); $configVars = new CRM_Core_Config_Variables(); foreach (array( - 'joinDate', 'startDate', 'endDate') as $date) { + 'joinDate', + 'startDate', + 'endDate' + ) as $date) { $$date = CRM_Utils_Date::customFormat($$date, $configVars->dateformatFull); } diff --git a/tests/phpunit/WebTest/Member/OfflineAutoRenewMembershipTest.php b/tests/phpunit/WebTest/Member/OfflineAutoRenewMembershipTest.php index 30168de410..1fcb2f82d0 100644 --- a/tests/phpunit/WebTest/Member/OfflineAutoRenewMembershipTest.php +++ b/tests/phpunit/WebTest/Member/OfflineAutoRenewMembershipTest.php @@ -43,10 +43,10 @@ class WebTest_Member_OfflineAutoRenewMembershipTest extends CiviSeleniumTestCase $this->webtestAddPaymentProcessor($processorName, 'AuthNet'); // Create a membership type to use for this test - $periodType = 'rolling'; + $periodType = 'rolling'; $duration_interval = 1; - $duration_unit = 'year'; - $auto_renew = "optional"; + $duration_unit = 'year'; + $auto_renew = "optional"; $memTypeParams = $this->webtestAddMembershipType($periodType, $duration_interval, $duration_unit, $auto_renew); diff --git a/tests/phpunit/WebTest/Member/OfflineMembershipAddPricesetTest.php b/tests/phpunit/WebTest/Member/OfflineMembershipAddPricesetTest.php index 5ce6b81fdf..644e606cb5 100644 --- a/tests/phpunit/WebTest/Member/OfflineMembershipAddPricesetTest.php +++ b/tests/phpunit/WebTest/Member/OfflineMembershipAddPricesetTest.php @@ -39,11 +39,11 @@ class WebTest_Member_OfflineMembershipAddPricesetTest extends CiviSeleniumTestCa // Log in using webtestLogin() method $this->webtestLogin(); - $title = substr(sha1(rand()), 0, 7); - $setTitle = "Membership Fees - $title"; - $usedFor = 'Membership'; + $title = substr(sha1(rand()), 0, 7); + $setTitle = "Membership Fees - $title"; + $usedFor = 'Membership'; $contributionType = 'Donation'; - $setHelp = 'Select your membership options.'; + $setHelp = 'Select your membership options.'; $this->_testAddSet($setTitle, $usedFor, $contributionType, $setHelp); // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form @@ -62,9 +62,9 @@ class WebTest_Member_OfflineMembershipAddPricesetTest extends CiviSeleniumTestCa $this->_testVerifyPriceSet($validateStrings, $sid); // Sign up for membership - $firstName = 'John_' . substr(sha1(rand()), 0, 7); - $lastName = 'Anderson_' . substr(sha1(rand()), 0, 7); - $email = "{$firstName}.{$lastName}@example.com"; + $firstName = 'John_' . substr(sha1(rand()), 0, 7); + $lastName = 'Anderson_' . substr(sha1(rand()), 0, 7); + $email = "{$firstName}.{$lastName}@example.com"; $contactParams = array( 'first_name' => $firstName, 'last_name' => $lastName, @@ -84,15 +84,15 @@ class WebTest_Member_OfflineMembershipAddPricesetTest extends CiviSeleniumTestCa // Log in using webtestLogin() method $this->webtestLogin(); - $title = substr(sha1(rand()), 0, 7); - $setTitle = "Membership Fees - $title"; - $usedFor = 'Membership'; + $title = substr(sha1(rand()), 0, 7); + $setTitle = "Membership Fees - $title"; + $usedFor = 'Membership'; $contributionType = 'Member Dues'; - $setHelp = 'Select your membership options.'; + $setHelp = 'Select your membership options.'; $memTypeParams1 = $this->webtestAddMembershipType(); - $memTypeTitle1 = $memTypeParams1['membership_type']; - $memTypeId1 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td[1]/div[text()='{$memTypeTitle1}']/../../td[12]/span/a[3]@href")); - $memTypeId1 = $memTypeId1[1]; + $memTypeTitle1 = $memTypeParams1['membership_type']; + $memTypeId1 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td[1]/div[text()='{$memTypeTitle1}']/../../td[12]/span/a[3]@href")); + $memTypeId1 = $memTypeId1[1]; $this->_testAddSet($setTitle, $usedFor, $contributionType, $setHelp); // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form @@ -108,10 +108,10 @@ class WebTest_Member_OfflineMembershipAddPricesetTest extends CiviSeleniumTestCa $this->select('html_type', "value={$fields[1]}"); $options = array( 1 => array( - 'label' => $memTypeTitle1 . "_1", - 'membership_type_id' => $memTypeId1, - 'amount' => 50.00, - 'membership_num_terms' => 1, + 'label' => $memTypeTitle1 . "_1", + 'membership_type_id' => $memTypeId1, + 'amount' => 50.00, + 'membership_num_terms' => 1, ), 2 => array( 'label' => $memTypeTitle1 . "_2", @@ -151,8 +151,8 @@ class WebTest_Member_OfflineMembershipAddPricesetTest extends CiviSeleniumTestCa $this->_testVerifyPriceSet($validateStrings, $sid); $firstName = 'John_' . substr(sha1(rand()), 0, 7); - $lastName = 'Anderson_' . substr(sha1(rand()), 0, 7); - $email = "{$firstName}.{$lastName}@example.com"; + $lastName = 'Anderson_' . substr(sha1(rand()), 0, 7); + $email = "{$firstName}.{$lastName}@example.com"; $contactParams = array( 'first_name' => $firstName, @@ -209,15 +209,15 @@ class WebTest_Member_OfflineMembershipAddPricesetTest extends CiviSeleniumTestCa */ public function _testAddPriceFields(&$fields, &$validateString, $dateSpecificFields = FALSE, $title, $sid, $contributionType) { $memTypeParams1 = $this->webtestAddMembershipType(); - $memTypeTitle1 = $memTypeParams1['membership_type']; + $memTypeTitle1 = $memTypeParams1['membership_type']; - $memTypeId1 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td[1]/div[text()='{$memTypeTitle1}']/../../td[12]/span/a[3]@href")); - $memTypeId1 = $memTypeId1[1]; + $memTypeId1 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td[1]/div[text()='{$memTypeTitle1}']/../../td[12]/span/a[3]@href")); + $memTypeId1 = $memTypeId1[1]; $memTypeParams2 = $this->webtestAddMembershipType(); - $memTypeTitle2 = $memTypeParams2['membership_type']; - $memTypeId2 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td[1]/div[text()='{$memTypeTitle2}']/../../td[12]/span/a[3]@href")); - $memTypeId2 = $memTypeId2[1]; + $memTypeTitle2 = $memTypeParams2['membership_type']; + $memTypeId2 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td[1]/div[text()='{$memTypeTitle2}']/../../td[12]/span/a[3]@href")); + $memTypeId2 = $memTypeId2[1]; $this->openCiviPage("admin/price/field", "reset=1&action=add&sid={$sid}"); @@ -231,9 +231,9 @@ class WebTest_Member_OfflineMembershipAddPricesetTest extends CiviSeleniumTestCa case 'Radio': $options = array( 1 => array( - 'label' => "$memTypeTitle1", - 'membership_type_id' => $memTypeId1, - 'amount' => 100.00, + 'label' => "$memTypeTitle1", + 'membership_type_id' => $memTypeId1, + 'amount' => 100.00, ), 2 => array( 'label' => "$memTypeTitle2", @@ -247,9 +247,9 @@ class WebTest_Member_OfflineMembershipAddPricesetTest extends CiviSeleniumTestCa case 'CheckBox': $options = array( 1 => array( - 'label' => "$memTypeTitle1", - 'membership_type_id' => $memTypeId1, - 'amount' => 100.00, + 'label' => "$memTypeTitle1", + 'membership_type_id' => $memTypeId1, + 'amount' => 100.00, ), 2 => array( 'label' => "$memTypeTitle2", @@ -302,16 +302,19 @@ class WebTest_Member_OfflineMembershipAddPricesetTest extends CiviSeleniumTestCa require_once 'CRM/Core/Config.php'; require_once 'CRM/Utils/Array.php'; require_once 'CRM/Utils/Date.php'; - $currentYear = date('Y'); + $currentYear = date('Y'); $currentMonth = date('m'); - $previousDay = date('d') - 1; - $endYear = ($renew) ? $currentYear + 2 : $currentYear + 1; - $joinDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, date('d'), $currentYear)); - $startDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, date('d'), $currentYear)); - $endDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, $previousDay, $endYear)); - $configVars = new CRM_Core_Config_Variables(); + $previousDay = date('d') - 1; + $endYear = ($renew) ? $currentYear + 2 : $currentYear + 1; + $joinDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, date('d'), $currentYear)); + $startDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, date('d'), $currentYear)); + $endDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, $previousDay, $endYear)); + $configVars = new CRM_Core_Config_Variables(); foreach (array( - 'joinDate', 'startDate', 'endDate') as $date) { + 'joinDate', + 'startDate', + 'endDate' + ) as $date) { $$date = CRM_Utils_Date::customFormat($$date, $configVars->dateformatFull); } @@ -389,16 +392,19 @@ class WebTest_Member_OfflineMembershipAddPricesetTest extends CiviSeleniumTestCa require_once 'CRM/Core/Config.php'; require_once 'CRM/Utils/Array.php'; require_once 'CRM/Utils/Date.php'; - $currentYear = date('Y'); + $currentYear = date('Y'); $currentMonth = date('m'); - $previousDay = date('d') - 1; - $endYear = ($term == 3) ? $currentYear + 3 : (($term == 2) ? $currentYear + 2 : $currentYear + 1); - $joinDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, date('d'), $currentYear)); - $startDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, date('d'), $currentYear)); - $endDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, $previousDay, $endYear)); - $configVars = new CRM_Core_Config_Variables(); + $previousDay = date('d') - 1; + $endYear = ($term == 3) ? $currentYear + 3 : (($term == 2) ? $currentYear + 2 : $currentYear + 1); + $joinDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, date('d'), $currentYear)); + $startDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, date('d'), $currentYear)); + $endDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, $previousDay, $endYear)); + $configVars = new CRM_Core_Config_Variables(); foreach (array( - 'joinDate', 'startDate', 'endDate') as $date) { + 'joinDate', + 'startDate', + 'endDate' + ) as $date) { $$date = CRM_Utils_Date::customFormat($$date, $configVars->dateformatFull); } @@ -411,7 +417,7 @@ class WebTest_Member_OfflineMembershipAddPricesetTest extends CiviSeleniumTestCa $this->select('price_set_id', "value={$sid}"); $this->waitForElementPresent('pricesetTotal'); - $i = ($term == 3) ? 3 : (($term == 2) ? 2 : 1); + $i = ($term == 3) ? 3 : (($term == 2) ? 2 : 1); $this->waitForElementPresent("xpath=//div[@id='priceset']/div[2]/div[2]/div[$i]/span/input"); $this->click("xpath=//div[@id='priceset']/div[2]/div[2]/div[$i]/span/input"); $amount = $this->getText("xpath=//div[@id='priceset']/div[2]/div[2]/div[$i]/span/label/span[@class='crm-price-amount-amount']"); diff --git a/tests/phpunit/WebTest/Member/OfflineMembershipRenewTest.php b/tests/phpunit/WebTest/Member/OfflineMembershipRenewTest.php index d4eb1e7f1c..e7395a4f18 100644 --- a/tests/phpunit/WebTest/Member/OfflineMembershipRenewTest.php +++ b/tests/phpunit/WebTest/Member/OfflineMembershipRenewTest.php @@ -205,9 +205,9 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { $this->waitForElementPresent('_qf_MembershipView_cancel-bottom'); - $joinDate = date('F jS, Y'); + $joinDate = date('F jS, Y'); $startDate = date('F jS, Y', strtotime("+1 month")); - $endDate = date('F jS, Y', strtotime("+4 year 1 month -1 day")); + $endDate = date('F jS, Y', strtotime("+4 year 1 month -1 day")); // verify membership renew override $verifyMembershipRenewOverrideData = array( @@ -302,9 +302,9 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { $this->waitForElementPresent('_qf_MembershipView_cancel-bottom'); - $joinDate = date('F jS, Y', strtotime("-2 year")); + $joinDate = date('F jS, Y', strtotime("-2 year")); $startDate = date('F jS, Y'); - $endDate = date('F jS, Y', strtotime("+1 year -1 day")); + $endDate = date('F jS, Y', strtotime("+1 year -1 day")); // verify membership renewed and the membership type is changed $verifyMembershipData = array( diff --git a/tests/phpunit/WebTest/Member/OnlineAutoRenewMembershipGCTest.php b/tests/phpunit/WebTest/Member/OnlineAutoRenewMembershipGCTest.php index 31c5024da0..cc0d05ade4 100644 --- a/tests/phpunit/WebTest/Member/OnlineAutoRenewMembershipGCTest.php +++ b/tests/phpunit/WebTest/Member/OnlineAutoRenewMembershipGCTest.php @@ -142,7 +142,8 @@ class WebTest_Member_OnlineAutoRenewMembershipGCTest extends CiviSeleniumTestCas $onBehalf = FALSE; $pledges = FALSE; $recurring = TRUE; - $membershipTypes = array(array('id' => 1, 'auto_renew' => 1), + $membershipTypes = array( + array('id' => 1, 'auto_renew' => 1), array('id' => 2, 'auto_renew' => 1), ); $memPriceSetId = NULL; diff --git a/tests/phpunit/WebTest/Member/OnlineAutoRenewMembershipTest.php b/tests/phpunit/WebTest/Member/OnlineAutoRenewMembershipTest.php index dde48702f9..366ffd871c 100644 --- a/tests/phpunit/WebTest/Member/OnlineAutoRenewMembershipTest.php +++ b/tests/phpunit/WebTest/Member/OnlineAutoRenewMembershipTest.php @@ -167,7 +167,8 @@ class WebTest_Member_OnlineAutoRenewMembershipTest extends CiviSeleniumTestCase $onBehalf = FALSE; $pledges = FALSE; $recurring = TRUE; - $membershipTypes = array(array('id' => 1, 'auto_renew' => 1), + $membershipTypes = array( + array('id' => 1, 'auto_renew' => 1), array('id' => 2, 'auto_renew' => 1), ); $memPriceSetId = NULL; diff --git a/tests/phpunit/WebTest/Member/OnlineMembershipAddPricesetTest.php b/tests/phpunit/WebTest/Member/OnlineMembershipAddPricesetTest.php index a3ff492c45..73e3ce4771 100644 --- a/tests/phpunit/WebTest/Member/OnlineMembershipAddPricesetTest.php +++ b/tests/phpunit/WebTest/Member/OnlineMembershipAddPricesetTest.php @@ -118,26 +118,26 @@ class WebTest_Member_OnlineMembershipAddPricesetTest extends CiviSeleniumTestCas $this->type('label', $fields[0]); $this->select('html_type', "value={$fields[1]}"); $options = array( - 1 => array( - 'label' => $memTypeTitle1 . "_1", - 'membership_type_id' => $memTypeId1, - 'amount' => 50.00, - 'membership_num_terms' => 1, - ), - 2 => array( - 'label' => $memTypeTitle1 . "_2", - 'membership_type_id' => $memTypeId1, - 'amount' => 90.00, - 'membership_num_terms' => 2, - ), - 3 => array( - 'label' => $memTypeTitle1 . "_3", - 'membership_type_id' => $memTypeId1, - 'amount' => 120.00, - 'membership_num_terms' => 3, - ), + 1 => array( + 'label' => $memTypeTitle1 . "_1", + 'membership_type_id' => $memTypeId1, + 'amount' => 50.00, + 'membership_num_terms' => 1, + ), + 2 => array( + 'label' => $memTypeTitle1 . "_2", + 'membership_type_id' => $memTypeId1, + 'amount' => 90.00, + 'membership_num_terms' => 2, + ), + 3 => array( + 'label' => $memTypeTitle1 . "_3", + 'membership_type_id' => $memTypeId1, + 'amount' => 120.00, + 'membership_num_terms' => 3, + ), - ); + ); $i = 2; foreach ($options as $index => $values) { $this->select("membership_type_id_{$index}", "value={$values['membership_type_id']}"); @@ -246,7 +246,7 @@ class WebTest_Member_OnlineMembershipAddPricesetTest extends CiviSeleniumTestCas case 'Radio': $options = array( 1 => array( - 'label' => "$memTypeTitle1", + 'label' => "$memTypeTitle1", 'membership_type_id' => $memTypeId1, 'amount' => 100.00, ), @@ -262,7 +262,7 @@ class WebTest_Member_OnlineMembershipAddPricesetTest extends CiviSeleniumTestCas case 'CheckBox': $options = array( 1 => array( - 'label' => "$memTypeTitle1", + 'label' => "$memTypeTitle1", 'membership_type_id' => $memTypeId1, 'amount' => 100.00, ), @@ -323,7 +323,10 @@ class WebTest_Member_OnlineMembershipAddPricesetTest extends CiviSeleniumTestCas $endDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, $previousDay, $endYear)); $configVars = new CRM_Core_Config_Variables(); foreach (array( - 'joinDate', 'startDate', 'endDate') as $date) { + 'joinDate', + 'startDate', + 'endDate' + ) as $date) { $$date = CRM_Utils_Date::customFormat($$date, $configVars->dateformatFull); } @@ -445,7 +448,10 @@ class WebTest_Member_OnlineMembershipAddPricesetTest extends CiviSeleniumTestCas $endDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, $previousDay, $endYear)); $configVars = new CRM_Core_Config_Variables(); foreach (array( - 'joinDate', 'startDate', 'endDate') as $date) { + 'joinDate', + 'startDate', + 'endDate' + ) as $date) { $$date = CRM_Utils_Date::customFormat($$date, $configVars->dateformatFull); } $i = ($term == 3) ? 3 : (($term == 2) ? 2 : 1); diff --git a/tests/phpunit/WebTest/Member/SeperateMembershipPaymentTest.php b/tests/phpunit/WebTest/Member/SeperateMembershipPaymentTest.php index 6dbd8c93f8..ffef11cc32 100644 --- a/tests/phpunit/WebTest/Member/SeperateMembershipPaymentTest.php +++ b/tests/phpunit/WebTest/Member/SeperateMembershipPaymentTest.php @@ -91,14 +91,14 @@ class WebTest_Member_SeperateMembershipPaymentTest extends CiviSeleniumTestCase // create new membership types $memTypeParams1 = $this->webtestAddMembershipType(); - $memTypeTitle1 = $memTypeParams1['membership_type']; - $memTypeId1 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td/div[text()='{$memTypeTitle1}']/../../td[12]/span/a[3]@href")); - $memTypeId1 = $memTypeId1[1]; + $memTypeTitle1 = $memTypeParams1['membership_type']; + $memTypeId1 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td/div[text()='{$memTypeTitle1}']/../../td[12]/span/a[3]@href")); + $memTypeId1 = $memTypeId1[1]; $memTypeParams2 = $this->webtestAddMembershipType(); - $memTypeTitle2 = $memTypeParams2['membership_type']; - $memTypeId2 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td/div[text()='{$memTypeTitle2}']/../../td[12]/span/a[3]@href")); - $memTypeId2 = $memTypeId2[1]; + $memTypeTitle2 = $memTypeParams2['membership_type']; + $memTypeId2 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td/div[text()='{$memTypeTitle2}']/../../td[12]/span/a[3]@href")); + $memTypeId2 = $memTypeId2[1]; // edit contribution page memberships tab to add two new membership types $this->openCiviPage('admin/contribute/membership', "reset=1&action=update&id={$pageId}", "_qf_MembershipBlock_next-bottom"); diff --git a/tests/phpunit/WebTest/Member/StandaloneAddTest.php b/tests/phpunit/WebTest/Member/StandaloneAddTest.php index 1453d603d2..ec624c6b26 100644 --- a/tests/phpunit/WebTest/Member/StandaloneAddTest.php +++ b/tests/phpunit/WebTest/Member/StandaloneAddTest.php @@ -249,8 +249,8 @@ class WebTest_Member_StandaloneAddTest extends CiviSeleniumTestCase { //ui actions which helps triggering possible $test = $this; $this->customFieldSetLoadOnTheFlyCheck($customSets, $pageUrl, - function() use ($test) { - $test->select('membership_type_id_0', 'value=1'); + function () use ($test) { + $test->select('membership_type_id_0', 'value=1'); } ); } diff --git a/tests/phpunit/WebTest/Pledge/ContactContextAddTest.php b/tests/phpunit/WebTest/Pledge/ContactContextAddTest.php index 6368dc5e31..74011cb284 100644 --- a/tests/phpunit/WebTest/Pledge/ContactContextAddTest.php +++ b/tests/phpunit/WebTest/Pledge/ContactContextAddTest.php @@ -41,9 +41,9 @@ class WebTest_Pledge_ContactContextAddTest extends CiviSeleniumTestCase { $this->enableDisablePopups(FALSE); // create unique name - $name = substr(sha1(rand()), 0, 7); + $name = substr(sha1(rand()), 0, 7); $firstName = 'Adam' . $name; - $lastName = 'Jones' . $name; + $lastName = 'Jones' . $name; // create new contact $this->webtestAddContact($firstName, $lastName, $firstName . "@example.com"); diff --git a/tests/phpunit/WebTest/Pledge/ContactContextPledgePaymentAddTest.php b/tests/phpunit/WebTest/Pledge/ContactContextPledgePaymentAddTest.php index c847d4bde4..9854f3c840 100644 --- a/tests/phpunit/WebTest/Pledge/ContactContextPledgePaymentAddTest.php +++ b/tests/phpunit/WebTest/Pledge/ContactContextPledgePaymentAddTest.php @@ -47,9 +47,9 @@ class WebTest_Pledge_ContactContextPledgePaymentAddTest extends CiviSeleniumTest $this->enableDisablePopups(FALSE); // create unique name - $name = substr(sha1(rand()), 0, 7); + $name = substr(sha1(rand()), 0, 7); $firstName = 'Adam' . $name; - $lastName = 'Jones' . $name; + $lastName = 'Jones' . $name; // create new contact $this->webtestAddContact($firstName, $lastName, $firstName . "@example.com"); @@ -211,9 +211,9 @@ class WebTest_Pledge_ContactContextPledgePaymentAddTest extends CiviSeleniumTest $this->enableDisablePopups(FALSE); // create unique name - $name = substr(sha1(rand()), 0, 7); + $name = substr(sha1(rand()), 0, 7); $firstName = 'Adam' . $name; - $lastName = 'Jones' . $name; + $lastName = 'Jones' . $name; // create new contact $this->webtestAddContact($firstName, $lastName, $firstName . "@example.com"); @@ -356,9 +356,9 @@ class WebTest_Pledge_ContactContextPledgePaymentAddTest extends CiviSeleniumTest $this->enableDisablePopups(FALSE); // create unique name - $name = substr(sha1(rand()), 0, 7); + $name = substr(sha1(rand()), 0, 7); $firstName = 'Adam' . $name; - $lastName = 'Jones' . $name; + $lastName = 'Jones' . $name; // create new contact $this->webtestAddContact($firstName, $lastName, $firstName . "@example.com"); diff --git a/tests/phpunit/WebTest/Profile/DedupeTest.php b/tests/phpunit/WebTest/Profile/DedupeTest.php index 6b8ca1dbc4..00e69530be 100644 --- a/tests/phpunit/WebTest/Profile/DedupeTest.php +++ b/tests/phpunit/WebTest/Profile/DedupeTest.php @@ -37,7 +37,12 @@ class WebTest_Profile_DedupeTest extends CiviSeleniumTestCase { public function testProfileCreateDupeStrictDefault() { // lets give profile related permision to anonymous user. - $permission = array('edit-1-profile-create', 'edit-1-profile-edit', 'edit-1-profile-listings', 'edit-1-profile-view'); + $permission = array( + 'edit-1-profile-create', + 'edit-1-profile-edit', + 'edit-1-profile-listings', + 'edit-1-profile-view' + ); $this->changePermissions($permission); // Log in as normal user diff --git a/tests/phpunit/WebTest/Profile/MultiRecordProfileAddTest.php b/tests/phpunit/WebTest/Profile/MultiRecordProfileAddTest.php index bfd18cf83a..be7fe7b609 100644 --- a/tests/phpunit/WebTest/Profile/MultiRecordProfileAddTest.php +++ b/tests/phpunit/WebTest/Profile/MultiRecordProfileAddTest.php @@ -34,6 +34,7 @@ class WebTest_Profile_MultiRecordProfileAddTest extends CiviSeleniumTestCase { protected function setUp() { parent::setUp(); } + public function testAdminAddNewProfile() { $this->webtestLogin(); list($id, $profileTitle) = $this->_addNewProfile(); @@ -116,7 +117,11 @@ class WebTest_Profile_MultiRecordProfileAddTest extends CiviSeleniumTestCase { $gid = $this->urlArg('gid'); - $this->openCiviPage('admin/uf/group/field/add', array('action' => 'add', 'reset' => 1, 'gid' => $gid), 'field_name[0]'); + $this->openCiviPage('admin/uf/group/field/add', array( + 'action' => 'add', + 'reset' => 1, + 'gid' => $gid + ), 'field_name[0]'); //Add field to profile $this->click('field_name[0]'); diff --git a/tests/phpunit/WebTest/Profile/ProfileAddTest.php b/tests/phpunit/WebTest/Profile/ProfileAddTest.php index eb0b80754f..0ed57f7cd2 100644 --- a/tests/phpunit/WebTest/Profile/ProfileAddTest.php +++ b/tests/phpunit/WebTest/Profile/ProfileAddTest.php @@ -156,8 +156,8 @@ class WebTest_Profile_ProfileAddTest extends CiviSeleniumTestCase { //Add fields to profile $fields = array( 'first_name' => 'Individual', - 'last_name' => 'Individual', - 'email' => 'Contact', + 'last_name' => 'Individual', + 'email' => 'Contact', ); $this->waitForElementPresent("field_name_0"); foreach ($fields as $field => $type) { @@ -174,7 +174,7 @@ class WebTest_Profile_ProfileAddTest extends CiviSeleniumTestCase { $gid = $this->urlArg('gid'); $this->openCiviPage('profile/create', "gid=$gid&reset=1", NULL); $firstName1 = "John_" . substr(sha1(rand()), 0, 7); - $lastName1 = "Smiths_x" . substr(sha1(rand()), 0, 7); + $lastName1 = "Smiths_x" . substr(sha1(rand()), 0, 7); $this->type('first_name', $firstName1); $this->type('last_name', $lastName1); $this->type('email-Primary', "$firstName1.$lastName1@example.com"); @@ -184,7 +184,7 @@ class WebTest_Profile_ProfileAddTest extends CiviSeleniumTestCase { $this->webtestLogout(); $this->openCiviPage('profile/create', "gid=$gid&reset=1", NULL); $firstName2 = "John12_" . substr(sha1(rand()), 0, 7); - $lastName2 = "Smiths34_x" . substr(sha1(rand()), 0, 7); + $lastName2 = "Smiths34_x" . substr(sha1(rand()), 0, 7); $this->type('first_name', $firstName2); $this->type('last_name', $lastName2); $this->type('email-Primary', "$firstName2.$lastName2@example.com"); diff --git a/tests/phpunit/WebTest/Profile/ProfileCountryState.php b/tests/phpunit/WebTest/Profile/ProfileCountryState.php index c0093c71c6..ab6344aa86 100644 --- a/tests/phpunit/WebTest/Profile/ProfileCountryState.php +++ b/tests/phpunit/WebTest/Profile/ProfileCountryState.php @@ -59,7 +59,11 @@ class WebTest_Profile_ProfileCountryState extends CiviSeleniumTestCase { $gid = $this->urlArg('gid'); //Add Country field to profile - $this->openCiviPage('admin/uf/group/field/add', array('action' => 'add', 'reset' => 1, 'gid' => $gid), 'field_name[0]'); + $this->openCiviPage('admin/uf/group/field/add', array( + 'action' => 'add', + 'reset' => 1, + 'gid' => $gid + ), 'field_name[0]'); $this->click('field_name[0]'); $this->select('field_name[0]', 'value=Contact'); $this->click("//option[@value='Contact']"); diff --git a/tests/phpunit/WebTest/Report/LoggingReportTest.php b/tests/phpunit/WebTest/Report/LoggingReportTest.php index 36c84cfd06..59b4cffdbf 100644 --- a/tests/phpunit/WebTest/Report/LoggingReportTest.php +++ b/tests/phpunit/WebTest/Report/LoggingReportTest.php @@ -50,7 +50,7 @@ class WebTest_Report_LoggingReportTest extends CiviSeleniumTestCase { //add new contact $orginalFirstName = $firstName = 'Anthony' . substr(sha1(rand()), 0, 7); - $lastName = 'Anderson' . substr(sha1(rand()), 0, 7); + $lastName = 'Anderson' . substr(sha1(rand()), 0, 7); $this->webtestAddContact($firstName, $lastName); $cid = $this->urlArg('cid'); @@ -186,34 +186,82 @@ class WebTest_Report_LoggingReportTest extends CiviSeleniumTestCase { array("log_type" => "Contact", "altered_contact" => "{$firstName} {$lastName}", "action" => "Update"), array("log_type" => "Contact", "altered_contact" => "{$firstName} {$lastName}", "action" => "Insert"), //relationship data check - array("log_type" => "Relationship", "altered_contact" => "{$firstName} {$lastName} [Employee of]", "action" => "Update"), - array("log_type" => "Relationship", "altered_contact" => "{$firstName} {$lastName} [Employee of]", "action" => "Insert"), - array("log_type" => "Relationship", "altered_contact" => "{$firstName} {$lastName} [Employee of]", "action" => "Delete"), + array( + "log_type" => "Relationship", + "altered_contact" => "{$firstName} {$lastName} [Employee of]", + "action" => "Update" + ), + array( + "log_type" => "Relationship", + "altered_contact" => "{$firstName} {$lastName} [Employee of]", + "action" => "Insert" + ), + array( + "log_type" => "Relationship", + "altered_contact" => "{$firstName} {$lastName} [Employee of]", + "action" => "Delete" + ), //group data check - array("log_type" => "Group", "altered_contact" => "{$firstName} {$lastName} [Case Resources]", "action" => "Added"), - array("log_type" => "Group", "altered_contact" => "{$firstName} {$lastName} [Case Resources]", "action" => "Removed"), + array( + "log_type" => "Group", + "altered_contact" => "{$firstName} {$lastName} [Case Resources]", + "action" => "Added" + ), + array( + "log_type" => "Group", + "altered_contact" => "{$firstName} {$lastName} [Case Resources]", + "action" => "Removed" + ), //note data check array("log_type" => "Note", "altered_contact" => "{$firstName} {$lastName}", "action" => "Update"), array("log_type" => "Note", "altered_contact" => "{$firstName} {$lastName}", "action" => "Insert"), array("log_type" => "Note", "altered_contact" => "{$firstName} {$lastName}", "action" => "Delete"), //tags data check array("log_type" => "Tag", "altered_contact" => "{$firstName} {$lastName} [Company]", "action" => "Insert"), - array("log_type" => "Tag", "altered_contact" => "{$firstName} {$lastName} [Government Entity]", "action" => "Insert"), + array( + "log_type" => "Tag", + "altered_contact" => "{$firstName} {$lastName} [Government Entity]", + "action" => "Insert" + ), array("log_type" => "Tag", "altered_contact" => "{$firstName} {$lastName} [Company]", "action" => "Delete"), //case data check - array("log_type" => "Case", "altered_contact" => "{$firstName} {$lastName} [Housing Support]", "action" => "Update"), - array("log_type" => "Case", "altered_contact" => "{$firstName} {$lastName} [Housing Support]", "action" => "Insert"), + array( + "log_type" => "Case", + "altered_contact" => "{$firstName} {$lastName} [Housing Support]", + "action" => "Update" + ), + array( + "log_type" => "Case", + "altered_contact" => "{$firstName} {$lastName} [Housing Support]", + "action" => "Insert" + ), //case activity check - array("log_type" => "Activity", "altered_contact" => "{$firstName} {$lastName} [Interview]", "action" => "Update"), - array("log_type" => "Activity", "altered_contact" => "{$firstName} {$lastName} [Interview]", "action" => "Insert"), + array( + "log_type" => "Activity", + "altered_contact" => "{$firstName} {$lastName} [Interview]", + "action" => "Update" + ), + array( + "log_type" => "Activity", + "altered_contact" => "{$firstName} {$lastName} [Interview]", + "action" => "Insert" + ), ); $this->verifyReportData($data); //update link (logging details report check) $contactInfo = array(); $contactInfo['data'] = array( - array('field' => 'Sort Name', 'changed_from' => "{$lastName}, {$orginalFirstName}", 'changed_to' => "{$lastName}, {$firstName}"), - array('field' => 'Display Name', 'changed_from' => "{$orginalFirstName} {$lastName}", 'changed_to' => "{$firstName} {$lastName}"), + array( + 'field' => 'Sort Name', + 'changed_from' => "{$lastName}, {$orginalFirstName}", + 'changed_to' => "{$lastName}, {$firstName}" + ), + array( + 'field' => 'Display Name', + 'changed_from' => "{$orginalFirstName} {$lastName}", + 'changed_to' => "{$firstName} {$lastName}" + ), array('field' => 'First Name', 'changed_from' => $orginalFirstName, 'changed_to' => $firstName), // array('field' => 'Email Greeting', 'changed_from' => "Dear {$orginalFirstName}", 'changed_to' => "Dear {$firstName}"), // array('field' => 'Postal Greeting', 'changed_from' => "Dear {$orginalFirstName}", 'changed_to' => "Dear {$firstName}"), @@ -223,7 +271,7 @@ class WebTest_Report_LoggingReportTest extends CiviSeleniumTestCase { $relationshipInfo = array(); $relationshipInfo['data'] = array( - array('field' => 'Relationship Is Active', 'changed_from' => 'true', 'changed_to' => 'false'), + array('field' => 'Relationship Is Active', 'changed_from' => 'true', 'changed_to' => 'false'), ); $relationshipInfo = array_merge($relationshipInfo, $data[2]); @@ -242,8 +290,8 @@ class WebTest_Report_LoggingReportTest extends CiviSeleniumTestCase { $activityInfo = array(); $activityInfo['data'] = array( - array('field' => 'Activity Status Id', 'changed_from' => 'Scheduled', 'changed_to' => 'Completed'), - ); + array('field' => 'Activity Status Id', 'changed_from' => 'Scheduled', 'changed_to' => 'Completed'), + ); $activityInfo = array_merge($activityInfo, $data[15]); $dataForReportDetail = array($contactInfo, $relationshipInfo, $noteInfo, $caseInfo, $activityInfo); @@ -261,7 +309,13 @@ class WebTest_Report_LoggingReportTest extends CiviSeleniumTestCase { $this->click("_qf_LoggingSummary_submit"); $this->waitForPageToLoad($this->getTimeoutMsec()); - $contactDataDelete = array(array("log_type" => "Contact", "altered_contact" => "{$firstName} {$lastName}", "action" => "Delete (to trash)")); + $contactDataDelete = array( + array( + "log_type" => "Contact", + "altered_contact" => "{$firstName} {$lastName}", + "action" => "Delete (to trash)" + ) + ); $this->verifyReportData($contactDataDelete); //disable the logging diff --git a/tests/phpunit/api/v3/ACLPermissionTest.php b/tests/phpunit/api/v3/ACLPermissionTest.php index 95febd633c..1cf86362b4 100644 --- a/tests/phpunit/api/v3/ACLPermissionTest.php +++ b/tests/phpunit/api/v3/ACLPermissionTest.php @@ -232,15 +232,15 @@ class api_v3_ACLPermissionTest extends CiviUnitTestCase { public function setupCoreACL() { $this->createLoggedInUser(); $this->_permissionedDisabledGroup = $this->groupCreate(array( - 'title' => 'pick-me-disabled', - 'is_active' => 0, - 'name' => 'pick-me-disabled', - )); + 'title' => 'pick-me-disabled', + 'is_active' => 0, + 'name' => 'pick-me-disabled', + )); $this->_permissionedGroup = $this->groupCreate(array( - 'title' => 'pick-me-active', - 'is_active' => 1, - 'name' => 'pick-me-active', - )); + 'title' => 'pick-me-active', + 'is_active' => 1, + 'name' => 'pick-me-active', + )); $this->setupACL(); } diff --git a/tests/phpunit/api/v3/APIStandardsTest.php b/tests/phpunit/api/v3/APIStandardsTest.php index 3fdaaef263..878ca5772d 100644 --- a/tests/phpunit/api/v3/APIStandardsTest.php +++ b/tests/phpunit/api/v3/APIStandardsTest.php @@ -49,7 +49,6 @@ class api_v3_APIStandardsTest extends CiviUnitTestCase { /* This test case doesn't require DB reset */ - public $DBResetRequired = FALSE; /** diff --git a/tests/phpunit/api/v3/APITest.php b/tests/phpunit/api/v3/APITest.php index 007a7ff822..5682e91a89 100644 --- a/tests/phpunit/api/v3/APITest.php +++ b/tests/phpunit/api/v3/APITest.php @@ -131,6 +131,7 @@ class api_v3_APITest extends CiviUnitTestCase { $this->assertEquals($expected, $actual, sprintf('input=%s expected=%s actual=%s', $input, $expected, $actual)); } } + /** * Test that calling via wrapper works */ diff --git a/tests/phpunit/api/v3/ActionScheduleTest.php b/tests/phpunit/api/v3/ActionScheduleTest.php index 21efe922a9..2cd3fa224b 100644 --- a/tests/phpunit/api/v3/ActionScheduleTest.php +++ b/tests/phpunit/api/v3/ActionScheduleTest.php @@ -31,7 +31,6 @@ require_once 'CiviTest/CiviUnitTestCase.php'; * @package CiviCRM_APIv3 * @subpackage API_ActionSchedule */ - class api_v3_ActionScheduleTest extends CiviUnitTestCase { protected $_params; protected $_params2; @@ -39,7 +38,6 @@ class api_v3_ActionScheduleTest extends CiviUnitTestCase { protected $_apiversion = 3; - /** * Test setup for every test * @@ -84,8 +82,8 @@ class api_v3_ActionScheduleTest extends CiviUnitTestCase { */ public function testActionScheduleCreateWithoutRequired() { $params = array( - 'subject' => 'this case should fail', - 'scheduled_date_time' => date('Ymd'), + 'subject' => 'this case should fail', + 'scheduled_date_time' => date('Ymd'), ); $result = $this->callAPIFailure('activity', 'create', $params); } diff --git a/tests/phpunit/api/v3/ActivityTest.php b/tests/phpunit/api/v3/ActivityTest.php index 2beacc9847..3be599cc91 100644 --- a/tests/phpunit/api/v3/ActivityTest.php +++ b/tests/phpunit/api/v3/ActivityTest.php @@ -40,7 +40,6 @@ require_once 'CiviTest/CiviUnitTestCase.php'; * @package CiviCRM_APIv3 * @subpackage API_Activity */ - class api_v3_ActivityTest extends CiviUnitTestCase { protected $_params; protected $_params2; @@ -239,7 +238,6 @@ class api_v3_ActivityTest extends CiviUnitTestCase { } - public function testActivityCreateWithValidStringPriority() { $params = array( 'source_contact_id' => $this->_contactID, @@ -326,8 +324,8 @@ class api_v3_ActivityTest extends CiviUnitTestCase { public function testActivityReturnTargetAssignee() { $description = "Example demonstrates setting & retrieving the target & source"; - $subfile = "GetTargetandAssignee"; - $params = array( + $subfile = "GetTargetandAssignee"; + $params = array( 'source_contact_id' => $this->_contactID, 'subject' => 'Make-it-Happen Meeting', 'activity_date_time' => '20110316', @@ -342,7 +340,12 @@ class api_v3_ActivityTest extends CiviUnitTestCase { ); $result = $this->callAPIAndDocument('activity', 'create', $params, __FUNCTION__, __FILE__, $description, $subfile); - $result = $this->callAPISuccess('activity', 'get', array('id' => $result['id'], 'version' => $this->_apiversion, 'return.assignee_contact_id' => 1, 'return.target_contact_id' => 1)); + $result = $this->callAPISuccess('activity', 'get', array( + 'id' => $result['id'], + 'version' => $this->_apiversion, + 'return.assignee_contact_id' => 1, + 'return.target_contact_id' => 1 + )); $this->assertEquals($this->_contactID, $result['values'][$result['id']]['assignee_contact_id'][0], 'in line ' . __LINE__); $this->assertEquals($this->_contactID, $result['values'][$result['id']]['target_contact_id'][0], 'in line ' . __LINE__); @@ -367,7 +370,11 @@ class api_v3_ActivityTest extends CiviUnitTestCase { $params = $this->_params; $params['custom_' . $ids['custom_field_id']] = "custom string"; $result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__); - $result = $this->callAPISuccess($this->_entity, 'get', array('return.custom_' . $ids['custom_field_id'] => 1, 'version' => 3, 'id' => $result['id'])); + $result = $this->callAPISuccess($this->_entity, 'get', array( + 'return.custom_' . $ids['custom_field_id'] => 1, + 'version' => 3, + 'id' => $result['id'] + )); $this->assertEquals("custom string", $result['values'][$result['id']]['custom_' . $ids['custom_field_id']], ' in line ' . __LINE__); $this->customFieldDelete($ids['custom_field_id']); @@ -381,10 +388,10 @@ class api_v3_ActivityTest extends CiviUnitTestCase { public function testActivityCreateCustomContactRefField() { $this->callAPISuccess('contact', 'create', array('id' => $this->_contactID, 'sort_name' => 'Contact, Test')); - $subfile = 'ContactRefCustomField'; + $subfile = 'ContactRefCustomField'; $description = "demonstrates create with Contact Reference Custom Field"; - $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, __FILE__); - $params = array( + $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, __FILE__); + $params = array( 'custom_group_id' => $ids['custom_group_id'], 'name' => 'Worker_Lookup', 'label' => 'Worker Lookup', @@ -400,7 +407,10 @@ class api_v3_ActivityTest extends CiviUnitTestCase { $params['custom_' . $customField['id']] = "$this->_contactID"; $result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__, $description, $subfile, 'Create'); - $result = $this->callAPIAndDocument($this->_entity, 'get', array('return.custom_' . $customField['id'] => 1, 'id' => $result['id']), __FUNCTION__, __FILE__, 'Get with Contact Ref Custom Field', 'ContactRefCustomFieldGet', 'get'); + $result = $this->callAPIAndDocument($this->_entity, 'get', array( + 'return.custom_' . $customField['id'] => 1, + 'id' => $result['id'] + ), __FUNCTION__, __FILE__, 'Get with Contact Ref Custom Field', 'ContactRefCustomFieldGet', 'get'); $this->assertEquals('Anderson, Anthony', $result['values'][$result['id']]['custom_' . $customField['id']], ' in line ' . __LINE__); $this->assertEquals($this->_contactID, $result['values'][$result['id']]['custom_' . $customField['id'] . "_id"], ' in line ' . __LINE__); @@ -489,19 +499,19 @@ class api_v3_ActivityTest extends CiviUnitTestCase { // Insert rows in civicrm_activity creating activities 4 and // 13 $description = "Function demonstrates getting asignee_contact_id & using it to get the contact"; - $subfile = 'ReturnAssigneeContact'; - $activity = $this->callAPISuccess('activity', 'create', $this->_params); + $subfile = 'ReturnAssigneeContact'; + $activity = $this->callAPISuccess('activity', 'create', $this->_params); $contact = $this->callAPISuccess('Contact', 'Create', array( - 'first_name' => "The Rock", - 'last_name' => 'roccky', - 'contact_type' => 'Individual', - 'version' => 3, - 'api.activity.create' => array( - 'id' => $activity['id'], - 'assignee_contact_id' => '$value.id', - ), - )); + 'first_name' => "The Rock", + 'last_name' => 'roccky', + 'contact_type' => 'Individual', + 'version' => 3, + 'api.activity.create' => array( + 'id' => $activity['id'], + 'assignee_contact_id' => '$value.id', + ), + )); $params = array( 'activity_id' => $activity['id'], @@ -579,11 +589,19 @@ class api_v3_ActivityTest extends CiviUnitTestCase { $params['target_contact_id'] = array($contact2 => $contact2); $activity = $this->callAPISuccess('Activity', 'Create', $params); - $activityget = $this->callAPISuccess('Activity', 'get', array('id' => $activity['id'], 'target_contact_id' => $contact2, 'return.target_contact_id' => 1)); + $activityget = $this->callAPISuccess('Activity', 'get', array( + 'id' => $activity['id'], + 'target_contact_id' => $contact2, + 'return.target_contact_id' => 1 + )); $this->assertEquals($activity['id'], $activityget['id'], 'In line ' . __LINE__); $this->assertEquals($contact2, $activityget['values'][$activityget['id']]['target_contact_id'][0], 'In line ' . __LINE__); - $activityget = $this->callAPISuccess('activity', 'get', array('target_contact_id' => $this->_contactID, 'return.target_contact_id' => 1, 'id' => $activity['id'])); + $activityget = $this->callAPISuccess('activity', 'get', array( + 'target_contact_id' => $this->_contactID, + 'return.target_contact_id' => 1, + 'id' => $activity['id'] + )); if ($activityget['count'] > 0) { $this->assertNotEquals($contact2, $activityget['values'][$activityget['id']]['target_contact_id'][0], 'In line ' . __LINE__); } @@ -614,8 +632,9 @@ class api_v3_ActivityTest extends CiviUnitTestCase { $result = $this->callAPISuccess('Activity', 'Get', array('activity_status_id' => '2')); $this->assertEquals(0, $result['count'], 'No activities of status 1 should exist'); $result = $this->callAPISuccess('Activity', 'Get', array( - 'version' => $this->_apiversion, - 'status_id' => '2')); + 'version' => $this->_apiversion, + 'status_id' => '2' + )); $this->assertEquals(0, $result['count'], 'No activities of status 1 should exist'); } @@ -640,8 +659,8 @@ class api_v3_ActivityTest extends CiviUnitTestCase { $params['activity_date_time'] = 20120216; $activityTwo = $this->callAPISuccess('Activity', 'Create', $params); $result = $this->callAPISuccess('Activity', 'Get', array( - 'version' => 3, - )); + 'version' => 3, + )); $description = "demonstrates _low filter (at time of writing doesn't work if contact_id is set"; $subfile = "DateTimeLow"; $this->assertEquals(2, $result['count']); @@ -870,7 +889,11 @@ class api_v3_ActivityTest extends CiviUnitTestCase { $result = $this->callAPISuccess('activity', 'create', $params); $activityId = $result['id']; - $result = $this->callAPISuccess($this->_entity, 'get', array('return.custom_' . $ids['custom_field_id'] => 1, 'version' => 3, 'id' => $result['id'])); + $result = $this->callAPISuccess($this->_entity, 'get', array( + 'return.custom_' . $ids['custom_field_id'] => 1, + 'version' => 3, + 'id' => $result['id'] + )); $this->assertEquals("custom string", $result['values'][$result['id']]['custom_' . $ids['custom_field_id']], ' in line ' . __LINE__); $this->assertEquals("2009-10-18 00:00:00", $result['values'][$result['id']]['activity_date_time'], ' in line ' . __LINE__); $fields = $this->callAPISuccess('activity', 'getfields', array('version' => $this->_apiversion)); @@ -890,7 +913,11 @@ class api_v3_ActivityTest extends CiviUnitTestCase { ); $result = $this->callAPISuccess('Activity', 'Create', $params); - $result = $this->callAPISuccess($this->_entity, 'get', array('return.custom_' . $ids['custom_field_id'] => 1, 'version' => 3, 'id' => $result['id'])); + $result = $this->callAPISuccess($this->_entity, 'get', array( + 'return.custom_' . $ids['custom_field_id'] => 1, + 'version' => 3, + 'id' => $result['id'] + )); $this->assertEquals("Updated my test data", $result['values'][$result['id']]['custom_' . $ids['custom_field_id']], ' in line ' . __LINE__); } @@ -1084,29 +1111,34 @@ class api_v3_ActivityTest extends CiviUnitTestCase { $this->assertEquals('Test activity type', $result['values'][$activity['id']]['activity_name'], 'In line ' . __LINE__); $this->assertEquals('Test activity type', $result['values'][$activity2['id']]['activity_name'], 'In line ' . __LINE__); } + /* * test chained Activity format */ public function testchainedActivityGet() { $activity = $this->callAPISuccess('Contact', 'Create', array( - 'display_name' => "bob brown", - 'contact_type' => 'Individual', - 'api.activity_type.create' => array( - 'weight' => '2', - 'label' => 'send out letters', - 'filter' => 0, - 'is_active' => 1, - 'is_optgroup' => 1, - 'is_default' => 0, - ), 'api.activity.create' => array('subject' => 'send letter', 'activity_type_id' => '$value.api.activity_type.create.values.0.value'), - )); + 'display_name' => "bob brown", + 'contact_type' => 'Individual', + 'api.activity_type.create' => array( + 'weight' => '2', + 'label' => 'send out letters', + 'filter' => 0, + 'is_active' => 1, + 'is_optgroup' => 1, + 'is_default' => 0, + ), + 'api.activity.create' => array( + 'subject' => 'send letter', + 'activity_type_id' => '$value.api.activity_type.create.values.0.value' + ), + )); $result = $this->callAPISuccess('Activity', 'Get', array( - 'id' => $activity['id'], - 'return.assignee_contact_id' => 1, - 'api.contact.get' => array('api.pledge.get' => 1), - )); + 'id' => $activity['id'], + 'return.assignee_contact_id' => 1, + 'api.contact.get' => array('api.pledge.get' => 1), + )); } /** diff --git a/tests/phpunit/api/v3/ActivityTypeTest.php b/tests/phpunit/api/v3/ActivityTypeTest.php index 927ff42ea2..c6ec4a41d6 100644 --- a/tests/phpunit/api/v3/ActivityTypeTest.php +++ b/tests/phpunit/api/v3/ActivityTypeTest.php @@ -32,7 +32,6 @@ require_once 'CiviTest/CiviUnitTestCase.php'; * @package CiviCRM_APIv3 * @subpackage API_Activity */ - class api_v3_ActivityTypeTest extends CiviUnitTestCase { protected $_apiversion; diff --git a/tests/phpunit/api/v3/AddressTest.php b/tests/phpunit/api/v3/AddressTest.php index b74c6bf1a9..a890a70ed9 100644 --- a/tests/phpunit/api/v3/AddressTest.php +++ b/tests/phpunit/api/v3/AddressTest.php @@ -128,9 +128,9 @@ class api_v3_AddressTest extends CiviUnitTestCase { ); $this->callAPISuccess('address', 'create', array_merge($this->_params, $individualParams)); $this->callAPISuccess('relationship', 'getcount', array( - 'contact_id_a' => $individualID, - 'contact_id_b' => $this->_contactID, - )); + 'contact_id_a' => $individualID, + 'contact_id_b' => $this->_contactID, + )); } /** @@ -145,9 +145,9 @@ class api_v3_AddressTest extends CiviUnitTestCase { ); $this->callAPISuccess('address', 'create', array_merge($this->_params, $individualParams)); $this->callAPISuccess('relationship', 'getcount', array( - 'contact_id_a' => $individualID, - 'contact_id_b' => $this->_contactID, - )); + 'contact_id_a' => $individualID, + 'contact_id_b' => $this->_contactID, + )); } /** @@ -170,10 +170,10 @@ class api_v3_AddressTest extends CiviUnitTestCase { $this->markTestIncomplete('Remainder of test checks that employer relationship is disabled when new one is created but turns out to be not happening - by design?'); $this->callAPISuccessGetCount('relationship', array('contact_id_a' => $individualID, 'is_active' => FALSE), 1); $this->callAPISuccessGetCount('relationship', array( - 'contact_id_a' => $individualID, - 'is_active' => TRUE, - 'contact_id_b' => $organisation2ID, - ), 1); + 'contact_id_a' => $individualID, + 'is_active' => TRUE, + 'contact_id_b' => $organisation2ID, + ), 1); } diff --git a/tests/phpunit/api/v3/AttachmentTest.php b/tests/phpunit/api/v3/AttachmentTest.php index 0a7d84d6bc..c80f89d0cf 100644 --- a/tests/phpunit/api/v3/AttachmentTest.php +++ b/tests/phpunit/api/v3/AttachmentTest.php @@ -253,7 +253,7 @@ class api_v3_AttachmentTest extends CiviUnitTestCase { ); $cases[] = array( array('check_permissions' => 1), - "/Mandatory key\\(s\\) missing from params array: 'id' or 'entity_table'/", + "/Mandatory key\\(s\\) missing from params array: 'id' or 'entity_table'/", ); $cases[] = array( array('entity_table' => 'civicrm_activity', 'name' => 'example_456.csv'), diff --git a/tests/phpunit/api/v3/CRM11793Test.php b/tests/phpunit/api/v3/CRM11793Test.php index 10153c3cd0..8af6e8076b 100644 --- a/tests/phpunit/api/v3/CRM11793Test.php +++ b/tests/phpunit/api/v3/CRM11793Test.php @@ -47,6 +47,7 @@ class api_v3_CRM11793Test extends CiviUnitTestCase { public function testCRM11793Household() { $this->_testCRM11793ContactType('Household'); } + public function testCRM11793Individual() { $this->_testCRM11793ContactType('Individual'); } diff --git a/tests/phpunit/api/v3/CaseTest.php b/tests/phpunit/api/v3/CaseTest.php index 9a85228a57..f284369e96 100644 --- a/tests/phpunit/api/v3/CaseTest.php +++ b/tests/phpunit/api/v3/CaseTest.php @@ -169,7 +169,10 @@ class api_v3_CaseTest extends CiviCaseTestCase { $activity = $case['activities'][0]; // Fetch case based on an activity id - $result = $this->callAPISuccess('case', 'get', array('activity_id' => $activity, 'return' => 'activities,contacts')); + $result = $this->callAPISuccess('case', 'get', array( + 'activity_id' => $activity, + 'return' => 'activities,contacts' + )); $this->assertEquals(FALSE, empty($result['values'][$id]), 'in line ' . __LINE__); $this->assertEquals($result['values'][$id], $case, 'in line ' . __LINE__); } @@ -186,7 +189,10 @@ class api_v3_CaseTest extends CiviCaseTestCase { $case = $this->callAPISuccess('case', 'getsingle', array('id' => $id)); // Fetch case based on client contact id - $result = $this->callAPISuccess('case', 'get', array('client_id' => $this->_params['contact_id'], 'return' => array('activities', 'contacts'))); + $result = $this->callAPISuccess('case', 'get', array( + 'client_id' => $this->_params['contact_id'], + 'return' => array('activities', 'contacts') + )); $this->assertAPIArrayComparison($result['values'][$id], $case); } @@ -202,7 +208,10 @@ class api_v3_CaseTest extends CiviCaseTestCase { $case = $this->callAPISuccess('case', 'getsingle', array('id' => $id)); // Fetch case based on client contact id - $result = $this->callAPISuccess('case', 'get', array('subject' => $this->_params['subject'], 'return' => array('activities', 'contacts'))); + $result = $this->callAPISuccess('case', 'get', array( + 'subject' => $this->_params['subject'], + 'return' => array('activities', 'contacts') + )); $this->assertAPIArrayComparison($result['values'][$id], $case); } @@ -215,7 +224,10 @@ class api_v3_CaseTest extends CiviCaseTestCase { $id = $result['id']; // Append 'wrong' to subject so that it is no longer the same - $result = $this->callAPISuccess('case', 'get', array('subject' => $this->_params['subject'] . 'wrong', 'return' => array('activities', 'contacts'))); + $result = $this->callAPISuccess('case', 'get', array( + 'subject' => $this->_params['subject'] . 'wrong', + 'return' => array('activities', 'contacts') + )); $this->assertEquals(0, $result['count'], 'in line ' . __LINE__); } diff --git a/tests/phpunit/api/v3/ContactTest.php b/tests/phpunit/api/v3/ContactTest.php index 760ae1adc7..84fa9ffa2f 100644 --- a/tests/phpunit/api/v3/ContactTest.php +++ b/tests/phpunit/api/v3/ContactTest.php @@ -327,9 +327,9 @@ class api_v3_ContactTest extends CiviUnitTestCase { $result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__, $description); $check = $this->callAPISuccess($this->_entity, 'get', array( - 'return.custom_' . $ids['custom_field_id'] => 1, - 'id' => $result['id'], - )); + 'return.custom_' . $ids['custom_field_id'] => 1, + 'id' => $result['id'], + )); $this->assertEquals("custom string", $check['values'][$check['id']]['custom_' . $ids['custom_field_id']]); $this->customFieldDelete($ids['custom_field_id']); @@ -426,11 +426,11 @@ class api_v3_ContactTest extends CiviUnitTestCase { public function testGetDeceasedRetrieved() { $this->callAPISuccess($this->_entity, 'create', $this->_params); $c2 = $this->callAPISuccess($this->_entity, 'create', array( - 'first_name' => 'bb', - 'last_name' => 'ccc', - 'contact_type' => 'Individual', - 'is_deceased' => 1, - )); + 'first_name' => 'bb', + 'last_name' => 'ccc', + 'contact_type' => 'Individual', + 'is_deceased' => 1, + )); $result = $this->callAPISuccess($this->_entity, 'get', array('is_deceased' => 0)); $this->assertFalse(array_key_exists($c2['id'], $result['values'])); } @@ -441,10 +441,10 @@ class api_v3_ContactTest extends CiviUnitTestCase { public function testGetSort() { $c1 = $this->callAPISuccess($this->_entity, 'create', $this->_params); $c2 = $this->callAPISuccess($this->_entity, 'create', array( - 'first_name' => 'bb', - 'last_name' => 'ccc', - 'contact_type' => 'Individual', - )); + 'first_name' => 'bb', + 'last_name' => 'ccc', + 'contact_type' => 'Individual', + )); $result = $this->callAPISuccess($this->_entity, 'get', array( 'sort' => 'first_name ASC', 'return.first_name' => 1, @@ -472,15 +472,15 @@ class api_v3_ContactTest extends CiviUnitTestCase { public function testGetINIDArray() { $c1 = $this->callAPISuccess($this->_entity, 'create', $this->_params); $c2 = $this->callAPISuccess($this->_entity, 'create', array( - 'first_name' => 'bb', - 'last_name' => 'ccc', - 'contact_type' => 'Individual', - )); + 'first_name' => 'bb', + 'last_name' => 'ccc', + 'contact_type' => 'Individual', + )); $c3 = $this->callAPISuccess($this->_entity, 'create', array( - 'first_name' => 'hh', - 'last_name' => 'll', - 'contact_type' => 'Individual', - )); + 'first_name' => 'hh', + 'last_name' => 'll', + 'contact_type' => 'Individual', + )); $result = $this->callAPISuccess($this->_entity, 'get', array('id' => array('IN' => array($c1['id'], $c3['id'])))); $this->assertEquals(2, $result['count']); $this->assertEquals(array($c1['id'], $c3['id']), array_keys($result['values'])); @@ -524,10 +524,10 @@ class api_v3_ContactTest extends CiviUnitTestCase { public function testGetSortNewSYntax() { $c1 = $this->callAPISuccess($this->_entity, 'create', $this->_params); $c2 = $this->callAPISuccess($this->_entity, 'create', array( - 'first_name' => 'bb', - 'last_name' => 'ccc', - 'contact_type' => 'Individual', - )); + 'first_name' => 'bb', + 'last_name' => 'ccc', + 'contact_type' => 'Individual', + )); $result = $this->callAPISuccess($this->_entity, 'getvalue', array( 'return' => 'first_name', 'options' => array( @@ -579,9 +579,9 @@ class api_v3_ContactTest extends CiviUnitTestCase { $result = $this->callAPISuccess($this->_entity, 'create', $params); $check = $this->callAPIAndDocument($this->_entity, 'get', array( - 'return.custom_' . $ids['custom_field_id'] => 1, - 'id' => $result['id'], - ), __FUNCTION__, __FILE__, $description, $subfile); + 'return.custom_' . $ids['custom_field_id'] => 1, + 'id' => $result['id'], + ), __FUNCTION__, __FILE__, $description, $subfile); $this->assertEquals("custom string", $check['values'][$check['id']]['custom_' . $ids['custom_field_id']]); $fields = ($this->callAPISuccess('contact', 'getfields', $params)); @@ -618,15 +618,15 @@ class api_v3_ContactTest extends CiviUnitTestCase { public function testGetReturnAddressName() { $contactID = $this->individualCreate(); $this->callAPISuccess('address', 'create', array( - 'contact_id' => $contactID, - 'address_name' => 'My house', - 'location_type_id' => 'Home', - 'street_address' => '1 my road', - )); + 'contact_id' => $contactID, + 'address_name' => 'My house', + 'location_type_id' => 'Home', + 'street_address' => '1 my road', + )); $result = $this->callAPISuccessGetSingle('contact', array( - 'return' => 'address_name, street_address', - 'id' => $contactID, - )); + 'return' => 'address_name, street_address', + 'id' => $contactID, + )); $this->assertEquals('1 my road', $result['street_address']); $this->assertEquals('My house', $result['address_name']); @@ -1257,15 +1257,15 @@ class api_v3_ContactTest extends CiviUnitTestCase { $this->assertEquals(1, $result['count']); $this->assertEquals(date('Y-m-d', strtotime('first day of next month -20 years')), $result['values'][$contact3['id']]['birth_date']); $result = $this->callAPISuccess('contact', 'get', array( - 'birth_date_low' => date('Y-m-d', strtotime('-6 years')), - 'birth_date_high' => date('Y-m-d', strtotime('- 3 years')), - )); + 'birth_date_low' => date('Y-m-d', strtotime('-6 years')), + 'birth_date_high' => date('Y-m-d', strtotime('- 3 years')), + )); $this->assertEquals(1, $result['count']); $this->assertEquals(date('Y-m-d', strtotime('first day of next month -5 years')), $result['values'][$contact2['id']]['birth_date']); $result = $this->callAPISuccess('contact', 'get', array( - 'birth_date_low' => '-6 years', - 'birth_date_high' => '- 3 years', - )); + 'birth_date_low' => '-6 years', + 'birth_date_high' => '- 3 years', + )); $this->assertEquals(1, $result['count']); $this->assertEquals(date('Y-m-d', strtotime('first day of next month -5 years')), $result['values'][$contact2['id']]['birth_date']); } @@ -1288,9 +1288,9 @@ class api_v3_ContactTest extends CiviUnitTestCase { $this->assertEquals(1, $result['count']); $this->assertEquals(date('Y-m-d', strtotime('first day of next month -20 years')), $result['values'][$contact3['id']]['deceased_date']); $result = $this->callAPISuccess('contact', 'get', array( - 'deceased_date_low' => '-6 years', - 'deceased_date_high' => date('Y-m-d', strtotime('- 3 years')), - )); + 'deceased_date_low' => '-6 years', + 'deceased_date_high' => date('Y-m-d', strtotime('- 3 years')), + )); $this->assertEquals(1, $result['count']); $this->assertEquals(date('Y-m-d', strtotime('first day of next month -5 years')), $result['values'][$contact2['id']]['deceased_date']); } @@ -1344,9 +1344,9 @@ class api_v3_ContactTest extends CiviUnitTestCase { } //now we check they are still returned with 'return' key $result = $this->callAPISuccess('contact', 'getsingle', array( - 'id' => $contactID, - 'return' => array_keys($extraParams), - )); + 'id' => $contactID, + 'return' => array_keys($extraParams), + )); foreach ($extraParams as $key => $value) { $this->assertEquals($result[$key], $value); } @@ -1531,9 +1531,9 @@ class api_v3_ContactTest extends CiviUnitTestCase { $params['custom_' . $ids['custom_field_id']] = "custom string"; $moreids = $this->CustomGroupMultipleCreateWithFields(); $andmoreids = $this->CustomGroupMultipleCreateWithFields(array( - 'title' => "another group", - 'name' => 'another name', - )); + 'title' => "another group", + 'name' => 'another name', + )); $description = "/*this demonstrates the usage of chained api functions. A variety of techniques are used"; $subfile = "APIChainedArrayMultipleCustom"; $params = array( @@ -1933,10 +1933,10 @@ class api_v3_ContactTest extends CiviUnitTestCase { $contactID = $this->individualCreate(); CRM_Core_Config::singleton()->defaultSearchProfileID = 1; $this->callAPISuccess('address', 'create', array( - 'contact_id' => $contactID, - 'city' => 'Cool City', - 'location_type_id' => 1, - )); + 'contact_id' => $contactID, + 'city' => 'Cool City', + 'location_type_id' => 1, + )); $result = $this->callAPISuccess('contact', 'get', array('city' => 'Cool City', 'return' => 'contact_type')); $this->assertEquals(1, $result['count']); } @@ -1954,9 +1954,9 @@ class api_v3_ContactTest extends CiviUnitTestCase { $this->assertEquals(2, $result['count'], 'In line ' . __LINE__); // Force-exclude the deceased contact $result = $this->callAPISuccess('contact', 'getlist', array( - 'input' => $name, - 'params' => array('is_deceased' => 0), - )); + 'input' => $name, + 'params' => array('is_deceased' => 0), + )); $this->assertEquals(1, $result['count'], 'In line ' . __LINE__); $this->assertEquals($contact, $result['values'][0]['id'], 'In line ' . __LINE__); } diff --git a/tests/phpunit/api/v3/ContactTypeTest.php b/tests/phpunit/api/v3/ContactTypeTest.php index fc068c3b39..84665931eb 100644 --- a/tests/phpunit/api/v3/ContactTypeTest.php +++ b/tests/phpunit/api/v3/ContactTypeTest.php @@ -26,9 +26,6 @@ */ - - - require_once 'CiviTest/CiviUnitTestCase.php'; /** @@ -230,7 +227,7 @@ class api_v3_ContactTypeTest extends CiviUnitTestCase { $updateContact = $this->callAPIFailure('contact', 'create', $updateParams); $params = array( 'contact_id' => $contact['id'], - ); + ); $this->callAPISuccess('contact', 'delete', $params); // check for Type:Organization diff --git a/tests/phpunit/api/v3/ContributionPageTest.php b/tests/phpunit/api/v3/ContributionPageTest.php index b0ded9fb30..edc3642002 100644 --- a/tests/phpunit/api/v3/ContributionPageTest.php +++ b/tests/phpunit/api/v3/ContributionPageTest.php @@ -245,9 +245,9 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase { $this->callAPIAndDocument('contribution_page', 'submit', $submitParams, __FUNCTION__, __FILE__, 'submit contribution page', NULL, 'Submit'); $contributions = $this->callAPISuccess('contribution', 'get', array( - 'contribution_page_id' => $this->_ids['contribution_page'], - 'contribution_status_id' => 1, - )); + 'contribution_page_id' => $this->_ids['contribution_page'], + 'contribution_status_id' => 1, + )); $this->assertCount(2, $contributions['values']); $membershipPayment = $this->callAPISuccess('membership_payment', 'getsingle', array()); $this->assertTrue(in_array($membershipPayment['contribution_id'], array_keys($contributions['values']))); @@ -291,9 +291,9 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase { $this->callAPIAndDocument('contribution_page', 'submit', $submitParams, __FUNCTION__, __FILE__, 'submit contribution page', NULL, 'Submit'); $contribution = $this->callAPISuccess('contribution', 'getsingle', array( - 'contribution_page_id' => $this->_ids['contribution_page'], - 'contribution_status_id' => 1, - )); + 'contribution_page_id' => $this->_ids['contribution_page'], + 'contribution_status_id' => 1, + )); $membershipPayment = $this->callAPISuccess('membership_payment', 'getsingle', array()); $this->assertEquals($membershipPayment['contribution_id'], $contribution['id']); $membership = $this->callAPISuccessGetSingle('membership', array('id' => $membershipPayment['membership_id'])); @@ -307,10 +307,10 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase { $dummyPP->setDoDirectPaymentResult(array('contribution_status_id' => 1, 'trxn_id' => 'create_second_success')); $this->callAPISuccess('contribution_page', 'submit', $submitParams); $this->callAPISuccess('contribution', 'getsingle', array( - 'id' => array('NOT IN' => array($contribution['id'])), - 'contribution_page_id' => $this->_ids['contribution_page'], - 'contribution_status_id' => 1, - )); + 'id' => array('NOT IN' => array($contribution['id'])), + 'contribution_page_id' => $this->_ids['contribution_page'], + 'contribution_status_id' => 1, + )); $renewedMembership = $this->callAPISuccessGetSingle('membership', array('id' => $membershipPayment['membership_id'])); $this->assertEquals(date('Y-m-d', strtotime('+ 1 year', strtotime($membership['end_date']))), $renewedMembership['end_date']); $recurringContribution = $this->callAPISuccess('contribution_recur', 'getsingle', array('id' => $contribution['contribution_recur_id'])); @@ -353,9 +353,9 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase { $this->callAPIAndDocument('contribution_page', 'submit', $submitParams, __FUNCTION__, __FILE__, 'submit contribution page', NULL, 'Submit'); $contribution = $this->callAPISuccess('contribution', 'getsingle', array( - 'contribution_page_id' => $this->_ids['contribution_page'], - 'contribution_status_id' => 2, - )); + 'contribution_page_id' => $this->_ids['contribution_page'], + 'contribution_status_id' => 2, + )); $membershipPayment = $this->callAPISuccess('membership_payment', 'getsingle', array()); $this->assertEquals($membershipPayment['contribution_id'], $contribution['id']); $membership = $this->callAPISuccessGetSingle('membership', array('id' => $membershipPayment['membership_id'])); @@ -364,9 +364,9 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase { //@todo - check with Joe about these not existing //$this->callAPISuccess('line_item', 'getsingle', array('contribution_id' => $contribution['id'], 'entity_id' => $membership['id'])); $this->callAPISuccess('contribution', 'completetransaction', array( - 'id' => $contribution['id'], - 'trxn_id' => 'ipn_called', - )); + 'id' => $contribution['id'], + 'trxn_id' => 'ipn_called', + )); $membership = $this->callAPISuccessGetSingle('membership', array('id' => $membershipPayment['membership_id'])); //renew it with processor setting completed - should extend membership $submitParams = array_merge($submitParams, array( @@ -424,9 +424,9 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase { */ public function setUpMembershipBlockPriceSet() { $this->_ids['price_set'][] = $this->callAPISuccess('price_set', 'getvalue', array( - 'name' => 'default_membership_type_amount', - 'return' => 'id', - )); + 'name' => 'default_membership_type_amount', + 'return' => 'id', + )); if (empty($this->_ids['membership_type'])) { $this->_ids['membership_type'] = array($this->membershipTypeCreate(array('minimum_fee' => 2))); } diff --git a/tests/phpunit/api/v3/ContributionRecurTest.php b/tests/phpunit/api/v3/ContributionRecurTest.php index 8676533e19..33c5ac94a5 100644 --- a/tests/phpunit/api/v3/ContributionRecurTest.php +++ b/tests/phpunit/api/v3/ContributionRecurTest.php @@ -34,8 +34,6 @@ require_once 'CiviTest/CiviUnitTestCase.php'; * @package CiviCRM_APIv3 * @subpackage API_Contribution */ - - class api_v3_ContributionRecurTest extends CiviUnitTestCase { protected $_apiversion = 3; protected $params; diff --git a/tests/phpunit/api/v3/ContributionSoftTest.php b/tests/phpunit/api/v3/ContributionSoftTest.php index 8ae38e1fdf..da2b9b37b0 100644 --- a/tests/phpunit/api/v3/ContributionSoftTest.php +++ b/tests/phpunit/api/v3/ContributionSoftTest.php @@ -33,7 +33,6 @@ require_once 'CiviTest/CiviUnitTestCase.php'; * @package CiviCRM_APIv3 * @subpackage API_ContributionSoft */ - class api_v3_ContributionSoftTest extends CiviUnitTestCase { /** @@ -64,7 +63,7 @@ class api_v3_ContributionSoftTest extends CiviUnitTestCase { 'contact_id' => $this->_individualId, 'receive_date' => '20120511', 'total_amount' => 100.00, - 'financial_type_id' => $this->_financialTypeId, + 'financial_type_id' => $this->_financialTypeId, 'non_deductible_amount' => 10.00, 'fee_amount' => 5.00, 'net_amount' => 95.00, @@ -135,7 +134,8 @@ class api_v3_ContributionSoftTest extends CiviUnitTestCase { //test get by contact id works $result = $this->callAPISuccess('contribution_soft', 'get', array( - 'contact_id' => $this->_softIndividual2Id) + 'contact_id' => $this->_softIndividual2Id + ) ); $this->assertEquals(1, $result['count'], 'In line ' . __LINE__); @@ -151,7 +151,7 @@ class api_v3_ContributionSoftTest extends CiviUnitTestCase { $this->callAPISuccess('ContributionSoft', 'Delete', array( 'id' => $this->_softcontribution2['id'], - )); + )); } diff --git a/tests/phpunit/api/v3/ContributionTest.php b/tests/phpunit/api/v3/ContributionTest.php index 530033d401..9f4087a987 100644 --- a/tests/phpunit/api/v3/ContributionTest.php +++ b/tests/phpunit/api/v3/ContributionTest.php @@ -442,9 +442,9 @@ class api_v3_ContributionTest extends CiviUnitTestCase { $this->assertEquals('EFT', $contribution['values'][0]['payment_instrument']); $this->callAPISuccess('contribution', 'create', array( - 'id' => $contribution['id'], - 'payment_instrument' => 'Credit Card', - )); + 'id' => $contribution['id'], + 'payment_instrument' => 'Credit Card', + )); $contribution = $this->callAPISuccess('contribution', 'get', array( 'sequential' => 1, 'id' => $contribution['id'], @@ -459,37 +459,37 @@ class api_v3_ContributionTest extends CiviUnitTestCase { $this->callAPISuccess('contribution', 'create', $params); $this->callAPISuccess('contribution', 'create', $params2); $contribution = $this->callAPISuccess('contribution', 'get', array( - 'sequential' => 1, - 'contribution_payment_instrument_id' => 'Cash', - )); + 'sequential' => 1, + 'contribution_payment_instrument_id' => 'Cash', + )); $this->assertArrayHasKey('payment_instrument', $contribution['values'][0]); $this->assertEquals('Cash', $contribution['values'][0]['payment_instrument']); $this->assertEquals(1, $contribution['count']); $contribution = $this->callAPISuccess('contribution', 'get', array( - 'sequential' => 1, - 'payment_instrument_id' => 'EFT', - )); + 'sequential' => 1, + 'payment_instrument_id' => 'EFT', + )); $this->assertArrayHasKey('payment_instrument', $contribution['values'][0]); $this->assertEquals('EFT', $contribution['values'][0]['payment_instrument']); $this->assertEquals(1, $contribution['count']); $contribution = $this->callAPISuccess('contribution', 'get', array( - 'sequential' => 1, - 'payment_instrument_id' => 5, - )); + 'sequential' => 1, + 'payment_instrument_id' => 5, + )); $this->assertArrayHasKey('payment_instrument', $contribution['values'][0]); $this->assertEquals('EFT', $contribution['values'][0]['payment_instrument']); $this->assertEquals(1, $contribution['count']); $contribution = $this->callAPISuccess('contribution', 'get', array( - 'sequential' => 1, - 'payment_instrument' => 'EFT', - )); + 'sequential' => 1, + 'payment_instrument' => 'EFT', + )); $this->assertArrayHasKey('payment_instrument', $contribution['values'][0]); $this->assertEquals('EFT', $contribution['values'][0]['payment_instrument']); $this->assertEquals(1, $contribution['count']); $contribution = $this->callAPISuccess('contribution', 'create', array( - 'id' => $contribution['id'], - 'payment_instrument' => 'Credit Card', - )); + 'id' => $contribution['id'], + 'payment_instrument' => 'Credit Card', + )); $contribution = $this->callAPISuccess('contribution', 'get', array('sequential' => 1, 'id' => $contribution['id'])); $this->assertArrayHasKey('payment_instrument', $contribution['values'][0]); $this->assertEquals('Credit Card', $contribution['values'][0]['payment_instrument']); @@ -601,10 +601,10 @@ class api_v3_ContributionTest extends CiviUnitTestCase { $contribution = $this->callAPIAndDocument('contribution', 'create', $params, __FUNCTION__, __FILE__, $description, $subfile); $result = $this->callAPISuccess('note', 'get', array( - 'entity_table' => 'civicrm_contribution', - 'entity_id' => $contribution['id'], - 'sequential' => 1, - )); + 'entity_table' => 'civicrm_contribution', + 'entity_id' => $contribution['id'], + 'sequential' => 1, + )); $this->assertEquals('my contribution note', $result['values'][0]['note']); $this->callAPISuccess('contribution', 'delete', array('id' => $contribution['id'])); } @@ -628,10 +628,10 @@ class api_v3_ContributionTest extends CiviUnitTestCase { $contribution = $this->callAPISuccess('contribution', 'create', $params); $result = $this->callAPISuccess('note', 'get', array( - 'entity_table' => 'civicrm_contribution', - 'entity_id' => $contribution['id'], - 'sequential' => 1, - )); + 'entity_table' => 'civicrm_contribution', + 'entity_id' => $contribution['id'], + 'sequential' => 1, + )); $this->assertEquals('my contribution note', $result['values'][0]['note']); $this->callAPISuccess('contribution', 'delete', array('id' => $contribution['id'])); } @@ -644,9 +644,9 @@ class api_v3_ContributionTest extends CiviUnitTestCase { $description = "Demonstrates creating contribution with SoftCredit"; $subfile = "ContributionCreateWithSoftCredit"; $contact2 = $this->callAPISuccess('Contact', 'create', array( - 'display_name' => 'superman', - 'contact_type' => 'Individual', - )); + 'display_name' => 'superman', + 'contact_type' => 'Individual', + )); $softparams = array( 'contact_id' => $contact2['id'], 'amount' => 50, @@ -669,9 +669,9 @@ class api_v3_ContributionTest extends CiviUnitTestCase { $description = "Demonstrates creating contribution with Soft Credit defaults for amount and type"; $subfile = "ContributionCreateWithSoftCreditDefaults"; $contact2 = $this->callAPISuccess('Contact', 'create', array( - 'display_name' => 'superman', - 'contact_type' => 'Individual', - )); + 'display_name' => 'superman', + 'contact_type' => 'Individual', + )); $params = $this->_params + array( 'soft_credit_to' => $contact2['id'], ); @@ -691,9 +691,9 @@ class api_v3_ContributionTest extends CiviUnitTestCase { $description = "Demonstrates creating contribution with Soft Credit by passing in honor_contact_id"; $subfile = "ContributionCreateWithHonoreeContact"; $contact2 = $this->callAPISuccess('Contact', 'create', array( - 'display_name' => 'superman', - 'contact_type' => 'Individual', - )); + 'display_name' => 'superman', + 'contact_type' => 'Individual', + )); $params = $this->_params + array( 'honor_contact_id' => $contact2['id'], ); @@ -898,9 +898,9 @@ class api_v3_ContributionTest extends CiviUnitTestCase { unset($this->_params['contribution_source_id'], $this->_params['payment_instrument_id']); $contribution = $this->callAPISuccess('contribution', 'create', $this->_params); $contribution = $this->callAPISuccess('contribution', 'getsingle', array( - 'id' => $contribution['id'], - 'api.contribution.delete' => 1, - )); + 'id' => $contribution['id'], + 'api.contribution.delete' => 1, + )); $this->assertEquals(1, $contribution['contribution_status_id']); $this->assertEquals('Check', $contribution['payment_instrument']); } @@ -1100,9 +1100,9 @@ class api_v3_ContributionTest extends CiviUnitTestCase { $contribution = $this->callAPISuccess('contribution', 'create', array_merge($this->_params, array('contribution_status_id' => 2))); $this->callAPISuccess('contribution', 'create', array('id' => $contribution['id'], 'source' => 'new source')); $contribution = $this->callAPISuccess('contribution', 'getsingle', array( - 'id' => $contribution['id'], - 'api.contribution.delete' => 1, - )); + 'id' => $contribution['id'], + 'api.contribution.delete' => 1, + )); $this->assertEquals(2, $contribution['contribution_status_id']); } //To Update Contribution @@ -1357,9 +1357,9 @@ class api_v3_ContributionTest extends CiviUnitTestCase { ) ); $participantStatus = $this->callAPISuccessGetValue('participant', array( - 'id' => $this->_ids['participant'], - 'return' => 'participant_status_id', - )); + 'id' => $this->_ids['participant'], + 'return' => 'participant_status_id', + )); $this->assertEquals(1, $participantStatus); $mut->checkMailLog(array( 'Annual CiviCRM meet', @@ -1602,9 +1602,9 @@ class api_v3_ContributionTest extends CiviUnitTestCase { $params = array_merge($this->_params, array('contribution_status_id' => 2, 'financial_type_id' => 'Event Fee')); $contribution = $this->callAPISuccess('contribution', 'create', $params); $this->callAPISuccess('participant_payment', 'create', array( - 'contribution_id' => $contribution['id'], - 'participant_id' => $participantID, - )); + 'contribution_id' => $contribution['id'], + 'participant_id' => $participantID, + )); $this->callAPISuccess('line_item', 'get', array( 'entity_id' => $contribution['id'], 'entity_table' => 'civicrm_contribution', diff --git a/tests/phpunit/api/v3/CustomFieldTest.php b/tests/phpunit/api/v3/CustomFieldTest.php index 6c5850fdd4..60b50f7d7a 100644 --- a/tests/phpunit/api/v3/CustomFieldTest.php +++ b/tests/phpunit/api/v3/CustomFieldTest.php @@ -46,7 +46,8 @@ class api_v3_CustomFieldTest extends CiviUnitTestCase { public function tearDown() { $tablesToTruncate = array( - 'civicrm_custom_group', 'civicrm_custom_field', + 'civicrm_custom_group', + 'civicrm_custom_field', ); // true tells quickCleanup to drop any tables that might have been created in the test $this->quickCleanup($tablesToTruncate, TRUE); @@ -101,9 +102,9 @@ class api_v3_CustomFieldTest extends CiviUnitTestCase { 'is_active' => 1, ); - $customField = $this->callAPIAndDocument('custom_field', 'create', $params, __FUNCTION__, __FILE__); + $customField = $this->callAPIAndDocument('custom_field', 'create', $params, __FUNCTION__, __FILE__); $params['id'] = $customField['id']; - $customField = $this->callAPISuccess('custom_field', 'create', $params); + $customField = $this->callAPISuccess('custom_field', 'create', $params); $this->assertNotNull($customField['id'], 'in line ' . __LINE__); } @@ -241,10 +242,12 @@ class api_v3_CustomFieldTest extends CiviUnitTestCase { $this->assertTrue(is_numeric($optionGroupID) && ($optionGroupID > 0)); $optionGroup = $this->callAPISuccess('option_group', 'getsingle', array( - 'id' => $optionGroupID)); + 'id' => $optionGroupID + )); $this->assertEquals($optionGroup['title'], 'Country'); $optionValueCount = $this->callAPISuccess('option_value', 'getcount', array( - 'option_group_id' => $optionGroupID)); + 'option_group_id' => $optionGroupID + )); $this->assertEquals(0, $optionValueCount); } @@ -301,7 +304,7 @@ class api_v3_CustomFieldTest extends CiviUnitTestCase { $customField = $this->customFieldCreate(array('custom_group_id' => $customGroup['id'])); $result = $this->callAPISuccess('custom_field', 'getsingle', array( - 'id' => $customField['id'], + 'id' => $customField['id'], 'return' => array('data_type'), )); $this->assertTrue(array_key_exists('data_type', $result)); @@ -316,7 +319,7 @@ class api_v3_CustomFieldTest extends CiviUnitTestCase { $customField = $this->customFieldCreate(array('custom_group_id' => $customGroup['id'])); $result = $this->callAPISuccess('custom_field', 'getsingle', array( - 'id' => $customField['id'], + 'id' => $customField['id'], 'return' => 'data_type, custom_group_id', )); $this->assertTrue(array_key_exists('data_type', $result)); @@ -329,7 +332,7 @@ class api_v3_CustomFieldTest extends CiviUnitTestCase { $option_values = array( array( - 'weight' => 1, + 'weight' => 1, 'label' => 'Label1', 'value' => 1, 'is_active' => 1, @@ -361,16 +364,16 @@ class api_v3_CustomFieldTest extends CiviUnitTestCase { $this->assertNotNull($customField['id']); $getFieldsParams = array( 'options' => array('get_options' => 'custom_' . $customField['id']), - 'action' => 'create', + 'action' => 'create', ); - $description = "Demonstrate retrieving metadata with custom field options"; + $description = "Demonstrate retrieving metadata with custom field options"; $subfile = "GetFieldsOptions"; $fields = $this->callAPIAndDocument('contact', 'getfields', $getFieldsParams, __FUNCTION__, 'ContactTest.php', $description, $subfile, 'GetFields'); $this->assertArrayHasKey('options', $fields['values']['custom_' . $customField['id']]); $this->assertEquals('Label1', $fields['values']['custom_' . $customField['id']]['options'][1]); $getOptionsArray = array( 'field' => 'custom_' . $customField['id'], - ); + ); $description = "Demonstrates retrieving options for a custom field"; $subfile = "GetOptions"; $result = $this->callAPIAndDocument('contact', 'getoptions', $getOptionsArray, __FUNCTION__, 'ContactTest.php', $description, '', 'getoptions'); @@ -446,11 +449,17 @@ class api_v3_CustomFieldTest extends CiviUnitTestCase { // Add some fields $contactGroup = $this->customGroupCreate(array('extends' => 'Contact', 'title' => 'test_group_c')); - $contactField = $this->customFieldCreate(array('custom_group_id' => $contactGroup['id'], 'label' => 'For Contacts')); + $contactField = $this->customFieldCreate(array( + 'custom_group_id' => $contactGroup['id'], + 'label' => 'For Contacts' + )); $indivGroup = $this->customGroupCreate(array('extends' => 'Individual', 'title' => 'test_group_i')); $indivField = $this->customFieldCreate(array('custom_group_id' => $indivGroup['id'], 'label' => 'For Individuals')); $activityGroup = $this->customGroupCreate(array('extends' => 'Activity', 'title' => 'test_group_a')); - $activityField = $this->customFieldCreate(array('custom_group_id' => $activityGroup['id'], 'label' => 'For Activities')); + $activityField = $this->customFieldCreate(array( + 'custom_group_id' => $activityGroup['id'], + 'label' => 'For Activities' + )); // Check getfields $this->assertEquals( @@ -488,7 +497,7 @@ class api_v3_CustomFieldTest extends CiviUnitTestCase { * @return array */ public function getCustomFieldKeys($getFieldsResult) { - $isCustom = function($key) { + $isCustom = function ($key) { return preg_match('/^custom_/', $key); }; $r = array_values(array_filter(array_keys($getFieldsResult['values']), $isCustom)); diff --git a/tests/phpunit/api/v3/CustomGroupTest.php b/tests/phpunit/api/v3/CustomGroupTest.php index 64c9c38e7d..a3c2587ae4 100644 --- a/tests/phpunit/api/v3/CustomGroupTest.php +++ b/tests/phpunit/api/v3/CustomGroupTest.php @@ -34,7 +34,6 @@ require_once 'CiviTest/CiviUnitTestCase.php'; * @package CiviCRM_APIv3 * @subpackage API_CustomGroup */ - class api_v3_CustomGroupTest extends CiviUnitTestCase { protected $_apiversion = 3; protected $_entity; @@ -43,8 +42,8 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase { public $DBResetRequired = TRUE; public function setUp() { - $this->_entity = 'CustomGroup'; - $this->_params = array( + $this->_entity = 'CustomGroup'; + $this->_params = array( 'title' => 'Test_Group_1', 'name' => 'test_group_1', 'extends' => 'Individual', @@ -195,7 +194,7 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase { ); $result = $this->callAPIFailure('custom_group', 'create', $params, - 'implode(): Invalid arguments passed'); + 'implode(): Invalid arguments passed'); } /** @@ -232,7 +231,7 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase { */ public function testCustomGroupCreateNoTitle() { $params = array( - 'extends' => array('Contact'), + 'extends' => array('Contact'), 'weight' => 5, 'collapse_display' => 1, 'style' => 'Tab', diff --git a/tests/phpunit/api/v3/CustomValueContactTypeTest.php b/tests/phpunit/api/v3/CustomValueContactTypeTest.php index 03aa27a234..6e284b1adf 100644 --- a/tests/phpunit/api/v3/CustomValueContactTypeTest.php +++ b/tests/phpunit/api/v3/CustomValueContactTypeTest.php @@ -33,7 +33,6 @@ require_once 'CiviTest/CiviUnitTestCase.php'; * @package CiviCRM_APIv3 * @subpackage API_Contact */ - class api_v3_CustomValueContactTypeTest extends CiviUnitTestCase { protected $_contactID; protected $_apiversion = 3; @@ -112,15 +111,22 @@ class api_v3_CustomValueContactTypeTest extends CiviUnitTestCase { $tablesToTruncate = array('civicrm_contact', 'civicrm_cache'); $this->quickCleanup($tablesToTruncate, TRUE); } + /* * Test that custom fields is returned for correct contact type only */ public function testGetFields() { $result = $this->callAPISuccess('Contact', 'getfields', array()); $this->assertArrayHasKey("custom_{$this->IndividualField['id']}", $result['values'], 'If This fails there is probably a caching issue - failure in line' . __LINE__ . print_r(array_keys($result['values']), TRUE)); - $result = $this->callAPISuccess('Contact', 'getfields', array('action' => 'create', 'contact_type' => 'Individual'), 'in line' . __LINE__); + $result = $this->callAPISuccess('Contact', 'getfields', array( + 'action' => 'create', + 'contact_type' => 'Individual' + ), 'in line' . __LINE__); $this->assertArrayHasKey("custom_{$this->IndividualField['id']}", $result['values']); - $result = $this->callAPISuccess('Contact', 'getfields', array('action' => 'create', 'contact_type' => 'Organization')); + $result = $this->callAPISuccess('Contact', 'getfields', array( + 'action' => 'create', + 'contact_type' => 'Organization' + )); $this->assertArrayNotHasKey("custom_{$this->IndividualField['id']}", $result['values'], 'in line' . __LINE__ . print_r(array_keys($result['values']), TRUE)); $result = $this->callAPISuccess('Relationship', 'getfields', array('action' => 'create'), 'in line' . __LINE__); $this->assertArrayNotHasKey("custom_{$this->IndividualField['id']}", $result['values']); @@ -135,7 +141,7 @@ class api_v3_CustomValueContactTypeTest extends CiviUnitTestCase { 'id' => $this->organization, 'contact_type' => 'Organization', "custom_{$this->IndividualField['id']}" => 'Test String', - 'debug' => 1, // so that undefined_fields is returned + 'debug' => 1, // so that undefined_fields is returned ); $contact = $this->callAPISuccess('contact', 'create', $params); @@ -149,7 +155,7 @@ class api_v3_CustomValueContactTypeTest extends CiviUnitTestCase { */ public function testAddCustomDataEmptyToIndividual() { $contact = $this->callAPIFailure('contact', 'create', array(), - 'Mandatory key(s) missing from params array: contact_type' + 'Mandatory key(s) missing from params array: contact_type' ); } @@ -198,7 +204,8 @@ class api_v3_CustomValueContactTypeTest extends CiviUnitTestCase { $params = array( 'contact_id' => $this->individualStudent, 'contact_type' => 'Individual', - "custom_{$this->IndiStudentField['id']}" => 'Test String',); + "custom_{$this->IndiStudentField['id']}" => 'Test String', + ); $result = $this->callAPISuccess('contact', 'create', $params); @@ -219,7 +226,7 @@ class api_v3_CustomValueContactTypeTest extends CiviUnitTestCase { 'contact_id' => $this->individualParent, 'contact_type' => 'Individual', "custom_{$this->IndiStudentField['id']}" => 'Test String', - 'debug' => 1, // so that undefined_fields is returned + 'debug' => 1, // so that undefined_fields is returned ); $contact = $this->callAPISuccess('contact', 'create', $params); $this->assertTrue(is_array($contact['undefined_fields']), __LINE__); @@ -238,7 +245,8 @@ class api_v3_CustomValueContactTypeTest extends CiviUnitTestCase { $params = array( 'contact_id' => $this->individual, 'contact_type' => 'Individual', - "custom_" . $this->IndividualField['id'] => 'Test String',); + "custom_" . $this->IndividualField['id'] => 'Test String', + ); $contact = $this->callAPISuccess('contact', 'create', $params); @@ -263,7 +271,8 @@ class api_v3_CustomValueContactTypeTest extends CiviUnitTestCase { 'contact_id' => $this->individualStudent, 'contact_type' => 'Individual', 'contact_sub_type' => 'Student', - "custom_{$this->IndiStudentField['id']}" => 'Test String',); + "custom_{$this->IndiStudentField['id']}" => 'Test String', + ); $contact = $this->callAPISuccess('contact', 'create', $params); $this->assertAPISuccess($contact); @@ -271,7 +280,7 @@ class api_v3_CustomValueContactTypeTest extends CiviUnitTestCase { 'contact_id' => $this->individualStudent, 'contact_type' => 'Individual', 'contact_sub_type' => 'Student', - "return.custom_{$this->IndiStudentField['id']}" => 1, + "return.custom_{$this->IndiStudentField['id']}" => 1, ); $getContact = $this->callAPISuccess('contact', 'get', $params); diff --git a/tests/phpunit/api/v3/CustomValueTest.php b/tests/phpunit/api/v3/CustomValueTest.php index df3a088cd6..420def5838 100644 --- a/tests/phpunit/api/v3/CustomValueTest.php +++ b/tests/phpunit/api/v3/CustomValueTest.php @@ -1,28 +1,28 @@ individual = $this->individualCreate(); - $this->params = array( + $this->individual = $this->individualCreate(); + $this->params = array( 'entity_id' => $this->individual, ); $this->ids['single'] = $this->entityCustomGroupWithSingleFieldCreate('mySingleField', 'Contacts'); - $this->ids['multi'] = $this->CustomGroupMultipleCreateWithFields(); + $this->ids['multi'] = $this->CustomGroupMultipleCreateWithFields(); $this->ids['multi2'] = $this->CustomGroupMultipleCreateWithFields(array('title' => 'group2')); } @@ -63,7 +63,8 @@ class api_v3_CustomValueTest extends CiviUnitTestCase { public function testCreateCustomValue() { $params = array( - 'custom_' . $this->ids['single']['custom_field_id'] => 'customString') + $this->params; + 'custom_' . $this->ids['single']['custom_field_id'] => 'customString' + ) + $this->params; $result = $this->callAPIAndDocument('custom_value', 'create', $params, __FUNCTION__, __FILE__); $this->assertEquals(1, $result['count'], 'In line ' . __LINE__); @@ -94,9 +95,9 @@ class api_v3_CustomValueTest extends CiviUnitTestCase { $createParams = array( 'contact_type' => 'Individual', 'id' => $contact_id, - 'custom_' . $firstCustomField => "value 3", - 'custom_' . $secondCustomField => "coffee", - 'custom_' . $thirdCustomField => "value 4", + 'custom_' . $firstCustomField => "value 3", + 'custom_' . $secondCustomField => "coffee", + 'custom_' . $thirdCustomField => "value 4", ); $result = $this->callAPISuccess('Contact', 'create', $createParams); @@ -143,8 +144,8 @@ class api_v3_CustomValueTest extends CiviUnitTestCase { $createParams = array( 'contact_type' => 'Individual', 'id' => $contact_id, - 'custom_' . $firstCustomField . '-1' => "second multi value 2", - 'custom_' . $firstCustomField . '-2' => "second multi value 3", + 'custom_' . $firstCustomField . '-1' => "second multi value 2", + 'custom_' . $firstCustomField . '-2' => "second multi value 3", ); $result = $this->callAPISuccess('Contact', 'create', $createParams); diff --git a/tests/phpunit/api/v3/DashboardContactTest.php b/tests/phpunit/api/v3/DashboardContactTest.php index 9dddfb00bc..a599b19012 100644 --- a/tests/phpunit/api/v3/DashboardContactTest.php +++ b/tests/phpunit/api/v3/DashboardContactTest.php @@ -30,7 +30,6 @@ require_once 'CiviTest/CiviUnitTestCase.php'; * @package CiviCRM_APIv3 * @subpackage API_ActionSchedule */ - class api_v3_DashboardContactTest extends CiviUnitTestCase { protected $_params; protected $_params2; diff --git a/tests/phpunit/api/v3/DashboardTest.php b/tests/phpunit/api/v3/DashboardTest.php index b874f194a9..68a3a61781 100644 --- a/tests/phpunit/api/v3/DashboardTest.php +++ b/tests/phpunit/api/v3/DashboardTest.php @@ -30,7 +30,6 @@ require_once 'CiviTest/CiviUnitTestCase.php'; * @package CiviCRM_APIv3 * @subpackage API_ActionSchedule */ - class api_v3_DashboardTest extends CiviUnitTestCase { protected $_params; protected $_params2; diff --git a/tests/phpunit/api/v3/EntityTagTest.php b/tests/phpunit/api/v3/EntityTagTest.php index 7725117e08..a6938f3432 100644 --- a/tests/phpunit/api/v3/EntityTagTest.php +++ b/tests/phpunit/api/v3/EntityTagTest.php @@ -31,8 +31,8 @@ require_once 'CiviTest/CiviUnitTestCase.php'; /** * Test APIv3 civicrm_entity_tag_* functions * - * @package CiviCRM_APIv3 - * @subpackage API_Core + * @package CiviCRM_APIv3 + * @subpackage API_Core */ require_once 'CiviTest/CiviUnitTestCase.php'; @@ -96,10 +96,10 @@ class api_v3_EntityTagTest extends CiviUnitTestCase { } public function testAddDouble() { - $individualId = $this->_individualID; + $individualId = $this->_individualID; $organizationId = $this->_organizationID; - $tagID = $this->_tagID; - $params = array( + $tagID = $this->_tagID; + $params = array( 'contact_id' => $individualId, 'tag_id' => $tagID, ); @@ -122,8 +122,8 @@ class api_v3_EntityTagTest extends CiviUnitTestCase { ///////////////// civicrm_entity_tag_get methods public function testGetNoEntityID() { $ContactId = $this->_individualID; - $tagID = $this->_tagID; - $params = array( + $tagID = $this->_tagID; + $params = array( 'contact_id' => $ContactId, 'tag_id' => $tagID, ); @@ -136,8 +136,8 @@ class api_v3_EntityTagTest extends CiviUnitTestCase { public function testIndividualEntityTagGet() { $contactId = $this->_individualID; - $tagID = $this->_tagID; - $params = array( + $tagID = $this->_tagID; + $params = array( 'contact_id' => $contactId, 'tag_id' => $tagID, ); @@ -153,8 +153,8 @@ class api_v3_EntityTagTest extends CiviUnitTestCase { public function testHouseholdEntityGet() { $ContactId = $this->_householdID; - $tagID = $this->_tagID; - $params = array( + $tagID = $this->_tagID; + $params = array( 'contact_id' => $ContactId, 'tag_id' => $tagID, ); @@ -165,8 +165,8 @@ class api_v3_EntityTagTest extends CiviUnitTestCase { public function testOrganizationEntityGet() { $ContactId = $this->_organizationID; - $tagID = $this->_tagID; - $params = array( + $tagID = $this->_tagID; + $params = array( 'contact_id' => $ContactId, 'tag_id' => $tagID, ); diff --git a/tests/phpunit/api/v3/EventTest.php b/tests/phpunit/api/v3/EventTest.php index 038b1ee13a..6e15818589 100644 --- a/tests/phpunit/api/v3/EventTest.php +++ b/tests/phpunit/api/v3/EventTest.php @@ -40,8 +40,8 @@ class api_v3_EventTest extends CiviUnitTestCase { public function setUp() { parent::setUp(); $this->_apiversion = 3; - $this->_entity = 'event'; - $this->_params = array( + $this->_entity = 'event'; + $this->_params = array( array( 'title' => 'Annual CiviCRM meet', 'summary' => 'If you have any CiviCRM realted issues or want to track where CiviCRM is heading, Sign up now', @@ -82,18 +82,20 @@ class api_v3_EventTest extends CiviUnitTestCase { array( 'title' => 'Annual CiviCRM meet', 'event_type_id' => 1, - 'start_date' => 20081021,), + 'start_date' => 20081021, + ), array( 'title' => 'Annual CiviCRM meet 2', 'event_type_id' => 1, - 'start_date' => 20101021,), + 'start_date' => 20101021, + ), ); $this->events = array(); $this->eventIds = array(); foreach ($params as $event) { - $result = $this->callAPISuccess('Event', 'Create', $event); - $this->_events[] = $result; + $result = $this->callAPISuccess('Event', 'Create', $event); + $this->_events[] = $result; $this->_eventIds[] = $result['id']; } } @@ -113,7 +115,8 @@ class api_v3_EventTest extends CiviUnitTestCase { public function testGetEventById() { $params = array( - 'id' => $this->_events[1]['id'],); + 'id' => $this->_events[1]['id'], + ); $result = $this->callAPISuccess('event', 'get', $params); $this->assertEquals($result['values'][$this->_eventIds[1]]['event_title'], 'Annual CiviCRM meet 2'); } @@ -132,21 +135,25 @@ class api_v3_EventTest extends CiviUnitTestCase { public function testGetEventByWrongTitle() { $params = array( - 'title' => 'No event with that title',); + 'title' => 'No event with that title', + ); $result = $this->callAPISuccess('Event', 'Get', $params); $this->assertEquals(0, $result['count']); } + public function testGetEventByIdSort() { $params = array( 'return.sort' => 'id ASC', - 'return.max_results' => 1,); + 'return.max_results' => 1, + ); $result = $this->callAPISuccess('Event', 'Get', $params); $this->assertEquals(1, $result['id'], ' in line ' . __LINE__); $params = array( 'options' => array( 'sort' => 'id DESC', 'limit' => 1, - ),); + ), + ); $result = $this->callAPISuccess('Event', 'Get', $params); $this->assertAPISuccess($result, ' in line ' . __LINE__); @@ -155,7 +162,8 @@ class api_v3_EventTest extends CiviUnitTestCase { 'options' => array( 'sort' => 'id ASC', 'limit' => 1, - ),); + ), + ); $result = $this->callAPISuccess('Event', 'Get', $params); $this->assertEquals(1, $result['id'], ' in line ' . __LINE__); @@ -184,14 +192,14 @@ class api_v3_EventTest extends CiviUnitTestCase { 'isCurrent' => 1, ); $currentEventParams = array( - 'start_date' => date('Y-m-d', strtotime('+ 1 day')), + 'start_date' => date('Y-m-d', strtotime('+ 1 day')), 'end_date' => date('Y-m-d', strtotime('+ 1 week')), ); $currentEventParams = array_merge($this->_params[1], $currentEventParams); - $currentEvent = $this->callAPISuccess('Event', 'Create', $currentEventParams); - $description = "demonstrates use of is.Current option"; - $subfile = "IsCurrentOption"; - $result = $this->callAPIAndDocument('Event', 'Get', $params, __FUNCTION__, __FILE__, $description, $subfile); + $currentEvent = $this->callAPISuccess('Event', 'Create', $currentEventParams); + $description = "demonstrates use of is.Current option"; + $subfile = "IsCurrentOption"; + $result = $this->callAPIAndDocument('Event', 'Get', $params, __FUNCTION__, __FILE__, $description, $subfile); $allEvents = $this->callAPISuccess('Event', 'Get', array()); $this->callAPISuccess('Event', 'Delete', array('id' => $currentEvent['id'])); $this->assertEquals(1, $result['count'], 'confirm only one event found in line ' . __LINE__); @@ -227,27 +235,33 @@ class api_v3_EventTest extends CiviUnitTestCase { $contactID = $this->individualCreate(); $params = array( 'id' => $this->_eventIds[0], - 'max_participants' => 1, + 'max_participants' => 1, ); $result = $this->callAPISuccess('Event', 'Create', $params); $getEventParams = array( 'id' => $this->_eventIds[0], - 'return.is_full' => 1, + 'return.is_full' => 1, ); $currentEvent = $this->callAPISuccess('Event', 'getsingle', $getEventParams); - $description = "demonstrates use of return is_full "; - $subfile = "IsFullOption"; + $description = "demonstrates use of return is_full "; + $subfile = "IsFullOption"; $this->assertEquals(0, $currentEvent['is_full'], ' is full is set in line ' . __LINE__); $this->assertEquals(1, $currentEvent['available_places'], 'available places is set in line ' . __LINE__); - $participant = $this->callAPISuccess('Participant', 'create', array('participant_status' => 1, 'role_id' => 1, 'contact_id' => $contactID, 'event_id' => $this->_eventIds[0])); + $participant = $this->callAPISuccess('Participant', 'create', array( + 'participant_status' => 1, + 'role_id' => 1, + 'contact_id' => $contactID, + 'event_id' => $this->_eventIds[0] + )); $currentEvent = $this->callAPIAndDocument('Event', 'getsingle', $getEventParams, __FUNCTION__, __FILE__, $description, $subfile, 'getsingle'); $this->assertEquals(1, $currentEvent['is_full'], ' is full is set in line ' . __LINE__); $this->assertEquals(0, $currentEvent['available_places'], 'available places is set in line ' . __LINE__); $this->contactDelete($contactID); } + /* * Legacy support for Contribution Type ID. We need to ensure this is supported * as an alias for financial_type_id @@ -280,7 +294,10 @@ class api_v3_EventTest extends CiviUnitTestCase { $result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__); - $check = $this->callAPISuccess($this->_entity, 'get', array('return.custom_' . $ids['custom_field_id'] => 1, 'id' => $result['id'])); + $check = $this->callAPISuccess($this->_entity, 'get', array( + 'return.custom_' . $ids['custom_field_id'] => 1, + 'id' => $result['id'] + )); $this->assertEquals("custom string", $check['values'][$check['id']]['custom_' . $ids['custom_field_id']], ' in line ' . __LINE__); $this->customFieldDelete($ids['custom_field_id']); @@ -362,7 +379,7 @@ class api_v3_EventTest extends CiviUnitTestCase { $params = array( 'id' => $result['id'], - 'max_participants' => 150, + 'max_participants' => 150, ); $this->callAPISuccess('Event', 'Create', $params); $updated = $this->callAPISuccess('Event', 'Get', $params, __FUNCTION__, __FILE__); @@ -388,7 +405,8 @@ class api_v3_EventTest extends CiviUnitTestCase { */ public function testDeleteWithEventId() { $params = array( - 'event_id' => $this->_eventIds[0],); + 'event_id' => $this->_eventIds[0], + ); $result = $this->callAPISuccess('Event', 'Delete', $params); $this->assertAPISuccess($result, 'in line ' . __LINE__); } @@ -431,7 +449,8 @@ class api_v3_EventTest extends CiviUnitTestCase { public function testSearchEmptyParams() { $event = $this->callAPISuccess('event', 'create', $this->_params[1]); - $getparams = array( 'sequential' => 1, + $getparams = array( + 'sequential' => 1, ); $result = $this->callAPISuccess('event', 'get', $getparams); $this->assertEquals($result['count'], 3, 'In line ' . __LINE__); @@ -448,7 +467,8 @@ class api_v3_EventTest extends CiviUnitTestCase { 'event_type_id' => 1, 'return.title' => 1, 'return.id' => 1, - 'return.start_date' => 1,); + 'return.start_date' => 1, + ); $result = $this->callAPISuccess('event', 'get', $params); $this->assertEquals($result['values'][$this->_eventIds[0]]['id'], $this->_eventIds[0], 'In line ' . __LINE__); @@ -464,7 +484,7 @@ class api_v3_EventTest extends CiviUnitTestCase { $events = array(); while ($maxEvents > 0) { $params = array( - 'title' => 'Test Event' . $maxEvents, + 'title' => 'Test Event' . $maxEvents, 'event_type_id' => 2, 'start_date' => 20081021, ); @@ -473,7 +493,7 @@ class api_v3_EventTest extends CiviUnitTestCase { $maxEvents--; } $params = array( - 'event_type_id' => 2, + 'event_type_id' => 2, 'return.id' => 1, 'return.title' => 1, 'return.offset' => 2, @@ -487,9 +507,10 @@ class api_v3_EventTest extends CiviUnitTestCase { public function testEventCreationPermissions() { $params = array( 'event_type_id' => 1, - 'start_date' => '2010-10-03', - 'title' => 'le cake is a tie', - 'check_permissions' => TRUE,); + 'start_date' => '2010-10-03', + 'title' => 'le cake is a tie', + 'check_permissions' => TRUE, + ); $config = &CRM_Core_Config::singleton(); $config->userPermissionClass->permissions = array('access CiviCRM'); $result = $this->callAPIFailure('event', 'create', $params); @@ -515,12 +536,14 @@ class api_v3_EventTest extends CiviUnitTestCase { $result = $this->callAPISuccess('event', 'getfields', $params); $this->assertEquals(1, $result['values']['title']['api.required'], 'in line ' . __LINE__); } + public function testgetfieldsGet() { $description = "demonstrate use of getfields to interrogate api"; $params = array('action' => 'get'); $result = $this->callAPISuccess('event', 'getfields', $params); $this->assertEquals('title', $result['values']['event_title']['name'], 'in line ' . __LINE__); } + public function testgetfieldsDelete() { $description = "demonstrate use of getfields to interrogate api"; $params = array('action' => 'delete'); diff --git a/tests/phpunit/api/v3/GrantTest.php b/tests/phpunit/api/v3/GrantTest.php index b63f4367a3..de1e20dee8 100644 --- a/tests/phpunit/api/v3/GrantTest.php +++ b/tests/phpunit/api/v3/GrantTest.php @@ -34,7 +34,6 @@ require_once 'CiviTest/CiviUnitTestCase.php'; * @package CiviCRM_APIv3 * @subpackage API_Grant */ - class api_v3_GrantTest extends CiviUnitTestCase { protected $_apiversion = 3; protected $params; @@ -47,7 +46,7 @@ class api_v3_GrantTest extends CiviUnitTestCase { parent::setUp(); $this->ids['contact'][0] = $this->individualCreate(); $this->params = array( - 'contact_id' => $this->ids['contact'][0], + 'contact_id' => $this->ids['contact'][0], 'application_received_date' => 'now', 'decision_date' => 'next Monday', 'amount_total' => '500', @@ -91,9 +90,10 @@ class api_v3_GrantTest extends CiviUnitTestCase { array('label' => 'my goat', 'value' => 'goat', 'is_active' => TRUE, 'weight' => 2), array('label' => 'mohair', 'value' => 'wool', 'is_active' => TRUE, 'weight' => 3), array('label' => 'hungry', 'value' => '', 'is_active' => TRUE, 'weight' => 3), - ))); + ) + )); $columnName = $result['values'][$result['id']]['column_name']; - $ids['custom_field_id'] = $result['id']; + $ids['custom_field_id'] = $result['id']; $customFieldLabel = 'custom_' . $ids['custom_field_id']; $expectedValue = CRM_Core_DAO::VALUE_SEPARATOR . 'valley' . CRM_Core_DAO::VALUE_SEPARATOR; //first we pass in the core separators ourselves @@ -156,6 +156,7 @@ class api_v3_GrantTest extends CiviUnitTestCase { $checkDeleted = $this->callAPISuccess($this->_entity, 'get', array()); $this->assertEquals(0, $checkDeleted['count'], 'In line ' . __LINE__); } + /* * This is a test to check if setting fields one at a time alters other fields * Issues Hit so far = @@ -166,9 +167,9 @@ class api_v3_GrantTest extends CiviUnitTestCase { public function testCreateAutoGrant() { $entityName = $this->_entity; - $baoString = 'CRM_Grant_BAO_Grant'; - $fields = $this->callAPISuccess($entityName, 'getfields', array( - 'action' => 'create', + $baoString = 'CRM_Grant_BAO_Grant'; + $fields = $this->callAPISuccess($entityName, 'getfields', array( + 'action' => 'create', ) ); @@ -177,9 +178,9 @@ class api_v3_GrantTest extends CiviUnitTestCase { $baoObj = new CRM_Core_DAO(); $baoObj->createTestObject($baoString, array('currency' => 'USD'), 2, 0); $getentities = $this->callAPISuccess($entityName, 'get', array( - 'sequential' => 1, - 'return' => $return, - )); + 'sequential' => 1, + 'return' => $return, + )); // lets use first rather than assume only one exists $entity = $getentities['values'][0]; @@ -225,8 +226,8 @@ class api_v3_GrantTest extends CiviUnitTestCase { $entity[$field] = 'warm.beer.com'; } $updateParams = array( - 'id' => $entity['id'], - $field => $entity[$field], + 'id' => $entity['id'], + $field => $entity[$field], 'debug' => 1, ); $update = $this->callAPISuccess($entityName, 'create', $updateParams); diff --git a/tests/phpunit/api/v3/GroupContactTest.php b/tests/phpunit/api/v3/GroupContactTest.php index ad4f856379..ff8f7b84cd 100644 --- a/tests/phpunit/api/v3/GroupContactTest.php +++ b/tests/phpunit/api/v3/GroupContactTest.php @@ -71,7 +71,7 @@ class api_v3_GroupContactTest extends CiviUnitTestCase { $this->_group = array( $this->_groupId1 => array( - 'title' => 'New Test Group Created', + 'title' => 'New Test Group Created', 'visibility' => 'Public Pages', 'in_method' => 'API', ), @@ -98,8 +98,8 @@ class api_v3_GroupContactTest extends CiviUnitTestCase { public function testGetGroupID() { $description = "Get all from group and display contacts"; - $subfile = "GetWithGroupID"; - $params = array( + $subfile = "GetWithGroupID"; + $params = array( 'group_id' => $this->_groupId1, 'api.group.get' => 1, 'sequential' => 1, @@ -122,7 +122,8 @@ class api_v3_GroupContactTest extends CiviUnitTestCase { public function testCreateWithoutGroupIdParams() { $params = array( - 'contact_id' => $this->_contactId,); + 'contact_id' => $this->_contactId, + ); $groups = $this->callAPIFailure('group_contact', 'create', $params); $this->assertEquals($groups['error_message'], 'Mandatory key(s) missing from params array: group_id'); @@ -130,7 +131,8 @@ class api_v3_GroupContactTest extends CiviUnitTestCase { public function testCreateWithoutContactIdParams() { $params = array( - 'group_id' => $this->_groupId1,); + 'group_id' => $this->_groupId1, + ); $groups = $this->callAPIFailure('group_contact', 'create', $params); $this->assertEquals($groups['error_message'], 'Mandatory key(s) missing from params array: contact_id'); } @@ -143,7 +145,8 @@ class api_v3_GroupContactTest extends CiviUnitTestCase { 'prefix_id' => 3, 'suffix_id' => 3, 'email' => 'amiteshwar.prasad@civicrm.org', - 'contact_type' => 'Individual',); + 'contact_type' => 'Individual', + ); $this->_contactId1 = $this->individualCreate($cont); $params = array( diff --git a/tests/phpunit/api/v3/GroupNestingTest.php b/tests/phpunit/api/v3/GroupNestingTest.php index c5037b8ca2..dbc7b69efe 100644 --- a/tests/phpunit/api/v3/GroupNestingTest.php +++ b/tests/phpunit/api/v3/GroupNestingTest.php @@ -105,10 +105,11 @@ class api_v3_GroupNestingTest extends CiviUnitTestCase { // expected data loaded in setUp $expected = array( 1 => array( - 'id' => 1, + 'id' => 1, 'child_group_id' => 2, 'parent_group_id' => 1, - )); + ) + ); $this->assertEquals($expected, $result['values']); } @@ -119,14 +120,15 @@ class api_v3_GroupNestingTest extends CiviUnitTestCase { */ public function testGetWithChildGroupId() { $params = array( - 'child_group_id' => 4,); + 'child_group_id' => 4, + ); $result = $this->callAPISuccess('group_nesting', 'get', $params); // expected data loaded in setUp $expected = array( 3 => array( - 'id' => 3, + 'id' => 3, 'child_group_id' => 4, 'parent_group_id' => 1, ), @@ -146,14 +148,15 @@ class api_v3_GroupNestingTest extends CiviUnitTestCase { */ public function testGetWithParentGroupId() { $params = array( - 'parent_group_id' => 1,); + 'parent_group_id' => 1, + ); $result = $this->callAPISuccess('group_nesting', 'get', $params); // expected data loaded in setUp $expected = array( 1 => array( - 'id' => 1, + 'id' => 1, 'child_group_id' => 2, 'parent_group_id' => 1, ), @@ -222,7 +225,8 @@ class api_v3_GroupNestingTest extends CiviUnitTestCase { // groups id=1 and id=2 loaded in setUp $getparams = array( 'parent_group_id' => 1, - 'child_group_id' => 2,); + 'child_group_id' => 2, + ); $result = $this->callAPISuccess('group_nesting', 'get', $getparams); $params = array('id' => $result['id']); diff --git a/tests/phpunit/api/v3/GroupOrganizationTest.php b/tests/phpunit/api/v3/GroupOrganizationTest.php index a8f52b5490..00b5b023f5 100644 --- a/tests/phpunit/api/v3/GroupOrganizationTest.php +++ b/tests/phpunit/api/v3/GroupOrganizationTest.php @@ -58,7 +58,8 @@ class api_v3_GroupOrganizationTest extends CiviUnitTestCase { $params = array( 'organization_id' => $this->_orgID, - 'group_id' => $this->_groupID,); + 'group_id' => $this->_groupID, + ); $result = $this->callAPISuccess('group_organization', 'create', $params); $paramsGet = array( 'organization_id' => $result['id'], @@ -108,7 +109,8 @@ class api_v3_GroupOrganizationTest extends CiviUnitTestCase { */ public function testGroupOrganizationGetWithInvalidKeys() { $params = array( - 'invalid_key' => 1,); + 'invalid_key' => 1, + ); $result = $this->callAPISuccess('group_organization', 'get', $params); $this->assertAPISuccess($result); @@ -122,7 +124,8 @@ class api_v3_GroupOrganizationTest extends CiviUnitTestCase { public function testGroupOrganizationCreate() { $params = array( 'organization_id' => $this->_orgID, - 'group_id' => $this->_groupID,); + 'group_id' => $this->_groupID, + ); $result = $this->callAPIAndDocument('group_organization', 'create', $params, __FUNCTION__, __FILE__); } @@ -131,12 +134,14 @@ class api_v3_GroupOrganizationTest extends CiviUnitTestCase { */ public function testGroupOrganizationCreateTwice() { $params = array( - 'organization_id' => $this->_orgID, - 'group_id' => $this->_groupID,); + 'organization_id' => $this->_orgID, + 'group_id' => $this->_groupID, + ); $result = $this->callAPISuccess('group_organization', 'create', $params); $result2 = $this->callAPISuccess('group_organization', 'create', $params); $this->assertEquals($result['values'], $result2['values']); } + /** * Check with empty params array */ @@ -160,7 +165,8 @@ class api_v3_GroupOrganizationTest extends CiviUnitTestCase { */ public function testGroupOrganizationCreateWithInvalidKeys() { $params = array( - 'invalid_key' => 1,); + 'invalid_key' => 1, + ); $result = $this->callAPIFailure('group_organization', 'create', $params); $this->assertEquals($result['error_message'], 'Mandatory key(s) missing from params array: group_id, organization_id'); } @@ -191,7 +197,8 @@ class api_v3_GroupOrganizationTest extends CiviUnitTestCase { public function testGroupOrganizationDelete() { $paramsC = array( 'organization_id' => $this->_orgID, - 'group_id' => $this->_groupID,); + 'group_id' => $this->_groupID, + ); $result = $this->callAPISuccess('group_organization', 'create', $paramsC); $params = array( @@ -205,7 +212,8 @@ class api_v3_GroupOrganizationTest extends CiviUnitTestCase { */ public function testGroupOrganizationDeleteWithInvalidKey() { $paramsDelete = array( - 'invalid_key' => 1,); + 'invalid_key' => 1, + ); $result = $this->callAPIFailure('group_organization', 'delete', $paramsDelete); $this->assertEquals($result['error_message'], 'Mandatory key(s) missing from params array: id'); } diff --git a/tests/phpunit/api/v3/GroupTest.php b/tests/phpunit/api/v3/GroupTest.php index 5e5188fc09..0f2f859a9b 100644 --- a/tests/phpunit/api/v3/GroupTest.php +++ b/tests/phpunit/api/v3/GroupTest.php @@ -32,7 +32,6 @@ require_once 'CiviTest/CiviUnitTestCase.php'; * * @package CiviCRM_APIv3 */ - class api_v3_GroupTest extends CiviUnitTestCase { protected $_apiversion; protected $_groupID; diff --git a/tests/phpunit/api/v3/ImTest.php b/tests/phpunit/api/v3/ImTest.php index 0e8152650a..f36ca49a78 100644 --- a/tests/phpunit/api/v3/ImTest.php +++ b/tests/phpunit/api/v3/ImTest.php @@ -34,7 +34,6 @@ require_once 'CiviTest/CiviUnitTestCase.php'; * @package CiviCRM_APIv3 * @subpackage API_Contact */ - class api_v3_ImTest extends CiviUnitTestCase { protected $_apiversion = 3; protected $params; @@ -47,9 +46,9 @@ class api_v3_ImTest extends CiviUnitTestCase { parent::setUp(); $this->useTransaction(TRUE); - $this->_entity = 'im'; - $this->_contactID = $this->organizationCreate(); - $this->params = array( + $this->_entity = 'im'; + $this->_contactID = $this->organizationCreate(); + $this->params = array( 'contact_id' => $this->_contactID, 'name' => 'My Yahoo IM Handle', 'location_type_id' => 1, @@ -79,6 +78,7 @@ class api_v3_ImTest extends CiviUnitTestCase { $checkDeleted = $this->callAPISuccess($this->_entity, 'get', array()); $this->assertEquals(0, $checkDeleted['count'], 'In line ' . __LINE__); } + public function testDeleteImInvalid() { $result = $this->callAPISuccess($this->_entity, 'create', $this->params); $deleteParams = array('id' => 600); diff --git a/tests/phpunit/api/v3/JobProcessMailingTest.php b/tests/phpunit/api/v3/JobProcessMailingTest.php index 4abb71115b..0db4658de9 100644 --- a/tests/phpunit/api/v3/JobProcessMailingTest.php +++ b/tests/phpunit/api/v3/JobProcessMailingTest.php @@ -38,6 +38,7 @@ require_once 'CiviTest/CiviUnitTestCase.php'; //@todo - why doesn't class loader find these (I tried renaming) require_once 'CiviTest/CiviMailUtils.php'; + /** * Class api_v3_JobTest */ @@ -101,7 +102,11 @@ class api_v3_JobProcessMailingTest extends CiviUnitTestCase { public function createContactsInGroup($count, $groupID) { for ($i = 1; $i <= $count; $i++) { $contactID = $this->individualCreate(array('first_name' => $count, 'email' => 'mail' . $i . '@nul.com')); - $this->callAPISuccess('group_contact', 'create', array('contact_id' => $contactID, 'group_id' => $groupID, 'status' => 'Added')); + $this->callAPISuccess('group_contact', 'create', array( + 'contact_id' => $contactID, + 'group_id' => $groupID, + 'status' => 'Added' + )); } } diff --git a/tests/phpunit/api/v3/JobTest.php b/tests/phpunit/api/v3/JobTest.php index dd9ad92e7e..eb40d6b42b 100644 --- a/tests/phpunit/api/v3/JobTest.php +++ b/tests/phpunit/api/v3/JobTest.php @@ -169,9 +169,9 @@ class api_v3_JobTest extends CiviUnitTestCase { */ public function testCallUpdateGreetingSuccess() { $result = $this->callAPISuccess($this->_entity, 'update_greeting', array( - 'gt' => 'postal_greeting', - 'ct' => 'Individual', - )); + 'gt' => 'postal_greeting', + 'ct' => 'Individual', + )); } public function testCallUpdateGreetingCommaSeparatedParamsSuccess() { @@ -209,10 +209,10 @@ class api_v3_JobTest extends CiviUnitTestCase { 'limit_to' => FALSE, )); $this->callAPISuccess('group_contact', 'create', array( - 'contact_id' => $contactID, - 'status' => 'Added', - 'group_id' => $groupID, - )); + 'contact_id' => $contactID, + 'status' => 'Added', + 'group_id' => $groupID, + )); } $result = $this->callAPISuccess('job', 'send_reminder', array()); $successfulCronCount = CRM_Core_DAO::singleValueQuery("SELECT count(*) FROM civicrm_action_log"); @@ -236,10 +236,10 @@ class api_v3_JobTest extends CiviUnitTestCase { } if ($i < 3) { $this->callAPISuccess('group_contact', 'create', array( - 'contact_id' => $contactID, - 'status' => 'Added', - 'group_id' => $groupID, - )); + 'contact_id' => $contactID, + 'status' => 'Added', + 'group_id' => $groupID, + )); } if ($i > 1) { $this->callAPISuccess('membership', 'create', array( @@ -274,9 +274,9 @@ class api_v3_JobTest extends CiviUnitTestCase { $orgID = $this->organizationCreate(); CRM_Utils_Hook_UnitTests::singleton()->setHook('civicrm_pre', array($this, 'hookPreRelationship')); $relationshipTypeID = $this->callAPISuccess('relationship_type', 'getvalue', array( - 'return' => 'id', - 'name_a_b' => 'Employee of', - )); + 'return' => 'id', + 'name_a_b' => 'Employee of', + )); $result = $this->callAPISuccess('relationship', 'create', array( 'relationship_type_id' => $relationshipTypeID, 'contact_id_a' => $individualID, diff --git a/tests/phpunit/api/v3/MailSettingsTest.php b/tests/phpunit/api/v3/MailSettingsTest.php index 2e71a931a9..e9055bcc32 100644 --- a/tests/phpunit/api/v3/MailSettingsTest.php +++ b/tests/phpunit/api/v3/MailSettingsTest.php @@ -102,8 +102,8 @@ class api_v3_MailSettingsTest extends CiviUnitTestCase { */ public function testGetMailSettingsChainDelete() { $description = "demonstrates get + delete in the same call"; - $subFile = 'ChainedGetDelete'; - $params = array( + $subFile = 'ChainedGetDelete'; + $params = array( 'title' => "MailSettings title", 'api.MailSettings.delete' => 1, ); diff --git a/tests/phpunit/api/v3/MailingABTest.php b/tests/phpunit/api/v3/MailingABTest.php index 43bf621741..45353cf791 100755 --- a/tests/phpunit/api/v3/MailingABTest.php +++ b/tests/phpunit/api/v3/MailingABTest.php @@ -169,22 +169,22 @@ class api_v3_MailingABTest extends CiviUnitTestCase { protected function assertJobCounts($expectedA, $expectedB, $expectedC) { $this->assertDBQuery($expectedA, 'SELECT count(*) FROM civicrm_mailing_job WHERE mailing_id = %1', array( - 1 => array( - $this->_mailingID_A, - 'Integer', - ), - )); + 1 => array( + $this->_mailingID_A, + 'Integer', + ), + )); $this->assertDBQuery($expectedB, 'SELECT count(*) FROM civicrm_mailing_job WHERE mailing_id = %1', array( - 1 => array( - $this->_mailingID_B, - 'Integer', - ), - )); + 1 => array( + $this->_mailingID_B, + 'Integer', + ), + )); $this->assertDBQuery($expectedC, 'SELECT count(*) FROM civicrm_mailing_job WHERE mailing_id = %1', array( - 1 => array( - $this->_mailingID_C, - 'Integer', - ), - )); + 1 => array( + $this->_mailingID_C, + 'Integer', + ), + )); } } diff --git a/tests/phpunit/api/v3/MailingTest.php b/tests/phpunit/api/v3/MailingTest.php index c185da7571..9a2b682c9f 100755 --- a/tests/phpunit/api/v3/MailingTest.php +++ b/tests/phpunit/api/v3/MailingTest.php @@ -79,10 +79,24 @@ class api_v3_MailingTest extends CiviUnitTestCase { // BEGIN SAMPLE DATA $groupIDs['a'] = $this->groupCreate(array('name' => 'Example include group', 'title' => 'Example include group')); $groupIDs['b'] = $this->groupCreate(array('name' => 'Example exclude group', 'title' => 'Example exclude group')); - $contactIDs['a'] = $this->individualCreate(array('email' => 'include.me@example.org', 'first_name' => 'Includer', 'last_name' => 'Person')); - $contactIDs['b'] = $this->individualCreate(array('email' => 'exclude.me@example.org', 'last_name' => 'Excluder', 'last_name' => 'Excluder')); - $this->callAPISuccess('GroupContact', 'create', array('group_id' => $groupIDs['a'], 'contact_id' => $contactIDs['a'])); - $this->callAPISuccess('GroupContact', 'create', array('group_id' => $groupIDs['b'], 'contact_id' => $contactIDs['b'])); + $contactIDs['a'] = $this->individualCreate(array( + 'email' => 'include.me@example.org', + 'first_name' => 'Includer', + 'last_name' => 'Person' + )); + $contactIDs['b'] = $this->individualCreate(array( + 'email' => 'exclude.me@example.org', + 'last_name' => 'Excluder', + 'last_name' => 'Excluder' + )); + $this->callAPISuccess('GroupContact', 'create', array( + 'group_id' => $groupIDs['a'], + 'contact_id' => $contactIDs['a'] + )); + $this->callAPISuccess('GroupContact', 'create', array( + 'group_id' => $groupIDs['b'], + 'contact_id' => $contactIDs['b'] + )); // END SAMPLE DATA // ** Pass 1: Create @@ -163,11 +177,28 @@ class api_v3_MailingTest extends CiviUnitTestCase { // BEGIN SAMPLE DATA $groupIDs['inc'] = $this->groupCreate(array('name' => 'Example include group', 'title' => 'Example include group')); $groupIDs['exc'] = $this->groupCreate(array('name' => 'Example exclude group', 'title' => 'Example exclude group')); - $contactIDs['includeme'] = $this->individualCreate(array('email' => 'include.me@example.org', 'first_name' => 'Includer', 'last_name' => 'Person')); - $contactIDs['excludeme'] = $this->individualCreate(array('email' => 'exclude.me@example.org', 'last_name' => 'Excluder', 'last_name' => 'Excluder')); - $this->callAPISuccess('GroupContact', 'create', array('group_id' => $groupIDs['inc'], 'contact_id' => $contactIDs['includeme'])); - $this->callAPISuccess('GroupContact', 'create', array('group_id' => $groupIDs['inc'], 'contact_id' => $contactIDs['excludeme'])); - $this->callAPISuccess('GroupContact', 'create', array('group_id' => $groupIDs['exc'], 'contact_id' => $contactIDs['excludeme'])); + $contactIDs['includeme'] = $this->individualCreate(array( + 'email' => 'include.me@example.org', + 'first_name' => 'Includer', + 'last_name' => 'Person' + )); + $contactIDs['excludeme'] = $this->individualCreate(array( + 'email' => 'exclude.me@example.org', + 'last_name' => 'Excluder', + 'last_name' => 'Excluder' + )); + $this->callAPISuccess('GroupContact', 'create', array( + 'group_id' => $groupIDs['inc'], + 'contact_id' => $contactIDs['includeme'] + )); + $this->callAPISuccess('GroupContact', 'create', array( + 'group_id' => $groupIDs['inc'], + 'contact_id' => $contactIDs['excludeme'] + )); + $this->callAPISuccess('GroupContact', 'create', array( + 'group_id' => $groupIDs['exc'], + 'contact_id' => $contactIDs['excludeme'] + )); $params = $this->_params; $params['groups']['include'] = array($groupIDs['inc']); @@ -206,7 +237,11 @@ class api_v3_MailingTest extends CiviUnitTestCase { } public function testMailerSendTest_email() { - $contactIDs['alice'] = $this->individualCreate(array('email' => 'alice@example.org', 'first_name' => 'Alice', 'last_name' => 'Person')); + $contactIDs['alice'] = $this->individualCreate(array( + 'email' => 'alice@example.org', + 'first_name' => 'Alice', + 'last_name' => 'Person' + )); $mail = $this->callAPISuccess('mailing', 'create', $this->_params); @@ -224,12 +259,33 @@ class api_v3_MailingTest extends CiviUnitTestCase { public function testMailerSendTest_group() { // BEGIN SAMPLE DATA $groupIDs['inc'] = $this->groupCreate(array('name' => 'Example include group', 'title' => 'Example include group')); - $contactIDs['alice'] = $this->individualCreate(array('email' => 'alice@example.org', 'first_name' => 'Alice', 'last_name' => 'Person')); - $contactIDs['bob'] = $this->individualCreate(array('email' => 'bob@example.org', 'first_name' => 'Bob', 'last_name' => 'Person')); - $contactIDs['carol'] = $this->individualCreate(array('email' => 'carol@example.org', 'first_name' => 'Carol', 'last_name' => 'Person')); - $this->callAPISuccess('GroupContact', 'create', array('group_id' => $groupIDs['inc'], 'contact_id' => $contactIDs['alice'])); - $this->callAPISuccess('GroupContact', 'create', array('group_id' => $groupIDs['inc'], 'contact_id' => $contactIDs['bob'])); - $this->callAPISuccess('GroupContact', 'create', array('group_id' => $groupIDs['inc'], 'contact_id' => $contactIDs['carol'])); + $contactIDs['alice'] = $this->individualCreate(array( + 'email' => 'alice@example.org', + 'first_name' => 'Alice', + 'last_name' => 'Person' + )); + $contactIDs['bob'] = $this->individualCreate(array( + 'email' => 'bob@example.org', + 'first_name' => 'Bob', + 'last_name' => 'Person' + )); + $contactIDs['carol'] = $this->individualCreate(array( + 'email' => 'carol@example.org', + 'first_name' => 'Carol', + 'last_name' => 'Person' + )); + $this->callAPISuccess('GroupContact', 'create', array( + 'group_id' => $groupIDs['inc'], + 'contact_id' => $contactIDs['alice'] + )); + $this->callAPISuccess('GroupContact', 'create', array( + 'group_id' => $groupIDs['inc'], + 'contact_id' => $contactIDs['bob'] + )); + $this->callAPISuccess('GroupContact', 'create', array( + 'group_id' => $groupIDs['inc'], + 'contact_id' => $contactIDs['carol'] + )); // END SAMPLE DATA $mail = $this->callAPISuccess('mailing', 'create', $this->_params); @@ -315,7 +371,7 @@ class api_v3_MailingTest extends CiviUnitTestCase { $mail = $this->callAPISuccess('mailing', 'create', $this->_params); $params = array('mailing_id' => $mail['id'], 'test_email' => NULL, 'test_group' => $this->_groupID); $deliveredInfo = $this->callAPISuccess($this->_entity, 'send_test', $params); - $deliveredIds = implode(',', array_keys($deliveredInfo['values'])); + $deliveredIds = implode(',', array_keys($deliveredInfo['values'])); //Change the test mail into live $sql = "UPDATE civicrm_mailing_job SET is_test = 0 WHERE mailing_id = {$mail['id']}"; @@ -354,6 +410,7 @@ SELECT event_queue_id, time_stamp FROM mail_{$type}_temp"; ); $this->checkArrayEquals($expectedResult, $result['values'][$mail['id']]); } + /** * Test civicrm_mailing_delete */ diff --git a/tests/phpunit/api/v3/MembershipPaymentTest.php b/tests/phpunit/api/v3/MembershipPaymentTest.php index de24189e5b..14eae97e8b 100644 --- a/tests/phpunit/api/v3/MembershipPaymentTest.php +++ b/tests/phpunit/api/v3/MembershipPaymentTest.php @@ -34,7 +34,6 @@ require_once 'CiviTest/CiviUnitTestCase.php'; * @package CiviCRM_APIv3 * @subpackage API_Member */ - class api_v3_MembershipPaymentTest extends CiviUnitTestCase { protected $_apiversion = 3; protected $_contactID; @@ -42,6 +41,7 @@ class api_v3_MembershipPaymentTest extends CiviUnitTestCase { protected $_membershipTypeID; protected $_membershipStatusID; protected $_contribution = array(); + public function setUp() { parent::setUp(); $this->useTransaction(TRUE); diff --git a/tests/phpunit/api/v3/MembershipStatusTest.php b/tests/phpunit/api/v3/MembershipStatusTest.php index d3d0a3a0af..1d05e79e7d 100644 --- a/tests/phpunit/api/v3/MembershipStatusTest.php +++ b/tests/phpunit/api/v3/MembershipStatusTest.php @@ -115,14 +115,16 @@ class api_v3_MembershipStatusTest extends CiviUnitTestCase { public function testUpdate() { $params = array( - 'name' => 'test membership status',); + 'name' => 'test membership status', + ); $result = $this->callAPISuccess('membership_status', 'create', $params); $id = $result['id']; $result = $this->callAPISuccess('membership_status', 'get', $params); $this->assertEquals('test membership status', $result['values'][$id]['name']); $newParams = array( 'id' => $id, - 'name' => 'renamed',); + 'name' => 'renamed', + ); $result = $this->callAPISuccess('membership_status', 'create', $newParams); $result = $this->callAPISuccess('membership_status', 'get', array('id' => $id)); $this->assertEquals('renamed', $result['values'][$id]['name']); diff --git a/tests/phpunit/api/v3/MembershipTypeTest.php b/tests/phpunit/api/v3/MembershipTypeTest.php index ac4d592510..b2fde42044 100644 --- a/tests/phpunit/api/v3/MembershipTypeTest.php +++ b/tests/phpunit/api/v3/MembershipTypeTest.php @@ -111,7 +111,8 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase { 'duration_unit' => 'month', 'duration_interval' => '10', 'period_type' => 'rolling', - 'visibility' => 'public',); + 'visibility' => 'public', + ); $membershiptype = $this->callAPIFailure('membership_type', 'create', $params); $this->assertEquals($membershiptype['error_message'], 'Mandatory key(s) missing from params array: financial_type_id' @@ -127,7 +128,8 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase { 'domain_id' => '1', 'minimum_fee' => '200', 'duration_interval' => '10', - 'visibility' => 'public',); + 'visibility' => 'public', + ); $membershiptype = $this->callAPIFailure('membership_type', 'create', $params); $this->assertEquals($membershiptype['error_message'], @@ -144,7 +146,8 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase { 'minimum_fee' => '200', 'duration_unit' => 'month', 'period_type' => 'rolling', - 'visibility' => 'public',); + 'visibility' => 'public', + ); $membershiptype = $this->callAPIFailure('membership_type', 'create', $params); $this->assertEquals($membershiptype['error_message'], 'Mandatory key(s) missing from params array: financial_type_id, duration_interval' @@ -159,7 +162,8 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase { 'minimum_fee' => '200', 'duration_interval' => '10', 'period_type' => 'rolling', - 'visibility' => 'public',); + 'visibility' => 'public', + ); $membershiptype = $this->callAPIFailure('membership_type', 'create', $params); $this->assertEquals($membershiptype['error_message'], @@ -177,7 +181,8 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase { 'duration_unit' => 'month', 'duration_interval' => '10', 'period_type' => 'rolling', - 'visibility' => 'public',); + 'visibility' => 'public', + ); $membershiptype = $this->callAPIFailure('membership_type', 'create', $params); $this->assertEquals($membershiptype['error_message'], 'Mandatory key(s) missing from params array: name'); @@ -221,7 +226,8 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase { 'duration_unit' => 'month', 'duration_interval' => '10', 'period_type' => 'rolling', - 'visibility' => 'public',); + 'visibility' => 'public', + ); $membershiptype = $this->callAPIFailure('membership_type', 'create', $params); $this->assertEquals($membershiptype['error_message'], 'Mandatory key(s) missing from params array: domain_id'); @@ -232,7 +238,8 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase { $newMembOrgParams = array( 'organization_name' => 'New membership organisation', 'contact_type' => 'Organization', - 'visibility' => 1,); + 'visibility' => 1, + ); // create a new contact to update this membership type to $newMembOrgID = $this->organizationCreate($newMembOrgParams); @@ -244,7 +251,8 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase { 'duration_unit' => 'month', 'duration_interval' => '10', 'period_type' => 'fixed', - 'domain_id' => 1,); + 'domain_id' => 1, + ); $this->callAPISuccess('membership_type', 'update', $params); diff --git a/tests/phpunit/api/v3/NoteTest.php b/tests/phpunit/api/v3/NoteTest.php index 0cf6fc488d..548669c951 100644 --- a/tests/phpunit/api/v3/NoteTest.php +++ b/tests/phpunit/api/v3/NoteTest.php @@ -54,7 +54,8 @@ class api_v3_NoteTest extends CiviUnitTestCase { 'note' => 'Hello!!! m testing Note', 'contact_id' => $this->_contactID, 'modified_date' => '2011-01-31', - 'subject' => 'Test Note',); + 'subject' => 'Test Note', + ); $this->_note = $this->noteCreate($this->_contactID); $this->_noteID = $this->_note['id']; } @@ -136,7 +137,8 @@ class api_v3_NoteTest extends CiviUnitTestCase { $this->assertArrayHasKey('id', $result); $note = array( - 'id' => $result['id'],); + 'id' => $result['id'], + ); $this->noteDelete($note); } @@ -148,7 +150,8 @@ class api_v3_NoteTest extends CiviUnitTestCase { 'contact_id' => $this->_contactID, 'modified_date' => '2011-01-31', 'subject' => "With a '", - 'sequential' => 1,); + 'sequential' => 1, + ); $result = $this->callAPISuccess('Note', 'Create', $params); $this->assertAPISuccess($result, 'in line ' . __LINE__); $this->assertEquals($result['values'][0]['note'], "Hello!!! ' testing Note", 'in line ' . __LINE__); @@ -157,7 +160,8 @@ class api_v3_NoteTest extends CiviUnitTestCase { //CleanUP $note = array( - 'id' => $result['id'],); + 'id' => $result['id'], + ); $this->noteDelete($note); } @@ -170,7 +174,8 @@ class api_v3_NoteTest extends CiviUnitTestCase { $this->assertAPISuccess($apiResult); $this->assertEquals(date('Y-m-d'), date('Y-m-d', strtotime($apiResult['values'][$apiResult['id']]['modified_date']))); $this->noteDelete(array( - 'id' => $apiResult['id'],)); + 'id' => $apiResult['id'], + )); } @@ -192,7 +197,8 @@ class api_v3_NoteTest extends CiviUnitTestCase { public function testUpdateWithoutContactId() { $params = array( 'entity_id' => $this->_contactID, - 'entity_table' => 'civicrm_contact',); + 'entity_table' => 'civicrm_contact', + ); $note = $this->callAPIFailure('note', 'create', $params, 'Mandatory key(s) missing from params array: note' ); @@ -206,7 +212,8 @@ class api_v3_NoteTest extends CiviUnitTestCase { 'id' => $this->_noteID, 'contact_id' => $this->_contactID, 'note' => 'Note1', - 'subject' => 'Hello World',); + 'subject' => 'Hello World', + ); //Update Note $this->callAPISuccess('note', 'create', $params); diff --git a/tests/phpunit/api/v3/OptionGroupTest.php b/tests/phpunit/api/v3/OptionGroupTest.php index 743815ff09..8b6899d785 100644 --- a/tests/phpunit/api/v3/OptionGroupTest.php +++ b/tests/phpunit/api/v3/OptionGroupTest.php @@ -53,6 +53,7 @@ class api_v3_OptionGroupTest extends CiviUnitTestCase { $result = $this->callAPISuccess('option_group', 'getfields', array()); $this->assertFalse(empty($result['values']), 'In line ' . __LINE__); } + public function testGetOptionGroupGetFieldsCreateAction() { $result = $this->callAPISuccess('option_group', 'getfields', array('action' => 'create')); $this->assertFalse(empty($result['values']), 'In line ' . __LINE__); @@ -81,21 +82,35 @@ class api_v3_OptionGroupTest extends CiviUnitTestCase { $result = $this->callAPISuccess('option_group', 'get', array('name' => 'FSIGUBSFGOMUUBSFGMOOUUBSFGMOOBUFSGMOOIIB')); $this->assertEquals(0, $result['count'], 'In line ' . __LINE__); } + public function testGetOptionCreateSuccess() { - $params = array('sequential' => 1, 'name' => 'civicrm_event.amount.560', 'is_reserved' => 1, 'is_active' => 1, 'api.OptionValue.create' => array('label' => 'workshop', 'value' => 35, 'is_default' => 1, 'is_active' => 1, 'format.only_id' => 1)); + $params = array( + 'sequential' => 1, + 'name' => 'civicrm_event.amount.560', + 'is_reserved' => 1, + 'is_active' => 1, + 'api.OptionValue.create' => array( + 'label' => 'workshop', + 'value' => 35, + 'is_default' => 1, + 'is_active' => 1, + 'format.only_id' => 1 + ) + ); $result = $this->callAPIAndDocument('OptionGroup', 'create', $params, __FUNCTION__, __FILE__); $this->assertEquals('civicrm_event.amount.560', $result['values'][0]['name'], 'In line ' . __LINE__); $this->assertTrue(is_integer($result['values'][0]['api.OptionValue.create'])); $this->assertGreaterThan(0, $result['values'][0]['api.OptionValue.create']); $this->callAPISuccess('OptionGroup', 'delete', array('id' => $result['id'])); } + /* * Test the error message when a failure is due to a key duplication issue */ public function testGetOptionCreateFailOnDuplicate() { $params = array( - 'sequential' => 1, + 'sequential' => 1, 'name' => 'civicrm_dup entry', 'is_reserved' => 1, 'is_active' => 1, @@ -112,11 +127,11 @@ class api_v3_OptionGroupTest extends CiviUnitTestCase { public function testGetOptionCreateFailRollback() { $countFirst = $this->callAPISuccess('OptionGroup', 'getcount', array( - 'options' => array('limit' => 5000), + 'options' => array('limit' => 5000), ) ); $params = array( - 'sequential' => 1, + 'sequential' => 1, 'name' => 'civicrm_rolback_test', 'is_reserved' => 1, 'is_active' => 1, @@ -131,7 +146,7 @@ class api_v3_OptionGroupTest extends CiviUnitTestCase { ); $result = $this->callAPIFailure('OptionGroup', 'create', $params); $countAfter = $this->callAPISuccess('OptionGroup', 'getcount', array( - 'options' => array('limit' => 5000), + 'options' => array('limit' => 5000), ) ); $this->assertEquals($countFirst, $countAfter, diff --git a/tests/phpunit/api/v3/OptionValueTest.php b/tests/phpunit/api/v3/OptionValueTest.php index 99b42b6f7b..b7a754a7fb 100644 --- a/tests/phpunit/api/v3/OptionValueTest.php +++ b/tests/phpunit/api/v3/OptionValueTest.php @@ -328,19 +328,19 @@ class api_v3_OptionValueTest extends CiviUnitTestCase { public function testUpdateOptionValueWithGroupId() { // create a option group $og = $this->callAPISuccess('option_group', 'create', array( - 'name' => 'our test Option Group for with group id', - 'is_active' => 1, - )); + 'name' => 'our test Option Group for with group id', + 'is_active' => 1, + )); // create a option value $ov = $this->callAPISuccess('option_value', 'create', array('option_group_id' => $og['id'], 'label' => 'test option value') ); // update option value without 'option_group_id' $this->callAPISuccess('option_value', 'create', array( - 'id' => $ov['id'], - 'option_group_id' => $og['id'], - 'is_active' => 0, - )); + 'id' => $ov['id'], + 'option_group_id' => $og['id'], + 'is_active' => 0, + )); $val = $this->callAPISuccess('option_value', 'getvalue', array( 'id' => $ov['id'], 'return' => 'is_active', diff --git a/tests/phpunit/api/v3/ParticipantPaymentTest.php b/tests/phpunit/api/v3/ParticipantPaymentTest.php index 1aa8adaff6..1a6a23767c 100644 --- a/tests/phpunit/api/v3/ParticipantPaymentTest.php +++ b/tests/phpunit/api/v3/ParticipantPaymentTest.php @@ -1,28 +1,28 @@ _createdParticipants = array(); $this->_individualId = $this->individualCreate(); - $this->_participantID = $this->participantCreate(array('contactID' => $this->_contactID, 'eventID' => $this->_eventID)); + $this->_participantID = $this->participantCreate(array( + 'contactID' => $this->_contactID, + 'eventID' => $this->_eventID + )); $this->_contactID2 = $this->individualCreate(); - $this->_participantID2 = $this->participantCreate(array('contactID' => $this->_contactID2, 'eventID' => $this->_eventID)); - $this->_participantID3 = $this->participantCreate(array('contactID' => $this->_contactID2, 'eventID' => $this->_eventID)); + $this->_participantID2 = $this->participantCreate(array( + 'contactID' => $this->_contactID2, + 'eventID' => $this->_eventID + )); + $this->_participantID3 = $this->participantCreate(array( + 'contactID' => $this->_contactID2, + 'eventID' => $this->_eventID + )); $this->_contactID3 = $this->individualCreate(); - $this->_participantID4 = $this->participantCreate(array('contactID' => $this->_contactID3, 'eventID' => $this->_eventID)); + $this->_participantID4 = $this->participantCreate(array( + 'contactID' => $this->_contactID3, + 'eventID' => $this->_eventID + )); } ///////////////// civicrm_participant_payment_create methods @@ -87,7 +98,8 @@ class api_v3_ParticipantPaymentTest extends CiviUnitTestCase { public function testPaymentCreateMissingContributionId() { //Without Payment EntityID $params = array( - 'participant_id' => $this->_participantID,); + 'participant_id' => $this->_participantID, + ); $participantPayment = $this->callAPIFailure('participant_payment', 'create', $params); } @@ -138,7 +150,8 @@ class api_v3_ParticipantPaymentTest extends CiviUnitTestCase { public function testPaymentUpdateMissingParticipantId() { //WithoutParticipantId $params = array( - 'contribution_id' => '3',); + 'contribution_id' => '3', + ); $participantPayment = $this->callAPIFailure('participant_payment', 'create', $params); } @@ -148,7 +161,8 @@ class api_v3_ParticipantPaymentTest extends CiviUnitTestCase { */ public function testPaymentUpdateMissingContributionId() { $params = array( - 'participant_id' => $this->_participantID,); + 'participant_id' => $this->_participantID, + ); $participantPayment = $this->callAPIFailure('participant_payment', 'create', $params); } @@ -164,7 +178,8 @@ class api_v3_ParticipantPaymentTest extends CiviUnitTestCase { $params = array( 'id' => $this->_participantPaymentID, 'participant_id' => $this->_participantID, - 'contribution_id' => $contributionID,); + 'contribution_id' => $contributionID, + ); // Update Payment $participantPayment = $this->callAPISuccess('participant_payment', 'create', $params); @@ -187,9 +202,9 @@ class api_v3_ParticipantPaymentTest extends CiviUnitTestCase { $pageParams['processor_id'] = $paymentProcessor->id; $contributionPage = $this->contributionPageCreate($pageParams); $contributionParams = array( - 'contact_id' => $this->_contactID, - 'contribution_page_id' => $contributionPage['id'], - 'payment_processor' => $paymentProcessor->id, + 'contact_id' => $this->_contactID, + 'contribution_page_id' => $contributionPage['id'], + 'payment_processor' => $paymentProcessor->id, ); $contributionID = $this->onlineContributionCreate($contributionParams, 1); @@ -197,7 +212,8 @@ class api_v3_ParticipantPaymentTest extends CiviUnitTestCase { $params = array( 'id' => $this->_participantPaymentID, 'participant_id' => $this->_participantID, - 'contribution_id' => $contributionID,); + 'contribution_id' => $contributionID, + ); // Update Payment $participantPayment = $this->callAPISuccess('participant_payment', 'create', $params); @@ -232,7 +248,8 @@ class api_v3_ParticipantPaymentTest extends CiviUnitTestCase { $params = array( 'id' => $this->_participantPaymentID, 'participant_id' => $this->_participantID, - 'contribution_id' => $contributionID,); + 'contribution_id' => $contributionID, + ); // Update Payment $participantPayment = $this->callAPISuccess('participant_payment', 'create', $params); @@ -270,7 +287,8 @@ class api_v3_ParticipantPaymentTest extends CiviUnitTestCase { */ public function testPaymentDeleteWithWrongID() { $params = array( - 'id' => 0,); + 'id' => 0, + ); $deletePayment = $this->callAPIFailure('participant_payment', 'delete', $params); $this->assertEquals($deletePayment['error_message'], 'Error while deleting participantPayment'); } diff --git a/tests/phpunit/api/v3/ParticipantTest.php b/tests/phpunit/api/v3/ParticipantTest.php index bbac928a8e..de6feff96e 100644 --- a/tests/phpunit/api/v3/ParticipantTest.php +++ b/tests/phpunit/api/v3/ParticipantTest.php @@ -30,7 +30,7 @@ require_once 'CiviTest/CiviUnitTestCase.php'; /** * Test class for Batch API - civicrm_participant_* * - * @package CiviCRM_APIv3 + * @package CiviCRM_APIv3 */ require_once 'CRM/Utils/DeprecatedUtils.php'; require_once 'CiviTest/CiviUnitTestCase.php'; @@ -53,8 +53,8 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { public function setUp() { $this->_apiversion = 3; parent::setUp(); - $this->_entity = 'participant'; - $event = $this->eventCreate(NULL); + $this->_entity = 'participant'; + $event = $this->eventCreate(NULL); $this->_eventID = $event['id']; $this->_contactID = $this->individualCreate(); @@ -62,10 +62,19 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { $this->_createdParticipants = array(); $this->_individualId = $this->individualCreate(); - $this->_participantID = $this->participantCreate(array('contact_id' => $this->_contactID, 'event_id' => $this->_eventID)); + $this->_participantID = $this->participantCreate(array( + 'contact_id' => $this->_contactID, + 'event_id' => $this->_eventID + )); $this->_contactID2 = $this->individualCreate(); - $this->_participantID2 = $this->participantCreate(array('contact_id' => $this->_contactID2, 'event_id' => $this->_eventID)); - $this->_participantID3 = $this->participantCreate(array('contact_id' => $this->_contactID2, 'event_id' => $this->_eventID)); + $this->_participantID2 = $this->participantCreate(array( + 'contact_id' => $this->_contactID2, + 'event_id' => $this->_eventID + )); + $this->_participantID3 = $this->participantCreate(array( + 'contact_id' => $this->_contactID2, + 'event_id' => $this->_eventID + )); $this->_params = array( 'contact_id' => $this->_contactID, 'event_id' => $this->_eventID, @@ -80,7 +89,10 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { public function tearDown() { $this->eventDelete($this->_eventID); $tablesToTruncate = array( - 'civicrm_custom_group', 'civicrm_custom_field', 'civicrm_contact', 'civicrm_participant', + 'civicrm_custom_group', + 'civicrm_custom_field', + 'civicrm_contact', + 'civicrm_participant', ); // true tells quickCleanup to drop any tables that might have been created in the test $this->quickCleanup($tablesToTruncate, TRUE); @@ -176,11 +188,14 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { public function testGetNestedEventGet() { //create a second event & add participant to it. $event = $this->eventCreate(NULL); - $this->callAPISuccess('participant', 'create', array('event_id' => $event['id'], 'contact_id' => $this->_contactID)); + $this->callAPISuccess('participant', 'create', array( + 'event_id' => $event['id'], + 'contact_id' => $this->_contactID + )); $description = "use nested get to get an event"; - $subfile = "NestedEventGet"; - $params = array( + $subfile = "NestedEventGet"; + $params = array( 'id' => $this->_participantID, 'api.event.get' => 1, ); @@ -197,7 +212,7 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { public function testGetWithReturnProperties() { $params = array( 'contact_id' => $this->_contactID, - 'return.status_id' => 1, + 'return.status_id' => 1, 'return.participant_status_id' => 1, 'options' => array('limit' => 1), ); @@ -210,7 +225,8 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { */ public function testGetContactIdOnly() { $params = array( - 'contact_id' => $this->_contactID,); + 'contact_id' => $this->_contactID, + ); $participant = $this->callAPISuccess('participant', 'get', $params); $this->assertEquals($this->_participantID, $participant['id'], @@ -237,7 +253,8 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { public function testGetMultiMatchReturnFirst() { $params = array( 'event_id' => $this->_eventID, - 'rowCount' => 1,); + 'rowCount' => 1, + ); $participant = $this->callAPISuccess('participant', 'get', $params); $this->assertNotNull($participant['id']); @@ -388,7 +405,7 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { public function testCreateUpdateReceiveDate() { $participant = $this->callAPISuccess('participant', 'create', $this->_params); $update = array( - 'id' => $participant['id'], + 'id' => $participant['id'], 'status_id' => 2, ); $this->callAPISuccess('participant', 'create', $update); @@ -540,7 +557,7 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { $participant = $this->callAPISuccess('participant', 'create', $myParams); $this->assertAPISuccess($participant); $update = array( - 'id' => $participant['id'], + 'id' => $participant['id'], 'status_id' => 2, ); $this->callAPISuccess('participant', 'create', $update); @@ -580,7 +597,8 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { 'role_id' => 3, 'register_date' => '2006-01-21', 'source' => 'US Open', - 'event_level' => 'Donation',); + 'event_level' => 'Donation', + ); $participant = $this->callAPIFailure('participant', 'create', $params); $this->assertEquals($participant['error_message'], 'Mandatory key(s) missing from params array: event_id'); // Cleanup created participant records. @@ -597,7 +615,8 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { 'role_id' => 3, 'register_date' => '2006-01-21', 'source' => 'US Open', - 'event_level' => 'Donation',); + 'event_level' => 'Donation', + ); $participant = $this->callAPIFailure('Participant', 'update', $params); } @@ -607,8 +626,8 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { public function testUpdateWithWrongContactId() { $participantId = $this->participantCreate(array( 'contactID' => $this->_individualId, - 'eventID' => $this->_eventID, - ), $this->_apiversion); + 'eventID' => $this->_eventID, + ), $this->_apiversion); $params = array( 'id' => $participantId, 'contact_id' => 12345, @@ -616,7 +635,8 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { 'role_id' => 3, 'register_date' => '2006-01-21', 'source' => 'US Open', - 'event_level' => 'Donation',); + 'event_level' => 'Donation', + ); $participant = $this->callAPIFailure('participant', 'create', $params); $result = $this->participantDelete($participantId); } @@ -644,7 +664,8 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { */ public function testParticipantDelete() { $params = array( - 'id' => $this->_participantID,); + 'id' => $this->_participantID, + ); $participant = $this->callAPISuccess('participant', 'delete', $params); $this->assertAPISuccess($participant); $this->assertDBState('CRM_Event_DAO_Participant', $this->_participantID, NULL, TRUE); @@ -657,7 +678,8 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { */ public function testParticipantDeleteMissingID() { $params = array( - 'event_id' => $this->_eventID,); + 'event_id' => $this->_eventID, + ); $participant = $this->callAPIFailure('participant', 'delete', $params); $this->assertNotNull($participant['error_message']); } @@ -666,8 +688,8 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { * Delete with a get - a 'criteria delete' */ public function testNestedDelete() { - $description = "Criteria delete by nesting a GET & a DELETE"; - $subfile = "NestedDelete"; + $description = "Criteria delete by nesting a GET & a DELETE"; + $subfile = "NestedDelete"; $participants = $this->callAPISuccess('Participant', 'Get', array()); $this->assertEquals($participants['count'], 3); $params = array('contact_id' => $this->_contactID2, 'api.participant.delete' => 1); diff --git a/tests/phpunit/api/v3/PaymentProcessorTypeTest.php b/tests/phpunit/api/v3/PaymentProcessorTypeTest.php index f0387629c9..fba29f681a 100644 --- a/tests/phpunit/api/v3/PaymentProcessorTypeTest.php +++ b/tests/phpunit/api/v3/PaymentProcessorTypeTest.php @@ -57,7 +57,8 @@ class api_v3_PaymentProcessorTypeTest extends CiviUnitTestCase { */ public function testPaymentProcessorTypeCreateWithoutName() { $payProcParams = array( - 'is_active' => 1,); + 'is_active' => 1, + ); $result = $this->callAPIFailure('payment_processor_type', 'create', $payProcParams); $this->assertEquals($result['error_message'], 'Mandatory key(s) missing from params array: name, title, class_name, billing_mode' @@ -69,7 +70,7 @@ class api_v3_PaymentProcessorTypeTest extends CiviUnitTestCase { */ public function testPaymentProcessorTypeCreate() { $params = array( - 'sequential' => 1, + 'sequential' => 1, 'name' => 'API_Test_PP', 'title' => 'API Test Payment Processor', 'class_name' => 'CRM_Core_Payment_APITest', @@ -178,7 +179,8 @@ class api_v3_PaymentProcessorTypeTest extends CiviUnitTestCase { 'title' => 'API Test Payment Processor 2', 'class_name' => 'CRM_Core_Payment_APITest 2', 'billing_mode' => 2, - 'is_recur' => 0,); + 'is_recur' => 0, + ); $result = $this->callAPISuccess('payment_processor_type', 'create', $params); $this->assertNotNull($result['id']); @@ -200,7 +202,8 @@ class api_v3_PaymentProcessorTypeTest extends CiviUnitTestCase { 'title' => 'API Test Payment Processor', 'class_name' => 'CRM_Core_Payment_APITest', 'billing_mode' => 1, - 'is_recur' => 0,); + 'is_recur' => 0, + ); $first = $this->callAPISuccess('PaymentProcessorType', 'Create', $firstRelTypeParams); @@ -209,7 +212,8 @@ class api_v3_PaymentProcessorTypeTest extends CiviUnitTestCase { 'title' => 'API Test Payment Processor 2', 'class_name' => 'CRM_Core_Payment_APITest 2', 'billing_mode' => 2, - 'is_recur' => 0,); + 'is_recur' => 0, + ); $second = $this->callAPISuccess('PaymentProcessorType', 'Create', $secondRelTypeParams); $result = $this->callAPISuccess('payment_processor_type', 'get', array()); @@ -226,7 +230,8 @@ class api_v3_PaymentProcessorTypeTest extends CiviUnitTestCase { 'title' => 'API Test Payment Processor 11', 'class_name' => 'CRM_Core_Payment_APITest_11', 'billing_mode' => 1, - 'is_recur' => 0,); + 'is_recur' => 0, + ); $first = $this->callAPISuccess('PaymentProcessorType', 'Create', $firstRelTypeParams); @@ -235,11 +240,13 @@ class api_v3_PaymentProcessorTypeTest extends CiviUnitTestCase { 'title' => 'API Test Payment Processor 12', 'class_name' => 'CRM_Core_Payment_APITest_12', 'billing_mode' => 2, - 'is_recur' => 0,); + 'is_recur' => 0, + ); $second = $this->callAPISuccess('PaymentProcessorType', 'Create', $secondRelTypeParams); $params = array( - 'name' => 'API_Test_PP_12',); + 'name' => 'API_Test_PP_12', + ); $result = $this->callAPISuccess('payment_processor_type', 'get', $params); $this->assertAPISuccess($result); diff --git a/tests/phpunit/api/v3/PledgePaymentTest.php b/tests/phpunit/api/v3/PledgePaymentTest.php index 836237e789..d34f02b0b0 100644 --- a/tests/phpunit/api/v3/PledgePaymentTest.php +++ b/tests/phpunit/api/v3/PledgePaymentTest.php @@ -32,7 +32,6 @@ require_once 'CiviTest/CiviUnitTestCase.php'; * * @package CiviCRM_APIv3 */ - class api_v3_PledgePaymentTest extends CiviUnitTestCase { /** @@ -189,8 +188,8 @@ class api_v3_PledgePaymentTest extends CiviUnitTestCase { $params['scheduled_date'] = '20131212'; $resultcreatenew = $this->callAPISuccess('pledge_payment', 'create', $params); $result = $this->callAPISuccess('PledgePayment', 'Get', array( - 'pledge_id' => $this->_pledgeID, - )); + 'pledge_id' => $this->_pledgeID, + )); $this->assertEquals(6, $result['count']); } @@ -232,7 +231,7 @@ class api_v3_PledgePaymentTest extends CiviUnitTestCase { //check existing updated not new one created - 'create' means add contribution_id in this context $afterAdd = $this->callAPISuccess('pledge_payment', 'get', array( 'contribution_id' => $contributionID, - )); + )); $this->assertEquals(1, $afterAdd['count'], " in line " . __LINE__); } diff --git a/tests/phpunit/api/v3/PledgeTest.php b/tests/phpunit/api/v3/PledgeTest.php index 08c4340d06..47486b8a00 100644 --- a/tests/phpunit/api/v3/PledgeTest.php +++ b/tests/phpunit/api/v3/PledgeTest.php @@ -127,9 +127,11 @@ class api_v3_PledgeTest extends CiviUnitTestCase { $this->assertEquals($pledge['pledge_next_pay_amount'], 20.00, 'in line' . __LINE__); $params2 = array( - 'pledge_id' => $this->_pledge['id'],); + 'pledge_id' => $this->_pledge['id'], + ); $pledge = $this->callAPISuccess('pledge', 'delete', $params2); } + /** * Test 'return.pledge_financial_type' => 1 works */ @@ -138,13 +140,14 @@ class api_v3_PledgeTest extends CiviUnitTestCase { $this->_pledge = $this->callAPISuccess('pledge', 'create', $this->_params); $params = array( 'pledge_id' => $this->_pledge['id'], - 'return.pledge_financial_type' => 1, + 'return.pledge_financial_type' => 1, ); $result = $this->callAPISuccess('pledge', 'get', $params); $pledge = $result['values'][$this->_pledge['id']]; $this->callAPISuccess('pledge', 'delete', $pledge); $this->assertEquals('Donation', $pledge['pledge_financial_type']); } + /** * Test 'return.pledge_contribution_type' => 1 works * This is for legacy compatibility @@ -154,7 +157,7 @@ class api_v3_PledgeTest extends CiviUnitTestCase { $this->_pledge = $this->callAPISuccess('pledge', 'create', $this->_params); $params = array( 'pledge_id' => $this->_pledge['id'], - 'return.pledge_financial_type' => 1, + 'return.pledge_financial_type' => 1, ); $result = $this->callAPISuccess('pledge', 'get', $params); $pledge = $result['values'][$this->_pledge['id']]; @@ -180,6 +183,7 @@ class api_v3_PledgeTest extends CiviUnitTestCase { $this->assertEquals(1, $earlyPledge['count'], ' check only one returned with start date filter in line ' . __LINE__); $this->assertEquals($oldPledge['id'], $earlyPledge['id'], ' check correct pledge returned ' . __LINE__); } + /* * create 2 pledges - see if we can get by status id */ @@ -189,11 +193,13 @@ class api_v3_PledgeTest extends CiviUnitTestCase { 'start_date' => 'first saturday of march last year', ); $this->_pledge = $this->callAPISuccess('pledge', 'create', array_merge($this->_params, $overdueParams)); - $params = array( 'pledge_status_id' => '6', + $params = array( + 'pledge_status_id' => '6', ); $result = $this->callAPISuccess('pledge', 'get', $params); - $emptyResult = $this->callAPISuccess('pledge', 'get', array( 'pledge_status_id' => '1', - )); + $emptyResult = $this->callAPISuccess('pledge', 'get', array( + 'pledge_status_id' => '1', + )); $pledge = $result['values'][$this->_pledge['id']]; $this->callAPISuccess('pledge', 'delete', $pledge); $this->assertEquals(1, $result['count']); @@ -213,17 +219,17 @@ class api_v3_PledgeTest extends CiviUnitTestCase { ); $pledge2 = $this->callAPISuccess('pledge', 'create', array_merge($this->_params, $overdueParams)); $params = array( - 'pledge_is_test' => 0, + 'pledge_is_test' => 0, 'rowCount' => 1, ); $result = $this->callAPISuccess('pledge', 'get', $params); $resultSortedAsc = $this->callAPISuccess('pledge', 'get', array( - 'rowCount' => 1, + 'rowCount' => 1, 'sort' => 'start_date ASC', )); $resultSortedDesc = $this->callAPISuccess('pledge', 'get', array( - 'rowCount' => 1, + 'rowCount' => 1, 'sort' => 'start_date DESC', )); @@ -273,12 +279,14 @@ class api_v3_PledgeTest extends CiviUnitTestCase { //ensure that correct number of payments created & last payment has the right date $payments = $this->callAPISuccess('PledgePayment', 'Get', array( 'pledge_id' => $pledge['id'], - 'sequential' => 1)); + 'sequential' => 1 + )); $this->assertEquals($payments['count'], 5, 'In line ' . __LINE__); $this->assertEquals('2011-07-06 00:00:00', $payments['values'][4]['scheduled_date'], 'In line ' . __LINE__); $this->callAPISuccess('pledge', 'delete', array('pledge_id' => $pledge['id'])); } + /* * Test that pledge with weekly schedule calculates dates correctly */ @@ -378,7 +386,8 @@ class api_v3_PledgeTest extends CiviUnitTestCase { $pledgeID = $this->pledgeCreate($this->_individualId); $old_params = array( 'id' => $pledgeID, - 'sequential' => 1,); + 'sequential' => 1, + ); $original = $this->callAPISuccess('pledge', 'get', $old_params); //Make sure it came back $this->assertEquals($original['values'][0]['pledge_id'], $pledgeID, 'In line ' . __LINE__); @@ -400,7 +409,8 @@ class api_v3_PledgeTest extends CiviUnitTestCase { 'amount' => 100, 'financial_type_id' => 1, 'start_date' => date('Ymd'), - 'installments' => 10,); + 'installments' => 10, + ); $pledge = $this->callAPISuccess('pledge', 'create', $params); $new_params = array( @@ -422,7 +432,8 @@ class api_v3_PledgeTest extends CiviUnitTestCase { $pledgeID = $this->pledgeCreate($this->_individualId); $old_params = array( 'id' => $pledgeID, - 'sequential' => 1,); + 'sequential' => 1, + ); $original = $this->callAPISuccess('pledge', 'get', $old_params); //Make sure it came back $this->assertEquals($original['values'][0]['pledge_id'], $pledgeID, 'In line ' . __LINE__); diff --git a/tests/phpunit/api/v3/PriceFieldTest.php b/tests/phpunit/api/v3/PriceFieldTest.php index f0f4956259..e58c6f1656 100644 --- a/tests/phpunit/api/v3/PriceFieldTest.php +++ b/tests/phpunit/api/v3/PriceFieldTest.php @@ -43,7 +43,7 @@ class api_v3_PriceFieldTest extends CiviUnitTestCase { parent::setUp(); // put stuff here that should happen before all tests in this unit $priceSetparams = array( - # [domain_id] => + # [domain_id] => 'name' => 'default_goat_priceset', 'title' => 'Goat accomodation', 'is_active' => 1, @@ -59,7 +59,7 @@ class api_v3_PriceFieldTest extends CiviUnitTestCase { $this->priceSetID = $price_set['id']; $this->_params = array( - 'price_set_id' => $this->priceSetID, + 'price_set_id' => $this->priceSetID, 'name' => 'grassvariety', 'label' => 'Grass Variety', 'html_type' => 'Text', @@ -70,13 +70,13 @@ class api_v3_PriceFieldTest extends CiviUnitTestCase { public function tearDown() { $tablesToTruncate = array( - 'civicrm_contact', - 'civicrm_contribution', + 'civicrm_contact', + 'civicrm_contribution', ); $this->quickCleanup($tablesToTruncate); $delete = $this->callAPISuccess('PriceSet', 'delete', array( - 'id' => $this->priceSetID, + 'id' => $this->priceSetID, )); $this->assertAPISuccess($delete); diff --git a/tests/phpunit/api/v3/PriceFieldValueTest.php b/tests/phpunit/api/v3/PriceFieldValueTest.php index 00ea139c18..34cf87e51b 100644 --- a/tests/phpunit/api/v3/PriceFieldValueTest.php +++ b/tests/phpunit/api/v3/PriceFieldValueTest.php @@ -74,7 +74,7 @@ class api_v3_PriceFieldValueTest extends CiviUnitTestCase { 'name' => 'ryegrass', 'label' => 'juicy and healthy', 'amount' => 1, - ); + ); $membershipOrgId = $this->organizationCreate(NULL); $this->_membershipTypeID = $this->membershipTypeCreate(array('member_of_contact_id' => $membershipOrgId)); @@ -103,19 +103,19 @@ class api_v3_PriceFieldValueTest extends CiviUnitTestCase { public function tearDown() { $tablesToTruncate = array( - 'civicrm_contact', - 'civicrm_contribution', + 'civicrm_contact', + 'civicrm_contribution', ); $this->quickCleanup($tablesToTruncate); $this->membershipTypeDelete(array('id' => $this->_membershipTypeID)); $this->callAPISuccess('PriceField', 'delete', array( - 'id' => $this->priceFieldID1, + 'id' => $this->priceFieldID1, )); $this->callAPISuccess('PriceSet', 'delete', array( 'id' => $this->priceSetID1, )); $this->callAPISuccess('PriceField', 'delete', array( - 'id' => $this->priceFieldID, + 'id' => $this->priceFieldID, )); $delete = $this->callAPISuccess('PriceSet', 'delete', array( 'id' => $this->priceSetID, @@ -169,12 +169,13 @@ class api_v3_PriceFieldValueTest extends CiviUnitTestCase { 'membership_num_terms' => 2, 'is_active' => 1, 'financial_type_id' => 2, - ); + ); $result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__); $this->assertEquals($result['values'][$result['id']]['membership_num_terms'], 2); $this->assertEquals(1, $result['count'], 'In line ' . __LINE__); $this->callAPISuccess($this->_entity, 'delete', array('id' => $result['id'])); } + public function testGetPriceFieldValuewithMultipleTerms() { $params1 = array( 'price_field_id' => $this->priceFieldID1, @@ -185,7 +186,7 @@ class api_v3_PriceFieldValueTest extends CiviUnitTestCase { 'membership_num_terms' => 2, 'is_active' => 1, 'financial_type_id' => 2, - ); + ); $params2 = array( 'price_field_id' => $this->priceFieldID1, 'membership_type_id' => $this->_membershipTypeID, @@ -195,7 +196,7 @@ class api_v3_PriceFieldValueTest extends CiviUnitTestCase { 'membership_num_terms' => 3, 'is_active' => 1, 'financial_type_id' => 2, - ); + ); $result1 = $this->callAPISuccess($this->_entity, 'create', $params1); $result2 = $this->callAPISuccess($this->_entity, 'create', $params2); $result = $this->callAPISuccess($this->_entity, 'get', array('price_field_id' => $this->priceFieldID1)); diff --git a/tests/phpunit/api/v3/PriceSetTest.php b/tests/phpunit/api/v3/PriceSetTest.php index 359e6665ee..d3f5538fba 100644 --- a/tests/phpunit/api/v3/PriceSetTest.php +++ b/tests/phpunit/api/v3/PriceSetTest.php @@ -39,10 +39,11 @@ class api_v3_PriceSetTest extends CiviUnitTestCase { protected $_entity = 'price_set'; public $DBResetRequired = TRUE; + public function setUp() { parent::setUp(); $this->_params = array( - # [domain_id] => + # [domain_id] => 'name' => 'default_goat_priceset', 'title' => 'Goat accessories', 'is_active' => 1, diff --git a/tests/phpunit/api/v3/ProductTest.php b/tests/phpunit/api/v3/ProductTest.php index 1d8fef5839..26101bc05a 100644 --- a/tests/phpunit/api/v3/ProductTest.php +++ b/tests/phpunit/api/v3/ProductTest.php @@ -1,28 +1,28 @@ _createIndividualContact(); - $expected = current($pofileFieldValues); - $contactId = key($pofileFieldValues); - $params = array( + $expected = current($pofileFieldValues); + $contactId = key($pofileFieldValues); + $params = array( 'profile_id' => $this->_profileID, 'contact_id' => $contactId, ); @@ -110,9 +110,9 @@ class api_v3_ProfileTest extends CiviUnitTestCase { public function testProfileGetMultiple() { $pofileFieldValues = $this->_createIndividualContact(); - $expected = current($pofileFieldValues); - $contactId = key($pofileFieldValues); - $params = array( + $expected = current($pofileFieldValues); + $contactId = key($pofileFieldValues); + $params = array( 'profile_id' => array($this->_profileID, 1, 'Billing'), 'contact_id' => $contactId, ); @@ -139,7 +139,7 @@ class api_v3_ProfileTest extends CiviUnitTestCase { public function testProfileGetBillingUseIsBillingLocation() { $individual = $this->_createIndividualContact(); - $contactId = key($individual); + $contactId = key($individual); $this->callAPISuccess('address', 'create', array( 'is_billing' => 1, 'street_address' => 'is billing st', @@ -172,9 +172,19 @@ class api_v3_ProfileTest extends CiviUnitTestCase { public function testProfileGetMultipleHasBillingLocation() { $individual = $this->_createIndividualContact(); - $contactId = key($individual); - $this->callAPISuccess('address', 'create', array('contact_id' => $contactId, 'street_address' => '25 Big Street', 'city' => 'big city', 'location_type_id' => 5)); - $this->callAPISuccess('email', 'create', array('contact_id' => $contactId, 'email' => 'big@once.com', 'location_type_id' => 2, 'is_billing' => 1)); + $contactId = key($individual); + $this->callAPISuccess('address', 'create', array( + 'contact_id' => $contactId, + 'street_address' => '25 Big Street', + 'city' => 'big city', + 'location_type_id' => 5 + )); + $this->callAPISuccess('email', 'create', array( + 'contact_id' => $contactId, + 'email' => 'big@once.com', + 'location_type_id' => 2, + 'is_billing' => 1 + )); $expected = current($individual); @@ -298,7 +308,10 @@ class api_v3_ProfileTest extends CiviUnitTestCase { public function testGetFields() { $this->_createIndividualProfile(); $this->_addCustomFieldToProfile($this->_profileID); - $result = $this->callAPIAndDocument('profile', 'getfields', array('action' => 'submit', 'profile_id' => $this->_profileID), __FUNCTION__, __FILE__, + $result = $this->callAPIAndDocument('profile', 'getfields', array( + 'action' => 'submit', + 'profile_id' => $this->_profileID + ), __FUNCTION__, __FILE__, 'demonstrates retrieving profile fields passing in an id'); $this->assertArrayKeyExists('first_name', $result['values']); $this->assertEquals('2', $result['values']['first_name']['type']); @@ -313,9 +326,10 @@ class api_v3_ProfileTest extends CiviUnitTestCase { */ public function testGetFieldsParticipantProfile() { $result = $this->callAPISuccess('profile', 'getfields', array( - 'action' => 'submit', - 'profile_id' => 'participant_status', - 'get_options' => 'all') + 'action' => 'submit', + 'profile_id' => 'participant_status', + 'get_options' => 'all' + ) ); $this->assertTrue(array_key_exists('participant_status_id', $result['values'])); $this->assertEquals('Attended', $result['values']['participant_status_id']['options'][2]); @@ -328,13 +342,18 @@ class api_v3_ProfileTest extends CiviUnitTestCase { */ public function testGetFieldsMembershipBatchProfile() { $result = $this->callAPISuccess('profile', 'getfields', array( - 'action' => 'submit', - 'profile_id' => 'membership_batch_entry', - 'get_options' => 'all') + 'action' => 'submit', + 'profile_id' => 'membership_batch_entry', + 'get_options' => 'all' + ) ); $this->assertTrue(array_key_exists('total_amount', $result['values'])); $this->assertTrue(array_key_exists('financial_type_id', $result['values'])); - $this->assertEquals(array('contribution_type_id', 'contribution_type', 'financial_type'), $result['values']['financial_type_id']['api.aliases']); + $this->assertEquals(array( + 'contribution_type_id', + 'contribution_type', + 'financial_type' + ), $result['values']['financial_type_id']['api.aliases']); $this->assertTrue(!array_key_exists('financial_type', $result['values'])); $this->assertEquals(12, $result['values']['receive_date']['type']); } @@ -348,9 +367,10 @@ class api_v3_ProfileTest extends CiviUnitTestCase { $profileIDs = array_keys($result['values']); foreach ($profileIDs as $profileID) { $result = $this->callAPISuccess('profile', 'getfields', array( - 'action' => 'submit', - 'profile_id' => $profileID, - 'get_options' => 'all') + 'action' => 'submit', + 'profile_id' => $profileID, + 'get_options' => 'all' + ) ); } } @@ -453,8 +473,15 @@ class api_v3_ProfileTest extends CiviUnitTestCase { $this->_membershipTypeID = $this->membershipTypeCreate(); $membershipTypes = $this->callAPISuccess('membership_type', 'get', array()); - $profileFields = $this->callAPISuccess('profile', 'getfields', array('get_options' => 'all', 'action' => 'submit', 'profile_id' => 'membership_batch_entry')); - $getoptions = $this->callAPISuccess('membership', 'getoptions', array('field' => 'membership_type', 'context' => 'validate')); + $profileFields = $this->callAPISuccess('profile', 'getfields', array( + 'get_options' => 'all', + 'action' => 'submit', + 'profile_id' => 'membership_batch_entry' + )); + $getoptions = $this->callAPISuccess('membership', 'getoptions', array( + 'field' => 'membership_type', + 'context' => 'validate' + )); $this->assertEquals(array_keys($membershipTypes['values']), array_keys($getoptions['values'])); $this->assertEquals(array_keys($membershipTypes['values']), array_keys($profileFields['values']['membership_type_id']['options'])); @@ -464,7 +491,10 @@ class api_v3_ProfileTest extends CiviUnitTestCase { * Test that the fields are returned in the right order despite the faffing around that goes on */ public function testMembershipGetFieldsOrder() { - $result = $this->callAPISuccess('profile', 'getfields', array('action' => 'submit', 'profile_id' => 'membership_batch_entry')); + $result = $this->callAPISuccess('profile', 'getfields', array( + 'action' => 'submit', + 'profile_id' => 'membership_batch_entry' + )); $weight = 1; foreach ($result['values'] as $fieldName => $field) { if ($fieldName == 'profile_id') { @@ -474,22 +504,24 @@ class api_v3_ProfileTest extends CiviUnitTestCase { $weight++; } } + /** * Check we can submit membership batch profiles (create mode) */ public function testProfileSubmitMembershipBatch() { $this->_contactID = $this->individualCreate(); $this->callAPISuccess('profile', 'submit', array( - 'profile_id' => 'membership_batch_entry', - 'financial_type_id' => 1, - 'membership_type' => $this->_membershipTypeID, - 'join_date' => 'now', - 'total_amount' => 10, - 'contribution_status_id' => 1, - 'receive_date' => 'now', - 'contact_id' => $this->_contactID, + 'profile_id' => 'membership_batch_entry', + 'financial_type_id' => 1, + 'membership_type' => $this->_membershipTypeID, + 'join_date' => 'now', + 'total_amount' => 10, + 'contribution_status_id' => 1, + 'receive_date' => 'now', + 'contact_id' => $this->_contactID, )); } + /** * Set is deprecated but we need to ensure it still works */ @@ -683,7 +715,10 @@ class api_v3_ProfileTest extends CiviUnitTestCase { } foreach (array( - 'email', 'phone', 'address') as $fieldType) { + 'email', + 'phone', + 'address' + ) as $fieldType) { $typeValues = array_pop($result['values'][$fieldType]); foreach ($expected[$fieldType] as $field => $value) { $this->assertEquals($value, CRM_Utils_Array::value($field, $typeValues), "In line " . __LINE__ . " error message: " . "missing/mismatching value for {$field} ({$fieldType})" @@ -700,29 +735,29 @@ class api_v3_ProfileTest extends CiviUnitTestCase { */ public function _createIndividualContact($params = array()) { $contactParams = array_merge(array( - 'first_name' => 'abc1', - 'last_name' => 'xyz1', - 'email' => 'abc1.xyz1@yahoo.com', - 'api.address.create' => array( - 'location_type_id' => 1, - 'is_primary' => 1, - 'street_address' => '5 Saint Helier St', - 'county' => 'Marin', - 'country' => 'United States', - 'state_province' => 'Michigan', - 'supplemental_address_1' => 'Hallmark Ct', - 'supplemental_address_2' => 'Jersey Village', - 'postal_code' => '90210', - 'city' => 'Gotham City', - 'is_billing' => 0, - ), - 'api.phone.create' => array( - 'location_type_id' => '1', - 'phone' => '021 512 755', - 'phone_type_id' => '1', - 'is_primary' => '1', - ), - ), $params + 'first_name' => 'abc1', + 'last_name' => 'xyz1', + 'email' => 'abc1.xyz1@yahoo.com', + 'api.address.create' => array( + 'location_type_id' => 1, + 'is_primary' => 1, + 'street_address' => '5 Saint Helier St', + 'county' => 'Marin', + 'country' => 'United States', + 'state_province' => 'Michigan', + 'supplemental_address_1' => 'Hallmark Ct', + 'supplemental_address_2' => 'Jersey Village', + 'postal_code' => '90210', + 'city' => 'Gotham City', + 'is_billing' => 0, + ), + 'api.phone.create' => array( + 'location_type_id' => '1', + 'phone' => '021 512 755', + 'phone_type_id' => '1', + 'is_primary' => '1', + ), + ), $params ); $this->_contactID = $this->individualCreate($contactParams); @@ -818,6 +853,7 @@ class api_v3_ProfileTest extends CiviUnitTestCase { return array($profileParams, $expected); } + /** * Create a profile */ @@ -883,7 +919,7 @@ class api_v3_ProfileTest extends CiviUnitTestCase { 'field_type' => 'Contact', 'location_type_id' => 1, 'label' => 'State Province', - ), + ), ), ); $profile = $this->callAPISuccess('uf_group', 'create', $ufGroupParams); @@ -895,6 +931,10 @@ class api_v3_ProfileTest extends CiviUnitTestCase { */ public function _addCustomFieldToProfile($profileID) { $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, ''); - $this->uFFieldCreate(array('uf_group_id' => $profileID, 'field_name' => 'custom_' . $ids['custom_field_id'], 'contact_type' => 'Contact')); + $this->uFFieldCreate(array( + 'uf_group_id' => $profileID, + 'field_name' => 'custom_' . $ids['custom_field_id'], + 'contact_type' => 'Contact' + )); } } diff --git a/tests/phpunit/api/v3/RelationshipTest.php b/tests/phpunit/api/v3/RelationshipTest.php index fe4c6d56c8..dbd8f607d5 100644 --- a/tests/phpunit/api/v3/RelationshipTest.php +++ b/tests/phpunit/api/v3/RelationshipTest.php @@ -53,10 +53,10 @@ class api_v3_RelationshipTest extends CiviUnitTestCase { parent::setUp(); $this->_cId_a = $this->individualCreate(); $this->_cId_a_2 = $this->individualCreate(array( - 'last_name' => 'c2', - 'email' => 'c@w.com', - 'contact_type' => 'Individual', - )); + 'last_name' => 'c2', + 'email' => 'c@w.com', + 'contact_type' => 'Individual', + )); $this->_cId_b = $this->organizationCreate(); $this->_cId_b2 = $this->organizationCreate(array('organization_name' => ' Org 2')); $this->_entity = 'relationship'; diff --git a/tests/phpunit/api/v3/RelationshipTypeTest.php b/tests/phpunit/api/v3/RelationshipTypeTest.php index da1daf94c4..b22cc0b692 100644 --- a/tests/phpunit/api/v3/RelationshipTypeTest.php +++ b/tests/phpunit/api/v3/RelationshipTypeTest.php @@ -67,8 +67,8 @@ class api_v3_RelationshipTypeTest extends CiviUnitTestCase { public function setUp() { parent::setUp(); - $this->_cId_a = $this->individualCreate(); - $this->_cId_b = $this->organizationCreate(); + $this->_cId_a = $this->individualCreate(); + $this->_cId_b = $this->organizationCreate(); } public function tearDown() { diff --git a/tests/phpunit/api/v3/ReportTemplateTest.php b/tests/phpunit/api/v3/ReportTemplateTest.php index fa77b7a478..2ce2645a2a 100644 --- a/tests/phpunit/api/v3/ReportTemplateTest.php +++ b/tests/phpunit/api/v3/ReportTemplateTest.php @@ -34,7 +34,6 @@ require_once 'CiviTest/CiviUnitTestCase.php'; * @package CiviCRM_APIv3 * @subpackage API_Report */ - class api_v3_ReportTemplateTest extends CiviUnitTestCase { protected $_apiversion = 3; @@ -64,7 +63,7 @@ class api_v3_ReportTemplateTest extends CiviUnitTestCase { // change component to null $result = $this->callAPISuccess('ReportTemplate', 'create', array( - 'id' => $entityId, + 'id' => $entityId, 'component' => '', )); $this->assertAPISuccess($result); @@ -78,7 +77,7 @@ class api_v3_ReportTemplateTest extends CiviUnitTestCase { // deactivate $result = $this->callAPISuccess('ReportTemplate', 'create', array( - 'id' => $entityId, + 'id' => $entityId, 'is_active' => 0, )); $this->assertAPISuccess($result); @@ -91,7 +90,7 @@ class api_v3_ReportTemplateTest extends CiviUnitTestCase { // activate $result = $this->callAPISuccess('ReportTemplate', 'create', array( - 'id' => $entityId, + 'id' => $entityId, 'is_active' => 1, )); $this->assertAPISuccess($result); @@ -102,7 +101,8 @@ class api_v3_ReportTemplateTest extends CiviUnitTestCase { $this->assertDBQuery(1, 'SELECT is_active FROM civicrm_option_value WHERE name = "CRM_Report_Form_Examplez"'); - $result = $this->callAPISuccess('ReportTemplate', 'delete', array( 'id' => $entityId, + $result = $this->callAPISuccess('ReportTemplate', 'delete', array( + 'id' => $entityId, )); $this->assertAPISuccess($result); $this->assertEquals(1, $result['count'], 'In line ' . __LINE__); @@ -142,7 +142,7 @@ class api_v3_ReportTemplateTest extends CiviUnitTestCase { $this->markTestIncomplete($reportID); } $result = $this->callAPISuccess('report_template', 'getrows', array( - 'report_id' => $reportID, + 'report_id' => $reportID, )); } @@ -168,24 +168,24 @@ class api_v3_ReportTemplateTest extends CiviUnitTestCase { */ public static function getReportTemplates() { $reportsToSkip = array( - 'activity' => 'does not respect function signature on from clause', - 'walklist' => 'Notice: Undefined index: type in CRM_Report_Form_Walklist_Walklist line 155. + 'activity' => 'does not respect function signature on from clause', + 'walklist' => 'Notice: Undefined index: type in CRM_Report_Form_Walklist_Walklist line 155. (suspect the select function should be removed in favour of the parent (state province field) also, type should be added to state province & others? & potentially getAddressColumns fn should be used per other reports', - 'contribute/repeat' => 'Reports with important functionality in postProcess are not callable via the api. For variable setting recommend beginPostProcessCommon, for temp table creation recommend From fn', - 'contribute/topDonor' => 'construction of query in postProcess makes inaccessible ', - 'contribute/sybunt' => 'e notice - (ui gives fatal error at civicrm/report/contribute/sybunt&reset=1&force=1 + 'contribute/repeat' => 'Reports with important functionality in postProcess are not callable via the api. For variable setting recommend beginPostProcessCommon, for temp table creation recommend From fn', + 'contribute/topDonor' => 'construction of query in postProcess makes inaccessible ', + 'contribute/sybunt' => 'e notice - (ui gives fatal error at civicrm/report/contribute/sybunt&reset=1&force=1 e-notice is on yid_valueContribute/Sybunt.php(214) because at the force url "yid_relative" not "yid_value" is defined', - 'contribute/lybunt' => 'same as sybunt - fatals on force url & test identifies why', - 'event/income' => 'I do no understand why but error is Call to undefined method CRM_Report_Form_Event_Income::from() in CRM/Report/Form.php on line 2120', - 'contact/relationship' => '(see contribute/repeat), property declaration issue, Undefined property: CRM_Report_Form_Contact_Relationship::$relationType in /Contact/Relationship.php(486):', - 'logging/contact/summary' => '(likely to be test related) probably logging off Undefined index: Form/Contact/LoggingSummary.php(231): PHP', - 'logging/contact/detail' => '(likely to be test related) probably logging off DB Error: no such table', - 'logging/contribute/summary' => '(likely to be test related) probably logging off DB Error: no such table', - 'logging/contribute/detail' => '(likely to be test related) probably logging off DB Error: no such table', - 'survey/detail' => '(likely to be test related) Undefined index: CiviCampaign civicrm CRM/Core/Component.php(196)', - 'contribute/history' => 'Declaration of CRM_Report_Form_Contribute_History::buildRows() should be compatible with CRM_Report_Form::buildRows($sql, &$rows)', + 'contribute/lybunt' => 'same as sybunt - fatals on force url & test identifies why', + 'event/income' => 'I do no understand why but error is Call to undefined method CRM_Report_Form_Event_Income::from() in CRM/Report/Form.php on line 2120', + 'contact/relationship' => '(see contribute/repeat), property declaration issue, Undefined property: CRM_Report_Form_Contact_Relationship::$relationType in /Contact/Relationship.php(486):', + 'logging/contact/summary' => '(likely to be test related) probably logging off Undefined index: Form/Contact/LoggingSummary.php(231): PHP', + 'logging/contact/detail' => '(likely to be test related) probably logging off DB Error: no such table', + 'logging/contribute/summary' => '(likely to be test related) probably logging off DB Error: no such table', + 'logging/contribute/detail' => '(likely to be test related) probably logging off DB Error: no such table', + 'survey/detail' => '(likely to be test related) Undefined index: CiviCampaign civicrm CRM/Core/Component.php(196)', + 'contribute/history' => 'Declaration of CRM_Report_Form_Contribute_History::buildRows() should be compatible with CRM_Report_Form::buildRows($sql, &$rows)', ); $reports = civicrm_api3('report_template', 'get', array('return' => 'value', 'options' => array('limit' => 500))); diff --git a/tests/phpunit/api/v3/SurveyTest.php b/tests/phpunit/api/v3/SurveyTest.php index d417856c96..bb97263ba4 100644 --- a/tests/phpunit/api/v3/SurveyTest.php +++ b/tests/phpunit/api/v3/SurveyTest.php @@ -31,8 +31,8 @@ require_once 'CiviTest/CiviUnitTestCase.php'; /** * Test APIv3 civicrm_survey_* functions * - * @package CiviCRM_APIv3 - * @subpackage API_Campaign + * @package CiviCRM_APIv3 + * @subpackage API_Campaign */ require_once 'CiviTest/CiviUnitTestCase.php'; @@ -55,7 +55,10 @@ class api_v3_SurveyTest extends CiviUnitTestCase { public function setUp() { - $phoneBankActivityTypeID = $this->callAPISuccessGetValue('Option_value', array('label' => 'PhoneBank', 'return' => 'value'), 'integer'); + $phoneBankActivityTypeID = $this->callAPISuccessGetValue('Option_value', array( + 'label' => 'PhoneBank', + 'return' => 'value' + ), 'integer'); $this->useTransaction(); $this->enableCiviCampaign(); $this->params = array( @@ -104,8 +107,8 @@ class api_v3_SurveyTest extends CiviUnitTestCase { */ public function testGetSurveyChainDelete() { $description = "demonstrates get + delete in the same call"; - $subfile = 'ChainedGetDelete'; - $params = array( + $subfile = 'ChainedGetDelete'; + $params = array( 'title' => "survey title", 'api.survey.delete' => 1, ); diff --git a/tests/phpunit/api/v3/SyntaxConformanceTest.php b/tests/phpunit/api/v3/SyntaxConformanceTest.php index ec1cf5f49e..f1e8c5f493 100644 --- a/tests/phpunit/api/v3/SyntaxConformanceTest.php +++ b/tests/phpunit/api/v3/SyntaxConformanceTest.php @@ -39,7 +39,6 @@ require_once 'CiviTest/CiviUnitTestCase.php'; * @package CiviCRM_APIv3 * @subpackage API_Core */ - class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { protected $_apiversion = 3; @@ -76,9 +75,37 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { public function setUp() { parent::setUp(); $this->enableCiviCampaign(); - $this->toBeImplemented['get'] = array('Profile', 'CustomValue', 'Constant', 'CustomSearch', 'Extension', 'ReportTemplate', 'System', 'Setting'); - $this->toBeImplemented['create'] = array('SurveyRespondant', 'OptionGroup', 'MailingRecipients', 'UFMatch', 'LocationType', 'CustomSearch', 'Extension', 'ReportTemplate', 'System'); - $this->toBeImplemented['delete'] = array('MembershipPayment', 'OptionGroup', 'SurveyRespondant', 'UFJoin', 'UFMatch', 'Extension', 'LocationType', 'System'); + $this->toBeImplemented['get'] = array( + 'Profile', + 'CustomValue', + 'Constant', + 'CustomSearch', + 'Extension', + 'ReportTemplate', + 'System', + 'Setting' + ); + $this->toBeImplemented['create'] = array( + 'SurveyRespondant', + 'OptionGroup', + 'MailingRecipients', + 'UFMatch', + 'LocationType', + 'CustomSearch', + 'Extension', + 'ReportTemplate', + 'System' + ); + $this->toBeImplemented['delete'] = array( + 'MembershipPayment', + 'OptionGroup', + 'SurveyRespondant', + 'UFJoin', + 'UFMatch', + 'Extension', + 'LocationType', + 'System' + ); $this->onlyIDNonZeroCount['get'] = array('ActivityType', 'Entity', 'Domain', 'Setting'); $this->deprecatedAPI = array('Location', 'ActivityType', 'SurveyRespondant'); $this->deletableTestObjects = array(); @@ -153,6 +180,7 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { public static function entities_getSqlOperators() { return static::entities(static::toBeSkipped_getSqlOperators()); } + /** * @return array */ @@ -166,6 +194,7 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { public static function entities_getfields() { return static::entities(static::toBeSkipped_getfields(TRUE)); } + /** * @return array */ @@ -184,7 +213,8 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { $entitiesToFix = array('Case', 'Relationship'); foreach ($entities as $entityName => $entity) { if (!in_array($entityName, $invalidEntities) - && !in_array($entityName, $entitiesToFix)) { + && !in_array($entityName, $entitiesToFix) + ) { if (!empty(self::$componentMap[$entityName]) && empty($enabledComponents[self::$componentMap[$entityName]])) { CRM_Core_BAO_ConfigSetting::enableComponent(self::$componentMap[$entityName]); } @@ -200,7 +230,13 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { * @return array */ public static function toBeSkipped_get($sequential = FALSE) { - $entitiesWithoutGet = array('MailingEventSubscribe', 'MailingEventConfirm', 'MailingEventResubscribe', 'MailingEventUnsubscribe', 'Location'); + $entitiesWithoutGet = array( + 'MailingEventSubscribe', + 'MailingEventConfirm', + 'MailingEventResubscribe', + 'MailingEventUnsubscribe', + 'Location' + ); if ($sequential === TRUE) { return $entitiesWithoutGet; } @@ -248,7 +284,21 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { * @return array */ public static function toBeSkipped_delete($sequential = FALSE) { - $entitiesWithout = array('MailingContact', 'MailingEventConfirm', 'MailingEventResubscribe', 'MailingEventSubscribe', 'MailingEventUnsubscribe', 'MailingRecipients', 'Constant', 'Entity', 'Location', 'Domain', 'Profile', 'CustomValue', 'Setting'); + $entitiesWithout = array( + 'MailingContact', + 'MailingEventConfirm', + 'MailingEventResubscribe', + 'MailingEventSubscribe', + 'MailingEventUnsubscribe', + 'MailingRecipients', + 'Constant', + 'Entity', + 'Location', + 'Domain', + 'Profile', + 'CustomValue', + 'Setting' + ); if ($sequential === TRUE) { return $entitiesWithout; } @@ -276,6 +326,7 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { } return $entities; } + /** * Generate list of entities to test for get by id functions * @param bool $sequential @@ -283,7 +334,19 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { * Entities to be skipped */ public static function toBeSkipped_automock($sequential = FALSE) { - $entitiesWithoutGet = array('MailingContact', 'EntityTag', 'Participant', 'ParticipantPayment', 'Setting', 'SurveyRespondant', 'MailingRecipients', 'CustomSearch', 'Extension', 'ReportTemplate', 'System'); + $entitiesWithoutGet = array( + 'MailingContact', + 'EntityTag', + 'Participant', + 'ParticipantPayment', + 'Setting', + 'SurveyRespondant', + 'MailingRecipients', + 'CustomSearch', + 'Extension', + 'ReportTemplate', + 'System' + ); if ($sequential === TRUE) { return $entitiesWithoutGet; } @@ -300,7 +363,8 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { */ public static function toBeSkipped_updatesingle($sequential = FALSE) { $entitiesWithout = array( - 'Attachment', // pseudo-entity; testUpdateSingleValueAlter doesn't introspect properly on it. Multiple magic fields + 'Attachment', + // pseudo-entity; testUpdateSingleValueAlter doesn't introspect properly on it. Multiple magic fields 'Mailing', 'MailingGroup', 'MailingJob', @@ -353,7 +417,8 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { 'PaymentProcessor', 'Setting', 'MailingContact', - 'SystemLog' //skip this because it doesn't make sense to update logs, + 'SystemLog' + //skip this because it doesn't make sense to update logs, ); if ($sequential === TRUE) { return $entitiesWithout; @@ -373,12 +438,18 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { */ public static function toBeSkipped_getlimit() { $entitiesWithout = array( - 'Case', //case api has non-std mandatory fields one of (case_id, contact_id, activity_id, contact_id) - 'EntityTag', // non-standard api - has inappropriate mandatory fields & doesn't implement limit - 'Event', // failed 'check that a 5 limit returns 5' - probably is_template field is wrong or something, or could be limit doesn't work right - 'Extension', // can't handle creating 25 - 'Note', // fails on 5 limit - probably a set up problem - 'Setting', //a bit of a pseudoapi - keys by domain + 'Case', + //case api has non-std mandatory fields one of (case_id, contact_id, activity_id, contact_id) + 'EntityTag', + // non-standard api - has inappropriate mandatory fields & doesn't implement limit + 'Event', + // failed 'check that a 5 limit returns 5' - probably is_template field is wrong or something, or could be limit doesn't work right + 'Extension', + // can't handle creating 25 + 'Note', + // fails on 5 limit - probably a set up problem + 'Setting', + //a bit of a pseudoapi - keys by domain ); return $entitiesWithout; } @@ -414,7 +485,8 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { ), 'ActivityContact' => array( 'cant_update' => array( - 'activity_id', //we have an FK on activity_id + contact_id + record id so if we don't leave this one distinct we get an FK constraint error + 'activity_id', + //we have an FK on activity_id + contact_id + record id so if we don't leave this one distinct we get an FK constraint error ), ), 'Address' => array( @@ -547,6 +619,7 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { $this->assertEquals(1, $result['is_error'], 'In line ' . __LINE__); $this->assertContains("Mandatory key(s) missing from params array", $result['error_message']); } + /** * @dataProvider entities_get */ @@ -560,6 +633,7 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { $this->assertEquals(2000, $result['error_code']); $this->assertEquals('Input variable `params` is not an array', $result['error_message']); } + /** * @dataProvider entities_get * @Xdepends testEmptyParam_get // no need to test the simple if the empty doesn't work/is skipped. doesn't seem to work @@ -610,7 +684,7 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { // big random number. fun fact: if you multiply it by pi^e, the result is another random number, but bigger ;) $nonExistantID = 30867307034; if (in_array($Entity, $this->toBeImplemented['get']) - || in_array($Entity, $this->toBeSkipped_getByID()) + || in_array($Entity, $this->toBeSkipped_getByID()) ) { return; } @@ -788,6 +862,7 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { $this->assertEquals($limit, count($result['values']), $message); } } + /** * Create two entities and make sure we can fetch them individually by ID (e.g. using "contact_id=>2" * or "group_id=>4") @@ -952,10 +1027,10 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { $valuesNotToReturn = $this->getKnownUnworkablesUpdateSingle($entityName, 'break_return'); // these can't be requested as return values $entityValuesThatDoNotWork = array_merge( - $this->getKnownUnworkablesUpdateSingle($entityName, 'cant_update'), - $this->getKnownUnworkablesUpdateSingle($entityName, 'cant_return'), - $valuesNotToReturn - ); + $this->getKnownUnworkablesUpdateSingle($entityName, 'cant_update'), + $this->getKnownUnworkablesUpdateSingle($entityName, 'cant_return'), + $valuesNotToReturn + ); $return = array_diff($return, $valuesNotToReturn); $baoObj = new CRM_Core_DAO(); @@ -982,7 +1057,8 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { $fieldName = $specs['uniquename']; } if ($field == 'currency' || $field == 'id' || $field == strtolower($entityName) . '_id' - || in_array($field, $entityValuesThatDoNotWork)) { + || in_array($field, $entityValuesThatDoNotWork) + ) { //@todo id & entity_id are correct but we should fix currency & frequency_day continue; } @@ -1052,8 +1128,14 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { if (empty($options['values'])) { //eg. pdf_format id doesn't ship with any if (isset($specs['pseudoconstant']['optionGroupName'])) { - $optionGroupID = $this->callAPISuccess('option_group', 'getvalue', array('name' => 'pdf_format', 'return' => 'id')); - $optionValue = $this->callAPISuccess('option_value', 'create', array('option_group_id' => $optionGroupID, 'label' => 'new option value')); + $optionGroupID = $this->callAPISuccess('option_group', 'getvalue', array( + 'name' => 'pdf_format', + 'return' => 'id' + )); + $optionValue = $this->callAPISuccess('option_value', 'create', array( + 'option_group_id' => $optionGroupID, + 'label' => 'new option value' + )); $options['values'][] = $optionValue['id']; } } @@ -1080,7 +1162,13 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { ); $checkEntity = $this->callAPISuccess($entityName, 'getsingle', $checkParams); - $this->assertAPIArrayComparison($entity, $checkEntity, array(), "checking if $fieldName was correctly updated\n" . print_r(array('update-params' => $updateParams, 'update-result' => $update, 'getsingle-params' => $checkParams, 'getsingle-result' => $checkEntity, 'expected entity' => $entity), TRUE)); + $this->assertAPIArrayComparison($entity, $checkEntity, array(), "checking if $fieldName was correctly updated\n" . print_r(array( + 'update-params' => $updateParams, + 'update-result' => $update, + 'getsingle-params' => $checkParams, + 'getsingle-result' => $checkEntity, + 'expected entity' => $entity + ), TRUE)); if ($resetFKTo) { //reset the foreign key fields because otherwise our cleanup routine fails & some other unexpected stuff can kick in $entity = array_merge($entity, $resetFKTo); @@ -1131,6 +1219,7 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { $this->assertEquals(1, $result['is_error'], 'In line ' . __LINE__); $this->assertContains("Mandatory key(s) missing from params array", $result['error_message']); } + /** * @dataProvider entities_delete */ @@ -1144,6 +1233,7 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { } $result = $this->callAPIFailure($Entity, 'Delete', array('id' => 999)); } + /** * @dataProvider entities */ @@ -1209,7 +1299,7 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { } $actions = $this->callAPISuccess($entity, 'getactions', array()); foreach ($actions['values'] as $action) { - if (substr($action, -7) == '_create' || substr($action, -4) == '_get' || substr($action, -7) == '_delete') { + 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; } @@ -1240,6 +1330,7 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { } return $returnEntities; } + /** * @param string $entityName * @param int $count diff --git a/tests/phpunit/api/v3/SystemTest.php b/tests/phpunit/api/v3/SystemTest.php index 66b4e788c0..cf73f07b2d 100644 --- a/tests/phpunit/api/v3/SystemTest.php +++ b/tests/phpunit/api/v3/SystemTest.php @@ -75,9 +75,9 @@ class api_v3_SystemTest extends CiviUnitTestCase { public function testSystemLog() { $this->callAPISuccess('system', 'log', array('level' => 'info', 'message' => 'We wish you a merry Christmas')); $result = $this->callAPISuccess('SystemLog', 'getsingle', array( - 'sequential' => 1, - 'message' => array('LIKE' => '%Chris%'), - )); + 'sequential' => 1, + 'message' => array('LIKE' => '%Chris%'), + )); $this->assertEquals($result['message'], 'We wish you a merry Christmas'); $this->assertEquals($result['level'], 'info'); } diff --git a/tests/phpunit/api/v3/TagTest.php b/tests/phpunit/api/v3/TagTest.php index b78b445ae2..4f72a7e80d 100644 --- a/tests/phpunit/api/v3/TagTest.php +++ b/tests/phpunit/api/v3/TagTest.php @@ -34,7 +34,6 @@ require_once 'CiviTest/CiviUnitTestCase.php'; * @package CiviCRM_APIv3 * @subpackage API_Core */ - class api_v3_TagTest extends CiviUnitTestCase { protected $_apiversion = 3; /** @@ -84,7 +83,7 @@ class api_v3_TagTest extends CiviUnitTestCase { */ public function testGetReturnArray() { $description = "demonstrates use of Return as an array"; - $subfile = "getReturnArray"; + $subfile = "getReturnArray"; $params = array( 'id' => $this->tagID, @@ -184,8 +183,8 @@ class api_v3_TagTest extends CiviUnitTestCase { public function testTagGetfields() { $description = "demonstrate use of getfields to interrogate api"; - $params = array('action' => 'create'); - $result = $this->callAPIAndDocument('tag', 'getfields', $params, __FUNCTION__, __FILE__, $description, NULL, 'getfields'); + $params = array('action' => 'create'); + $result = $this->callAPIAndDocument('tag', 'getfields', $params, __FUNCTION__, __FILE__, $description, NULL, 'getfields'); $this->assertEquals('civicrm_contact', $result['values']['used_for']['api.default']); } diff --git a/tests/phpunit/api/v3/TaxContributionPageTest.php b/tests/phpunit/api/v3/TaxContributionPageTest.php index 8752a257ba..5ff39b9dbb 100644 --- a/tests/phpunit/api/v3/TaxContributionPageTest.php +++ b/tests/phpunit/api/v3/TaxContributionPageTest.php @@ -336,6 +336,7 @@ class api_v3_TaxContributionPageTest extends CiviUnitTestCase { $this->assertEquals($contribution['values'][$contribution['id']]['contribution_status_id'], 2, 'In line ' . __LINE__); $this->_checkFinancialRecords($contribution, 'payLater'); } + public function testCreateContributionPendingOnline() { $this->setUpContributionPage(); $params = array( @@ -372,7 +373,7 @@ class api_v3_TaxContributionPageTest extends CiviUnitTestCase { 'contact_id' => $this->_individualId, 'receive_date' => '20120511', 'total_amount' => 100.00, - 'financial_type_id' => $this->financialtypeID, + 'financial_type_id' => $this->financialtypeID, 'source' => 'SSF', 'contribution_status_id' => 1, ); @@ -388,7 +389,7 @@ class api_v3_TaxContributionPageTest extends CiviUnitTestCase { $this->assertEquals('120.00', $trxnAmount); $newParams = array( 'id' => $contribution['id'], - 'financial_type_id' => 1, // without tax rate i.e Donation + 'financial_type_id' => 1, // without tax rate i.e Donation 'total_amount' => '300', ); $contribution = $this->callAPISuccess('contribution', 'update', $newParams); @@ -510,8 +511,8 @@ class api_v3_TaxContributionPageTest extends CiviUnitTestCase { $accountRel = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Income Account is' ")); $searchParams = array( - 'entity_table' => 'civicrm_financial_type', - 'entity_id' => $financialTypeId, + 'entity_table' => 'civicrm_financial_type', + 'entity_id' => $financialTypeId, 'account_relationship' => $accountRel, ); diff --git a/tests/phpunit/api/v3/UFFieldTest.php b/tests/phpunit/api/v3/UFFieldTest.php index 31f85c8252..03a84e3265 100644 --- a/tests/phpunit/api/v3/UFFieldTest.php +++ b/tests/phpunit/api/v3/UFFieldTest.php @@ -114,6 +114,7 @@ class api_v3_UFFieldTest extends CiviUnitTestCase { $this->callAPIFailure('uf_field', 'create', array('field_name' => 'test field')); $this->callAPIFailure('uf_field', 'create', array('label' => 'name-less field')); } + /** * Create a field with 'weight=1' and then a second with 'weight=1'. The second field * winds up with weight=1, and the first field gets bumped to 'weight=2'. diff --git a/tests/phpunit/api/v3/UFGroupTest.php b/tests/phpunit/api/v3/UFGroupTest.php index a611172006..4e77db76af 100644 --- a/tests/phpunit/api/v3/UFGroupTest.php +++ b/tests/phpunit/api/v3/UFGroupTest.php @@ -49,7 +49,7 @@ class api_v3_UFGroupTest extends CiviUnitTestCase { $this->createLoggedInUser(); $ufGroup = $this->callAPISuccess('uf_group', 'create', array( 'group_type' => 'Contact', - 'help_pre' => 'Profile to Test API', + 'help_pre' => 'Profile to Test API', 'title' => 'Test Profile', )); $this->_ufGroupId = $ufGroup['id']; @@ -105,7 +105,7 @@ class api_v3_UFGroupTest extends CiviUnitTestCase { 'help_post' => 'Profile Pro help text.', 'is_active' => 1, 'id' => $this->_ufGroupId, - ); + ); $result = $this->callAPISuccess('uf_group', 'create', $params); foreach ($params as $key => $value) { @@ -160,7 +160,8 @@ class api_v3_UFGroupTest extends CiviUnitTestCase { 'name' => 'test_group', 'notify' => 'admin@example.org', 'post_URL' => 'http://example.org/post', - 'title' => 'Test Group',); + 'title' => 'Test Group', + ); $result = $this->callAPISuccess('uf_group', 'create', $params); $params['created_date'] = date('YmdHis', strtotime($params['created_date'])); foreach ($params as $key => $value) { diff --git a/tests/phpunit/api/v3/UFJoinTest.php b/tests/phpunit/api/v3/UFJoinTest.php index 1a9c09acdd..50ea902262 100644 --- a/tests/phpunit/api/v3/UFJoinTest.php +++ b/tests/phpunit/api/v3/UFJoinTest.php @@ -26,8 +26,6 @@ */ - - require_once 'CiviTest/CiviUnitTestCase.php'; /** @@ -86,12 +84,14 @@ class api_v3_UFJoinTest extends CiviUnitTestCase { 'entity_id' => 1, 'weight' => 1, 'uf_group_id' => $this->_ufGroupId, - 'is_active' => 1,); + 'is_active' => 1, + ); $ufJoin = $this->callAPISuccess('uf_join', 'create', $params); $searchParams = array( 'entity_table' => 'civicrm_contribution_page', - 'entity_id' => 1,); + 'entity_id' => 1, + ); $result = $this->callAPISuccess('uf_join', 'get', $searchParams); foreach ($result['values'] as $key => $value) { @@ -118,7 +118,8 @@ class api_v3_UFJoinTest extends CiviUnitTestCase { 'entity_table' => 'civicrm_contribution_page', 'entity_id' => 1, 'weight' => 1, - 'is_active' => 1,); + 'is_active' => 1, + ); $result = $this->callAPIFailure('uf_join', 'create', $params); $this->assertEquals($result['error_message'], 'Mandatory key(s) missing from params array: uf_group_id', 'In line ' . __LINE__); } @@ -134,7 +135,7 @@ class api_v3_UFJoinTest extends CiviUnitTestCase { 'weight' => 1, 'uf_group_id' => $this->_ufGroupId, 'is_active' => 1, - 'sequential' => 1, + 'sequential' => 1, ); $ufJoin = $this->callAPIAndDocument('uf_join', 'create', $params, __FUNCTION__, __FILE__); $this->assertEquals($ufJoin['values'][0]['module'], $params['module'], 'In line ' . __LINE__); @@ -149,7 +150,7 @@ class api_v3_UFJoinTest extends CiviUnitTestCase { 'weight' => 1, 'uf_group_id' => $this->_ufGroupId, 'is_active' => 0, - 'sequential' => 1, + 'sequential' => 1, ); $ufJoinUpdated = $this->callAPISuccess('uf_join', 'create', $params); $this->assertEquals($ufJoinUpdated['values'][0]['module'], $params['module'], 'In line ' . __LINE__); @@ -191,13 +192,14 @@ class api_v3_UFJoinTest extends CiviUnitTestCase { 'entity_id' => 1, 'weight' => 1, 'uf_group_id' => $this->_ufGroupId, - 'is_active' => 1,); + 'is_active' => 1, + ); $ufJoin = $this->callAPISuccess('uf_join', 'create', $params); $searchParams = array( 'entity_table' => 'civicrm_contribution_page', 'entity_id' => 1, - 'sequential' => 1, + 'sequential' => 1, ); $result = $this->callAPIAndDocument('uf_join', 'get', $searchParams, __FUNCTION__, __FILE__); diff --git a/tests/phpunit/api/v3/UFMatchTest.php b/tests/phpunit/api/v3/UFMatchTest.php index 2c0952caee..30432e32f9 100644 --- a/tests/phpunit/api/v3/UFMatchTest.php +++ b/tests/phpunit/api/v3/UFMatchTest.php @@ -26,8 +26,6 @@ */ - - require_once 'CiviTest/CiviUnitTestCase.php'; /** @@ -45,7 +43,6 @@ class api_v3_UFMatchTest extends CiviUnitTestCase { protected $_params = array(); - protected function setUp() { parent::setUp(); $this->_apiversion = 3; @@ -70,7 +67,7 @@ class api_v3_UFMatchTest extends CiviUnitTestCase { 'uf_id' => '2', 'uf_name' => 'blahdyblah@gmail.com', 'domain_id' => 1, - ); + ); } public function tearDown() { @@ -136,13 +133,13 @@ class api_v3_UFMatchTest extends CiviUnitTestCase { public function testDelete() { $result = $this->callAPISuccess('uf_match', 'create', $this->_params); $this->assertEquals(1, $this->callAPISuccess('uf_match', 'getcount', array( - 'id' => $result['id'], - ))); + 'id' => $result['id'], + ))); $this->callAPISuccess('uf_match', 'delete', array( - 'id' => $result['id'], + 'id' => $result['id'], )); $this->assertEquals(0, $this->callAPISuccess('uf_match', 'getcount', array( - 'id' => $result['id'], - ))); + 'id' => $result['id'], + ))); } } diff --git a/tests/phpunit/api/v3/UtilsTest.php b/tests/phpunit/api/v3/UtilsTest.php index 84e0d089fe..ccf59b074e 100644 --- a/tests/phpunit/api/v3/UtilsTest.php +++ b/tests/phpunit/api/v3/UtilsTest.php @@ -79,7 +79,7 @@ class api_v3_UtilsTest extends CiviUnitTestCase { $config->userPermissionClass->permissions = array('access CiviCRM'); $this->runPermissionCheck('contact', 'create', $check, TRUE); } - catch(Exception $e) { + catch (Exception $e) { $message = $e->getMessage(); } $this->assertEquals($message, 'API permission check failed for contact/create call; insufficient permission: require access CiviCRM and add contacts', 'lacking permissions should throw an exception'); @@ -145,7 +145,7 @@ class api_v3_UtilsTest extends CiviUnitTestCase { try { $result = civicrm_api3_verify_mandatory($params, 'CRM_Core_BAO_Note', array('note', 'subject')); } - catch(Exception $expected) { + catch (Exception $expected) { $this->assertEquals('Mandatory key(s) missing from params array: entity_id, note, subject', $expected->getMessage()); return; } @@ -170,7 +170,7 @@ class api_v3_UtilsTest extends CiviUnitTestCase { try { $result = civicrm_api3_verify_one_mandatory($params, 'CRM_Core_BAO_Note', array('note', 'subject')); } - catch(Exception $expected) { + catch (Exception $expected) { $this->assertEquals('Mandatory key(s) missing from params array: entity_id, one of (note, subject)', $expected->getMessage()); return; } @@ -183,12 +183,19 @@ class api_v3_UtilsTest extends CiviUnitTestCase { */ public function testVerifyOneMandatoryOneSet() { _civicrm_api3_initialize(TRUE); - $params = array('version' => 3, 'entity_table' => 'civicrm_contact', 'note' => 'note', 'contact_id' => $this->_contactID, 'modified_date' => '2011-01-31', 'subject' => NULL); + $params = array( + 'version' => 3, + 'entity_table' => 'civicrm_contact', + 'note' => 'note', + 'contact_id' => $this->_contactID, + 'modified_date' => '2011-01-31', + 'subject' => NULL + ); try { civicrm_api3_verify_one_mandatory($params, NULL, array('note', 'subject')); } - catch(Exception$expected) { + catch (Exception$expected) { $this->fail('Exception raised when it shouldn\'t have been in line ' . __LINE__); } } @@ -243,7 +250,13 @@ class api_v3_UtilsTest extends CiviUnitTestCase { } public function test_civicrm_api3_validate_fields_membership() { - $params = array('start_date' => '2010-12-20', 'end_date' => '', 'membership_end_date' => '0', 'join_date' => '2010-12-20', 'membership_start_date' => '2010-12-20'); + $params = array( + 'start_date' => '2010-12-20', + 'end_date' => '', + 'membership_end_date' => '0', + 'join_date' => '2010-12-20', + 'membership_start_date' => '2010-12-20' + ); $fields = civicrm_api3('Membership', 'getfields', array('action' => 'get')); _civicrm_api3_validate_fields('Membership', 'get', $params, $fields['values']); $this->assertEquals('20101220000000', $params['start_date'], 'in line ' . __LINE__); @@ -256,8 +269,8 @@ class api_v3_UtilsTest extends CiviUnitTestCase { $params = array( 'registration_start_date' => 20080601, 'registration_end_date' => '2008-10-15', - 'start_date' => '2010-12-20', - 'end_date' => '', + 'start_date' => '2010-12-20', + 'end_date' => '', ); $fields = civicrm_api3('Event', 'getfields', array('action' => 'create')); _civicrm_api3_validate_fields('event', 'create', $params, $fields['values']); @@ -275,7 +288,7 @@ class api_v3_UtilsTest extends CiviUnitTestCase { $fields = civicrm_api3('Membership', 'getfields', array('action' => 'get')); _civicrm_api3_validate_fields('Membership', 'get', $params, $fields['values']); } - catch(Exception$expected) { + catch (Exception$expected) { $this->assertEquals('join_date is not a valid date: abc', $expected->getMessage()); } } diff --git a/tests/phpunit/api/v3/WebsiteTest.php b/tests/phpunit/api/v3/WebsiteTest.php index 765decd696..23fd4fab40 100644 --- a/tests/phpunit/api/v3/WebsiteTest.php +++ b/tests/phpunit/api/v3/WebsiteTest.php @@ -34,7 +34,6 @@ require_once 'CiviTest/CiviUnitTestCase.php'; * @package CiviCRM_APIv3 * @subpackage API_Contact */ - class api_v3_WebsiteTest extends CiviUnitTestCase { protected $_apiversion = 3; protected $params; @@ -47,9 +46,9 @@ class api_v3_WebsiteTest extends CiviUnitTestCase { parent::setUp(); $this->useTransaction(); - $this->_entity = 'website'; - $this->_contactID = $this->organizationCreate(); - $this->params = array( + $this->_entity = 'website'; + $this->_contactID = $this->organizationCreate(); + $this->params = array( 'contact_id' => $this->_contactID, 'url' => 'website.com', 'website_type_id' => 1, @@ -78,6 +77,7 @@ class api_v3_WebsiteTest extends CiviUnitTestCase { $checkDeleted = $this->callAPISuccess($this->_entity, 'get', array()); $this->assertEquals(0, $checkDeleted['count'], 'In line ' . __LINE__); } + public function testDeleteWebsiteInvalid() { $result = $this->callAPISuccess($this->_entity, 'create', $this->params); $deleteParams = array('id' => 600); @@ -85,16 +85,19 @@ class api_v3_WebsiteTest extends CiviUnitTestCase { $checkDeleted = $this->callAPISuccess($this->_entity, 'get', array()); $this->assertEquals(1, $checkDeleted['count'], 'In line ' . __LINE__); } + /** * Test retrieval of metadata */ public function testGetMetadata() { $result = $this->callAPIAndDocument($this->_entity, 'get', array( 'options' => array( - 'metadata' => array('fields'), - )), __FUNCTION__, __FILE__, 'Demonostrates returning field metadata', 'GetWithMetadata'); + 'metadata' => array('fields'), + ) + ), __FUNCTION__, __FILE__, 'Demonostrates returning field metadata', 'GetWithMetadata'); $this->assertEquals('Website', $result['metadata']['fields']['url']['title']); } + /** * Test retrieval of label metadata */ diff --git a/tests/phpunit/api/v3/settings/test.setting.php b/tests/phpunit/api/v3/settings/test.setting.php index 3f1edd1c5d..8df00223a5 100644 --- a/tests/phpunit/api/v3/settings/test.setting.php +++ b/tests/phpunit/api/v3/settings/test.setting.php @@ -59,4 +59,4 @@ return array( 'html_type' => 'Text', 'quick_form_type' => 'Element', ), - ); +); -- 2.25.1