From 39b959db2c4b46180f1a87b15862baa4806a732f Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sun, 7 Apr 2019 08:14:21 +1000 Subject: [PATCH] Update Unit test styling to cover the future coder version --- .../main.php | 2 +- .../main.php | 1 + .../main.php | 4 +- tests/phpunit/CRM/ACL/ListTest.php | 60 ++-- .../CRM/Activity/BAO/ActivityTargetTest.php | 1 - .../phpunit/CRM/Activity/BAO/ActivityTest.php | 13 +- .../phpunit/CRM/Activity/Form/SearchTest.php | 2 +- tests/phpunit/CRM/Batch/BAO/BatchTest.php | 2 +- tests/phpunit/CRM/Bridge/OG/DrupalTest.php | 1 + .../phpunit/CRM/Case/BAO/CaseTypeForkTest.php | 2 +- tests/phpunit/CRM/Case/BAO/CaseTypeTest.php | 20 +- tests/phpunit/CRM/Case/BAO/QueryTest.php | 6 +- .../CRM/Case/XMLProcessor/ProcessTest.php | 16 +- .../CRM/Contact/BAO/ActivitySearchTest.php | 1 - tests/phpunit/CRM/Contact/BAO/ContactTest.php | 3 +- .../CRM/Contact/BAO/GroupContactCacheTest.php | 1 - .../CRM/Contact/BAO/GroupContactTest.php | 1 - tests/phpunit/CRM/Contact/BAO/GroupTest.php | 3 +- .../CRM/Contact/BAO/IndividualTest.php | 6 +- tests/phpunit/CRM/Contact/BAO/QueryTest.php | 37 +- .../CRM/Contact/BAO/RelationshipTest.php | 6 +- .../Form/Search/Custom/FullTextTest.php | 47 ++- .../Contact/Form/Search/SearchContactTest.php | 2 +- .../CRM/Contact/Import/Parser/ContactTest.php | 7 +- tests/phpunit/CRM/Contact/SelectorTest.php | 93 +++-- .../CRM/Contribute/BAO/ContributionTest.php | 17 +- .../phpunit/CRM/Contribute/BAO/QueryTest.php | 1 + .../CRM/Contribute/Form/ContributionTest.php | 146 +++----- .../CRM/Contribute/Form/Task/InvoiceTest.php | 4 +- .../Form/Task/PDFLetterCommonTest.php | 3 - .../CRM/Contribute/Form/Task/StatusTest.php | 4 +- .../phpunit/CRM/Contribute/Form/TaskTest.php | 4 +- .../Import/Parser/ContributionTest.php | 2 + .../CRM/Core/BAO/ActionScheduleTest.php | 59 +-- tests/phpunit/CRM/Core/BAO/AddressTest.php | 1 + tests/phpunit/CRM/Core/BAO/CacheTest.php | 24 +- .../CRM/Core/BAO/ConfigSettingTest.php | 1 + .../phpunit/CRM/Core/BAO/CustomValueTest.php | 1 + tests/phpunit/CRM/Core/BAO/EmailTest.php | 1 + .../CRM/Core/BAO/FinancialTrxnTest.php | 4 +- tests/phpunit/CRM/Core/BAO/IMTest.php | 1 + tests/phpunit/CRM/Core/BAO/LocationTest.php | 15 +- tests/phpunit/CRM/Core/BAO/NavigationTest.php | 2 +- tests/phpunit/CRM/Core/BAO/OpenIDTest.php | 1 + .../phpunit/CRM/Core/BAO/OptionValueTest.php | 1 - .../CRM/Core/BAO/RecurringEntityTest.php | 3 +- tests/phpunit/CRM/Core/BAO/SettingTest.php | 4 +- tests/phpunit/CRM/Core/BAO/UFFieldTest.php | 24 +- .../CRM/Core/CodeGen/FreshnessTest.php | 27 +- .../CRM/Core/CommunityMessagesTest.php | 21 +- tests/phpunit/CRM/Core/Config/MailerTest.php | 12 +- .../CRM/Core/DAO/AllCoreTablesTest.php | 1 + tests/phpunit/CRM/Core/DAOConformanceTest.php | 3 +- tests/phpunit/CRM/Core/DAOTest.php | 6 +- tests/phpunit/CRM/Core/I18n/LocaleTest.php | 2 +- tests/phpunit/CRM/Core/I18n/SchemaTest.php | 2 +- tests/phpunit/CRM/Core/InnoDBIndexerTest.php | 7 +- .../phpunit/CRM/Core/ManagedEntitiesTest.php | 14 +- tests/phpunit/CRM/Core/MenuTest.php | 17 +- tests/phpunit/CRM/Core/OptionGroupTest.php | 2 - tests/phpunit/CRM/Core/Page/AJAXTest.php | 1 + tests/phpunit/CRM/Core/Page/RedirectTest.php | 1 + .../CRM/Core/Payment/AuthorizeNetIPNTest.php | 20 +- .../CRM/Core/Payment/AuthorizeNetTest.php | 2 +- .../phpunit/CRM/Core/Payment/BaseIPNTest.php | 13 +- .../CRM/Core/Payment/PayPalIPNTest.php | 24 +- .../CRM/Core/Payment/PayPalProIPNTest.php | 49 ++- tests/phpunit/CRM/Core/PseudoConstantTest.php | 30 +- tests/phpunit/CRM/Core/RegionTest.php | 1 + tests/phpunit/CRM/Core/ResourcesTest.php | 30 +- .../CRM/Core/Smarty/plugins/CrmMoneyTest.php | 3 +- .../CRM/Core/Smarty/plugins/CrmScopeTest.php | 1 + tests/phpunit/CRM/Core/TransactionTest.php | 84 +++-- tests/phpunit/CRM/Dedupe/MergerTest.php | 20 +- .../CRM/Event/BAO/AdditionalPaymentTest.php | 6 +- .../CRM/Event/BAO/ChangeFeeSelectionTest.php | 15 +- tests/phpunit/CRM/Event/BAO/QueryTest.php | 6 +- .../CRM/Event/Form/ParticipantTest.php | 7 +- .../Form/Registration/RegistrationTest.php | 1 - tests/phpunit/CRM/Export/BAO/ExportTest.php | 187 +++++----- tests/phpunit/CRM/Extension/BrowserTest.php | 1 + .../CRM/Extension/Container/BasicTest.php | 1 + .../Extension/Container/CollectionTest.php | 18 +- .../CRM/Extension/Container/StaticTest.php | 1 + tests/phpunit/CRM/Extension/InfoTest.php | 1 + .../CRM/Extension/Manager/ModuleTest.php | 15 +- .../CRM/Extension/Manager/ReportTest.php | 1 + .../CRM/Extension/Manager/SearchTest.php | 1 + tests/phpunit/CRM/Extension/ManagerTest.php | 25 +- tests/phpunit/CRM/Extension/MapperTest.php | 21 +- .../CRM/Financial/BAO/FinancialItemTest.php | 14 +- .../Financial/BAO/PaymentProcessorTest.php | 1 + .../Financial/Page/AjaxBatchSummaryTest.php | 1 + tests/phpunit/CRM/Group/Page/AjaxTest.php | 18 +- tests/phpunit/CRM/Logging/LoggingTest.php | 1 - tests/phpunit/CRM/Mailing/BAO/MailingTest.php | 7 +- .../CRM/Mailing/BaseMailingSystemTest.php | 27 +- tests/phpunit/CRM/Mailing/TokensTest.php | 1 + .../phpunit/CRM/Member/BAO/MembershipTest.php | 9 +- .../CRM/Member/Form/MembershipRenewalTest.php | 21 +- .../CRM/Member/Form/MembershipTest.php | 70 ++-- .../CRM/Member/StatusOverrideTypesTest.php | 2 +- .../CRM/Pledge/BAO/PledgePaymentTest.php | 21 +- tests/phpunit/CRM/Pledge/Form/SearchTest.php | 41 ++- tests/phpunit/CRM/Queue/RunnerTest.php | 17 +- .../CRM/Report/Form/ContactSummaryTest.php | 8 +- tests/phpunit/CRM/SMS/ProviderTest.php | 1 - .../phpunit/CRM/UF/Page/ProfileEditorTest.php | 1 + .../CRM/Upgrade/Incremental/BaseTest.php | 14 +- .../phpunit/CRM/Utils/API/MatchOptionTest.php | 14 +- .../CRM/Utils/API/ReloadOptionTest.php | 3 +- tests/phpunit/CRM/Utils/AddressTest.php | 9 +- tests/phpunit/CRM/Utils/ArrayTest.php | 18 +- .../phpunit/CRM/Utils/Cache/SqlGroupTest.php | 16 +- tests/phpunit/CRM/Utils/DateTest.php | 6 +- tests/phpunit/CRM/Utils/FileTest.php | 1 + tests/phpunit/CRM/Utils/HTMLTest.php | 49 ++- tests/phpunit/CRM/Utils/HookTest.php | 6 +- tests/phpunit/CRM/Utils/HtmlToTextTest.php | 3 +- tests/phpunit/CRM/Utils/ICalendarTest.php | 6 +- tests/phpunit/CRM/Utils/JSTest.php | 34 +- .../CRM/Utils/Mail/EmailProcessorTest.php | 7 +- .../phpunit/CRM/Utils/QueryFormatterTest.php | 11 +- tests/phpunit/CRM/Utils/RuleTest.php | 4 +- tests/phpunit/CRM/Utils/SQL/InsertTest.php | 1 + tests/phpunit/CRM/Utils/SQL/SelectTest.php | 1 + tests/phpunit/CRM/Utils/SignerTest.php | 12 +- tests/phpunit/CRM/Utils/StringTest.php | 3 +- tests/phpunit/CRM/Utils/SystemTest.php | 16 +- tests/phpunit/CRM/Utils/TimeTest.php | 4 +- .../phpunit/CRMTraits/ACL/PermissionTrait.php | 9 + tests/phpunit/CRMTraits/PCP/PCPTestTrait.php | 1 + .../phpunit/CRMTraits/Page/PageTestTrait.php | 2 +- tests/phpunit/Civi/API/KernelTest.php | 10 +- .../Subscriber/DynamicFKAuthorizationTest.php | 12 +- .../ActionSchedule/AbstractMappingTest.php | 5 +- tests/phpunit/Civi/Angular/ManagerTest.php | 2 +- .../Civi/CCase/SequenceListenerTest.php | 14 +- tests/phpunit/Civi/Core/ResolverTest.php | 5 +- .../Civi/Test/ExampleTransactionalTest.php | 2 +- .../phpunit/Civi/Token/TokenProcessorTest.php | 7 +- tests/phpunit/CiviTest/CiviCaseTestCase.php | 7 +- tests/phpunit/CiviTest/CiviReportTestCase.php | 1 + tests/phpunit/CiviTest/CiviTestSuite.php | 9 +- tests/phpunit/CiviTest/CiviUnitTestCase.php | 147 ++++---- tests/phpunit/E2E/Cache/TieredTest.php | 9 +- tests/phpunit/E2E/Cache/TwoInstancesTest.php | 7 +- tests/phpunit/E2E/Core/AssetBuilderTest.php | 1 - tests/phpunit/E2E/Core/PrevNextTest.php | 10 +- tests/phpunit/E2E/Extern/RestTest.php | 54 ++- tests/phpunit/E2E/Extern/SoapTest.php | 21 +- tests/phpunit/EnvTests.php | 1 + tests/phpunit/HelloTest.php | 7 +- tests/phpunit/api/v3/ACLPermissionTest.php | 16 +- tests/phpunit/api/v3/APIWrapperTest.php | 1 + tests/phpunit/api/v3/ActivityContactTest.php | 1 - tests/phpunit/api/v3/ActivityTest.php | 18 +- tests/phpunit/api/v3/AddressTest.php | 12 +- tests/phpunit/api/v3/AttachmentTest.php | 38 +- tests/phpunit/api/v3/CaseTest.php | 24 +- tests/phpunit/api/v3/CaseTypeTest.php | 4 +- tests/phpunit/api/v3/ContactTest.php | 83 ++--- tests/phpunit/api/v3/ContactTypeTest.php | 3 - tests/phpunit/api/v3/ContributionPageTest.php | 100 +++--- tests/phpunit/api/v3/ContributionSoftTest.php | 7 +- tests/phpunit/api/v3/ContributionTest.php | 336 ++++++++---------- tests/phpunit/api/v3/CountryTest.php | 1 - tests/phpunit/api/v3/CustomApiTest.php | 10 +- tests/phpunit/api/v3/CustomFieldTest.php | 15 +- .../api/v3/CustomValueContactTypeTest.php | 21 +- tests/phpunit/api/v3/DashboardContactTest.php | 11 +- tests/phpunit/api/v3/DomainTest.php | 48 +-- tests/phpunit/api/v3/EmailTest.php | 6 +- tests/phpunit/api/v3/EntityTagACLTest.php | 4 +- tests/phpunit/api/v3/EventTest.php | 30 +- tests/phpunit/api/v3/FinancialTypeACLTest.php | 3 - tests/phpunit/api/v3/GroupTest.php | 32 +- .../phpunit/api/v3/JobProcessMailingTest.php | 143 +++++--- tests/phpunit/api/v3/JobTest.php | 47 ++- .../phpunit/api/v3/JobTestCustomDataTest.php | 1 + tests/phpunit/api/v3/LoggingTest.php | 55 +-- tests/phpunit/api/v3/MailingABTest.php | 3 +- tests/phpunit/api/v3/MailingContactTest.php | 6 +- tests/phpunit/api/v3/MailingTest.php | 318 ++++++++++------- .../phpunit/api/v3/MembershipPaymentTest.php | 1 - tests/phpunit/api/v3/MembershipStatusTest.php | 2 - tests/phpunit/api/v3/MembershipTest.php | 19 +- tests/phpunit/api/v3/MessageTemplateTest.php | 5 +- tests/phpunit/api/v3/MultilingualTest.php | 9 +- tests/phpunit/api/v3/OptionGroupTest.php | 12 +- tests/phpunit/api/v3/OptionValueTest.php | 1 - tests/phpunit/api/v3/OrderTest.php | 9 +- .../phpunit/api/v3/ParticipantPaymentTest.php | 26 +- tests/phpunit/api/v3/ParticipantTest.php | 28 +- .../api/v3/PaymentProcessorTypeTest.php | 3 +- tests/phpunit/api/v3/PaymentTest.php | 6 +- tests/phpunit/api/v3/PcpTest.php | 3 +- tests/phpunit/api/v3/PhoneTest.php | 1 - tests/phpunit/api/v3/PledgePaymentTest.php | 4 - tests/phpunit/api/v3/PledgeTest.php | 5 - tests/phpunit/api/v3/ProfileTest.php | 146 ++++---- tests/phpunit/api/v3/RelationshipTest.php | 18 +- tests/phpunit/api/v3/ReportTemplateTest.php | 18 +- tests/phpunit/api/v3/SettingTest.php | 31 +- tests/phpunit/api/v3/StatusPreferenceTest.php | 1 - tests/phpunit/api/v3/SurveyRespondantTest.php | 1 - tests/phpunit/api/v3/SurveyTest.php | 7 +- .../phpunit/api/v3/SyntaxConformanceTest.php | 93 +++-- tests/phpunit/api/v3/SystemCheckTest.php | 1 - tests/phpunit/api/v3/TagTest.php | 3 + .../api/v3/TaxContributionPageTest.php | 3 +- tests/phpunit/api/v3/UFFieldTest.php | 5 +- tests/phpunit/api/v3/UFGroupTest.php | 5 +- tests/phpunit/api/v3/UFJoinTest.php | 6 +- tests/phpunit/api/v3/UFMatchTest.php | 6 +- tests/phpunit/api/v3/UtilsTest.php | 12 +- tests/phpunit/api/v3/ValidateTest.php | 1 + .../api/v3/custom_api/MailingProviderData.php | 13 +- tests/qunit/crm-translate/test.php | 17 +- 219 files changed, 2237 insertions(+), 1883 deletions(-) diff --git a/tests/extensions/test.extension.manager.paymenttest/main.php b/tests/extensions/test.extension.manager.paymenttest/main.php index dac3dc64e3..e6affe4bc9 100644 --- a/tests/extensions/test.extension.manager.paymenttest/main.php +++ b/tests/extensions/test.extension.manager.paymenttest/main.php @@ -5,7 +5,7 @@ */ class test_extension_manager_paymenttest extends CRM_Core_Payment { - static $counts = array(); + public static $counts = array(); public function install() { self::$counts['install'] = isset(self::$counts['install']) ? self::$counts['install'] : 0; diff --git a/tests/extensions/test.extension.manager.reporttest/main.php b/tests/extensions/test.extension.manager.reporttest/main.php index 66e29af22c..96d1b7657b 100644 --- a/tests/extensions/test.extension.manager.reporttest/main.php +++ b/tests/extensions/test.extension.manager.reporttest/main.php @@ -4,6 +4,7 @@ * Class test_extension_manager_reporttest */ class test_extension_manager_reporttest extends CRM_Core_Report { + /** * Class constructor. */ diff --git a/tests/extensions/test.extension.manager.searchtest/main.php b/tests/extensions/test.extension.manager.searchtest/main.php index 7ae801e52b..f1bcdcd6a1 100644 --- a/tests/extensions/test.extension.manager.searchtest/main.php +++ b/tests/extensions/test.extension.manager.searchtest/main.php @@ -6,6 +6,7 @@ require_once 'CRM/Contact/Form/Search/Custom/Base.php'; * Class test_extension_manager_searchtest */ class test_extension_manager_searchtest extends CRM_Contact_Form_Search_Custom_Base implements CRM_Contact_Form_Search_Interface { + /** * @param $formValues */ @@ -48,7 +49,8 @@ class test_extension_manager_searchtest extends CRM_Contact_Form_Search_Custom_B /** * Get a list of summary data points. * - * @return mixed; NULL or array with keys: + * @return mixed + * - NULL or array with keys: * - summary: string * - total: numeric */ diff --git a/tests/phpunit/CRM/ACL/ListTest.php b/tests/phpunit/CRM/ACL/ListTest.php index c7157d72b5..c9b78c76ef 100644 --- a/tests/phpunit/CRM/ACL/ListTest.php +++ b/tests/phpunit/CRM/ACL/ListTest.php @@ -28,7 +28,8 @@ class CRM_ACL_ListTest extends CiviUnitTestCase { $contacts = $this->createScenarioPlain(); // test WITH all permissions - CRM_Core_Config::singleton()->userPermissionClass->permissions = NULL; // NULL means 'all permissions' in UnitTests environment + // NULL means 'all permissions' in UnitTests environment + CRM_Core_Config::singleton()->userPermissionClass->permissions = NULL; $result = CRM_Contact_BAO_Contact_Permission::allowList($contacts); sort($result); $this->assertEquals($result, $contacts, "Contacts should be viewable when 'view all contacts'"); @@ -52,7 +53,6 @@ class CRM_ACL_ListTest extends CiviUnitTestCase { $this->assertEmpty($result, "Contacts should NOT be viewable when 'view all contacts' is not set"); } - /** * general test for the 'view all contacts' permission */ @@ -73,7 +73,6 @@ class CRM_ACL_ListTest extends CiviUnitTestCase { $this->assertEmpty($result, "Contacts should NOT be viewable when 'edit all contacts' is not set"); } - /** * Test access related to the 'access deleted contact' permission */ @@ -95,7 +94,6 @@ class CRM_ACL_ListTest extends CiviUnitTestCase { $this->assertEquals(count($result), count($contacts) - 1, "Only deleted contacts should be excluded"); } - /** * Test access based on relations * @@ -177,7 +175,6 @@ class CRM_ACL_ListTest extends CiviUnitTestCase { } } - /** * Test access based on ACL */ @@ -202,7 +199,6 @@ class CRM_ACL_ListTest extends CiviUnitTestCase { $this->assertContains($contacts[4], $result, "User[0] should NOT have an ACL permission on contact[4]."); } - /** * Test access with a mix of ACL and relationship */ @@ -285,10 +281,9 @@ class CRM_ACL_ListTest extends CiviUnitTestCase { } } - - /**************************************************** - * Scenario Builders * - ***************************************************/ + /* + * Scenario Builders + */ /** * create plain test scenario, no relationships/ACLs @@ -322,66 +317,79 @@ class CRM_ACL_ListTest extends CiviUnitTestCase { // create some relationships $this->callAPISuccess('Relationship', 'create', array( - 'relationship_type_id' => 1, // CHILD OF + // CHILD OF + 'relationship_type_id' => 1, 'contact_id_a' => $contacts[1], 'contact_id_b' => $contacts[0], 'is_permission_b_a' => 1, 'is_active' => 1, - )); + )); $this->callAPISuccess('Relationship', 'create', array( - 'relationship_type_id' => 1, // CHILD OF + // CHILD OF + 'relationship_type_id' => 1, 'contact_id_a' => $contacts[2], 'contact_id_b' => $contacts[1], 'is_permission_b_a' => 1, 'is_active' => 1, - )); + )); $this->callAPISuccess('Relationship', 'create', array( - 'relationship_type_id' => 1, // CHILD OF + // CHILD OF + 'relationship_type_id' => 1, 'contact_id_a' => $contacts[4], 'contact_id_b' => $contacts[2], 'is_permission_b_a' => 1, 'is_active' => 1, - )); + )); $this->callAPISuccess('Relationship', 'create', array( - 'relationship_type_id' => 4, // SIBLING OF + // SIBLING OF + 'relationship_type_id' => 4, 'contact_id_a' => $contacts[5], 'contact_id_b' => $contacts[0], - 'is_permission_b_a' => 2, // View + // View + 'is_permission_b_a' => 2, 'is_active' => 1, )); $this->callAPISuccess('Relationship', 'create', array( - 'relationship_type_id' => 1, // CHILD OF + // CHILD OF + 'relationship_type_id' => 1, 'contact_id_a' => $contacts[6], 'contact_id_b' => $contacts[5], - 'is_permission_b_a' => 1, // Edit + // Edit + 'is_permission_b_a' => 1, 'is_active' => 1, )); $this->callAPISuccess('Relationship', 'create', array( - 'relationship_type_id' => 1, // CHILD OF + // CHILD OF + 'relationship_type_id' => 1, 'contact_id_a' => $contacts[7], 'contact_id_b' => $contacts[5], - 'is_permission_b_a' => 2, // View + // View + 'is_permission_b_a' => 2, 'is_active' => 1, )); $this->callAPISuccess('Relationship', 'create', array( - 'relationship_type_id' => 4, // SIBLING OF + // SIBLING OF + 'relationship_type_id' => 4, 'contact_id_a' => $contacts[0], 'contact_id_b' => $contacts[8], - 'is_permission_a_b' => 1, // edit (as a_b) + // edit (as a_b) + 'is_permission_a_b' => 1, 'is_active' => 1, )); $this->callAPISuccess('Relationship', 'create', array( - 'relationship_type_id' => 1, // CHILD OF + // CHILD OF + 'relationship_type_id' => 1, 'contact_id_a' => $contacts[9], 'contact_id_b' => $contacts[8], - 'is_permission_b_a' => 2, // view + // view + 'is_permission_b_a' => 2, 'is_active' => 1, )); diff --git a/tests/phpunit/CRM/Activity/BAO/ActivityTargetTest.php b/tests/phpunit/CRM/Activity/BAO/ActivityTargetTest.php index 39e9df34f7..09330c5fbd 100644 --- a/tests/phpunit/CRM/Activity/BAO/ActivityTargetTest.php +++ b/tests/phpunit/CRM/Activity/BAO/ActivityTargetTest.php @@ -55,7 +55,6 @@ class CRM_Activity_BAO_ActivityTargetTest extends CiviUnitTestCase { $this->assertSame($target, array(), 'No targets returned'); } - public function testRetrieveTargetIdsByActivityIdOneID() { $activity = $this->activityCreate(); diff --git a/tests/phpunit/CRM/Activity/BAO/ActivityTest.php b/tests/phpunit/CRM/Activity/BAO/ActivityTest.php index 51b3dcd4de..1f49256bb8 100644 --- a/tests/phpunit/CRM/Activity/BAO/ActivityTest.php +++ b/tests/phpunit/CRM/Activity/BAO/ActivityTest.php @@ -5,6 +5,7 @@ * @group headless */ class CRM_Activity_BAO_ActivityTest extends CiviUnitTestCase { + public function setUp() { parent::setUp(); $this->prepareForACLs(); @@ -343,7 +344,8 @@ class CRM_Activity_BAO_ActivityTest extends CiviUnitTestCase { 'caseId' => NULL, 'context' => 'home', 'activity_type_id' => NULL, - 'activity_status_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'status_id', 'Scheduled'), // for dashlet the Scheduled status is set by default + // for dashlet the Scheduled status is set by default + 'activity_status_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'status_id', 'Scheduled'), 'offset' => 0, 'rowCount' => 0, 'sort' => NULL, @@ -513,7 +515,8 @@ class CRM_Activity_BAO_ActivityTest extends CiviUnitTestCase { 'caseId' => NULL, 'context' => 'home', 'activity_type_id' => NULL, - 'activity_status_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'status_id', 'Scheduled'), // for dashlet the Scheduled status is set by default + // for dashlet the Scheduled status is set by default + 'activity_status_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'status_id', 'Scheduled'), 'offset' => 0, 'rowCount' => 0, 'sort' => NULL, @@ -958,7 +961,7 @@ class CRM_Activity_BAO_ActivityTest extends CiviUnitTestCase { 'count' => 2, 'earliest' => strtotime('first day of january last year'), 'latest' => strtotime('first day of january this year'), - ] + ], ], ]; } @@ -1040,7 +1043,8 @@ class CRM_Activity_BAO_ActivityTest extends CiviUnitTestCase { 'caseId' => NULL, 'context' => 'home', 'activity_type_id' => NULL, - 'activity_status_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'status_id', 'Scheduled'), // for dashlet the Scheduled status is set by default + // for dashlet the Scheduled status is set by default + 'activity_status_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'status_id', 'Scheduled'), 'offset' => 0, 'rowCount' => 0, 'sort' => NULL, @@ -1239,7 +1243,6 @@ $text $this->assertEquals(0, $success, "Expected success to be 0"); } - /** * @param int $phoneType (0=no phone, phone_type option group (1=fixed, 2=mobile) * @param bool $passPhoneTypeInContactDetails diff --git a/tests/phpunit/CRM/Activity/Form/SearchTest.php b/tests/phpunit/CRM/Activity/Form/SearchTest.php index 9061313f1f..e5ec443e98 100644 --- a/tests/phpunit/CRM/Activity/Form/SearchTest.php +++ b/tests/phpunit/CRM/Activity/Form/SearchTest.php @@ -116,7 +116,7 @@ class CRM_Activity_Form_SearchTest extends CiviUnitTestCase { ], [ 'search_criteria' => [ - ['activity_status_id', '=', ['IN' => ['1', '2']], 0, 0] + ['activity_status_id', '=', ['IN' => ['1', '2']], 0, 0], ], 'expected_qill' => [['Activity Status In Scheduled, Completed']], ], diff --git a/tests/phpunit/CRM/Batch/BAO/BatchTest.php b/tests/phpunit/CRM/Batch/BAO/BatchTest.php index 7a9631ac93..1e7b4664e9 100644 --- a/tests/phpunit/CRM/Batch/BAO/BatchTest.php +++ b/tests/phpunit/CRM/Batch/BAO/BatchTest.php @@ -66,7 +66,7 @@ class CRM_Batch_BAO_BatchTest extends CiviUnitTestCase { ]); $this->contributionCreate([ 'contact_id' => $contactId, - 'total_amount' => 1, + 'total_amount' => 1, 'payment_instrument_id' => 'Credit Card', 'financial_type_id' => 'Member Dues', 'contribution_status_id' => 'Completed', diff --git a/tests/phpunit/CRM/Bridge/OG/DrupalTest.php b/tests/phpunit/CRM/Bridge/OG/DrupalTest.php index 566f8820db..fdbda50049 100644 --- a/tests/phpunit/CRM/Bridge/OG/DrupalTest.php +++ b/tests/phpunit/CRM/Bridge/OG/DrupalTest.php @@ -41,6 +41,7 @@ require_once 'api/api.php'; * @group headless */ class CRM_Bridge_OG_DrupalTest extends CiviUnitTestCase { + /** * Test that one (ane only one) role (option value) is deleted by the updateCiviACLRole function */ diff --git a/tests/phpunit/CRM/Case/BAO/CaseTypeForkTest.php b/tests/phpunit/CRM/Case/BAO/CaseTypeForkTest.php index 21f0c46eb6..caa23c93d3 100644 --- a/tests/phpunit/CRM/Case/BAO/CaseTypeForkTest.php +++ b/tests/phpunit/CRM/Case/BAO/CaseTypeForkTest.php @@ -6,6 +6,7 @@ * @group headless */ class CRM_Case_BAO_CaseTypeForkTest extends CiviCaseTestCase { + public function setUp() { parent::setUp(); CRM_Core_ManagedEntities::singleton(TRUE)->reconcile(); @@ -41,7 +42,6 @@ class CRM_Case_BAO_CaseTypeForkTest extends CiviCaseTestCase { $this->assertEquals($relTypeID, $xmlProcessor->getCaseManagerRoleId('ForkableCaseType')); } - /** * Edit the definition of ForkableCaseType. */ diff --git a/tests/phpunit/CRM/Case/BAO/CaseTypeTest.php b/tests/phpunit/CRM/Case/BAO/CaseTypeTest.php index d0f8bed73d..b83fac0cca 100644 --- a/tests/phpunit/CRM/Case/BAO/CaseTypeTest.php +++ b/tests/phpunit/CRM/Case/BAO/CaseTypeTest.php @@ -117,13 +117,13 @@ class CRM_Case_BAO_CaseTypeTest extends CiviUnitTestCase { $cases = array(); foreach (array( - 'empty-defn', - 'empty-lists', - 'one-item-in-each', - 'two-items-in-each', - 'forkable-0', - 'forkable-1', - ) as $key) { + 'empty-defn', + 'empty-lists', + 'one-item-in-each', + 'two-items-in-each', + 'forkable-0', + 'forkable-1', + ) as $key) { $cases[] = array($key, $fixtures[$key]['json'], $fixtures[$key]['xml']); } return $cases; @@ -187,8 +187,10 @@ class CRM_Case_BAO_CaseTypeTest extends CiviUnitTestCase { */ public function normalizeXml($xml) { return trim( - preg_replace(":\n*<:", "\n<", // tags on new lines - preg_replace("/\n[\n ]+/", "\n", // no leading whitespace + // tags on new lines + preg_replace(":\n*<:", "\n<", + // no leading whitespace + preg_replace("/\n[\n ]+/", "\n", $xml ) ) diff --git a/tests/phpunit/CRM/Case/BAO/QueryTest.php b/tests/phpunit/CRM/Case/BAO/QueryTest.php index 9bef8b6b02..3543366524 100644 --- a/tests/phpunit/CRM/Case/BAO/QueryTest.php +++ b/tests/phpunit/CRM/Case/BAO/QueryTest.php @@ -59,9 +59,9 @@ class CRM_Case_BAO_QueryTest extends CiviUnitTestCase { $queryObj = new CRM_Contact_BAO_Query($params, NULL, NULL, FALSE, FALSE, CRM_Contact_BAO_Query::MODE_CASE); $this->assertEquals(array( - 0 => 'Activity Type = Contribution', - 1 => 'Activity Type = Scheduled', - 2 => 'Activity Medium = In Person', + 0 => 'Activity Type = Contribution', + 1 => 'Activity Type = Scheduled', + 2 => 'Activity Medium = In Person', ), $queryObj->_qill[1] ); diff --git a/tests/phpunit/CRM/Case/XMLProcessor/ProcessTest.php b/tests/phpunit/CRM/Case/XMLProcessor/ProcessTest.php index 2d30c0bc82..53dcd83690 100644 --- a/tests/phpunit/CRM/Case/XMLProcessor/ProcessTest.php +++ b/tests/phpunit/CRM/Case/XMLProcessor/ProcessTest.php @@ -37,18 +37,18 @@ class CRM_Case_XMLProcessor_ProcessTest extends CiviCaseTestCase { */ protected function setupDefaultAssigneeOptions() { $options = [ - 'NONE', 'BY_RELATIONSHIP', 'SPECIFIC_CONTACT', 'USER_CREATING_THE_CASE' + 'NONE', 'BY_RELATIONSHIP', 'SPECIFIC_CONTACT', 'USER_CREATING_THE_CASE', ]; CRM_Core_BAO_OptionGroup::ensureOptionGroupExists([ - 'name' => 'activity_default_assignee' + 'name' => 'activity_default_assignee', ]); foreach ($options as $option) { $optionValue = CRM_Core_BAO_OptionValue::ensureOptionValueExists([ 'option_group_id' => 'activity_default_assignee', 'name' => $option, - 'label' => $option + 'label' => $option, ]); $this->defaultAssigneeOptionsValues[$option] = $optionValue['value']; @@ -65,19 +65,19 @@ class CRM_Case_XMLProcessor_ProcessTest extends CiviCaseTestCase { 'name_a_b' => 'Pupil of', 'name_b_a' => 'Instructor', 'contact_id_a' => $this->contacts['ana'], - 'contact_id_b' => $this->contacts['beto'] + 'contact_id_b' => $this->contacts['beto'], ], 'ana_is_spouse_of_carlos' => [ 'type_id' => NULL, 'name_a_b' => 'Spouse of', 'name_b_a' => 'Spouse of', 'contact_id_a' => $this->contacts['ana'], - 'contact_id_b' => $this->contacts['carlos'] + 'contact_id_b' => $this->contacts['carlos'], ], 'unassigned_employee' => [ 'type_id' => NULL, 'name_a_b' => 'Employee of', - 'name_b_a' => 'Employer' + 'name_b_a' => 'Employer', ], ]; @@ -88,7 +88,7 @@ class CRM_Case_XMLProcessor_ProcessTest extends CiviCaseTestCase { 'name_a_b' => $relationship['name_a_b'], 'label_a_b' => $relationship['name_a_b'], 'name_b_a' => $relationship['name_b_a'], - 'label_b_a' => $relationship['name_b_a'] + 'label_b_a' => $relationship['name_b_a'], ]); if (isset($relationship['contact_id_a'])) { @@ -231,7 +231,7 @@ class CRM_Case_XMLProcessor_ProcessTest extends CiviCaseTestCase { $expectedContact = $assigneeContactId === NULL ? [] : [$assigneeContactId]; $result = $this->callAPISuccess('Activity', 'get', [ 'target_contact_id' => $this->activityParams['clientID'], - 'return' => ['assignee_contact_id'] + 'return' => ['assignee_contact_id'], ]); $activity = CRM_Utils_Array::first($result['values']); diff --git a/tests/phpunit/CRM/Contact/BAO/ActivitySearchTest.php b/tests/phpunit/CRM/Contact/BAO/ActivitySearchTest.php index cfad097932..69a094ac6d 100644 --- a/tests/phpunit/CRM/Contact/BAO/ActivitySearchTest.php +++ b/tests/phpunit/CRM/Contact/BAO/ActivitySearchTest.php @@ -43,7 +43,6 @@ class CRM_Contact_BAO_ActivitySearchTest extends CiviUnitTestCase { protected $_params; protected $test_activity_type_value; - /** * Test setup for every test. * diff --git a/tests/phpunit/CRM/Contact/BAO/ContactTest.php b/tests/phpunit/CRM/Contact/BAO/ContactTest.php index 81998d865d..cc168dfeac 100644 --- a/tests/phpunit/CRM/Contact/BAO/ContactTest.php +++ b/tests/phpunit/CRM/Contact/BAO/ContactTest.php @@ -1550,7 +1550,8 @@ class CRM_Contact_BAO_ContactTest extends CiviUnitTestCase { $prevTimestamps = $origTimestamps; foreach ($callbacks as $callbackName => $callback) { - sleep(1); // advance clock by 1 second to ensure timestamps change + // advance clock by 1 second to ensure timestamps change + sleep(1); $callback($contactId); $newTimestamps = CRM_Contact_BAO_Contact::getTimestamps($contactId); diff --git a/tests/phpunit/CRM/Contact/BAO/GroupContactCacheTest.php b/tests/phpunit/CRM/Contact/BAO/GroupContactCacheTest.php index faf560bd73..b8af15bcba 100644 --- a/tests/phpunit/CRM/Contact/BAO/GroupContactCacheTest.php +++ b/tests/phpunit/CRM/Contact/BAO/GroupContactCacheTest.php @@ -486,7 +486,6 @@ class CRM_Contact_BAO_GroupContactCacheTest extends CiviUnitTestCase { $this->callAPISuccess('group', 'delete', ['id' => $group2->id]); } - public function testMultipleGroupWhereClause() { $returnProperties = array( 'contact_type' => 1, diff --git a/tests/phpunit/CRM/Contact/BAO/GroupContactTest.php b/tests/phpunit/CRM/Contact/BAO/GroupContactTest.php index 0a19579237..718a623249 100644 --- a/tests/phpunit/CRM/Contact/BAO/GroupContactTest.php +++ b/tests/phpunit/CRM/Contact/BAO/GroupContactTest.php @@ -192,7 +192,6 @@ class CRM_Contact_BAO_GroupContactTest extends CiviUnitTestCase { $this->callAPISuccess('Contact', 'delete', array('id' => $childSmartGroupContact)); } - /** * CRM-19698: Test case for combine contact search in regular and smart group */ diff --git a/tests/phpunit/CRM/Contact/BAO/GroupTest.php b/tests/phpunit/CRM/Contact/BAO/GroupTest.php index 481e9bca1a..b37d5ddb36 100644 --- a/tests/phpunit/CRM/Contact/BAO/GroupTest.php +++ b/tests/phpunit/CRM/Contact/BAO/GroupTest.php @@ -94,7 +94,8 @@ class CRM_Contact_BAO_GroupTest extends CiviUnitTestCase { 'name' => uniqid(), 'title' => 'Parent Group B', 'description' => 'Parent Group Two', - 'is_active' => 0, // disable + // disable + 'is_active' => 0, )); $group2 = CRM_Contact_BAO_Group::create($params); diff --git a/tests/phpunit/CRM/Contact/BAO/IndividualTest.php b/tests/phpunit/CRM/Contact/BAO/IndividualTest.php index 71938a96fc..9d70a7e2ae 100644 --- a/tests/phpunit/CRM/Contact/BAO/IndividualTest.php +++ b/tests/phpunit/CRM/Contact/BAO/IndividualTest.php @@ -58,8 +58,10 @@ class CRM_Contact_BAO_IndividualTest extends CiviUnitTestCase { 'contact_type' => 'Individual', 'first_name' => 'Ben', 'last_name' => 'Lee', - 'prefix_id' => 4, // this is the doctor - 'suffix_id' => 2, // and the doctor is a senior + // this is the doctor + 'prefix_id' => 4, + // and the doctor is a senior + 'suffix_id' => 2, ); $contact = new CRM_Contact_DAO_Contact(); diff --git a/tests/phpunit/CRM/Contact/BAO/QueryTest.php b/tests/phpunit/CRM/Contact/BAO/QueryTest.php index abbe151527..95ea92894a 100644 --- a/tests/phpunit/CRM/Contact/BAO/QueryTest.php +++ b/tests/phpunit/CRM/Contact/BAO/QueryTest.php @@ -78,10 +78,10 @@ class CRM_Contact_BAO_QueryTest 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, + )); $params = array( 0 => array( 0 => 'city-1', @@ -117,10 +117,10 @@ class CRM_Contact_BAO_QueryTest 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, + )); $params = array( 0 => array( 0 => 'city-1', @@ -242,7 +242,6 @@ class CRM_Contact_BAO_QueryTest extends CiviUnitTestCase { $resultDAO->fetch(); } - /** * CRM-14263 search builder failure with search profile & address in criteria. * @@ -252,16 +251,18 @@ class CRM_Contact_BAO_QueryTest extends CiviUnitTestCase { * @dataProvider getSearchProfileData * * @param array $params + * @param string $selectClause + * @param string $whereClause */ public function testSearchProfilePrimaryCityCRM14263($params, $selectClause, $whereClause) { $contactID = $this->individualCreate(); CRM_Core_Config::singleton()->defaultSearchProfileID = 1; $this->callAPISuccess('address', 'create', array( - 'contact_id' => $contactID, - 'city' => 'Cool CITY', - 'street_address' => 'Long STREET', - 'location_type_id' => 1, - )); + 'contact_id' => $contactID, + 'city' => 'Cool CITY', + 'street_address' => 'Long STREET', + 'location_type_id' => 1, + )); $returnProperties = array( 'contact_type' => 1, 'contact_sub_type' => 1, @@ -770,7 +771,7 @@ civicrm_relationship.is_active = 1 AND 'avg' => '$ 233.33', 'amount' => '$ 1,400.00', 'count' => 6, - ], + ], 'cancel' => [ 'count' => 2, 'amount' => '$ 100.00', @@ -822,13 +823,15 @@ civicrm_relationship.is_active = 1 AND */ public function testConvertFormValuesCRM21816() { $fv = array( - "member_end_date_relative" => "starting_2.month", // next 60 days + // next 60 days + "member_end_date_relative" => "starting_2.month", "member_end_date_low" => "20180101000000", "member_end_date_high" => "20180331235959", "membership_is_current_member" => "1", "member_is_primary" => "1", ); - $fv_orig = $fv; // $fv is modified by convertFormValues() + // $fv is modified by convertFormValues() + $fv_orig = $fv; $params = CRM_Contact_BAO_Query::convertFormValues($fv); // restructure for easier testing diff --git a/tests/phpunit/CRM/Contact/BAO/RelationshipTest.php b/tests/phpunit/CRM/Contact/BAO/RelationshipTest.php index 7a58b6d9a6..4ad1e34123 100644 --- a/tests/phpunit/CRM/Contact/BAO/RelationshipTest.php +++ b/tests/phpunit/CRM/Contact/BAO/RelationshipTest.php @@ -51,7 +51,7 @@ class CRM_Contact_BAO_RelationshipTest extends CiviUnitTestCase { $this->quickCleanup([ 'civicrm_relationship_type', 'civicrm_relationship', - 'civicrm_contact' + 'civicrm_contact', ]); parent::tearDown(); @@ -120,7 +120,7 @@ class CRM_Contact_BAO_RelationshipTest extends CiviUnitTestCase { $options = CRM_Contact_BAO_Relationship::buildRelationshipTypeOptions([ 'relationship_id' => (string) $relationship['id'], - 'contact_id' => $individual['id'] + 'contact_id' => $individual['id'], ]); // for this relationship only individual=>organization is possible @@ -132,7 +132,7 @@ class CRM_Contact_BAO_RelationshipTest extends CiviUnitTestCase { $this->assertNotContains($personToPersonReverseType, $options); $options = CRM_Contact_BAO_Relationship::buildRelationshipTypeOptions([ - 'contact_id' => $individual['id'] + 'contact_id' => $individual['id'], ]); // for this result we only know that "A" must be an individual diff --git a/tests/phpunit/CRM/Contact/Form/Search/Custom/FullTextTest.php b/tests/phpunit/CRM/Contact/Form/Search/Custom/FullTextTest.php index 7d84df4864..4bff5fb7f9 100644 --- a/tests/phpunit/CRM/Contact/Form/Search/Custom/FullTextTest.php +++ b/tests/phpunit/CRM/Contact/Form/Search/Custom/FullTextTest.php @@ -1,30 +1,29 @@ groupCreate([ 'group_type' => [ $groupTypes['Access Control'] => 1, - ] + ], ]); // Add random 5 contacts to a group. $this->groupContactCreate($groupId, 5); diff --git a/tests/phpunit/CRM/Contact/Import/Parser/ContactTest.php b/tests/phpunit/CRM/Contact/Import/Parser/ContactTest.php index e1312ea1d8..f6a4598d32 100644 --- a/tests/phpunit/CRM/Contact/Import/Parser/ContactTest.php +++ b/tests/phpunit/CRM/Contact/Import/Parser/ContactTest.php @@ -89,9 +89,9 @@ class CRM_Contact_Import_Parser_ContactTest extends CiviUnitTestCase { $this->assertEquals(CRM_Import_Parser::VALID, $parser->import(CRM_Import_Parser::DUPLICATE_UPDATE, $values), 'Return code from parser import was not as expected'); $this->callAPISuccess("Contact", "get", array( - "first_name" => "Alok", - "last_name" => "Patel", - "organization_name" => "Agileware", + "first_name" => "Alok", + "last_name" => "Patel", + "organization_name" => "Agileware", )); } @@ -272,7 +272,6 @@ class CRM_Contact_Import_Parser_ContactTest extends CiviUnitTestCase { $this->callAPISuccess('Contact', 'delete', array('id' => $contact['id'])); } - /** * Test that the import parser adds the address to the primary location. * diff --git a/tests/phpunit/CRM/Contact/SelectorTest.php b/tests/phpunit/CRM/Contact/SelectorTest.php index 1eb5337323..917396028b 100644 --- a/tests/phpunit/CRM/Contact/SelectorTest.php +++ b/tests/phpunit/CRM/Contact/SelectorTest.php @@ -40,6 +40,7 @@ class CRM_Contact_SelectorTest extends CiviUnitTestCase { public function tearDown() { } + /** * Test the query from the selector class is consistent with the dataset expectation. * @@ -147,11 +148,11 @@ class CRM_Contact_SelectorTest extends CiviUnitTestCase { // build cache key and use to it to fetch prev-next cache record $cacheKey = 'civicrm search ' . $key; $contacts = CRM_Utils_SQL_Select::from('civicrm_prevnext_cache') - ->select(['entity_id1', 'cacheKey']) - ->where("cacheKey = @key") - ->param('key', $cacheKey) - ->execute() - ->fetchAll(); + ->select(['entity_id1', 'cacheKey']) + ->where("cacheKey = @key") + ->param('key', $cacheKey) + ->execute() + ->fetchAll(); $this->assertEquals(1, count($contacts)); // check the prevNext record matches $expectedEntry = [ @@ -293,13 +294,15 @@ class CRM_Contact_SelectorTest extends CiviUnitTestCase { * Test the contact ID query does not fail on country search. */ public function testContactIDQuery() { - $params = [[ - 0 => 'country-1', - 1 => '=', - 2 => '1228', - 3 => 1, - 4 => 0, - ]]; + $params = [ + [ + 0 => 'country-1', + 1 => '=', + 2 => '1228', + 3 => 1, + 4 => 0, + ], + ]; $searchOBJ = new CRM_Contact_Selector(NULL); $searchOBJ->contactIDQuery($params, '1_u'); @@ -325,13 +328,15 @@ class CRM_Contact_SelectorTest extends CiviUnitTestCase { $selector = new CRM_Contact_Selector( 'CRM_Contact_Selector', ['email' => ['IS NOT NULL' => 1]], - [[ - 0 => 'email-' . $locationType->id, - 1 => 'IS NOT NULL', - 2 => NULL, - 3 => 1, - 4 => 0, - ]], + [ + [ + 0 => 'email-' . $locationType->id, + 1 => 'IS NOT NULL', + 2 => NULL, + 3 => 1, + 4 => 0, + ], + ], [ 'contact_type' => 1, 'contact_sub_type' => 1, @@ -380,23 +385,30 @@ class CRM_Contact_SelectorTest extends CiviUnitTestCase { 'IN' => ['IN' => ['Adam']], ]; $filtersByWhereClause = [ - 'IS NOT NULL' => '( contact_a.first_name IS NOT NULL )', // doesn't matter - '=' => "( contact_a.first_name = 'Adam' )", // case sensitive check - 'LIKE' => "( contact_a.first_name LIKE '%Ad%' )", // case insensitive check - 'RLIKE' => "( contact_a.first_name RLIKE BINARY '^A[a-z]{3}$' )", // case sensitive check - 'IN' => '( contact_a.first_name IN ("Adam") )', // case sensitive check + // doesn't matter + 'IS NOT NULL' => '( contact_a.first_name IS NOT NULL )', + // case sensitive check + '=' => "( contact_a.first_name = 'Adam' )", + // case insensitive check + 'LIKE' => "( contact_a.first_name LIKE '%Ad%' )", + // case sensitive check + 'RLIKE' => "( contact_a.first_name RLIKE BINARY '^A[a-z]{3}$' )", + // case sensitive check + 'IN' => '( contact_a.first_name IN ("Adam") )', ]; foreach ($filters as $op => $filter) { $selector = new CRM_Contact_Selector( 'CRM_Contact_Selector', ['first_name' => [$op => $filter]], - [[ - 0 => 'first_name', - 1 => $op, - 2 => $filter, - 3 => 1, - 4 => 0, - ]], + [ + [ + 0 => 'first_name', + 1 => $op, + 2 => $filter, + 3 => 1, + 4 => 0, + ], + ], [], CRM_Core_Action::NONE, NULL, @@ -419,13 +431,15 @@ class CRM_Contact_SelectorTest extends CiviUnitTestCase { */ public function testSelectorQueryOrderByCustomField() { //Search for any params. - $params = [[ - 0 => 'country-1', - 1 => '=', - 2 => '1228', - 3 => 1, - 4 => 0, - ]]; + $params = [ + [ + 0 => 'country-1', + 1 => '=', + 2 => '1228', + 3 => 1, + 4 => 0, + ], + ]; //Create a test custom group and field. $customGroup = $this->callAPISuccess('CustomGroup', 'create', array( @@ -505,7 +519,8 @@ class CRM_Contact_SelectorTest extends CiviUnitTestCase { 2 => 1, 3 => 1, 4 => 0, - ]], + ], + ], [], CRM_Core_Action::NONE, NULL, diff --git a/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php b/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php index 16a9d0eb47..44505f9f46 100644 --- a/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php +++ b/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php @@ -331,7 +331,8 @@ class CRM_Contribute_BAO_ContributionTest extends CiviUnitTestCase { public function testAnnualWithMultipleLineItems() { $contactID = $this->createLoggedInUserWithFinancialACL(); $this->createContributionWithTwoLineItemsAgainstPriceSet([ - 'contact_id' => $contactID] + 'contact_id' => $contactID, + ] ); $this->enableFinancialACLs(); $sql = CRM_Contribute_BAO_Contribution::getAnnualQuery([$contactID]); @@ -1382,14 +1383,12 @@ WHERE eft.entity_id = %1 AND ft.to_financial_account_id <> %2"; $form = new CRM_Contribute_Form_Contribution(); $form->testSubmit(array( - 'total_amount' => $params['total_amount'], - 'financial_type_id' => $financialType['id'], - 'contact_id' => $contactId, - 'contribution_status_id' => 1, - 'price_set_id' => 0, - ), - CRM_Core_Action::ADD - ); + 'total_amount' => $params['total_amount'], + 'financial_type_id' => $financialType['id'], + 'contact_id' => $contactId, + 'contribution_status_id' => 1, + 'price_set_id' => 0, + ), CRM_Core_Action::ADD); $contribution = $this->callAPISuccessGetSingle('Contribution', array( 'contact_id' => $contactId, diff --git a/tests/phpunit/CRM/Contribute/BAO/QueryTest.php b/tests/phpunit/CRM/Contribute/BAO/QueryTest.php index b3e27b9bca..8942d740cf 100644 --- a/tests/phpunit/CRM/Contribute/BAO/QueryTest.php +++ b/tests/phpunit/CRM/Contribute/BAO/QueryTest.php @@ -5,6 +5,7 @@ * @group headless */ class CRM_Contribute_BAO_QueryTest extends CiviUnitTestCase { + public function tearDown() { $this->quickCleanUpFinancialEntities(); } diff --git a/tests/phpunit/CRM/Contribute/Form/ContributionTest.php b/tests/phpunit/CRM/Contribute/Form/ContributionTest.php index 8904cf1ccf..81e3540365 100644 --- a/tests/phpunit/CRM/Contribute/Form/ContributionTest.php +++ b/tests/phpunit/CRM/Contribute/Form/ContributionTest.php @@ -34,9 +34,6 @@ */ class CRM_Contribute_Form_ContributionTest extends CiviUnitTestCase { - /** - * Assume empty database with just civicrm_data. - */ protected $_individualId; protected $_contribution; protected $_financialTypeId = 1; @@ -158,8 +155,7 @@ class CRM_Contribute_Form_ContributionTest extends CiviUnitTestCase { 'contact_id' => $this->_individualId, 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), 'contribution_status_id' => 1, - ), - CRM_Core_Action::ADD); + ), CRM_Core_Action::ADD); $contribution = $this->callAPISuccessGetSingle('Contribution', array('contact_id' => $this->_individualId)); $this->assertEmpty($contribution['amount_level']); $this->assertEquals(1234, $contribution['total_amount']); @@ -181,8 +177,7 @@ class CRM_Contribute_Form_ContributionTest extends CiviUnitTestCase { $this->callAPISuccessGetCount('Contribution', array( 'contact_id' => $this->_individualId, 'contribution_status_id' => 'Completed', - ), - 1); + ), 1); } /** @@ -240,7 +235,7 @@ class CRM_Contribute_Form_ContributionTest extends CiviUnitTestCase { 'payment_instrument_id' => $this->callAPISuccessGetValue('PaymentProcessor', array( 'return' => 'payment_instrument_id', 'id' => $paymentProcessorID, - )), + )), )); $this->assertEquals(1, $contribution["count"], "Contribution count should be one."); @@ -314,7 +309,6 @@ class CRM_Contribute_Form_ContributionTest extends CiviUnitTestCase { $mut->stop(); } - /** * Test the submit function on the contribution page. */ @@ -369,7 +363,7 @@ class CRM_Contribute_Form_ContributionTest extends CiviUnitTestCase { 'payment_instrument_id' => $this->callAPISuccessGetValue('PaymentProcessor', array( 'return' => 'payment_instrument_id', 'id' => $this->paymentProcessorID, - )), + )), ), 1); $contact = $this->callAPISuccessGetSingle('Contact', array('id' => $this->_individualId)); $this->assertTrue(empty($contact['source'])); @@ -501,9 +495,7 @@ class CRM_Contribute_Form_ContributionTest extends CiviUnitTestCase { 'payment_processor_id' => $this->paymentProcessorID, 'credit_card_exp_date' => array('M' => 5, 'Y' => 2012), 'credit_card_number' => '411111111111111', - ), CRM_Core_Action::ADD, - 'live' - ); + ), CRM_Core_Action::ADD, 'live'); } catch (\Civi\Payment\Exception\PaymentProcessorException $e) { $this->callAPISuccessGetCount('Contribution', array( @@ -540,9 +532,7 @@ class CRM_Contribute_Form_ContributionTest extends CiviUnitTestCase { 'credit_card_exp_date' => array('M' => 5, 'Y' => 2025), 'credit_card_number' => '411111111111111', 'billing_city-5' => 'Vancouver', - ), CRM_Core_Action::ADD, - 'live' - ); + ), CRM_Core_Action::ADD, 'live'); $contribution = $this->callAPISuccessGetSingle('Contribution', array('return' => 'address_id')); $this->assertNotEmpty($contribution['address_id']); // CRM-18490 : There is a unwanted test leakage due to below getsingle Api as it only fails in Jenkin @@ -573,9 +563,7 @@ class CRM_Contribute_Form_ContributionTest extends CiviUnitTestCase { 'credit_card_exp_date' => array('M' => 5, 'Y' => 2025), 'credit_card_number' => '411111111111111', 'billing_city-5' => 'Vancouver', - ), CRM_Core_Action::ADD, - 'live' - ); + ), CRM_Core_Action::ADD, 'live'); $contribution = $this->callAPISuccessGetSingle('Contribution', array('return' => 'receive_date')); $this->assertEquals($contribution['receive_date'], $receiveDate); } @@ -593,9 +581,7 @@ class CRM_Contribute_Form_ContributionTest extends CiviUnitTestCase { 'payment_processor_id' => $this->paymentProcessorID, 'credit_card_exp_date' => array('M' => 5, 'Y' => 2025), 'credit_card_number' => '411111111111111', - ), CRM_Core_Action::ADD, - 'live' - ); + ), CRM_Core_Action::ADD, 'live'); $contribution = $this->callAPISuccessGetSingle('Contribution', array('return' => 'address_id')); $this->assertEmpty($contribution['address_id']); $this->callAPISuccessGetCount('Address', array( @@ -620,8 +606,8 @@ class CRM_Contribute_Form_ContributionTest extends CiviUnitTestCase { ), CRM_Core_Action::ADD); $this->callAPISuccessGetCount('Contribution', array('contact_id' => $this->_individualId), 1); $mut->checkMailLog(array( - '

Please print this receipt for your records.

', - ) + '

Please print this receipt for your records.

', + ) ); $mut->stop(); } @@ -646,10 +632,9 @@ class CRM_Contribute_Form_ContributionTest extends CiviUnitTestCase { ), CRM_Core_Action::ADD); $this->callAPISuccessGetCount('Contribution', array('contact_id' => $this->_individualId), 1); $mut->checkMailLog(array( - '

Please print this receipt for your records.

', - '', - ) - ); + '

Please print this receipt for your records.

', + '', + )); $mut->stop(); } @@ -714,14 +699,13 @@ class CRM_Contribute_Form_ContributionTest extends CiviUnitTestCase { $form->testSubmit($params, CRM_Core_Action::ADD); $mut->checkMailLog(array( - 'Financial Type: Donation + 'Financial Type: Donation --------------------------------------------------------- Item Qty Each Total ---------------------------------------------------------- Price Field - Price Field 1 1 $ 100.00 $ 100.00 ', - ) - ); + )); $mut->stop(); } @@ -809,8 +793,7 @@ Price Field - Price Field 1 1 $ 100.00 $ 100.00 'payment_processor_id' => $this->paymentProcessorID, 'credit_card_exp_date' => array('M' => 5, 'Y' => 2026), 'credit_card_number' => '411111111111111', - ), CRM_Core_Action::ADD, - 'live'); + ), CRM_Core_Action::ADD, 'live'); $contributionProduct = $this->callAPISuccess('contribution_product', 'getsingle', array()); $this->assertEquals('clumsy smurf', $contributionProduct['product_option']); $mut->checkMailLog(array( @@ -833,8 +816,7 @@ Price Field - Price Field 1 1 $ 100.00 $ 100.00 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), 'contribution_status_id' => 1, 'note' => 'Super cool and interesting stuff', - ), - CRM_Core_Action::ADD); + ), CRM_Core_Action::ADD); $this->callAPISuccessGetCount('Contribution', array('contact_id' => $this->_individualId), 1); $note = $this->callAPISuccessGetSingle('note', array('entity_table' => 'civicrm_contribution')); $this->assertEquals($note['note'], 'Super cool and interesting stuff'); @@ -897,14 +879,13 @@ Price Field - Price Field 1 1 $ 100.00 $ 100.00 $form = new CRM_Contribute_Form_Contribution(); $form->testSubmit(array( - 'total_amount' => $this->formatMoneyInput(6100.10), - 'financial_type_id' => 1, - 'contact_id' => $this->_individualId, - 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), - 'contribution_status_id' => 1, - 'price_set_id' => 0, - ), - CRM_Core_Action::ADD); + 'total_amount' => $this->formatMoneyInput(6100.10), + 'financial_type_id' => 1, + 'contact_id' => $this->_individualId, + 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), + 'contribution_status_id' => 1, + 'price_set_id' => 0, + ), CRM_Core_Action::ADD); $contribution = $this->callAPISuccessGetSingle('Contribution', array('contact_id' => $this->_individualId)); $form->testSubmit(array( 'total_amount' => $this->formatMoneyInput(5200.20), @@ -915,8 +896,7 @@ Price Field - Price Field 1 1 $ 100.00 $ 100.00 'contribution_status_id' => 1, 'price_set_id' => 0, 'id' => $contribution['id'], - ), - CRM_Core_Action::UPDATE); + ), CRM_Core_Action::UPDATE); $contribution = $this->callAPISuccessGetSingle('Contribution', array('contact_id' => $this->_individualId)); $this->assertEquals(5200.20, $contribution['total_amount'], 2); @@ -941,15 +921,14 @@ Price Field - Price Field 1 1 $ 100.00 $ 100.00 $form = new CRM_Contribute_Form_Contribution(); $form->testSubmit(array( - 'total_amount' => 1200.55, - 'financial_type_id' => 1, - 'contact_id' => $this->_individualId, - 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), - 'check_number' => '123AX', - 'contribution_status_id' => 1, - 'price_set_id' => 0, - ), - CRM_Core_Action::ADD); + 'total_amount' => 1200.55, + 'financial_type_id' => 1, + 'contact_id' => $this->_individualId, + 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), + 'check_number' => '123AX', + 'contribution_status_id' => 1, + 'price_set_id' => 0, + ), CRM_Core_Action::ADD); $contribution = $this->callAPISuccessGetSingle('Contribution', array('contact_id' => $this->_individualId)); $form->testSubmit(array( 'total_amount' => 1200.55, @@ -962,8 +941,7 @@ Price Field - Price Field 1 1 $ 100.00 $ 100.00 'contribution_status_id' => 1, 'price_set_id' => 0, 'id' => $contribution['id'], - ), - CRM_Core_Action::UPDATE); + ), CRM_Core_Action::UPDATE); $contribution = $this->callAPISuccessGetSingle('Contribution', array('contact_id' => $this->_individualId)); $this->assertEquals(1200.55, $contribution['total_amount']); @@ -1061,13 +1039,13 @@ Price Field - Price Field 1 1 $ 100.00 $ 100.00 $form = new CRM_Contribute_Form_Contribution(); $form->testSubmit(array( - 'total_amount' => $this->formatMoneyInput(1000.00), - 'financial_type_id' => $this->_financialTypeId, - 'contact_id' => $this->_individualId, - 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), - 'contribution_status_id' => 1, - 'price_set_id' => 0, - ), + 'total_amount' => $this->formatMoneyInput(1000.00), + 'financial_type_id' => $this->_financialTypeId, + 'contact_id' => $this->_individualId, + 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), + 'contribution_status_id' => 1, + 'price_set_id' => 0, + ), CRM_Core_Action::ADD ); $contribution = $this->callAPISuccessGetSingle('Contribution', @@ -1086,14 +1064,12 @@ Price Field - Price Field 1 1 $ 100.00 $ 100.00 // CRM-20423: Upon simple submit of 'Edit Contribution' form ensure that total amount is same $form->testSubmit(array( - 'id' => $contribution['id'], - 'financial_type_id' => 3, - 'contact_id' => $this->_individualId, - 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), - 'contribution_status_id' => 1, - ), - CRM_Core_Action::UPDATE - ); + 'id' => $contribution['id'], + 'financial_type_id' => 3, + 'contact_id' => $this->_individualId, + 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), + 'contribution_status_id' => 1, + ), CRM_Core_Action::UPDATE); $contribution = $this->callAPISuccessGetSingle('Contribution', array('contact_id' => $this->_individualId)); // Check if total amount is unchanged @@ -1109,15 +1085,13 @@ Price Field - Price Field 1 1 $ 100.00 $ 100.00 $form = new CRM_Contribute_Form_Contribution(); $form->testSubmit(array( - 'total_amount' => 100, - 'financial_type_id' => 3, - 'contact_id' => $this->_individualId, - 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), - 'contribution_status_id' => 1, - 'price_set_id' => 0, - ), - CRM_Core_Action::ADD - ); + 'total_amount' => 100, + 'financial_type_id' => 3, + 'contact_id' => $this->_individualId, + 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), + 'contribution_status_id' => 1, + 'price_set_id' => 0, + ), CRM_Core_Action::ADD); $contribution = $this->callAPISuccessGetSingle('Contribution', array( 'contact_id' => $this->_individualId, @@ -1170,9 +1144,7 @@ Price Field - Price Field 1 1 $ 100.00 $ 100.00 'contribution_status_id' => 1, 'is_email_receipt' => 1, 'from_email_address' => 'demo@example.com', - ), - CRM_Core_Action::UPDATE - ); + ), CRM_Core_Action::UPDATE); $contribution = $this->callAPISuccessGetSingle('Contribution', array( 'contribution_id' => 1, @@ -1231,9 +1203,7 @@ Price Field - Price Field 1 1 $ 100.00 $ 100.00 'contribution_status_id' => 1, 'is_email_receipt' => 1, 'from_email_address' => 'demo@example.com', - ), - CRM_Core_Action::UPDATE - ); + ), CRM_Core_Action::UPDATE); $contribution = $this->callAPISuccessGetSingle('Contribution', array( 'contribution_id' => 1, @@ -1285,9 +1255,7 @@ Price Field - Price Field 1 1 $ 100.00 $ 100.00 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), 'contribution_status_id' => 1, 'price_set_id' => 0, - ), - CRM_Core_Action::ADD - ); + ), CRM_Core_Action::ADD); $contribution = $this->callAPISuccessGetSingle('Contribution', array( 'contribution_id' => 1, diff --git a/tests/phpunit/CRM/Contribute/Form/Task/InvoiceTest.php b/tests/phpunit/CRM/Contribute/Form/Task/InvoiceTest.php index 7611023912..2f87e3b135 100644 --- a/tests/phpunit/CRM/Contribute/Form/Task/InvoiceTest.php +++ b/tests/phpunit/CRM/Contribute/Form/Task/InvoiceTest.php @@ -33,9 +33,7 @@ * @group headless */ class CRM_Contribute_Form_Task_InvoiceTest extends CiviUnitTestCase { - /** - * Assume empty database with just civicrm_data. - */ + protected $_individualId; /** diff --git a/tests/phpunit/CRM/Contribute/Form/Task/PDFLetterCommonTest.php b/tests/phpunit/CRM/Contribute/Form/Task/PDFLetterCommonTest.php index e7efed51b9..b7eada9d98 100644 --- a/tests/phpunit/CRM/Contribute/Form/Task/PDFLetterCommonTest.php +++ b/tests/phpunit/CRM/Contribute/Form/Task/PDFLetterCommonTest.php @@ -34,9 +34,6 @@ */ class CRM_Contribute_Form_Task_PDFLetterCommonTest extends CiviUnitTestCase { - /** - * Assume empty database with just civicrm_data. - */ protected $_individualId; protected $_docTypes = NULL; diff --git a/tests/phpunit/CRM/Contribute/Form/Task/StatusTest.php b/tests/phpunit/CRM/Contribute/Form/Task/StatusTest.php index 5afdb1b595..498efed17d 100644 --- a/tests/phpunit/CRM/Contribute/Form/Task/StatusTest.php +++ b/tests/phpunit/CRM/Contribute/Form/Task/StatusTest.php @@ -29,9 +29,7 @@ * Class CRM_Contribute_Form_Task_StatusTest */ class CRM_Contribute_Form_Task_StatusTest extends CiviUnitTestCase { - /** - * Assume empty database with just civicrm_data. - */ + protected $_individualId; /** diff --git a/tests/phpunit/CRM/Contribute/Form/TaskTest.php b/tests/phpunit/CRM/Contribute/Form/TaskTest.php index ffecaada62..5cd4cdec9c 100644 --- a/tests/phpunit/CRM/Contribute/Form/TaskTest.php +++ b/tests/phpunit/CRM/Contribute/Form/TaskTest.php @@ -29,9 +29,7 @@ * Class CRM_Contribute_Form_Tasktest */ class CRM_Contribute_Form_TaskTest extends CiviUnitTestCase { - /** - * Assume empty database with just civicrm_data. - */ + protected $_individualId; /** diff --git a/tests/phpunit/CRM/Contribute/Import/Parser/ContributionTest.php b/tests/phpunit/CRM/Contribute/Import/Parser/ContributionTest.php index 740178e609..ed21e72e2e 100644 --- a/tests/phpunit/CRM/Contribute/Import/Parser/ContributionTest.php +++ b/tests/phpunit/CRM/Contribute/Import/Parser/ContributionTest.php @@ -11,12 +11,14 @@ */ class CRM_Contribute_Import_Parser_ContributionTest extends CiviUnitTestCase { protected $_tablesToTruncate = array(); + /** * Setup function. */ public function setUp() { parent::setUp(); } + /** * Test import parser will add contribution and soft contribution each for different contact. * diff --git a/tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php b/tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php index fead50b0dd..e552004e26 100644 --- a/tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php +++ b/tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php @@ -79,8 +79,10 @@ class CRM_Core_BAO_ActionScheduleTest extends CiviUnitTestCase { 'start_date' => '20120315', 'end_date' => '20120615', ), - 'role_id' => '1', // Attendee. - 'status_id' => '8', // No-show. + // Attendee. + 'role_id' => '1', + // No-show. + 'status_id' => '8', ); $this->fixtures['phonecall'] = array( @@ -528,12 +530,15 @@ class CRM_Core_BAO_ActionScheduleTest extends CiviUnitTestCase { 'end_date' => '', 'end_frequency_interval' => '', 'end_frequency_unit' => '', - 'entity_status' => '', // participant status id - 'entity_value' => '', // event type id + // participant status id + 'entity_status' => '', + // event type id + 'entity_value' => '', 'group_id' => '', 'is_active' => 1, 'is_repeat' => '0', - 'mapping_id' => 2, // event type + // event type + 'mapping_id' => 2, 'msg_template_id' => '', 'recipient' => '', 'recipient_listing' => '', @@ -557,12 +562,15 @@ class CRM_Core_BAO_ActionScheduleTest extends CiviUnitTestCase { 'end_date' => 'event_end_date', 'end_frequency_interval' => '3', 'end_frequency_unit' => 'month', - 'entity_status' => '', // participant status id - 'entity_value' => '', // event type id + // participant status id + 'entity_status' => '', + // event type id + 'entity_value' => '', 'group_id' => '', 'is_active' => 1, 'is_repeat' => '1', - 'mapping_id' => 2, // event type + // event type + 'mapping_id' => 2, 'msg_template_id' => '', 'recipient' => '', 'recipient_listing' => '', @@ -709,11 +717,16 @@ class CRM_Core_BAO_ActionScheduleTest extends CiviUnitTestCase { // Some tokens - short as subject has 128char limit in DB. $someTokensTmpl = implode(';;', array( - '{contact.display_name}', // basic contact token - '{contact.gender}', // funny legacy contact token - '{contact.gender_id}', // funny legacy contact token - '{domain.name}', // domain token - '{activity.activity_type}', // action-scheduler token + // basic contact token + '{contact.display_name}', + // funny legacy contact token + '{contact.gender}', + // funny legacy contact token + '{contact.gender_id}', + // domain token + '{domain.name}', + // action-scheduler token + '{activity.activity_type}', )); // Further tokens can be tested in the body text/html. $manyTokensTmpl = implode(';;', array( @@ -1051,7 +1064,6 @@ class CRM_Core_BAO_ActionScheduleTest extends CiviUnitTestCase { )); } - /** * CRM-21675: Support parent and smart group in 'Limit to' field */ @@ -1307,7 +1319,6 @@ class CRM_Core_BAO_ActionScheduleTest extends CiviUnitTestCase { )); } - /** * Test membership end date email. * @@ -1573,9 +1584,12 @@ class CRM_Core_BAO_ActionScheduleTest extends CiviUnitTestCase { $result = $this->callAPISuccess('contact', 'create', array_merge($this->fixtures['contact'], array('contact_id' => $membership->contact_id))); $this->assertAPISuccess($result); - $actionScheduleBefore = $this->fixtures['sched_membership_end_2week']; // Send email 2 weeks before end_date - $actionScheduleOn = $this->fixtures['sched_on_membership_end_date']; // Send email on end_date/expiry date - $actionScheduleAfter = $this->fixtures['sched_after_1day_membership_end_date']; // Send email 1 day after end_date/grace period + // Send email 2 weeks before end_date + $actionScheduleBefore = $this->fixtures['sched_membership_end_2week']; + // Send email on end_date/expiry date + $actionScheduleOn = $this->fixtures['sched_on_membership_end_date']; + // Send email 1 day after end_date/grace period + $actionScheduleAfter = $this->fixtures['sched_after_1day_membership_end_date']; $actionScheduleBefore['entity_value'] = $actionScheduleOn['entity_value'] = $actionScheduleAfter['entity_value'] = $membership->membership_type_id; foreach (array('actionScheduleBefore', 'actionScheduleOn', 'actionScheduleAfter') as $value) { $$value = CRM_Core_BAO_ActionSchedule::add($$value); @@ -1622,17 +1636,20 @@ class CRM_Core_BAO_ActionScheduleTest extends CiviUnitTestCase { $this->assertApproxEquals( strtotime('2012-06-01 01:00:00'), strtotime(CRM_Core_DAO::getFieldValue('CRM_Core_DAO_ActionLog', $actionScheduleBefore->id, 'action_date_time', 'action_schedule_id', TRUE)), - 3 // Variation in test execution time. + // Variation in test execution time. + 3 ); $this->assertApproxEquals( strtotime('2012-06-15 00:00:00'), strtotime(CRM_Core_DAO::getFieldValue('CRM_Core_DAO_ActionLog', $actionScheduleOn->id, 'action_date_time', 'action_schedule_id', TRUE)), - 3 // Variation in test execution time. + // Variation in test execution time. + 3 ); $this->assertApproxEquals( strtotime('2012-06-16 01:00:00'), strtotime(CRM_Core_DAO::getFieldValue('CRM_Core_DAO_ActionLog', $actionScheduleAfter->id, 'action_date_time', 'action_schedule_id', TRUE)), - 3 // Variation in test execution time. + // Variation in test execution time. + 3 ); //extend MED to 2 weeks after the current MED (that may signifies as membership renewal activity) diff --git a/tests/phpunit/CRM/Core/BAO/AddressTest.php b/tests/phpunit/CRM/Core/BAO/AddressTest.php index 53c5c40eb5..44130a7786 100644 --- a/tests/phpunit/CRM/Core/BAO/AddressTest.php +++ b/tests/phpunit/CRM/Core/BAO/AddressTest.php @@ -30,6 +30,7 @@ * @group headless */ class CRM_Core_BAO_AddressTest extends CiviUnitTestCase { + public function setUp() { parent::setUp(); diff --git a/tests/phpunit/CRM/Core/BAO/CacheTest.php b/tests/phpunit/CRM/Core/BAO/CacheTest.php index ac154eb205..99abb9e649 100644 --- a/tests/phpunit/CRM/Core/BAO/CacheTest.php +++ b/tests/phpunit/CRM/Core/BAO/CacheTest.php @@ -84,14 +84,22 @@ class CRM_Core_BAO_CacheTest extends CiviUnitTestCase { public function getCleanKeyExamples() { $es = []; - $es[] = ['hello_world and/other.planets', 'hello_world-20and-2fother.planets']; // allowed chars - $es[] = ['hello/world+-#@{}', 'hello-2fworld-2b-2d-23-40-7b-7d']; // escaped chars - $es[] = ["LF-\nTAB-\tCR-\remojiskull💀", 'LF-2d-aTAB-2d-9CR-2d-demojiskull-f0-9f-92-80']; // short with emoji - $es[] = ["LF-\nTAB-\tCR-\remojibomb💣emojiskull💀", '-5d9324e052f6e10240dce5029c5e8525']; // long with emoji - $es[] = ['123456789 123456789 123456789 123456789 123456789 123', '123456789-20123456789-20123456789-20123456789-20123456789-20123']; // spaces are escaped - $es[] = ['123456789_123456789_123456789_123456789_123456789_123456789_123', '123456789_123456789_123456789_123456789_123456789_123456789_123']; // long but allowed - $es[] = ['123456789_123456789_123456789_123456789_123456789_123456789_1234', '-e02b981aff954fdcc9a81c25f5ec9681']; // too long, md5 fallback - $es[] = ['123456789-/23456789-+23456789--23456789_123456789_123456789', '-43b6dec1026187ae6f6a8fe4d56ab22e']; // too long, md5 fallback + // allowed chars + $es[] = ['hello_world and/other.planets', 'hello_world-20and-2fother.planets']; + // escaped chars + $es[] = ['hello/world+-#@{}', 'hello-2fworld-2b-2d-23-40-7b-7d']; + // short with emoji + $es[] = ["LF-\nTAB-\tCR-\remojiskull💀", 'LF-2d-aTAB-2d-9CR-2d-demojiskull-f0-9f-92-80']; + // long with emoji + $es[] = ["LF-\nTAB-\tCR-\remojibomb💣emojiskull💀", '-5d9324e052f6e10240dce5029c5e8525']; + // spaces are escaped + $es[] = ['123456789 123456789 123456789 123456789 123456789 123', '123456789-20123456789-20123456789-20123456789-20123456789-20123']; + // long but allowed + $es[] = ['123456789_123456789_123456789_123456789_123456789_123456789_123', '123456789_123456789_123456789_123456789_123456789_123456789_123']; + // too long, md5 fallback + $es[] = ['123456789_123456789_123456789_123456789_123456789_123456789_1234', '-e02b981aff954fdcc9a81c25f5ec9681']; + // too long, md5 fallback + $es[] = ['123456789-/23456789-+23456789--23456789_123456789_123456789', '-43b6dec1026187ae6f6a8fe4d56ab22e']; return $es; } diff --git a/tests/phpunit/CRM/Core/BAO/ConfigSettingTest.php b/tests/phpunit/CRM/Core/BAO/ConfigSettingTest.php index 4930469b53..38ad72fd97 100644 --- a/tests/phpunit/CRM/Core/BAO/ConfigSettingTest.php +++ b/tests/phpunit/CRM/Core/BAO/ConfigSettingTest.php @@ -30,6 +30,7 @@ * @group headless */ class CRM_Core_BAO_ConfigSettingTest extends CiviUnitTestCase { + public function testToggleComponent() { $origNames = array(); foreach (CRM_Core_Component::getEnabledComponents() as $c) { diff --git a/tests/phpunit/CRM/Core/BAO/CustomValueTest.php b/tests/phpunit/CRM/Core/BAO/CustomValueTest.php index 39a751f348..16fcde5311 100644 --- a/tests/phpunit/CRM/Core/BAO/CustomValueTest.php +++ b/tests/phpunit/CRM/Core/BAO/CustomValueTest.php @@ -36,6 +36,7 @@ * @group headless */ class CRM_Core_BAO_CustomValueTest extends CiviUnitTestCase { + public function testTypeCheckWithValidInput() { $values = array( diff --git a/tests/phpunit/CRM/Core/BAO/EmailTest.php b/tests/phpunit/CRM/Core/BAO/EmailTest.php index a97290d2fa..530a4030a7 100644 --- a/tests/phpunit/CRM/Core/BAO/EmailTest.php +++ b/tests/phpunit/CRM/Core/BAO/EmailTest.php @@ -5,6 +5,7 @@ * @group headless */ class CRM_Core_BAO_EmailTest extends CiviUnitTestCase { + public function setUp() { parent::setUp(); diff --git a/tests/phpunit/CRM/Core/BAO/FinancialTrxnTest.php b/tests/phpunit/CRM/Core/BAO/FinancialTrxnTest.php index 94de1d4d10..388dcea22b 100644 --- a/tests/phpunit/CRM/Core/BAO/FinancialTrxnTest.php +++ b/tests/phpunit/CRM/Core/BAO/FinancialTrxnTest.php @@ -30,6 +30,7 @@ * @group headless */ class CRM_Core_BAO_FinancialTrxnTest extends CiviUnitTestCase { + public function setUp() { parent::setUp(); } @@ -120,7 +121,8 @@ class CRM_Core_BAO_FinancialTrxnTest extends CiviUnitTestCase { $paid = CRM_Core_BAO_FinancialTrxn::getTotalPayments($params['contribution_id']); $total = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $params['contribution_id'], 'total_amount'); $cmp = bccomp($total, $paid, 5); - if ($cmp == 0 || $cmp == -1) {// If paid amount is greater or equal to total amount + // If paid amount is greater or equal to total amount + if ($cmp == 0 || $cmp == -1) { civicrm_api3('Contribution', 'completetransaction', array('id' => $contribution['id'])); } diff --git a/tests/phpunit/CRM/Core/BAO/IMTest.php b/tests/phpunit/CRM/Core/BAO/IMTest.php index c1420a9e9f..c5700282ae 100644 --- a/tests/phpunit/CRM/Core/BAO/IMTest.php +++ b/tests/phpunit/CRM/Core/BAO/IMTest.php @@ -5,6 +5,7 @@ * @group headless */ class CRM_Core_BAO_IMTest extends CiviUnitTestCase { + public function setUp() { parent::setUp(); } diff --git a/tests/phpunit/CRM/Core/BAO/LocationTest.php b/tests/phpunit/CRM/Core/BAO/LocationTest.php index b7745fc5fa..548b3f71e1 100644 --- a/tests/phpunit/CRM/Core/BAO/LocationTest.php +++ b/tests/phpunit/CRM/Core/BAO/LocationTest.php @@ -38,17 +38,18 @@ * @group headless */ 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', - )); + 'civicrm_contact', + 'civicrm_address', + 'civicrm_loc_block', + 'civicrm_email', + 'civicrm_phone', + 'civicrm_im', + )); } /** diff --git a/tests/phpunit/CRM/Core/BAO/NavigationTest.php b/tests/phpunit/CRM/Core/BAO/NavigationTest.php index fab453d83e..a851141726 100644 --- a/tests/phpunit/CRM/Core/BAO/NavigationTest.php +++ b/tests/phpunit/CRM/Core/BAO/NavigationTest.php @@ -290,7 +290,7 @@ class CRM_Core_BAO_NavigationTest extends CiviUnitTestCase { public function testCheckPermissions() { $menuItem = [ 'permission' => 'access CiviCRM, access CiviContribute', - 'operator' => 'AND' + 'operator' => 'AND', ]; CRM_Core_BAO_ConfigSetting::enableComponent('CiviContribute'); CRM_Core_Config::singleton()->userPermissionClass->permissions = ['access CiviCRM', 'access CiviContribute']; diff --git a/tests/phpunit/CRM/Core/BAO/OpenIDTest.php b/tests/phpunit/CRM/Core/BAO/OpenIDTest.php index ffa02b7af1..313fbe0ac4 100644 --- a/tests/phpunit/CRM/Core/BAO/OpenIDTest.php +++ b/tests/phpunit/CRM/Core/BAO/OpenIDTest.php @@ -5,6 +5,7 @@ * @group headless */ class CRM_Core_BAO_OpenIDTest extends CiviUnitTestCase { + public function tearDown() { // If we truncate only contact, then stale domain and openid records will be left. // If we truncate none of these tables, then contactDelete() will incrementally diff --git a/tests/phpunit/CRM/Core/BAO/OptionValueTest.php b/tests/phpunit/CRM/Core/BAO/OptionValueTest.php index a4598d1962..778812833c 100644 --- a/tests/phpunit/CRM/Core/BAO/OptionValueTest.php +++ b/tests/phpunit/CRM/Core/BAO/OptionValueTest.php @@ -64,7 +64,6 @@ class CRM_Core_BAO_OptionValueTest extends CiviUnitTestCase { $this->fail('Should not have gotten this far'); } - /** * Ensure only one option value copes with disabled. * diff --git a/tests/phpunit/CRM/Core/BAO/RecurringEntityTest.php b/tests/phpunit/CRM/Core/BAO/RecurringEntityTest.php index 7ee88cefb4..199d46873e 100644 --- a/tests/phpunit/CRM/Core/BAO/RecurringEntityTest.php +++ b/tests/phpunit/CRM/Core/BAO/RecurringEntityTest.php @@ -187,7 +187,8 @@ class CRM_Core_BAO_RecurringEntityTest extends CiviUnitTestCase { //Create tell a friend for event $daoTellAFriend = new CRM_Friend_DAO_Friend(); $daoTellAFriend->entity_table = 'civicrm_event'; - $daoTellAFriend->entity_id = $daoEvent->id; // join with event + // join with event + $daoTellAFriend->entity_id = $daoEvent->id; $daoTellAFriend->title = 'Testing tell a friend'; $daoTellAFriend->is_active = 1; $daoTellAFriend->save(); diff --git a/tests/phpunit/CRM/Core/BAO/SettingTest.php b/tests/phpunit/CRM/Core/BAO/SettingTest.php index 53527d9a4c..b9bf5507d0 100644 --- a/tests/phpunit/CRM/Core/BAO/SettingTest.php +++ b/tests/phpunit/CRM/Core/BAO/SettingTest.php @@ -30,6 +30,7 @@ * @group headless */ class CRM_Core_BAO_SettingTest extends CiviUnitTestCase { + public function setUp() { parent::setUp(); global $civicrm_setting; @@ -143,7 +144,8 @@ class CRM_Core_BAO_SettingTest extends CiviUnitTestCase { 'is_contact' => 0, 'description' => NULL, 'help_text' => NULL, - 'on_change' => array(// list of callbacks + // list of callbacks + 'on_change' => array( array(__CLASS__, '_testOnChange_onChangeExample'), ), ), diff --git a/tests/phpunit/CRM/Core/BAO/UFFieldTest.php b/tests/phpunit/CRM/Core/BAO/UFFieldTest.php index c745657fb6..24b6d2597b 100644 --- a/tests/phpunit/CRM/Core/BAO/UFFieldTest.php +++ b/tests/phpunit/CRM/Core/BAO/UFFieldTest.php @@ -45,25 +45,31 @@ class CRM_Core_BAO_UFFieldTest extends CiviUnitTestCase { $fields = CRM_Core_BAO_UFField::getAvailableFields($ufGroupId); // Make sure that each entity has 1+ present field and 1+ missing (already-used) field - $this->assertFalse(isset($fields['Contact']['do_not_sms'])); // already used + // already used + $this->assertFalse(isset($fields['Contact']['do_not_sms'])); $this->assertEquals('city', $fields['Contact']['city']['name']); - $this->assertFalse(isset($fields['Individual']['first_name'])); // already used + // already used + $this->assertFalse(isset($fields['Individual']['first_name'])); $this->assertEquals('birth_date', $fields['Individual']['birth_date']['name']); $this->assertEquals('organization_name', $fields['Organization']['organization_name']['name']); $this->assertEquals('legal_name', $fields['Organization']['legal_name']['name']); - $this->assertFalse(isset($fields['Contribution']['amount_level'])); // already used + // already used + $this->assertFalse(isset($fields['Contribution']['amount_level'])); $this->assertEquals('cancel_reason', $fields['Contribution']['cancel_reason']['name']); - $this->assertFalse(isset($fields['Participant']['participant_note'])); // already used + // already used + $this->assertFalse(isset($fields['Participant']['participant_note'])); $this->assertEquals('participant_role', $fields['Participant']['participant_role']['name']); - $this->assertFalse(isset($fields['Membership']['join_date'])); // already used + // already used + $this->assertFalse(isset($fields['Membership']['join_date'])); $this->assertEquals('end_date', $fields['Membership']['membership_end_date']['name']); - $this->assertFalse(isset($fields['Activity']['activity_date_time'])); // already used + // already used + $this->assertFalse(isset($fields['Activity']['activity_date_time'])); $this->assertEquals('subject', $fields['Activity']['activity_subject']['name']); // Make sure that some of the blacklisted fields don't appear @@ -93,10 +99,12 @@ class CRM_Core_BAO_UFFieldTest extends CiviUnitTestCase { $defaults = array('field_name' => array('Individual', 'first_name')); $fields = CRM_Core_BAO_UFField::getAvailableFields($ufGroupId, $defaults); - $this->assertFalse(isset($fields['Contact']['do_not_sms'])); // already used + // already used + $this->assertFalse(isset($fields['Contact']['do_not_sms'])); $this->assertEquals('city', $fields['Contact']['city']['name']); - $this->assertEquals('first_name', $fields['Individual']['first_name']['name']); // used by me + // used by me + $this->assertEquals('first_name', $fields['Individual']['first_name']['name']); $this->assertEquals('birth_date', $fields['Individual']['birth_date']['name']); } diff --git a/tests/phpunit/CRM/Core/CodeGen/FreshnessTest.php b/tests/phpunit/CRM/Core/CodeGen/FreshnessTest.php index bde3451d1e..d58bbddbf6 100644 --- a/tests/phpunit/CRM/Core/CodeGen/FreshnessTest.php +++ b/tests/phpunit/CRM/Core/CodeGen/FreshnessTest.php @@ -56,15 +56,24 @@ class CRM_Core_CodeGen_FreshnessTest extends CiviUnitTestCase { $path = rtrim($GLOBALS['civicrm_root'], '/'); $genCode = new CRM_Core_CodeGen_Main( - $path . '/CRM/Core/DAO/', // $CoreDAOCodePath - $path . '/sql/', // $sqlCodePath - $path . '/', // $phpCodePath - $path . '/templates/', // $tplCodePath - NULL, // IGNORE, - CIVICRM_UF, // cms - NULL, // db version - $path . '/xml/schema/Schema.xml', // schema file - NULL // path to digest file + // $CoreDAOCodePath + $path . '/CRM/Core/DAO/', + // $sqlCodePath + $path . '/sql/', + // $phpCodePath + $path . '/', + // $tplCodePath + $path . '/templates/', + // IGNORE, + NULL, + // cms + CIVICRM_UF, + // db version + NULL, + // schema file + $path . '/xml/schema/Schema.xml', + // path to digest file + NULL ); return $genCode; } diff --git a/tests/phpunit/CRM/Core/CommunityMessagesTest.php b/tests/phpunit/CRM/Core/CommunityMessagesTest.php index 5073ec548e..427a252f20 100644 --- a/tests/phpunit/CRM/Core/CommunityMessagesTest.php +++ b/tests/phpunit/CRM/Core/CommunityMessagesTest.php @@ -64,8 +64,10 @@ class CRM_Core_CommunityMessagesTest extends CiviUnitTestCase { 'invalid-ttl-document' => array( CRM_Utils_HttpClient::STATUS_OK, json_encode(array( - 'ttl' => 'z', // not an integer! - 'retry' => 'z', // not an integer! + // not an integer! + 'ttl' => 'z', + // not an integer! + 'retry' => 'z', 'messages' => array( array( 'markup' => '

Invalid document

', @@ -206,7 +208,8 @@ class CRM_Core_CommunityMessagesTest extends CiviUnitTestCase { $this->assertApproxEquals(strtotime('2013-03-01 10:10:00'), $doc2['expires'], self::APPROX_TIME_EQUALITY); // third try, $doc1 expired, update it - CRM_Utils_Time::setTime('2013-03-01 12:00:02'); // more than 2 hours later (DEFAULT_RETRY) + // more than 2 hours later (DEFAULT_RETRY) + CRM_Utils_Time::setTime('2013-03-01 12:00:02'); $communityMessages = new CRM_Core_CommunityMessages( $this->cache, $this->expectOneHttpRequest(self::$webResponses['second-valid-response']) @@ -248,7 +251,8 @@ class CRM_Core_CommunityMessagesTest extends CiviUnitTestCase { $this->assertEquals($doc1['expires'], $doc2['expires']); // third try, $doc1 expired, try again, get a good response - CRM_Utils_Time::setTime('2013-03-01 12:00:02'); // more than 2 hours later (DEFAULT_RETRY) + // more than 2 hours later (DEFAULT_RETRY) + CRM_Utils_Time::setTime('2013-03-01 12:00:02'); $communityMessages = new CRM_Core_CommunityMessages( $this->cache, $this->expectOneHttpRequest(self::$webResponses['first-valid-response']) @@ -283,7 +287,8 @@ class CRM_Core_CommunityMessagesTest extends CiviUnitTestCase { $this->assertApproxEquals(strtotime('2013-03-01 10:10:00'), $doc1['expires'], self::APPROX_TIME_EQUALITY); // second try, $doc1 has expired; bad response; keep old data - CRM_Utils_Time::setTime('2013-03-01 12:00:02'); // more than 2 hours later (DEFAULT_RETRY) + // more than 2 hours later (DEFAULT_RETRY) + CRM_Utils_Time::setTime('2013-03-01 12:00:02'); $communityMessages = new CRM_Core_CommunityMessages( $this->cache, $this->expectOneHttpRequest($badWebResponse) @@ -327,7 +332,8 @@ class CRM_Core_CommunityMessagesTest extends CiviUnitTestCase { // randomly pick many times $trials = 80; - $freq = array(); // array($message => $count) + // array($message => $count) + $freq = array(); for ($i = 0; $i < $trials; $i++) { $message = $communityMessages->pick(); $freq[$message['markup']] = CRM_Utils_Array::value($message['markup'], $freq, 0) + 1; @@ -354,7 +360,8 @@ class CRM_Core_CommunityMessagesTest extends CiviUnitTestCase { // randomly pick many times $trials = 10; - $freq = array(); // array($message => $count) + // array($message => $count) + $freq = array(); for ($i = 0; $i < $trials; $i++) { $message = $communityMessages->pick(); $freq[$message['markup']] = CRM_Utils_Array::value($message['markup'], $freq, 0) + 1; diff --git a/tests/phpunit/CRM/Core/Config/MailerTest.php b/tests/phpunit/CRM/Core/Config/MailerTest.php index 64f94339cf..4db3883b8b 100644 --- a/tests/phpunit/CRM/Core/Config/MailerTest.php +++ b/tests/phpunit/CRM/Core/Config/MailerTest.php @@ -42,7 +42,7 @@ class CRM_Core_Config_MailerTest extends CiviUnitTestCase { /** * @var array (string=>int) Keep count of the #times different functions are called */ - var $calls; + public $calls; public function setUp() { $this->calls = array( @@ -55,11 +55,11 @@ 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', diff --git a/tests/phpunit/CRM/Core/DAO/AllCoreTablesTest.php b/tests/phpunit/CRM/Core/DAO/AllCoreTablesTest.php index 6029a0c91e..9931ac0265 100644 --- a/tests/phpunit/CRM/Core/DAO/AllCoreTablesTest.php +++ b/tests/phpunit/CRM/Core/DAO/AllCoreTablesTest.php @@ -5,6 +5,7 @@ * @group headless */ class CRM_Core_DAO_AllCoreTablesTest extends CiviUnitTestCase { + public function testGetTableForClass() { $this->assertEquals('civicrm_email', CRM_Core_DAO_AllCoreTables::getTableForClass('CRM_Core_DAO_Email')); $this->assertEquals('civicrm_email', CRM_Core_DAO_AllCoreTables::getTableForClass('CRM_Core_BAO_Email')); diff --git a/tests/phpunit/CRM/Core/DAOConformanceTest.php b/tests/phpunit/CRM/Core/DAOConformanceTest.php index ea6ba085fb..7c30686276 100644 --- a/tests/phpunit/CRM/Core/DAOConformanceTest.php +++ b/tests/phpunit/CRM/Core/DAOConformanceTest.php @@ -25,7 +25,8 @@ class CRM_Core_DAOConformanceTest extends CiviUnitTestCase { * Get all DAO classes. */ public function getAllDAO() { - $this->setUp(); // Ugh. Need full bootstrap to enumerate classes. + // Ugh. Need full bootstrap to enumerate classes. + $this->setUp(); $classList = CRM_Core_DAO_AllCoreTables::getClasses(); $return = array(); foreach ($classList as $class) { diff --git a/tests/phpunit/CRM/Core/DAOTest.php b/tests/phpunit/CRM/Core/DAOTest.php index 2d362709f7..397e54ec12 100644 --- a/tests/phpunit/CRM/Core/DAOTest.php +++ b/tests/phpunit/CRM/Core/DAOTest.php @@ -300,14 +300,16 @@ class CRM_Core_DAOTest extends CiviUnitTestCase { $tempName = CRM_Core_DAO::createTempTableName('civicrm', FALSE); $this->assertEquals(0, CRM_Core_DAO::isDBMyISAM()); CRM_Core_DAO::executeQuery("CREATE TABLE $tempName (`id` int(10) unsigned NOT NULL) ENGINE = MyISAM"); - $this->assertEquals(0, CRM_Core_DAO::isDBMyISAM()); // Ignore temp tables + // Ignore temp tables + $this->assertEquals(0, CRM_Core_DAO::isDBMyISAM()); CRM_Core_DAO::executeQuery("DROP TABLE $tempName"); // A temp table should not raise flag (randomized naming). $tempName = CRM_Core_DAO::createTempTableName('civicrm', TRUE); $this->assertEquals(0, CRM_Core_DAO::isDBMyISAM()); CRM_Core_DAO::executeQuery("CREATE TABLE $tempName (`id` int(10) unsigned NOT NULL) ENGINE = MyISAM"); - $this->assertEquals(0, CRM_Core_DAO::isDBMyISAM()); // Ignore temp tables + // Ignore temp tables + $this->assertEquals(0, CRM_Core_DAO::isDBMyISAM()); CRM_Core_DAO::executeQuery("DROP TABLE $tempName"); } diff --git a/tests/phpunit/CRM/Core/I18n/LocaleTest.php b/tests/phpunit/CRM/Core/I18n/LocaleTest.php index 4d4bfbef97..16690fbec4 100644 --- a/tests/phpunit/CRM/Core/I18n/LocaleTest.php +++ b/tests/phpunit/CRM/Core/I18n/LocaleTest.php @@ -91,7 +91,7 @@ class CRM_Core_I18n_LocaleTest extends CiviUnitTestCase { $this->assertTreeEquals([ 'en_US' => 'English (United States)', 'fr_CA' => 'French (Canada)', - ], $result); + ], $result); CRM_Core_I18n::singleton()->setLocale('en_US'); CRM_Core_I18n_Schema::makeSinglelingual('en_US'); diff --git a/tests/phpunit/CRM/Core/I18n/SchemaTest.php b/tests/phpunit/CRM/Core/I18n/SchemaTest.php index ed5a78ce88..ec0574eb4a 100644 --- a/tests/phpunit/CRM/Core/I18n/SchemaTest.php +++ b/tests/phpunit/CRM/Core/I18n/SchemaTest.php @@ -90,7 +90,7 @@ class CRM_Core_I18n_SchemaTest extends CiviUnitTestCase { // Test Currently skipped for civicrm_option_group and civicrm_event due to issues with the regex. // Agreed as not a blocker for CRM-20427 as an issue previously. if (!$skip_tests) { - $query6 = "SELECT " . '"' . "Fixed the the {$table} ticket" . '"'; + $query6 = "SELECT " . '"' . "Fixed the the {$table} ticket" . '"'; $new_query6 = CRM_Core_I18n_Schema::rewriteQuery($query6); $this->assertEquals($query6, $new_query6); } diff --git a/tests/phpunit/CRM/Core/InnoDBIndexerTest.php b/tests/phpunit/CRM/Core/InnoDBIndexerTest.php index e594e2d3ef..60470e2ffd 100644 --- a/tests/phpunit/CRM/Core/InnoDBIndexerTest.php +++ b/tests/phpunit/CRM/Core/InnoDBIndexerTest.php @@ -5,6 +5,7 @@ * @group headless */ class CRM_Core_InnoDBIndexerTest extends CiviUnitTestCase { + public function tearDown() { // May or may not cleanup well if there's a bug in the indexer. // This is better than nothing -- and better than duplicating the @@ -28,8 +29,10 @@ class CRM_Core_InnoDBIndexerTest extends CiviUnitTestCase { $this->assertTrue($idx->hasDeclaredIndex('civicrm_contact', array('first_name', 'last_name'))); $this->assertTrue($idx->hasDeclaredIndex('civicrm_contact', array('last_name', 'first_name'))); - $this->assertTrue($idx->hasDeclaredIndex('civicrm_contact', array('first_name'))); // not sure if this is right behavior - $this->assertTrue($idx->hasDeclaredIndex('civicrm_contact', array('last_name'))); // not sure if this is right behavior + // not sure if this is right behavior + $this->assertTrue($idx->hasDeclaredIndex('civicrm_contact', array('first_name'))); + // not sure if this is right behavior + $this->assertTrue($idx->hasDeclaredIndex('civicrm_contact', array('last_name'))); $this->assertTrue($idx->hasDeclaredIndex('civicrm_contact', array('foo'))); $this->assertFalse($idx->hasDeclaredIndex('civicrm_contact', array('whiz'))); diff --git a/tests/phpunit/CRM/Core/ManagedEntitiesTest.php b/tests/phpunit/CRM/Core/ManagedEntitiesTest.php index da9da77bca..7e95163fa5 100644 --- a/tests/phpunit/CRM/Core/ManagedEntitiesTest.php +++ b/tests/phpunit/CRM/Core/ManagedEntitiesTest.php @@ -16,7 +16,7 @@ class CRM_Core_ManagedEntitiesTest extends CiviUnitTestCase { protected $adhocProvider; /** - * @var array(string $shortName => CRM_Core_Module $module) + * @var array(string */ protected $modules; @@ -173,7 +173,8 @@ class CRM_Core_ManagedEntitiesTest extends CiviUnitTestCase { // create first managed entity ('foo') $decls[] = array_merge($this->fixtures['com.example.one-foo'], array( - 'update' => 'never', // Policy is to never update after initial creation + // Policy is to never update after initial creation + 'update' => 'never', )); $me = new CRM_Core_ManagedEntities($this->modules, $decls); $me->reconcile(); @@ -281,7 +282,8 @@ class CRM_Core_ManagedEntitiesTest extends CiviUnitTestCase { // create first managed entity ('foo') $decls = array(); $decls[] = array( - 'module' => 'com.example.unknown', // erroneous + // erroneous + 'module' => 'com.example.unknown', 'name' => 'foo', 'entity' => 'CustomSearch', 'params' => array( @@ -308,7 +310,8 @@ class CRM_Core_ManagedEntitiesTest extends CiviUnitTestCase { $decls = array(); $decls[] = array( 'module' => 'com.example.unknown', - 'name' => NULL, // erroneous + // erroneous + 'name' => NULL, 'entity' => 'CustomSearch', 'params' => array( 'version' => 3, @@ -335,7 +338,8 @@ class CRM_Core_ManagedEntitiesTest extends CiviUnitTestCase { $decls[] = array( 'module' => 'com.example.unknown', 'name' => 'foo', - 'entity' => NULL, // erroneous + // erroneous + 'entity' => NULL, 'params' => array( 'version' => 3, 'class_name' => 'CRM_Example_One_Foo', diff --git a/tests/phpunit/CRM/Core/MenuTest.php b/tests/phpunit/CRM/Core/MenuTest.php index 1b6a7d311a..fcb4c7ec6c 100644 --- a/tests/phpunit/CRM/Core/MenuTest.php +++ b/tests/phpunit/CRM/Core/MenuTest.php @@ -57,10 +57,14 @@ class CRM_Core_MenuTest extends CiviUnitTestCase { $this->assertEquals(array(), $menu['civicrm/foo/bar']['ids_arguments']['html']); $idsConfig = CRM_Core_IDS::createRouteConfig($menu['civicrm/foo/bar']); - $this->assertTrue(in_array('alpha', $idsConfig['General']['json'])); // XML - $this->assertTrue(in_array('beta', $idsConfig['General']['json'])); // XML - $this->assertTrue(in_array('gamma', $idsConfig['General']['exceptions'])); // XML - $this->assertTrue(in_array('thankyou_text', $idsConfig['General']['exceptions'])); // Inherited + // XML + $this->assertTrue(in_array('alpha', $idsConfig['General']['json'])); + // XML + $this->assertTrue(in_array('beta', $idsConfig['General']['json'])); + // XML + $this->assertTrue(in_array('gamma', $idsConfig['General']['exceptions'])); + // Inherited + $this->assertTrue(in_array('thankyou_text', $idsConfig['General']['exceptions'])); } /** @@ -73,7 +77,7 @@ class CRM_Core_MenuTest extends CiviUnitTestCase { $this->assertFalse(isset($item['ids_arguments']['exceptions'])); $this->assertFalse(isset($item['whimsy'])); - CRM_Utils_Hook::singleton()->setHook('civicrm_alterMenu', function(&$items){ + CRM_Utils_Hook::singleton()->setHook('civicrm_alterMenu', function(&$items) { $items['civicrm/case']['ids_arguments']['exceptions'][] = 'foobar'; $items['civicrm/case']['whimsy'] = 'godliness'; }); @@ -88,7 +92,8 @@ class CRM_Core_MenuTest extends CiviUnitTestCase { * @return array */ public function pathArguments() { - $cases = array(); // array(0 => string $input, 1 => array $expectedOutput) + // array(0 => string $input, 1 => array $expectedOutput) + $cases = array(); //$cases[] = array(NULL, array()); //$cases[] = array('', array()); //$cases[] = array('freestanding', array('freestanding' => NULL)); diff --git a/tests/phpunit/CRM/Core/OptionGroupTest.php b/tests/phpunit/CRM/Core/OptionGroupTest.php index d5309f0bf9..340756d0db 100644 --- a/tests/phpunit/CRM/Core/OptionGroupTest.php +++ b/tests/phpunit/CRM/Core/OptionGroupTest.php @@ -91,7 +91,6 @@ class CRM_Core_OptionGroupTest extends CiviUnitTestCase { } } - public function emailAddressTests() { $tests[] = array('"Name"', '"Name" '); $tests[] = array('"Name" ', '"Name" '); @@ -99,7 +98,6 @@ class CRM_Core_OptionGroupTest extends CiviUnitTestCase { return $tests; } - /** * @dataProvider emailAddressTests */ diff --git a/tests/phpunit/CRM/Core/Page/AJAXTest.php b/tests/phpunit/CRM/Core/Page/AJAXTest.php index 6079069776..4ba11db870 100644 --- a/tests/phpunit/CRM/Core/Page/AJAXTest.php +++ b/tests/phpunit/CRM/Core/Page/AJAXTest.php @@ -5,6 +5,7 @@ * @group headless */ class CRM_Core_Page_AJAXTest extends CiviUnitTestCase { + public function testCheckAuthz() { $cases = array(); diff --git a/tests/phpunit/CRM/Core/Page/RedirectTest.php b/tests/phpunit/CRM/Core/Page/RedirectTest.php index 686665df92..85514f6dd0 100644 --- a/tests/phpunit/CRM/Core/Page/RedirectTest.php +++ b/tests/phpunit/CRM/Core/Page/RedirectTest.php @@ -10,6 +10,7 @@ class CRM_Core_Page_RedirectTest extends CiviUnitTestCase { * * @return array */ + /** * @return array */ diff --git a/tests/phpunit/CRM/Core/Payment/AuthorizeNetIPNTest.php b/tests/phpunit/CRM/Core/Payment/AuthorizeNetIPNTest.php index 300f6324ff..0c302a5b41 100644 --- a/tests/phpunit/CRM/Core/Payment/AuthorizeNetIPNTest.php +++ b/tests/phpunit/CRM/Core/Payment/AuthorizeNetIPNTest.php @@ -33,6 +33,7 @@ class CRM_Core_Payment_AuthorizeNetIPNTest extends CiviUnitTestCase { public function tearDown() { $this->quickCleanUpFinancialEntities(); } + /** * Ensure recurring contributions from Contribution Pages * with receipt turned off don't send a receipt. @@ -131,9 +132,9 @@ class CRM_Core_Payment_AuthorizeNetIPNTest extends CiviUnitTestCase { $IPN = new CRM_Core_Payment_AuthorizeNetIPN($this->getRecurSubsequentTransaction()); $IPN->main(); $contribution = $this->callAPISuccess('contribution', 'get', array( - 'contribution_recur_id' => $this->_contributionRecurID, - 'sequential' => 1, - )); + 'contribution_recur_id' => $this->_contributionRecurID, + 'sequential' => 1, + )); $this->assertEquals(2, $contribution['count']); $this->assertEquals('second_one', $contribution['values'][1]['trxn_id']); $this->assertEquals(date('Y-m-d'), date('Y-m-d', strtotime($contribution['values'][1]['receive_date']))); @@ -184,7 +185,6 @@ class CRM_Core_Payment_AuthorizeNetIPNTest extends CiviUnitTestCase { $this->assertEquals('2010-07-01', date('Y-m-d', strtotime($contribution['values'][1]['receive_date']))); } - /** * Test IPN response updates contribution_recur & contribution for first & second contribution */ @@ -202,9 +202,9 @@ class CRM_Core_Payment_AuthorizeNetIPNTest extends CiviUnitTestCase { $IPN = new CRM_Core_Payment_AuthorizeNetIPN($this->getRecurSubsequentTransaction()); $IPN->main(); $contribution = $this->callAPISuccess('contribution', 'get', array( - 'contribution_recur_id' => $this->_contributionRecurID, - 'sequential' => 1, - )); + 'contribution_recur_id' => $this->_contributionRecurID, + 'sequential' => 1, + )); $this->assertEquals(2, $contribution['count']); // Ensure both contributions are coded as credit card contributions. $this->assertEquals(1, $contribution['values'][0]['payment_instrument_id']); @@ -212,9 +212,9 @@ class CRM_Core_Payment_AuthorizeNetIPNTest extends CiviUnitTestCase { $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', - )); + '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 080a8d720d..4a1e48c908 100644 --- a/tests/phpunit/CRM/Core/Payment/AuthorizeNetTest.php +++ b/tests/phpunit/CRM/Core/Payment/AuthorizeNetTest.php @@ -53,7 +53,7 @@ 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) . uniqid(); + $firstName = 'John_' . substr(sha1(rand()), 0, 7) . uniqid(); $lastName = 'Smith_' . substr(sha1(rand()), 0, 7) . uniqid(); $nameParams = array('first_name' => $firstName, 'last_name' => $lastName); $contactId = $this->individualCreate($nameParams); diff --git a/tests/phpunit/CRM/Core/Payment/BaseIPNTest.php b/tests/phpunit/CRM/Core/Payment/BaseIPNTest.php index 20598d4712..a1e6073706 100644 --- a/tests/phpunit/CRM/Core/Payment/BaseIPNTest.php +++ b/tests/phpunit/CRM/Core/Payment/BaseIPNTest.php @@ -140,8 +140,8 @@ class CRM_Core_Payment_BaseIPNTest extends CiviUnitTestCase { $this->ids['contact'] = $this->_contactId = $this->individualCreate(array( 'first_name' => 'Donald', 'last_name' => 'Duck', - 'email' => 'the-don@duckville.com, - ')); + 'email' => 'the-don@duckville.com', + )); $contribution = $this->callAPISuccess('contribution', 'create', array_merge($this->_contributionParams, array('invoice_id' => 'abc'))); $this->_contributionId = $contribution['id']; $this->_setUpMembershipObjects(); @@ -273,11 +273,10 @@ class CRM_Core_Payment_BaseIPNTest extends CiviUnitTestCase { $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(); } diff --git a/tests/phpunit/CRM/Core/Payment/PayPalIPNTest.php b/tests/phpunit/CRM/Core/Payment/PayPalIPNTest.php index 3f1b49dda6..126bc6cb6f 100644 --- a/tests/phpunit/CRM/Core/Payment/PayPalIPNTest.php +++ b/tests/phpunit/CRM/Core/Payment/PayPalIPNTest.php @@ -135,9 +135,9 @@ class CRM_Core_Payment_PayPalIPNTest extends CiviUnitTestCase { $paypalIPN = new CRM_Core_Payment_PayPalIPN($this->getPaypalRecurSubsequentTransaction()); $paypalIPN->main(); $contributions = $this->callAPISuccess('contribution', 'get', array( - 'contribution_recur_id' => $this->_contributionRecurID, - 'sequential' => 1, - )); + 'contribution_recur_id' => $this->_contributionRecurID, + 'sequential' => 1, + )); $this->assertEquals(2, $contributions['count']); $contribution2 = $contributions['values'][1]; $this->assertEquals('secondone', $contribution2['trxn_id']); @@ -177,19 +177,19 @@ class CRM_Core_Payment_PayPalIPNTest extends CiviUnitTestCase { $renewedMembershipEndDate = $this->membershipRenewalDate($durationUnit, $membershipEndDate); $this->assertEquals($renewedMembershipEndDate, $this->callAPISuccessGetValue('membership', array('return' => 'end_date'))); $contribution = $this->callAPISuccess('contribution', 'get', array( - 'contribution_recur_id' => $this->_contributionRecurID, - 'sequential' => 1, - )); + '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); + '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', - )); + 'contribution_id' => $contribution['values'][1]['id'], + 'entity_table' => 'civicrm_membership', + )); $this->callAPISuccessGetSingle('membership_payment', array('contribution_id' => $contribution['values'][1]['id'])); } diff --git a/tests/phpunit/CRM/Core/Payment/PayPalProIPNTest.php b/tests/phpunit/CRM/Core/Payment/PayPalProIPNTest.php index 949d3aa35c..f1cb8d2919 100644 --- a/tests/phpunit/CRM/Core/Payment/PayPalProIPNTest.php +++ b/tests/phpunit/CRM/Core/Payment/PayPalProIPNTest.php @@ -52,12 +52,11 @@ class CRM_Core_Payment_PayPalProIPNTest extends CiviUnitTestCase { $this->_paymentProcessorID = $this->paymentProcessorCreate(array('is_test' => 0)); $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']; } @@ -90,9 +89,9 @@ class CRM_Core_Payment_PayPalProIPNTest extends CiviUnitTestCase { $paypalIPN = new CRM_Core_Payment_PayPalProIPN($this->getPaypalProRecurSubsequentTransaction()); $paypalIPN->main(); $contribution = $this->callAPISuccess('contribution', 'get', array( - 'contribution_recur_id' => $this->_contributionRecurID, - 'sequential' => 1, - )); + 'contribution_recur_id' => $this->_contributionRecurID, + 'sequential' => 1, + )); $this->assertEquals(2, $contribution['count']); $this->assertEquals('secondone', $contribution['values'][1]['trxn_id']); $this->assertEquals('Debit Card', $contribution['values'][1]['payment_instrument']); @@ -121,19 +120,19 @@ class CRM_Core_Payment_PayPalProIPNTest extends CiviUnitTestCase { $renewedMembershipEndDate = $this->membershipRenewalDate($durationUnit, $membershipEndDate); $this->assertEquals($renewedMembershipEndDate, $this->callAPISuccessGetValue('membership', array('return' => 'end_date'))); $contribution = $this->callAPISuccess('contribution', 'get', array( - 'contribution_recur_id' => $this->_contributionRecurID, - 'sequential' => 1, - )); + '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); + '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', - )); + 'contribution_id' => $contribution['values'][1]['id'], + 'entity_table' => 'civicrm_membership', + )); $this->callAPISuccessGetSingle('membership_payment', array('contribution_id' => $contribution['values'][1]['id'])); } @@ -161,9 +160,9 @@ class CRM_Core_Payment_PayPalProIPNTest extends CiviUnitTestCase { $paypalIPN = new CRM_Core_Payment_PayPalProIPN($this->getPaypalProRecurSubsequentTransaction()); $paypalIPN->main(); $contribution = $this->callAPISuccess('contribution', 'get', array( - 'contribution_recur_id' => $this->_contributionRecurID, - 'sequential' => 1, - )); + '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'])); @@ -397,10 +396,10 @@ class CRM_Core_Payment_PayPalProIPNTest extends CiviUnitTestCase { 'residence_country' => 'GB', 'initial_payment_amount' => '0.00', 'rp_invoice_id' => 'i=' . $this->_invoiceID - . '&m=&c=' . $this->_contributionID - . '&r=' . $this->_contributionRecurID - . '&b=' . $this->_contactID - . '&p=' . $this->_contributionPageID, + . '&m=&c=' . $this->_contributionID + . '&r=' . $this->_contributionRecurID + . '&b=' . $this->_contactID + . '&p=' . $this->_contributionPageID, 'currency_code' => 'GBP', 'time_created' => '12:39:01 May 09, 2018 PDT', 'verify_sign' => 'AUg223oCjn4HgJXKkrICawXQ3fyUA2gAd1.f1IPJ4r.9sln-nWcB-EJG', diff --git a/tests/phpunit/CRM/Core/PseudoConstantTest.php b/tests/phpunit/CRM/Core/PseudoConstantTest.php index e924e6240d..100f317ecb 100644 --- a/tests/phpunit/CRM/Core/PseudoConstantTest.php +++ b/tests/phpunit/CRM/Core/PseudoConstantTest.php @@ -1078,16 +1078,16 @@ class CRM_Core_PseudoConstantTest extends CiviUnitTestCase { $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', - )); + '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, - )); + 'keyColumn' => 'id', + 'labelColumn' => 'name', + 'flip' => TRUE, + )); $this->assertEquals(array_flip($byId), $result); } @@ -1099,14 +1099,14 @@ class CRM_Core_PseudoConstantTest extends CiviUnitTestCase { 'is_active' => 1, )); $financialAccount = $this->callAPISuccess('financial_account', 'create', array( - 'name' => 'Test Tax financial account ', - 'contact_id' => $contact, - 'financial_account_type_id' => 2, - 'is_tax' => 1, - 'tax_rate' => 5.00, - 'is_reserved' => 0, - 'is_active' => 1, - 'is_default' => 0, + 'name' => 'Test Tax financial account ', + 'contact_id' => $contact, + 'financial_account_type_id' => 2, + 'is_tax' => 1, + 'tax_rate' => 5.00, + 'is_reserved' => 0, + 'is_active' => 1, + 'is_default' => 0, )); $financialTypeId = $financialType['id']; $financialAccountId = $financialAccount['id']; diff --git a/tests/phpunit/CRM/Core/RegionTest.php b/tests/phpunit/CRM/Core/RegionTest.php index 3f4956eba1..b4ed3894ed 100644 --- a/tests/phpunit/CRM/Core/RegionTest.php +++ b/tests/phpunit/CRM/Core/RegionTest.php @@ -5,6 +5,7 @@ * @group headless */ class CRM_Core_RegionTest extends CiviUnitTestCase { + public function setUp() { parent::setUp(); require_once 'CRM/Core/Smarty.php'; diff --git a/tests/phpunit/CRM/Core/ResourcesTest.php b/tests/phpunit/CRM/Core/ResourcesTest.php index 8feda00796..c9b76195ee 100644 --- a/tests/phpunit/CRM/Core/ResourcesTest.php +++ b/tests/phpunit/CRM/Core/ResourcesTest.php @@ -77,12 +77,14 @@ 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 + // extra + ->addScriptFile('com.example.ext', 'foo%20bar.js', 0, 'testAddScriptFile') ->addScriptFile('civicrm', 'foo%20bar.js', 0, 'testAddScriptFile'); $smarty = CRM_Core_Smarty::singleton(); $actual = $smarty->fetch('string:{crmRegion name=testAddScriptFile}{/crmRegion}'); - $expected = "" // stable ordering: alphabetical by (snippet.weight,snippet.name) + // stable ordering: alphabetical by (snippet.weight,snippet.name) + $expected = "" . "\n" . "\n"; $this->assertEquals($expected, $actual); @@ -108,12 +110,14 @@ class CRM_Core_ResourcesTest extends CiviUnitTestCase { public function testAddScriptURL() { $this->res ->addScriptUrl('/whiz/foo%20bar.js', 0, 'testAddScriptURL') - ->addScriptUrl('/whiz/foo%20bar.js', 0, 'testAddScriptURL')// extra + // extra + ->addScriptUrl('/whiz/foo%20bar.js', 0, 'testAddScriptURL') ->addScriptUrl('/whizbang/foo%20bar.js', 0, 'testAddScriptURL'); $smarty = CRM_Core_Smarty::singleton(); $actual = $smarty->fetch('string:{crmRegion name=testAddScriptURL}{/crmRegion}'); - $expected = "" // stable ordering: alphabetical by (snippet.weight,snippet.name) + // stable ordering: alphabetical by (snippet.weight,snippet.name) + $expected = "" . "\n" . "\n"; $this->assertEquals($expected, $actual); @@ -218,7 +222,8 @@ class CRM_Core_ResourcesTest extends CiviUnitTestCase { $this->assertEquals('', $actual); $actual = $smarty->fetch('string:{crmRegion name=testCrmJS}{/crmRegion}'); - $expected = "" // stable ordering: alphabetical by (snippet.weight,snippet.name) + // stable ordering: alphabetical by (snippet.weight,snippet.name) + $expected = "" . "\n" . "\n"; $this->assertEquals($expected, $actual); @@ -227,12 +232,14 @@ 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 + // extra + ->addStyleFile('com.example.ext', 'foo%20bar.css', 0, 'testAddStyleFile') ->addStyleFile('civicrm', 'foo%20bar.css', 0, 'testAddStyleFile'); $smarty = CRM_Core_Smarty::singleton(); $actual = $smarty->fetch('string:{crmRegion name=testAddStyleFile}{/crmRegion}'); - $expected = "" // stable ordering: alphabetical by (snippet.weight,snippet.name) + // stable ordering: alphabetical by (snippet.weight,snippet.name) + $expected = "" . "\n" . "\n"; $this->assertEquals($expected, $actual); @@ -241,12 +248,14 @@ 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 + // extra + ->addStyleUrl('/whiz/foo%20bar.css', 0, 'testAddStyleURL') ->addStyleUrl('/whizbang/foo%20bar.css', 0, 'testAddStyleURL'); $smarty = CRM_Core_Smarty::singleton(); $actual = $smarty->fetch('string:{crmRegion name=testAddStyleURL}{/crmRegion}'); - $expected = "" // stable ordering: alphabetical by (snippet.weight,snippet.name) + // stable ordering: alphabetical by (snippet.weight,snippet.name) + $expected = "" . "\n" . "\n"; $this->assertEquals($expected, $actual); @@ -275,7 +284,8 @@ class CRM_Core_ResourcesTest extends CiviUnitTestCase { $this->assertEquals('', $actual); $actual = $smarty->fetch('string:{crmRegion name=testCrmCSS}{/crmRegion}'); - $expected = "" // stable ordering: alphabetical by (snippet.weight,snippet.name) + // stable ordering: alphabetical by (snippet.weight,snippet.name) + $expected = "" . "\n" . "\n"; $this->assertEquals($expected, $actual); diff --git a/tests/phpunit/CRM/Core/Smarty/plugins/CrmMoneyTest.php b/tests/phpunit/CRM/Core/Smarty/plugins/CrmMoneyTest.php index 1a2f62f7fa..e2e2e6a40a 100644 --- a/tests/phpunit/CRM/Core/Smarty/plugins/CrmMoneyTest.php +++ b/tests/phpunit/CRM/Core/Smarty/plugins/CrmMoneyTest.php @@ -5,6 +5,7 @@ * @group headless */ class CRM_Core_Smarty_plugins_CrmMoneyTest extends CiviUnitTestCase { + public function setUp() { parent::setUp(); require_once 'CRM/Core/Smarty.php'; @@ -23,7 +24,7 @@ class CRM_Core_Smarty_plugins_CrmMoneyTest extends CiviUnitTestCase { $cases[] = ['€ 1,234.00', '{assign var="amount" value="1234.00"}{$amount|crmMoney:EUR}']; $cases[] = [ '$ ', - '{assign var="amount" value=\'\'}{$amount|crmMoney:USD}' + '{assign var="amount" value=\'\'}{$amount|crmMoney:USD}', ]; return $cases; } diff --git a/tests/phpunit/CRM/Core/Smarty/plugins/CrmScopeTest.php b/tests/phpunit/CRM/Core/Smarty/plugins/CrmScopeTest.php index 79ddcbcff4..54ac3a2e8d 100644 --- a/tests/phpunit/CRM/Core/Smarty/plugins/CrmScopeTest.php +++ b/tests/phpunit/CRM/Core/Smarty/plugins/CrmScopeTest.php @@ -5,6 +5,7 @@ * @group headless */ class CRM_Core_Smarty_plugins_CrmScopeTest extends CiviUnitTestCase { + public function setUp() { parent::setUp(); require_once 'CRM/Core/Smarty.php'; diff --git a/tests/phpunit/CRM/Core/TransactionTest.php b/tests/phpunit/CRM/Core/TransactionTest.php index 43d109a081..5836f791bb 100644 --- a/tests/phpunit/CRM/Core/TransactionTest.php +++ b/tests/phpunit/CRM/Core/TransactionTest.php @@ -84,8 +84,10 @@ class CRM_Core_TransactionTest extends CiviUnitTestCase { $this->runBatch( 'reuse-tx', array( - array('reuse-tx', $createStyle, $commitStyle), // cid 0 - array('reuse-tx', $createStyle, $commitStyle), // cid 1 + // cid 0 + array('reuse-tx', $createStyle, $commitStyle), + // cid 1 + array('reuse-tx', $createStyle, $commitStyle), ), array(0 => TRUE, 1 => TRUE), 'rollback' @@ -110,9 +112,12 @@ class CRM_Core_TransactionTest extends CiviUnitTestCase { $this->runBatch( 'reuse-tx', array( - array('nest-tx', $createStyle, $commitStyle), // cid 0 - array('nest-tx', $createStyle, 'rollback'), // cid 1 - array('nest-tx', $createStyle, $commitStyle), // cid 2 + // cid 0 + array('nest-tx', $createStyle, $commitStyle), + // cid 1 + array('nest-tx', $createStyle, 'rollback'), + // cid 2 + array('nest-tx', $createStyle, $commitStyle), ), array(0 => TRUE, 1 => FALSE, 2 => TRUE), $commitStyle @@ -137,9 +142,12 @@ class CRM_Core_TransactionTest extends CiviUnitTestCase { $this->runBatch( 'reuse-tx', array( - array('reuse-tx', $createStyle, $commitStyle), // cid 0 - array('reuse-tx', $createStyle, 'rollback'), // cid 1 - array('reuse-tx', $createStyle, $commitStyle), // cid 2 + // cid 0 + array('reuse-tx', $createStyle, $commitStyle), + // cid 1 + array('reuse-tx', $createStyle, 'rollback'), + // cid 2 + array('reuse-tx', $createStyle, $commitStyle), ), array(0 => TRUE, 1 => TRUE, 2 => TRUE), $commitStyle @@ -164,9 +172,12 @@ class CRM_Core_TransactionTest extends CiviUnitTestCase { $this->runBatch( 'reuse-tx', array( - array('nest-tx', $createStyle, $commitStyle), // cid 0 - array('nest-tx', $createStyle, 'rollback'), // cid 1 - array('nest-tx', $createStyle, $commitStyle), // cid 2 + // cid 0 + array('nest-tx', $createStyle, $commitStyle), + // cid 1 + array('nest-tx', $createStyle, 'rollback'), + // cid 2 + array('nest-tx', $createStyle, $commitStyle), ), array(0 => TRUE, 1 => FALSE, 2 => TRUE), 'rollback' @@ -208,21 +219,21 @@ class CRM_Core_TransactionTest extends CiviUnitTestCase { $tx = new CRM_Core_Transaction(); CRM_Core_Transaction::addCallback(CRM_Core_Transaction::PHASE_PRE_COMMIT, array($this, '_preCommit'), array( - 'qwe', - 'rty', - )); + 'qwe', + 'rty', + )); CRM_Core_Transaction::addCallback(CRM_Core_Transaction::PHASE_POST_COMMIT, array($this, '_postCommit'), array( - 'uio', - 'p[]', - )); + 'uio', + 'p[]', + )); CRM_Core_Transaction::addCallback(CRM_Core_Transaction::PHASE_PRE_ROLLBACK, array( - $this, - '_preRollback', - ), array('asd', 'fgh')); + $this, + '_preRollback', + ), array('asd', 'fgh')); CRM_Core_Transaction::addCallback(CRM_Core_Transaction::PHASE_POST_ROLLBACK, array( - $this, - '_postRollback', - ), array('jkl', ';')); + $this, + '_postRollback', + ), array('jkl', ';')); CRM_Core_DAO::executeQuery('UPDATE civicrm_contact SET id = 100 WHERE id = 100'); @@ -236,21 +247,21 @@ class CRM_Core_TransactionTest extends CiviUnitTestCase { $tx = new CRM_Core_Transaction(); CRM_Core_Transaction::addCallback(CRM_Core_Transaction::PHASE_PRE_COMMIT, array($this, '_preCommit'), array( - 'ewq', - 'ytr', - )); + 'ewq', + 'ytr', + )); CRM_Core_Transaction::addCallback(CRM_Core_Transaction::PHASE_POST_COMMIT, array($this, '_postCommit'), array( - 'oiu', - '][p', - )); + 'oiu', + '][p', + )); CRM_Core_Transaction::addCallback(CRM_Core_Transaction::PHASE_PRE_ROLLBACK, array( - $this, - '_preRollback', - ), array('dsa', 'hgf')); + $this, + '_preRollback', + ), array('dsa', 'hgf')); CRM_Core_Transaction::addCallback(CRM_Core_Transaction::PHASE_POST_ROLLBACK, array( - $this, - '_postRollback', - ), array('lkj', ';')); + $this, + '_postRollback', + ), array('lkj', ';')); CRM_Core_DAO::executeQuery('UPDATE civicrm_contact SET id = 100 WHERE id = 100'); $tx->rollback(); @@ -287,7 +298,8 @@ class CRM_Core_TransactionTest extends CiviUnitTestCase { public function testRun_exception($createStyle, $commitStyle) { $tx = new CRM_Core_Transaction(); $test = $this; - $e = NULL; // Exception + // Exception + $e = NULL; try { CRM_Core_Transaction::create(TRUE)->run(function ($tx) use (&$test, $createStyle, $commitStyle) { $test->createContactWithTransaction('nest-tx', $createStyle, $commitStyle); diff --git a/tests/phpunit/CRM/Dedupe/MergerTest.php b/tests/phpunit/CRM/Dedupe/MergerTest.php index e98380a807..96f440873f 100644 --- a/tests/phpunit/CRM/Dedupe/MergerTest.php +++ b/tests/phpunit/CRM/Dedupe/MergerTest.php @@ -153,7 +153,8 @@ class CRM_Dedupe_MergerTest extends CiviUnitTestCase { $this->assertEquals(count($foundDupes), 3, 'Check Individual-Supervised dupe rule for dupesInGroup().'); // Run dedupe finder as the browser would - $_SERVER['REQUEST_METHOD'] = 'GET'; //avoid invalid key error + //avoid invalid key error + $_SERVER['REQUEST_METHOD'] = 'GET'; $object = new CRM_Contact_Page_DedupeFind(); $object->set('gid', $this->_groupId); $object->set('rgid', $dao->id); @@ -216,7 +217,8 @@ class CRM_Dedupe_MergerTest extends CiviUnitTestCase { $this->assertEquals(count($foundDupes), 3, 'Check Individual-Supervised dupe rule for dupesInGroup().'); // Run dedupe finder as the browser would - $_SERVER['REQUEST_METHOD'] = 'GET'; //avoid invalid key error + //avoid invalid key error + $_SERVER['REQUEST_METHOD'] = 'GET'; $object = new CRM_Contact_Page_DedupeFind(); $object->set('gid', $this->_groupId); $object->set('rgid', $dao->id); @@ -510,7 +512,7 @@ class CRM_Dedupe_MergerTest extends CiviUnitTestCase { //Merge and move the mem to the main contact. $this->mergeContacts($originalContactID, $duplicateContactID, [ 'move_rel_table_memberships' => 1, - 'operation' => ['move_rel_table_memberships' => ['add' => 1]] + 'operation' => ['move_rel_table_memberships' => ['add' => 1]], ]); //Check if membership is correctly transferred to original contact. @@ -535,8 +537,10 @@ class CRM_Dedupe_MergerTest extends CiviUnitTestCase { $this->setupMatchData(); $originalContactID = $this->contacts[0]['id']; - $duplicateContactID1 = $this->contacts[1]['id']; // used as duplicate contact in 1st use-case - $duplicateContactID2 = $this->contacts[2]['id']; // used as duplicate contact in 2nd use-case + // used as duplicate contact in 1st use-case + $duplicateContactID1 = $this->contacts[1]['id']; + // used as duplicate contact in 2nd use-case + $duplicateContactID2 = $this->contacts[2]['id']; // update the text custom field for original contact with value 'abc' $this->callAPISuccess('Contact', 'create', array( @@ -561,7 +565,7 @@ class CRM_Dedupe_MergerTest extends CiviUnitTestCase { /*** USE-CASE 1: DO NOT OVERWRITE CUSTOM FIELD VALUE **/ $this->mergeContacts($originalContactID, $duplicateContactID1, array( - "move_{$customFieldName}" => NULL, + "move_{$customFieldName}" => NULL, )); $this->assertCustomFieldValue($originalContactID, 'abc', $customFieldName); @@ -818,7 +822,6 @@ class CRM_Dedupe_MergerTest extends CiviUnitTestCase { } } - /** * Get the list of tables that refer to the CID. * @@ -958,7 +961,8 @@ class CRM_Dedupe_MergerTest extends CiviUnitTestCase { ), 'civicrm_participant' => array( 0 => 'contact_id', - 1 => 'transferred_to_contact_id', //CRM-16761 + //CRM-16761 + 1 => 'transferred_to_contact_id', ), 'civicrm_payment_token' => array( 0 => 'contact_id', diff --git a/tests/phpunit/CRM/Event/BAO/AdditionalPaymentTest.php b/tests/phpunit/CRM/Event/BAO/AdditionalPaymentTest.php index 8c05c65f9b..aa4cd9e431 100644 --- a/tests/phpunit/CRM/Event/BAO/AdditionalPaymentTest.php +++ b/tests/phpunit/CRM/Event/BAO/AdditionalPaymentTest.php @@ -103,9 +103,9 @@ class CRM_Event_BAO_AdditionalPaymentTest extends CiviUnitTestCase { // add participant payment entry $this->callAPISuccess('participant_payment', 'create', array( - 'participant_id' => $participant['id'], - 'contribution_id' => $contributionId, - )); + 'participant_id' => $participant['id'], + 'contribution_id' => $contributionId, + )); // -- processing priceSet using the BAO $lineItem = array(); diff --git a/tests/phpunit/CRM/Event/BAO/ChangeFeeSelectionTest.php b/tests/phpunit/CRM/Event/BAO/ChangeFeeSelectionTest.php index d3002c716e..a2fc34fbbc 100644 --- a/tests/phpunit/CRM/Event/BAO/ChangeFeeSelectionTest.php +++ b/tests/phpunit/CRM/Event/BAO/ChangeFeeSelectionTest.php @@ -79,8 +79,8 @@ class CRM_Event_BAO_ChangeFeeSelectionTest extends CiviUnitTestCase { protected function priceSetCreate($type = 'Radio') { $feeTotal = 55; $minAmt = 0; - $paramsSet['title'] = 'Two Options' . substr(sha1(rand()), 0, 4); - $paramsSet['name'] = CRM_Utils_String::titleToVar('Two Options') . substr(sha1(rand()), 0, 4); + $paramsSet['title'] = 'Two Options' . substr(sha1(rand()), 0, 4); + $paramsSet['name'] = CRM_Utils_String::titleToVar('Two Options') . substr(sha1(rand()), 0, 4); $paramsSet['is_active'] = FALSE; $paramsSet['extends'] = 1; @@ -129,7 +129,7 @@ class CRM_Event_BAO_ChangeFeeSelectionTest extends CiviUnitTestCase { $field = CRM_Price_BAO_PriceField::create($paramsField); $values = $this->callAPISuccess('PriceFieldValue', 'get', [ 'price_field_id' => $field->id, - 'return' => ['id', 'label'] + 'return' => ['id', 'label'], ]); foreach ($values['values'] as $value) { switch ($value['label']) { @@ -410,19 +410,22 @@ class CRM_Event_BAO_ChangeFeeSelectionTest extends CiviUnitTestCase { $unpaidStatus = CRM_Core_PseudoConstant::getKey('CRM_Financial_DAO_FinancialItem', 'status_id', 'Unpaid'); $expectedResults = array( array( - 'amount' => 10.00, // when qty 1 is used + // when qty 1 is used + 'amount' => 10.00, 'status_id' => $unpaidStatus, 'entity_table' => 'civicrm_line_item', 'entity_id' => 1, ), array( - 'amount' => 20.00, // when qty 3 is used, add the surplus amount i.e. $30 - $10 = $20 + // when qty 3 is used, add the surplus amount i.e. $30 - $10 = $20 + 'amount' => 20.00, 'status_id' => $unpaidStatus, 'entity_table' => 'civicrm_line_item', 'entity_id' => 1, ), array( - 'amount' => -10.00, // when qty 2 is used, add the surplus amount i.e. $20 - $30 = -$10 + // when qty 2 is used, add the surplus amount i.e. $20 - $30 = -$10 + 'amount' => -10.00, 'status_id' => $unpaidStatus, 'entity_table' => 'civicrm_line_item', 'entity_id' => 1, diff --git a/tests/phpunit/CRM/Event/BAO/QueryTest.php b/tests/phpunit/CRM/Event/BAO/QueryTest.php index d95a7fbb0e..efa9bb5554 100644 --- a/tests/phpunit/CRM/Event/BAO/QueryTest.php +++ b/tests/phpunit/CRM/Event/BAO/QueryTest.php @@ -15,13 +15,13 @@ class CRM_Event_BAO_QueryTest extends CiviUnitTestCase { 'api.participant.create' => [ 'event_id' => $event['id'], 'note' => 'some_note', - ] + ], ]); $this->individualCreate([ 'api.participant.create' => [ 'event_id' => $event['id'], 'note' => 'some_other_note', - ] + ], ]); $params = [ [ @@ -30,7 +30,7 @@ class CRM_Event_BAO_QueryTest extends CiviUnitTestCase { 2 => 'some_note', 3 => 1, 4 => 0, - ] + ], ]; $query = new CRM_Contact_BAO_Query($params, NULL, NULL, FALSE, FALSE, CRM_Contact_BAO_Query::MODE_CONTACTS); diff --git a/tests/phpunit/CRM/Event/Form/ParticipantTest.php b/tests/phpunit/CRM/Event/Form/ParticipantTest.php index 4ed8844c0f..77f0982f03 100644 --- a/tests/phpunit/CRM/Event/Form/ParticipantTest.php +++ b/tests/phpunit/CRM/Event/Form/ParticipantTest.php @@ -207,10 +207,9 @@ class CRM_Event_Form_ParticipantTest extends CiviUnitTestCase { $this->testSubmitWithPayment($thousandSeparator); //Check if type is correctly populated in mails. $mail = $mut->checkMailLog([ - '

Test event type - 1

', - $this->formatMoneyInput(1550.55), - ] - ); + '

Test event type - 1

', + $this->formatMoneyInput(1550.55), + ]); } /** diff --git a/tests/phpunit/CRM/Event/Form/Registration/RegistrationTest.php b/tests/phpunit/CRM/Event/Form/Registration/RegistrationTest.php index 757119cbef..260d2d422e 100644 --- a/tests/phpunit/CRM/Event/Form/Registration/RegistrationTest.php +++ b/tests/phpunit/CRM/Event/Form/Registration/RegistrationTest.php @@ -35,7 +35,6 @@ class CRM_Event_Form_Registration_RegistrationTest extends CiviUnitTestCase { parent::setUp(); } - /** * CRM-19626 - Test minimum value configured for priceset. */ diff --git a/tests/phpunit/CRM/Export/BAO/ExportTest.php b/tests/phpunit/CRM/Export/BAO/ExportTest.php index 00626abc0f..156cc1d295 100644 --- a/tests/phpunit/CRM/Export/BAO/ExportTest.php +++ b/tests/phpunit/CRM/Export/BAO/ExportTest.php @@ -654,7 +654,7 @@ class CRM_Export_BAO_ExportTest extends CiviUnitTestCase { $relationships = [ $this->contactIDs[1] => ['label' => 'Spouse of'], $this->contactIDs[2] => ['label' => 'Household Member of'], - $this->contactIDs[3] => ['label' => 'Employee of'] + $this->contactIDs[3] => ['label' => 'Employee of'], ]; foreach ($relationships as $contactID => $relationshipType) { @@ -662,7 +662,7 @@ class CRM_Export_BAO_ExportTest extends CiviUnitTestCase { $result = $this->callAPISuccess('Relationship', 'create', [ 'contact_id_a' => $this->contactIDs[0], 'relationship_type_id' => $relationshipTypeID, - 'contact_id_b' => $contactID + 'contact_id_b' => $contactID, ]); $relationships[$contactID]['id'] = $result['id']; $relationships[$contactID]['relationship_type_id'] = $relationshipTypeID; @@ -817,7 +817,6 @@ class CRM_Export_BAO_ExportTest extends CiviUnitTestCase { } - /** * Test phone data export. * @@ -845,7 +844,7 @@ class CRM_Export_BAO_ExportTest extends CiviUnitTestCase { } $relationships = [ - $this->contactIDs[1] => ['label' => 'Spouse of'] + $this->contactIDs[1] => ['label' => 'Spouse of'], ]; foreach ($relationships as $contactID => $relationshipType) { @@ -853,7 +852,7 @@ class CRM_Export_BAO_ExportTest extends CiviUnitTestCase { $result = $this->callAPISuccess('Relationship', 'create', [ 'contact_id_a' => $this->contactIDs[0], 'relationship_type_id' => $relationshipTypeID, - 'contact_id_b' => $contactID + 'contact_id_b' => $contactID, ]); $relationships[$contactID]['id'] = $result['id']; $relationships[$contactID]['relationship_type_id'] = $relationshipTypeID; @@ -943,7 +942,7 @@ class CRM_Export_BAO_ExportTest extends CiviUnitTestCase { $relationships = [ $this->contactIDs[1] => ['label' => 'Spouse of'], $this->contactIDs[2] => ['label' => 'Household Member of'], - $this->contactIDs[3] => ['label' => 'Employee of'] + $this->contactIDs[3] => ['label' => 'Employee of'], ]; foreach ($relationships as $contactID => $relationshipType) { @@ -951,7 +950,7 @@ class CRM_Export_BAO_ExportTest extends CiviUnitTestCase { $result = $this->callAPISuccess('Relationship', 'create', [ 'contact_id_a' => $this->contactIDs[0], 'relationship_type_id' => $relationshipTypeID, - 'contact_id_b' => $contactID + 'contact_id_b' => $contactID, ]); $relationships[$contactID]['id'] = $result['id']; $relationships[$contactID]['relationship_type_id'] = $relationshipTypeID; @@ -1148,6 +1147,7 @@ class CRM_Export_BAO_ExportTest extends CiviUnitTestCase { [[], ['street_address' => '']], ]; } + /** * @return array */ @@ -1158,8 +1158,8 @@ class CRM_Export_BAO_ExportTest extends CiviUnitTestCase { 'api.Address.create' => [ 'city' => 'Portland', 'state_province_id' => 'Maine', - 'location_type_id' => 'Home' - ] + 'location_type_id' => 'Home', + ], ]); $relationshipTypes = $this->callAPISuccess('RelationshipType', 'get', [])['values']; @@ -1738,6 +1738,7 @@ class CRM_Export_BAO_ExportTest extends CiviUnitTestCase { list($tableName, $sqlColumns) = $this->doExport($selectedFields, $this->contactIDs[1], CRM_Export_Form_Select::EVENT_EXPORT); $this->assertEquals($expected, $sqlColumns); } + /** * Get all return fields (@todo - still being built up. * @@ -2035,90 +2036,90 @@ class CRM_Export_BAO_ExportTest extends CiviUnitTestCase { */ protected function getBasicHeaderDefinition($isContactExport) { $headers = [ - 0 => 'Contact ID', - 1 => 'Contact Type', - 2 => 'Contact Subtype', - 3 => 'Do Not Email', - 4 => 'Do Not Phone', - 5 => 'Do Not Mail', - 6 => 'Do Not Sms', - 7 => 'Do Not Trade', - 8 => 'No Bulk Emails (User Opt Out)', - 9 => 'Legal Identifier', - 10 => 'External Identifier', - 11 => 'Sort Name', - 12 => 'Display Name', - 13 => 'Nickname', - 14 => 'Legal Name', - 15 => 'Image Url', - 16 => 'Preferred Communication Method', - 17 => 'Preferred Language', - 18 => 'Preferred Mail Format', - 19 => 'Contact Hash', - 20 => 'Contact Source', - 21 => 'First Name', - 22 => 'Middle Name', - 23 => 'Last Name', - 24 => 'Individual Prefix', - 25 => 'Individual Suffix', - 26 => 'Formal Title', - 27 => 'Communication Style', - 28 => 'Email Greeting ID', - 29 => 'Postal Greeting ID', - 30 => 'Addressee ID', - 31 => 'Job Title', - 32 => 'Gender', - 33 => 'Birth Date', - 34 => 'Deceased', - 35 => 'Deceased Date', - 36 => 'Household Name', - 37 => 'Organization Name', - 38 => 'Sic Code', - 39 => 'Unique ID (OpenID)', - 40 => 'Current Employer ID', - 41 => 'Contact is in Trash', - 42 => 'Created Date', - 43 => 'Modified Date', - 44 => 'Addressee', - 45 => 'Email Greeting', - 46 => 'Postal Greeting', - 47 => 'Current Employer', - 48 => 'Location Type', - 49 => 'Street Address', - 50 => 'Street Number', - 51 => 'Street Number Suffix', - 52 => 'Street Name', - 53 => 'Street Unit', - 54 => 'Supplemental Address 1', - 55 => 'Supplemental Address 2', - 56 => 'Supplemental Address 3', - 57 => 'City', - 58 => 'Postal Code Suffix', - 59 => 'Postal Code', - 60 => 'Latitude', - 61 => 'Longitude', - 62 => 'Address Name', - 63 => 'Master Address Belongs To', - 64 => 'County', - 65 => 'State', - 66 => 'Country', - 67 => 'Phone', - 68 => 'Phone Extension', - 69 => 'Phone Type', - 70 => 'Email', - 71 => 'On Hold', - 72 => 'Use for Bulk Mail', - 73 => 'Signature Text', - 74 => 'Signature Html', - 75 => 'IM Provider', - 76 => 'IM Screen Name', - 77 => 'OpenID', - 78 => 'World Region', - 79 => 'Website', - 80 => 'Group(s)', - 81 => 'Tag(s)', - 82 => 'Note(s)', - ]; + 0 => 'Contact ID', + 1 => 'Contact Type', + 2 => 'Contact Subtype', + 3 => 'Do Not Email', + 4 => 'Do Not Phone', + 5 => 'Do Not Mail', + 6 => 'Do Not Sms', + 7 => 'Do Not Trade', + 8 => 'No Bulk Emails (User Opt Out)', + 9 => 'Legal Identifier', + 10 => 'External Identifier', + 11 => 'Sort Name', + 12 => 'Display Name', + 13 => 'Nickname', + 14 => 'Legal Name', + 15 => 'Image Url', + 16 => 'Preferred Communication Method', + 17 => 'Preferred Language', + 18 => 'Preferred Mail Format', + 19 => 'Contact Hash', + 20 => 'Contact Source', + 21 => 'First Name', + 22 => 'Middle Name', + 23 => 'Last Name', + 24 => 'Individual Prefix', + 25 => 'Individual Suffix', + 26 => 'Formal Title', + 27 => 'Communication Style', + 28 => 'Email Greeting ID', + 29 => 'Postal Greeting ID', + 30 => 'Addressee ID', + 31 => 'Job Title', + 32 => 'Gender', + 33 => 'Birth Date', + 34 => 'Deceased', + 35 => 'Deceased Date', + 36 => 'Household Name', + 37 => 'Organization Name', + 38 => 'Sic Code', + 39 => 'Unique ID (OpenID)', + 40 => 'Current Employer ID', + 41 => 'Contact is in Trash', + 42 => 'Created Date', + 43 => 'Modified Date', + 44 => 'Addressee', + 45 => 'Email Greeting', + 46 => 'Postal Greeting', + 47 => 'Current Employer', + 48 => 'Location Type', + 49 => 'Street Address', + 50 => 'Street Number', + 51 => 'Street Number Suffix', + 52 => 'Street Name', + 53 => 'Street Unit', + 54 => 'Supplemental Address 1', + 55 => 'Supplemental Address 2', + 56 => 'Supplemental Address 3', + 57 => 'City', + 58 => 'Postal Code Suffix', + 59 => 'Postal Code', + 60 => 'Latitude', + 61 => 'Longitude', + 62 => 'Address Name', + 63 => 'Master Address Belongs To', + 64 => 'County', + 65 => 'State', + 66 => 'Country', + 67 => 'Phone', + 68 => 'Phone Extension', + 69 => 'Phone Type', + 70 => 'Email', + 71 => 'On Hold', + 72 => 'Use for Bulk Mail', + 73 => 'Signature Text', + 74 => 'Signature Html', + 75 => 'IM Provider', + 76 => 'IM Screen Name', + 77 => 'OpenID', + 78 => 'World Region', + 79 => 'Website', + 80 => 'Group(s)', + 81 => 'Tag(s)', + 82 => 'Note(s)', + ]; if (!$isContactExport) { unset($headers[80]); unset($headers[81]); diff --git a/tests/phpunit/CRM/Extension/BrowserTest.php b/tests/phpunit/CRM/Extension/BrowserTest.php index 065b94ce13..722bfdf803 100644 --- a/tests/phpunit/CRM/Extension/BrowserTest.php +++ b/tests/phpunit/CRM/Extension/BrowserTest.php @@ -5,6 +5,7 @@ * @group headless */ class CRM_Extension_BrowserTest extends CiviUnitTestCase { + public function setUp() { parent::setUp(); } diff --git a/tests/phpunit/CRM/Extension/Container/BasicTest.php b/tests/phpunit/CRM/Extension/Container/BasicTest.php index b3aea51c47..7bd9ba822c 100644 --- a/tests/phpunit/CRM/Extension/Container/BasicTest.php +++ b/tests/phpunit/CRM/Extension/Container/BasicTest.php @@ -5,6 +5,7 @@ * @group headless */ class CRM_Extension_Container_BasicTest extends CiviUnitTestCase { + public function setUp() { parent::setUp(); } diff --git a/tests/phpunit/CRM/Extension/Container/CollectionTest.php b/tests/phpunit/CRM/Extension/Container/CollectionTest.php index a258453a5e..d79a0a0974 100644 --- a/tests/phpunit/CRM/Extension/Container/CollectionTest.php +++ b/tests/phpunit/CRM/Extension/Container/CollectionTest.php @@ -47,12 +47,12 @@ 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()); + 'test.conflict', + 'test.whiz', + 'test.whizbang', + 'test.foo', + 'test.foo.bar', + ), $c->getKeys()); } public function testGetPath() { @@ -97,8 +97,10 @@ class CRM_Extension_Container_CollectionTest extends CiviUnitTestCase { $this->assertTrue(is_array($cache->get('ext-collection'))); $cacheData = $cache->get('ext-collection'); - $this->assertEquals('a', $cacheData['test.foo']); // 'test.foo' was defined in the 'a' container - $this->assertEquals('b', $cacheData['test.whiz']); // 'test.whiz' was defined in the 'b' container + // 'test.foo' was defined in the 'a' container + $this->assertEquals('a', $cacheData['test.foo']); + // 'test.whiz' was defined in the 'b' container + $this->assertEquals('b', $cacheData['test.whiz']); } /** diff --git a/tests/phpunit/CRM/Extension/Container/StaticTest.php b/tests/phpunit/CRM/Extension/Container/StaticTest.php index 46edf4d1f9..c5e460d93a 100644 --- a/tests/phpunit/CRM/Extension/Container/StaticTest.php +++ b/tests/phpunit/CRM/Extension/Container/StaticTest.php @@ -5,6 +5,7 @@ * @group headless */ class CRM_Extension_Container_StaticTest extends CiviUnitTestCase { + public function setUp() { parent::setUp(); } diff --git a/tests/phpunit/CRM/Extension/InfoTest.php b/tests/phpunit/CRM/Extension/InfoTest.php index 879cb76288..492a34b88c 100644 --- a/tests/phpunit/CRM/Extension/InfoTest.php +++ b/tests/phpunit/CRM/Extension/InfoTest.php @@ -5,6 +5,7 @@ * @group headless */ class CRM_Extension_InfoTest extends CiviUnitTestCase { + public function setUp() { parent::setUp(); $this->file = NULL; diff --git a/tests/phpunit/CRM/Extension/Manager/ModuleTest.php b/tests/phpunit/CRM/Extension/Manager/ModuleTest.php index 282e912a5d..a193171490 100644 --- a/tests/phpunit/CRM/Extension/Manager/ModuleTest.php +++ b/tests/phpunit/CRM/Extension/Manager/ModuleTest.php @@ -140,7 +140,8 @@ class CRM_Extension_Manager_ModuleTest extends CiviUnitTestCase { $this->assertHookCounts('test_extension_manager_module_auto1', array( 'install' => 1, 'enable' => 1, - 'disable' => 0, // normally called -- but not for missing modules! + // normally called -- but not for missing modules! + 'disable' => 0, 'uninstall' => 0, )); $this->assertModuleActiveByName(FALSE, 'test_extension_manager_module_auto1'); @@ -150,8 +151,10 @@ class CRM_Extension_Manager_ModuleTest extends CiviUnitTestCase { $this->assertHookCounts('test_extension_manager_module_auto1', array( 'install' => 1, 'enable' => 1, - 'disable' => 0, // normally called -- but not for missing modules! - 'uninstall' => 0, // normally called -- but not for missing modules! + // normally called -- but not for missing modules! + 'disable' => 0, + // normally called -- but not for missing modules! + 'uninstall' => 0, )); $this->assertEquals('unknown', $manager->getStatus('test.extension.manager.module.auto1')); $this->assertModuleActiveByName(FALSE, 'test_extension_manager_module_auto1'); @@ -193,7 +196,8 @@ class CRM_Extension_Manager_ModuleTest extends CiviUnitTestCase { $this->assertHookCounts('test_extension_manager_module_auto2', array( 'install' => 1, 'enable' => 1, - 'disable' => 0, // normally called -- but not for missing modules! + // normally called -- but not for missing modules! + 'disable' => 0, 'uninstall' => 0, )); $this->assertModuleActiveByName(FALSE, 'test_extension_manager_module_auto2'); @@ -233,7 +237,8 @@ class CRM_Extension_Manager_ModuleTest extends CiviUnitTestCase { * @param $prefix */ public function assertModuleActiveByName($expectedIsActive, $prefix) { - $activeModules = CRM_Core_PseudoConstant::getModuleExtensions(TRUE); // FIXME + // FIXME + $activeModules = CRM_Core_PseudoConstant::getModuleExtensions(TRUE); foreach ($activeModules as $activeModule) { if ($activeModule['prefix'] == $prefix) { $this->assertEquals($expectedIsActive, TRUE); diff --git a/tests/phpunit/CRM/Extension/Manager/ReportTest.php b/tests/phpunit/CRM/Extension/Manager/ReportTest.php index 99aea38dc2..3d44db92bf 100644 --- a/tests/phpunit/CRM/Extension/Manager/ReportTest.php +++ b/tests/phpunit/CRM/Extension/Manager/ReportTest.php @@ -5,6 +5,7 @@ * @group headless */ class CRM_Extension_Manager_ReportTest extends CiviUnitTestCase { + public function setUp() { parent::setUp(); //if (class_exists('test_extension_manager_reporttest')) { diff --git a/tests/phpunit/CRM/Extension/Manager/SearchTest.php b/tests/phpunit/CRM/Extension/Manager/SearchTest.php index 4771997cf0..d6b28e52eb 100644 --- a/tests/phpunit/CRM/Extension/Manager/SearchTest.php +++ b/tests/phpunit/CRM/Extension/Manager/SearchTest.php @@ -5,6 +5,7 @@ * @group headless */ class CRM_Extension_Manager_SearchTest extends CiviUnitTestCase { + public function setUp() { parent::setUp(); //if (class_exists('test_extension_manager_searchtest')) { diff --git a/tests/phpunit/CRM/Extension/ManagerTest.php b/tests/phpunit/CRM/Extension/ManagerTest.php index 53afb936c2..3cf5b894c1 100644 --- a/tests/phpunit/CRM/Extension/ManagerTest.php +++ b/tests/phpunit/CRM/Extension/ManagerTest.php @@ -93,7 +93,8 @@ class CRM_Extension_ManagerTest extends CiviUnitTestCase { ->method('onPostDisable'); $manager->disable(array('test.foo.bar')); $this->assertEquals('disabled', $manager->getStatus('test.foo.bar')); - $this->assertEquals('installed', $manager->getStatus('test.whiz.bang')); // no side-effect + // no side-effect + $this->assertEquals('installed', $manager->getStatus('test.whiz.bang')); $testingTypeManager ->expects($this->once()) @@ -103,7 +104,8 @@ class CRM_Extension_ManagerTest extends CiviUnitTestCase { ->method('onPostUninstall'); $manager->uninstall(array('test.foo.bar')); $this->assertEquals('uninstalled', $manager->getStatus('test.foo.bar')); - $this->assertEquals('installed', $manager->getStatus('test.whiz.bang')); // no side-effect + // no side-effect + $this->assertEquals('installed', $manager->getStatus('test.whiz.bang')); } /** @@ -222,7 +224,6 @@ class CRM_Extension_ManagerTest extends CiviUnitTestCase { $this->assertEquals('uninstalled', $manager->getStatus('test.whiz.bang')); } - /** * Install an extension and then harshly remove the underlying source. * Subseuently disable and uninstall. @@ -341,7 +342,8 @@ class CRM_Extension_ManagerTest extends CiviUnitTestCase { $testingTypeManager ->expects($this->once()) ->method('onPostEnable'); - $manager->install(array('test.foo.bar')); // install() instead of enable() + // install() instead of enable() + $manager->install(array('test.foo.bar')); $this->assertEquals('installed', $manager->getStatus('test.foo.bar')); } @@ -368,7 +370,8 @@ class CRM_Extension_ManagerTest extends CiviUnitTestCase { $testingTypeManager ->expects($this->never()) ->method('onPostEnable'); - $manager->enable(array('test.foo.bar')); // enable not install + // enable not install + $manager->enable(array('test.foo.bar')); $this->assertEquals('installed', $manager->getStatus('test.foo.bar')); } @@ -400,10 +403,12 @@ class CRM_Extension_ManagerTest extends CiviUnitTestCase { $this->download = $this->_createDownload('test.newextension', 'newextension'); $testingTypeManager - ->expects($this->never())// no data to replace + // no data to replace + ->expects($this->never()) ->method('onPreReplace'); $testingTypeManager - ->expects($this->never())// no data to replace + // no data to replace + ->expects($this->never()) ->method('onPostReplace'); $manager->replace($this->download); $this->assertEquals('uninstalled', $manager->getStatus('test.newextension')); @@ -428,10 +433,12 @@ class CRM_Extension_ManagerTest extends CiviUnitTestCase { $this->download = $this->_createDownload('test.whiz.bang', 'newextension'); $testingTypeManager - ->expects($this->never())// no data to replace + // no data to replace + ->expects($this->never()) ->method('onPreReplace'); $testingTypeManager - ->expects($this->never())// no data to replace + // no data to replace + ->expects($this->never()) ->method('onPostReplace'); $manager->replace($this->download); $this->assertEquals('uninstalled', $manager->getStatus('test.whiz.bang')); diff --git a/tests/phpunit/CRM/Extension/MapperTest.php b/tests/phpunit/CRM/Extension/MapperTest.php index 748d6ab16e..828852ee75 100644 --- a/tests/phpunit/CRM/Extension/MapperTest.php +++ b/tests/phpunit/CRM/Extension/MapperTest.php @@ -9,17 +9,32 @@ class CRM_Extension_MapperTest extends CiviUnitTestCase { /** * @var string */ - protected $basedir, $basedir2; + protected $basedir; + + /** + * @var string + */ + protected $basedir2; + + /** + * @var CRM_Extension_Container_Interface + */ + protected $container; /** * @var CRM_Extension_Container_Interface */ - protected $container, $containerWithSlash; + protected $containerWithSlash; + + /** + * @var CRM_Extension_Mapper + */ + protected $mapper; /** * @var CRM_Extension_Mapper */ - protected $mapper, $mapperWithSlash; + protected $mapperWithSlash; public function setUp() { parent::setUp(); diff --git a/tests/phpunit/CRM/Financial/BAO/FinancialItemTest.php b/tests/phpunit/CRM/Financial/BAO/FinancialItemTest.php index 2fb343e290..6217d95b16 100644 --- a/tests/phpunit/CRM/Financial/BAO/FinancialItemTest.php +++ b/tests/phpunit/CRM/Financial/BAO/FinancialItemTest.php @@ -318,14 +318,12 @@ class CRM_Financial_BAO_FinancialItemTest extends CiviUnitTestCase { $this->relationForFinancialTypeWithFinancialAccount(1); $form = new CRM_Contribute_Form_Contribution(); $form->testSubmit(array( - 'total_amount' => 100, - 'financial_type_id' => 1, - 'contact_id' => $contactId, - 'contribution_status_id' => 1, - 'price_set_id' => 0, - ), - CRM_Core_Action::ADD - ); + 'total_amount' => 100, + 'financial_type_id' => 1, + 'contact_id' => $contactId, + 'contribution_status_id' => 1, + 'price_set_id' => 0, + ), CRM_Core_Action::ADD); $contribution = $this->callAPISuccessGetSingle('Contribution', array( 'contact_id' => $contactId, diff --git a/tests/phpunit/CRM/Financial/BAO/PaymentProcessorTest.php b/tests/phpunit/CRM/Financial/BAO/PaymentProcessorTest.php index 1a12e8a8d0..729bd1cd63 100644 --- a/tests/phpunit/CRM/Financial/BAO/PaymentProcessorTest.php +++ b/tests/phpunit/CRM/Financial/BAO/PaymentProcessorTest.php @@ -30,6 +30,7 @@ * @group headless */ class CRM_Financial_BAO_PaymentProcessorTest extends CiviUnitTestCase { + public function setUp() { parent::setUp(); } diff --git a/tests/phpunit/CRM/Financial/Page/AjaxBatchSummaryTest.php b/tests/phpunit/CRM/Financial/Page/AjaxBatchSummaryTest.php index c4ed28412f..9ae40bcb89 100644 --- a/tests/phpunit/CRM/Financial/Page/AjaxBatchSummaryTest.php +++ b/tests/phpunit/CRM/Financial/Page/AjaxBatchSummaryTest.php @@ -30,6 +30,7 @@ * @group headless */ class CRM_Financial_Page_AjaxBatchSummaryTest extends CiviUnitTestCase { + /** * Test the makeBatchSummary function. * diff --git a/tests/phpunit/CRM/Group/Page/AjaxTest.php b/tests/phpunit/CRM/Group/Page/AjaxTest.php index b6eb77718b..fd69fd866e 100644 --- a/tests/phpunit/CRM/Group/Page/AjaxTest.php +++ b/tests/phpunit/CRM/Group/Page/AjaxTest.php @@ -38,15 +38,15 @@ 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', - )); + '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->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')); } @@ -242,7 +242,6 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { $this->assertEquals('pick-me-disabled', $groups['data'][3]['title']); } - /** * Retrieve groups as 'view all contacts' */ @@ -443,7 +442,6 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { $this->assertEquals(0, $groups['recordsTotal'], 'Total needs to be set correctly'); } - /** * ACL Group hook. */ diff --git a/tests/phpunit/CRM/Logging/LoggingTest.php b/tests/phpunit/CRM/Logging/LoggingTest.php index f104644474..880cddb22f 100644 --- a/tests/phpunit/CRM/Logging/LoggingTest.php +++ b/tests/phpunit/CRM/Logging/LoggingTest.php @@ -30,7 +30,6 @@ class CRM_Logging_LoggingTest extends CiviUnitTestCase { $logging->disableLogging(); } - /** * Test creating logging schema when database is in multilingual mode. * Also test altering a multilingual table. diff --git a/tests/phpunit/CRM/Mailing/BAO/MailingTest.php b/tests/phpunit/CRM/Mailing/BAO/MailingTest.php index cff6d4fc3a..326f434085 100644 --- a/tests/phpunit/CRM/Mailing/BAO/MailingTest.php +++ b/tests/phpunit/CRM/Mailing/BAO/MailingTest.php @@ -265,7 +265,6 @@ class CRM_Mailing_BAO_MailingTest extends CiviUnitTestCase { } } - /** * @todo Missing tests: * - Ensure opt out emails are not mailed @@ -610,9 +609,9 @@ class CRM_Mailing_BAO_MailingTest extends CiviUnitTestCase { // modify the filter to include only deceased recipient(s) that is Tagged $criteria['is_deceased'] = CRM_Utils_SQL_Select::fragment()->where("civicrm_contact.is_deceased = 1"); $criteria['tagged_contact'] = CRM_Utils_SQL_Select::fragment() - ->join('civicrm_entity_tag', "INNER JOIN civicrm_entity_tag et ON et.entity_id = civicrm_contact.id AND et.entity_table = 'civicrm_contact'") - ->join('civicrm_tag', "INNER JOIN civicrm_tag t ON t.id = et.tag_id") - ->where("t.name = 'Tagged'"); + ->join('civicrm_entity_tag', "INNER JOIN civicrm_entity_tag et ON et.entity_id = civicrm_contact.id AND et.entity_table = 'civicrm_contact'") + ->join('civicrm_tag', "INNER JOIN civicrm_tag t ON t.id = et.tag_id") + ->where("t.name = 'Tagged'"); } else { $mailingRecipients = $this->callAPISuccess('MailingRecipients', 'get', array( diff --git a/tests/phpunit/CRM/Mailing/BaseMailingSystemTest.php b/tests/phpunit/CRM/Mailing/BaseMailingSystemTest.php index 3c658fc4e3..5b1238a72e 100644 --- a/tests/phpunit/CRM/Mailing/BaseMailingSystemTest.php +++ b/tests/phpunit/CRM/Mailing/BaseMailingSystemTest.php @@ -76,7 +76,8 @@ abstract class CRM_Mailing_BaseMailingSystemTest extends CiviUnitTestCase { public function tearDown() { $this->_mut->stop(); CRM_Utils_Hook::singleton()->reset(); - CRM_Mailing_BAO_MailingJob::$mailsProcessed = 0; // DGW + // DGW + CRM_Mailing_BAO_MailingJob::$mailsProcessed = 0; parent::tearDown(); } @@ -125,9 +126,11 @@ abstract class CRM_Mailing_BaseMailingSystemTest extends CiviUnitTestCase { $this->assertEquals('plain', $message->body->subType); $this->assertRegExp( ";" . - "Sample Header for TEXT formatted content.\n" . // Default header + // Default header + "Sample Header for TEXT formatted content.\n" . "BEWARE children need regular infusions of toys. Santa knows your .*\\. There is no http.*civicrm/mailing/optout.*\\.\n" . - "to unsubscribe: http.*civicrm/mailing/optout" . // Default footer + // Default footer + "to unsubscribe: http.*civicrm/mailing/optout" . ";", $message->body->text ); @@ -156,10 +159,13 @@ abstract class CRM_Mailing_BaseMailingSystemTest extends CiviUnitTestCase { $this->assertEquals('html', $htmlPart->subType); $this->assertRegExp( ";" . - "Sample Header for HTML formatted content.\n" . // Default header + // Default header + "Sample Header for HTML formatted content.\n" . // FIXME: CiviMail puts double " after hyperlink! - "

You can go to Google or opt out.

\n" . // body_html - "Sample Footer for HTML formatted content" . // Default footer + // body_html + "

You can go to Google or opt out.

\n" . + // Default footer + "Sample Footer for HTML formatted content" . ".*\n" . "assertEquals('plain', $textPart->subType); $this->assertRegExp( ";" . - "Sample Header for TEXT formatted content.\n" . // Default header - "You can go to Google \\[1\\] or opt out \\[2\\]\\.\n" . // body_html, filtered + // Default header + "Sample Header for TEXT formatted content.\n" . + // body_html, filtered + "You can go to Google \\[1\\] or opt out \\[2\\]\\.\n" . "\n" . "Links:\n" . "------\n" . "\\[1\\] http://example.net/first\\?cs=[0-9a-f_]+\n" . "\\[2\\] http.*civicrm/mailing/optout.*\n" . "\n" . - "to unsubscribe: http.*civicrm/mailing/optout" . // Default footer + // Default footer + "to unsubscribe: http.*civicrm/mailing/optout" . ";", $textPart->text ); diff --git a/tests/phpunit/CRM/Mailing/TokensTest.php b/tests/phpunit/CRM/Mailing/TokensTest.php index 2cbd3124be..721f87f7c0 100644 --- a/tests/phpunit/CRM/Mailing/TokensTest.php +++ b/tests/phpunit/CRM/Mailing/TokensTest.php @@ -4,6 +4,7 @@ * @group headless */ class CRM_Mailing_TokensTest extends \CiviUnitTestCase { + protected function setUp() { $this->useTransaction(); parent::setUp(); diff --git a/tests/phpunit/CRM/Member/BAO/MembershipTest.php b/tests/phpunit/CRM/Member/BAO/MembershipTest.php index 9e33b02206..edea7ade40 100644 --- a/tests/phpunit/CRM/Member/BAO/MembershipTest.php +++ b/tests/phpunit/CRM/Member/BAO/MembershipTest.php @@ -71,11 +71,13 @@ class CRM_Member_BAO_MembershipTest extends CiviUnitTestCase { /** * Create membership type using given organization id. * @param $organizationId + * @param bool $withRelationship * @return array|int */ private function createMembershipType($organizationId, $withRelationship = FALSE) { $membershipType = $this->callAPISuccess('MembershipType', 'create', array( - 'domain_id' => 1, //Default domain ID + //Default domain ID + 'domain_id' => 1, 'member_of_contact_id' => $organizationId, 'financial_type_id' => "Member Dues", 'duration_unit' => "year", @@ -111,7 +113,8 @@ class CRM_Member_BAO_MembershipTest extends CiviUnitTestCase { // Create relationship between organization and individual contact $this->callAPISuccess('Relationship', 'create', array( - 'relationship_type_id' => 5, // Employer of relationship + // Employer of relationship + 'relationship_type_id' => 5, 'contact_id_a' => $contactId, 'contact_id_b' => $organizationId, 'is_active' => 1, @@ -396,7 +399,6 @@ class CRM_Member_BAO_MembershipTest extends CiviUnitTestCase { $this->contactDelete($contactId); } - /** * Get the contribution. * page id from the membership record @@ -489,7 +491,6 @@ class CRM_Member_BAO_MembershipTest extends CiviUnitTestCase { $this->contactDelete($contactId); } - /** * Checkup sort name function. */ diff --git a/tests/phpunit/CRM/Member/Form/MembershipRenewalTest.php b/tests/phpunit/CRM/Member/Form/MembershipRenewalTest.php index 6165e70928..b4c118daba 100644 --- a/tests/phpunit/CRM/Member/Form/MembershipRenewalTest.php +++ b/tests/phpunit/CRM/Member/Form/MembershipRenewalTest.php @@ -33,9 +33,6 @@ */ class CRM_Member_Form_MembershipRenewalTest extends CiviUnitTestCase { - /** - * Assume empty database with just civicrm_data. - */ protected $_individualId; protected $_contribution; protected $_financialTypeId = 1; @@ -170,7 +167,8 @@ class CRM_Member_Form_MembershipRenewalTest extends CiviUnitTestCase { 'cvv2' => '123', 'credit_card_exp_date' => array( 'M' => '9', - 'Y' => '2024', // TODO: Future proof + // TODO: Future proof + 'Y' => '2024', ), 'credit_card_type' => 'Visa', 'billing_first_name' => 'Test', @@ -204,7 +202,7 @@ class CRM_Member_Form_MembershipRenewalTest extends CiviUnitTestCase { 'id' => $this->_paymentProcessorID, 'return' => 'payment_instrument_id', )), - ), 'online'); + ), 'online'); } /** @@ -247,7 +245,8 @@ class CRM_Member_Form_MembershipRenewalTest extends CiviUnitTestCase { 'cvv2' => '123', 'credit_card_exp_date' => array( 'M' => '9', - 'Y' => '2019', // TODO: Future proof + // TODO: Future proof + 'Y' => '2019', ), 'credit_card_type' => 'Visa', 'billing_first_name' => 'Test', @@ -296,7 +295,7 @@ class CRM_Member_Form_MembershipRenewalTest extends CiviUnitTestCase { $this->callAPISuccessGetSingle('address', array( 'contact_id' => $this->_individualId, 'street_address' => '10 Test St', - 'postal_code' => 90210, + 'postal_code' => 90210, )); } @@ -400,7 +399,7 @@ class CRM_Member_Form_MembershipRenewalTest extends CiviUnitTestCase { $contributionRecur = $this->callAPISuccessGetSingle('ContributionRecur', array('contact_id' => $this->_individualId)); $this->assertEquals(1, $contributionRecur['is_email_receipt']); $this->mut->checkMailLog([ - '$ ' . $this->formatMoneyInput(7800.90) + '$ ' . $this->formatMoneyInput(7800.90), ]); $this->mut->stop(); $this->setCurrencySeparators(','); @@ -611,7 +610,8 @@ class CRM_Member_Form_MembershipRenewalTest extends CiviUnitTestCase { 'num_terms' => '1', 'source' => '', 'total_amount' => $this->formatMoneyInput('7800.90'), - 'financial_type_id' => '2', //Member dues, see data.xml + //Member dues, see data.xml + 'financial_type_id' => '2', 'soft_credit_type_id' => 11, 'soft_credit_contact_id' => '', 'from_email_address' => '"Demonstrators Anonymous" ', @@ -621,7 +621,8 @@ class CRM_Member_Form_MembershipRenewalTest extends CiviUnitTestCase { 'cvv2' => '123', 'credit_card_exp_date' => array( 'M' => '9', - 'Y' => '2019', // TODO: Future proof + // TODO: Future proof + 'Y' => '2019', ), 'credit_card_type' => 'Visa', 'billing_first_name' => 'Test', diff --git a/tests/phpunit/CRM/Member/Form/MembershipTest.php b/tests/phpunit/CRM/Member/Form/MembershipTest.php index c6b52dedfd..0ac9a2803e 100644 --- a/tests/phpunit/CRM/Member/Form/MembershipTest.php +++ b/tests/phpunit/CRM/Member/Form/MembershipTest.php @@ -41,9 +41,6 @@ */ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase { - /** - * Assume empty database with just civicrm_data. - */ protected $_individualId; protected $_contribution; protected $_financialTypeId = 1; @@ -472,7 +469,8 @@ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase { 'num_terms' => '1', 'source' => '', 'total_amount' => $this->formatMoneyInput(1234.56), - 'financial_type_id' => '2', //Member dues, see data.xml + //Member dues, see data.xml + 'financial_type_id' => '2', 'soft_credit_type_id' => '', 'soft_credit_contact_id' => '', 'from_email_address' => '"Demonstrators Anonymous" ', @@ -481,7 +479,8 @@ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase { 'cvv2' => '123', 'credit_card_exp_date' => array( 'M' => '9', - 'Y' => '2024', // TODO: Future proof + // TODO: Future proof + 'Y' => '2024', ), 'credit_card_type' => 'Visa', 'billing_first_name' => 'Test', @@ -570,7 +569,8 @@ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase { 'receive_date' => date('Y-m-d', time()) . ' 20:36:00', 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), 'contribution_status_id' => CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed'), - 'financial_type_id' => '2', //Member dues, see data.xml + //Member dues, see data.xml + 'financial_type_id' => '2', 'payment_processor_id' => $this->_paymentProcessorID, ); $form->_contactID = $this->_individualId; @@ -618,7 +618,8 @@ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase { 'total_amount' => 25, 'receive_date' => date('Y-m-d', time()) . ' 20:36:00', 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), - 'financial_type_id' => '2', //Member dues, see data.xml + //Member dues, see data.xml + 'financial_type_id' => '2', 'payment_processor_id' => $this->_paymentProcessorID, ); $form->_contactID = $this->_individualId; @@ -668,7 +669,8 @@ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase { 'total_amount' => $this->formatMoneyInput($partiallyPaidAmount), 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), 'contribution_status_id' => CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Partially paid'), - 'financial_type_id' => '2', //Member dues, see data.xml + //Member dues, see data.xml + 'financial_type_id' => '2', 'payment_processor_id' => $this->_paymentProcessorID, ); $form->_contactID = $this->_individualId; @@ -959,26 +961,25 @@ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase { 'contribution_id' => $contribution['id'], ), 1); $mut->checkMailLog(array( - '=========================================================== + '=========================================================== Billing Name and Address =========================================================== Test 10 Test St Test, AR 90210 US', - '=========================================================== + '=========================================================== Membership Information =========================================================== Membership Type: AnnualFixed Membership Start Date: ', - '=========================================================== + '=========================================================== Credit Card Information =========================================================== Visa ************1111 Expires: ', - ) - ); + )); $mut->stop(); } @@ -1124,7 +1125,8 @@ Expires: ', 'num_terms' => '1', 'source' => '', 'total_amount' => '77.00', - 'financial_type_id' => '2', //Member dues, see data.xml + //Member dues, see data.xml + 'financial_type_id' => '2', 'soft_credit_type_id' => 11, 'soft_credit_contact_id' => '', 'from_email_address' => '"Demonstrators Anonymous" ', @@ -1134,7 +1136,8 @@ Expires: ', 'cvv2' => '123', 'credit_card_exp_date' => array( 'M' => '9', - 'Y' => '2019', // TODO: Future proof + // TODO: Future proof + 'Y' => '2019', ), 'credit_card_type' => 'Visa', 'billing_first_name' => 'Test', @@ -1177,26 +1180,24 @@ Expires: ', $priceFieldID = $priceField['id']; // create two price options, each represent a membership type of amount 20 and 10 respectively $priceFieldValue = $this->callAPISuccess('price_field_value', 'create', array( - 'price_set_id' => $priceSetID, - 'price_field_id' => $priceField['id'], - 'label' => 'Long Haired Goat', - 'amount' => 20, - 'financial_type_id' => 'Donation', - 'membership_type_id' => 15, - 'membership_num_terms' => 1, - ) - ); + 'price_set_id' => $priceSetID, + 'price_field_id' => $priceField['id'], + 'label' => 'Long Haired Goat', + 'amount' => 20, + 'financial_type_id' => 'Donation', + 'membership_type_id' => 15, + 'membership_num_terms' => 1, + )); $pfvIDs = array($priceFieldValue['id'] => 1); $priceFieldValue = $this->callAPISuccess('price_field_value', 'create', array( - 'price_set_id' => $priceSetID, - 'price_field_id' => $priceField['id'], - 'label' => 'Shoe-eating Goat', - 'amount' => 10, - 'financial_type_id' => 'Donation', - 'membership_type_id' => 35, - 'membership_num_terms' => 2, - ) - ); + 'price_set_id' => $priceSetID, + 'price_field_id' => $priceField['id'], + 'label' => 'Shoe-eating Goat', + 'amount' => 10, + 'financial_type_id' => 'Donation', + 'membership_type_id' => 35, + 'membership_num_terms' => 2, + )); $pfvIDs[$priceFieldValue['id']] = 1; // register for both of these memberships via backoffice membership form submission @@ -1320,7 +1321,8 @@ Expires: ', 'receive_date' => date('Y-m-d', time()) . ' 20:36:00', 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), 'contribution_status_id' => CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed'), - 'financial_type_id' => 2, //Member dues, see data.xml + //Member dues, see data.xml + 'financial_type_id' => 2, 'payment_processor_id' => $this->_paymentProcessorID, ); $form->_contactID = $this->_individualId; diff --git a/tests/phpunit/CRM/Member/StatusOverrideTypesTest.php b/tests/phpunit/CRM/Member/StatusOverrideTypesTest.php index a4fd727318..6f3f9e7818 100644 --- a/tests/phpunit/CRM/Member/StatusOverrideTypesTest.php +++ b/tests/phpunit/CRM/Member/StatusOverrideTypesTest.php @@ -30,6 +30,7 @@ * @group headless */ class CRM_Member_StatusOverrideTypesTest extends CiviUnitTestCase { + public function setUp() { parent::setUp(); } @@ -46,7 +47,6 @@ class CRM_Member_StatusOverrideTypesTest extends CiviUnitTestCase { $this->assertTrue($isOverridden); } - public function testIsOverriddenReturnTrueForUntilDateStatusOverrideType() { $statusOverrideTypes = new CRM_Member_StatusOverrideTypes(); $isOverridden = $statusOverrideTypes::isOverridden(CRM_Member_StatusOverrideTypes::UNTIL_DATE); diff --git a/tests/phpunit/CRM/Pledge/BAO/PledgePaymentTest.php b/tests/phpunit/CRM/Pledge/BAO/PledgePaymentTest.php index aff2727f00..c02ed24977 100644 --- a/tests/phpunit/CRM/Pledge/BAO/PledgePaymentTest.php +++ b/tests/phpunit/CRM/Pledge/BAO/PledgePaymentTest.php @@ -395,11 +395,14 @@ class CRM_Pledge_BAO_PledgePaymentTest extends CiviUnitTestCase { CRM_Core_Action::ADD, $pledgePayments['values'][0]['id'], $contributionID, - NULL, // adjustTotalAmount + // adjustTotalAmount + NULL, 404.70, 134.90, - 1, // contribution_status_id - NULL // original_contribution_status_id + // contribution_status_id + 1, + // original_contribution_status_id + NULL ); // Fetch the pledge payments again to see if the amounts and statuses @@ -450,7 +453,8 @@ class CRM_Pledge_BAO_PledgePaymentTest extends CiviUnitTestCase { 'amount' => 100.00, 'pledge_status_id' => 2, 'pledge_financial_type_id' => 1, - 'original_installment_amount' => (100 / 12), // the API does not allow this + // the API does not allow this + 'original_installment_amount' => (100 / 12), 'frequency_interval' => 1, 'frequency_unit' => 'month', 'frequency_day' => 1, @@ -491,11 +495,14 @@ class CRM_Pledge_BAO_PledgePaymentTest extends CiviUnitTestCase { CRM_Core_Action::ADD, $pledgePayments['values'][0]['id'], $contributionID, - NULL, // adjustTotalAmount + // adjustTotalAmount + NULL, 100.00, 100.00, - 1, // contribution_status_id - NULL // original_contribution_status_id + // contribution_status_id + 1, + // original_contribution_status_id + NULL ); // Fetch the pledge payments again to see if the amounts and statuses diff --git a/tests/phpunit/CRM/Pledge/Form/SearchTest.php b/tests/phpunit/CRM/Pledge/Form/SearchTest.php index 4209849b09..bff24470a6 100644 --- a/tests/phpunit/CRM/Pledge/Form/SearchTest.php +++ b/tests/phpunit/CRM/Pledge/Form/SearchTest.php @@ -5,11 +5,13 @@ * @group headless */ class CRM_Pledge_Form_SearchTest extends CiviUnitTestCase { + public function setUp() { parent::setUp(); $this->individualID = $this->individualCreate(); $this->pledgeCreate(array('contact_id' => $this->individualID)); } + public function tearDown() { parent::tearDown(); $tablesToTruncate = array( @@ -19,6 +21,7 @@ class CRM_Pledge_Form_SearchTest extends CiviUnitTestCase { ); $this->quickCleanup($tablesToTruncate); } + /** * Test submitted the search form. */ @@ -32,25 +35,25 @@ class CRM_Pledge_Form_SearchTest extends CiviUnitTestCase { $date = date('Y-m-d') . ' 00:00:00'; $rows = $form->controller->get('rows'); $this->assertEquals(array( - 'contact_id' => '3', - 'sort_name' => 'Anderson, Anthony', - 'display_name' => 'Mr. Anthony Anderson II', - 'pledge_id' => '1', - 'pledge_amount' => '100.00', - 'pledge_create_date' => $date, - 'pledge_next_pay_date' => $date, - 'pledge_next_pay_amount' => '20.00', - 'pledge_status_id' => '2', - 'pledge_status' => 'Pending', - 'pledge_is_test' => '0', - 'pledge_financial_type' => 'Donation', - 'pledge_currency' => 'USD', - 'campaign' => NULL, - 'campaign_id' => NULL, - 'pledge_status_name' => 'Pending', - 'checkbox' => 'mark_x_1', - 'action' => 'ViewEditmore', - 'contact_type' => '
', + 'contact_id' => '3', + 'sort_name' => 'Anderson, Anthony', + 'display_name' => 'Mr. Anthony Anderson II', + 'pledge_id' => '1', + 'pledge_amount' => '100.00', + 'pledge_create_date' => $date, + 'pledge_next_pay_date' => $date, + 'pledge_next_pay_amount' => '20.00', + 'pledge_status_id' => '2', + 'pledge_status' => 'Pending', + 'pledge_is_test' => '0', + 'pledge_financial_type' => 'Donation', + 'pledge_currency' => 'USD', + 'campaign' => NULL, + 'campaign_id' => NULL, + 'pledge_status_name' => 'Pending', + 'checkbox' => 'mark_x_1', + 'action' => 'ViewEditmore', + 'contact_type' => '
', ), $rows[0]); } diff --git a/tests/phpunit/CRM/Queue/RunnerTest.php b/tests/phpunit/CRM/Queue/RunnerTest.php index d88fe13a67..1216ce41f9 100644 --- a/tests/phpunit/CRM/Queue/RunnerTest.php +++ b/tests/phpunit/CRM/Queue/RunnerTest.php @@ -228,10 +228,11 @@ class CRM_Queue_RunnerTest extends CiviUnitTestCase { $this->assertEquals(2, $this->queue->numberOfItems()); } - /* **** Queue tasks **** */ - - - static $_recordedValues; + /** + * Queue tasks + * @var array + */ + protected static $_recordedValues; /** * @param $taskCtx @@ -239,7 +240,7 @@ class CRM_Queue_RunnerTest extends CiviUnitTestCase { * * @return bool */ - static public function _recordValue($taskCtx, $value) { + public static function _recordValue($taskCtx, $value) { self::$_recordedValues[] = $value; return TRUE; } @@ -249,7 +250,7 @@ class CRM_Queue_RunnerTest extends CiviUnitTestCase { * * @return bool */ - static public function _returnFalse($taskCtx) { + public static function _returnFalse($taskCtx) { return FALSE; } @@ -259,7 +260,7 @@ class CRM_Queue_RunnerTest extends CiviUnitTestCase { * * @throws Exception */ - static public function _throwException($taskCtx, $value) { + public static function _throwException($taskCtx, $value) { throw new Exception("Manufactured error: $value"); } @@ -270,7 +271,7 @@ class CRM_Queue_RunnerTest extends CiviUnitTestCase { * * @return bool */ - static public function _enqueueNumbers($taskCtx, $low, $high) { + public static function _enqueueNumbers($taskCtx, $low, $high) { for ($i = $low; $i <= $high; $i++) { $taskCtx->queue->createItem(new CRM_Queue_Task( array('CRM_Queue_RunnerTest', '_recordValue'), diff --git a/tests/phpunit/CRM/Report/Form/ContactSummaryTest.php b/tests/phpunit/CRM/Report/Form/ContactSummaryTest.php index 6765e43731..4a4077707e 100644 --- a/tests/phpunit/CRM/Report/Form/ContactSummaryTest.php +++ b/tests/phpunit/CRM/Report/Form/ContactSummaryTest.php @@ -63,28 +63,28 @@ class CRM_Report_Form_ContactSummaryTest extends CiviReportTestCase { 'location_type_id' => 1, 'is_primary' => 1, 'street_number' => 3, - ] + ], ]), 'odd_street_number_2' => $this->individualCreate([ 'api.Address.create' => [ 'location_type_id' => 1, 'is_primary' => 1, 'street_number' => 5, - ] + ], ]), 'even_street_number_1' => $this->individualCreate([ 'api.Address.create' => [ 'location_type_id' => 1, 'is_primary' => 1, 'street_number' => 2, - ] + ], ]), 'even_street_number_2' => $this->individualCreate([ 'api.Address.create' => [ 'location_type_id' => 1, 'is_primary' => 1, 'street_number' => 4, - ] + ], ]), 'no_street_number' => $this->individualCreate(), ]; diff --git a/tests/phpunit/CRM/SMS/ProviderTest.php b/tests/phpunit/CRM/SMS/ProviderTest.php index f402cbd28e..bf03ef8ec2 100644 --- a/tests/phpunit/CRM/SMS/ProviderTest.php +++ b/tests/phpunit/CRM/SMS/ProviderTest.php @@ -96,7 +96,6 @@ class CRM_SMS_ProviderTest extends CiviUnitTestCase { $this->assertEquals($contact['id'], $activity['source_contact_id']); } - public function smsHookTest(&$message) { $testSourceContact = $this->individualCreate(array('phone' => array(1 => array('phone' => '+61487654321')))); $message->toContactID = $testSourceContact; diff --git a/tests/phpunit/CRM/UF/Page/ProfileEditorTest.php b/tests/phpunit/CRM/UF/Page/ProfileEditorTest.php index 58d416f820..94e4321cb1 100644 --- a/tests/phpunit/CRM/UF/Page/ProfileEditorTest.php +++ b/tests/phpunit/CRM/UF/Page/ProfileEditorTest.php @@ -5,6 +5,7 @@ * @group headless */ class CRM_UF_Page_ProfileEditorTest extends CiviUnitTestCase { + public function setUp() { parent::setUp(); } diff --git a/tests/phpunit/CRM/Upgrade/Incremental/BaseTest.php b/tests/phpunit/CRM/Upgrade/Incremental/BaseTest.php index 3827a8c2c7..74dbaca6ab 100644 --- a/tests/phpunit/CRM/Upgrade/Incremental/BaseTest.php +++ b/tests/phpunit/CRM/Upgrade/Incremental/BaseTest.php @@ -89,10 +89,10 @@ class CRM_Upgrade_Incremental_BaseTest extends CiviUnitTestCase { */ public function testSmartGroupDatePickerConversion() { $this->callAPISuccess('SavedSearch', 'create', [ - 'form_values' => [ + 'form_values' => [ ['grant_application_received_date_high', '=', '01/20/2019'], ['grant_due_date_low', '=', '01/22/2019'], - ] + ], ]); $smartGroupConversionObject = new CRM_Upgrade_Incremental_SmartGroups(); $smartGroupConversionObject->updateGroups([ @@ -100,8 +100,8 @@ class CRM_Upgrade_Incremental_BaseTest extends CiviUnitTestCase { 'grant_application_received_date', 'grant_decision_date', 'grant_money_transfer_date', - 'grant_due_date' - ] + 'grant_due_date', + ], ]); $savedSearch = $this->callAPISuccessGetSingle('SavedSearch', []); $this->assertEquals('grant_application_received_date_high', $savedSearch['form_values'][0][0]); @@ -124,7 +124,7 @@ class CRM_Upgrade_Incremental_BaseTest extends CiviUnitTestCase { $this->callAPISuccess('SavedSearch', 'create', [ 'form_values' => [ ['on_hold', '=', '1'], - ] + ], ]); $smartGroupConversionObject = new CRM_Upgrade_Incremental_SmartGroups('5.11.alpha1'); $smartGroupConversionObject->convertEqualsStringToInArray('on_hold'); @@ -141,7 +141,7 @@ class CRM_Upgrade_Incremental_BaseTest extends CiviUnitTestCase { $this->callAPISuccess('SavedSearch', 'create', [ 'form_values' => [ ['activity_date_low', '=', '01/22/2019'], - ] + ], ]); $smartGroupConversionObject = new CRM_Upgrade_Incremental_SmartGroups(); $smartGroupConversionObject->renameField('activity_date_low', 'activity_date_time_low'); @@ -157,7 +157,7 @@ class CRM_Upgrade_Incremental_BaseTest extends CiviUnitTestCase { 'form_values' => [ ['activity_date_low', '=', '01/22/2019'], ['activity_date_relative', '=', 0], - ] + ], ]); $smartGroupConversionObject = new CRM_Upgrade_Incremental_SmartGroups(); $smartGroupConversionObject->renameFields([ diff --git a/tests/phpunit/CRM/Utils/API/MatchOptionTest.php b/tests/phpunit/CRM/Utils/API/MatchOptionTest.php index 2dcd6fbd33..4ba2d584bf 100644 --- a/tests/phpunit/CRM/Utils/API/MatchOptionTest.php +++ b/tests/phpunit/CRM/Utils/API/MatchOptionTest.php @@ -9,7 +9,7 @@ class CRM_Utils_API_MatchOptionTest extends CiviUnitTestCase { /** * @var array */ - var $noise; + public $noise; public function setUp() { parent::setUp(); @@ -108,7 +108,8 @@ class CRM_Utils_API_MatchOptionTest extends CiviUnitTestCase { 'external_identifier' => '1', )); - $this->individualCreate(array('email' => 'ignore2@example.com')); // more noise! + // more noise! + $this->individualCreate(array('email' => 'ignore2@example.com')); // update the record by matching first/last name $result2 = $this->callAPISuccess('contact', 'create', array( @@ -156,7 +157,8 @@ class CRM_Utils_API_MatchOptionTest extends CiviUnitTestCase { 'external_identifier' => '2', )); - $this->individualCreate(array('email' => 'ignore2@example.com')); // more noise! + // more noise! + $this->individualCreate(array('email' => 'ignore2@example.com')); // Try to update - but fail due to ambiguity $result3 = $this->callAPIFailure('contact', 'create', array( @@ -239,7 +241,8 @@ class CRM_Utils_API_MatchOptionTest extends CiviUnitTestCase { $this->assertEquals($createEmailValues[0]['id'], $updateEmailValues[0]['id']); $this->assertEquals($createEmailValues[0]['id'], $getValues[0]['id']); $this->assertEquals('j1-b@example.com', $getValues[0]['email']); - $this->assertEquals('The Dude abides.', $getValues[0]['signature_text']); // preserved from original creation; proves that we updated existing record + // preserved from original creation; proves that we updated existing record + $this->assertEquals('The Dude abides.', $getValues[0]['signature_text']); // The second email (j2@example.com) is deleted because contact_id+location_type_id doesn't appear in new list. // The third email (j3@example.com) is inserted (new ID#) because it doesn't match an existing contact_id+location_type_id. @@ -324,7 +327,8 @@ class CRM_Utils_API_MatchOptionTest extends CiviUnitTestCase { $this->assertEquals($createAddressValues[0]['id'], $updateAddressValues[0]['id']); $this->assertEquals($createAddressValues[0]['id'], $getValues[0]['id']); $this->assertEquals('j1-b Example Ave', $getValues[0]['street_address']); - $this->assertEquals('The Dude abides.', $getValues[0]['supplemental_address_1']); // preserved from original creation; proves that we updated existing record + // preserved from original creation; proves that we updated existing record + $this->assertEquals('The Dude abides.', $getValues[0]['supplemental_address_1']); // The second street_address (j2 Example Ave) is deleted because contact_id+location_type_id doesn't appear in new list. // The third street_address (j3 Example Ave) is inserted (new ID#) because it doesn't match an existing contact_id+location_type_id. diff --git a/tests/phpunit/CRM/Utils/API/ReloadOptionTest.php b/tests/phpunit/CRM/Utils/API/ReloadOptionTest.php index bb492f4f3e..3fcb389df6 100644 --- a/tests/phpunit/CRM/Utils/API/ReloadOptionTest.php +++ b/tests/phpunit/CRM/Utils/API/ReloadOptionTest.php @@ -28,7 +28,8 @@ class CRM_Utils_API_ReloadOptionTest extends CiviUnitTestCase { 'nick_name' => 'Firstie', )); $this->assertEquals('First', $result['values'][$result['id']]['first_name']); - $this->assertEquals('Firstie', $result['values'][$result['id']]['nick_name']); // munged by hook, but we haven't realized it + // munged by hook, but we haven't realized it + $this->assertEquals('Firstie', $result['values'][$result['id']]['nick_name']); } /** diff --git a/tests/phpunit/CRM/Utils/AddressTest.php b/tests/phpunit/CRM/Utils/AddressTest.php index 6fa80cabaf..1f66726cae 100644 --- a/tests/phpunit/CRM/Utils/AddressTest.php +++ b/tests/phpunit/CRM/Utils/AddressTest.php @@ -42,7 +42,8 @@ class CRM_Utils_AddressTest extends CiviUnitTestCase { 'billing_street_address-99' => '123 Happy Place', 'billing_city-99' => 'Miami', 'billing_postal_code-99' => 33101, - 'state_province-99' => '1000', // 1000 => Alabama (AL) + // 1000 => Alabama (AL) + 'state_province-99' => '1000', 'country-99' => 'United States', ); @@ -59,14 +60,16 @@ class CRM_Utils_AddressTest extends CiviUnitTestCase { // test using alternate names for state/province field unset($params['state_province-99']); - $params['billing_state_province-99'] = '1000'; // alternate name 1 + // alternate name 1 + $params['billing_state_province-99'] = '1000'; $addFormat = '{contact.state_province_name}'; Civi::settings()->set('address_format', $addFormat); $formatted_address = CRM_Utils_Address::getFormattedBillingAddressFieldsFromParameters($params, '99'); $this->assertTrue((bool) $formatted_address == 'Alabama'); unset($params['state_province-99']); - $params['billing_state_province_id-99'] = '1000'; // alternate name 2 + // alternate name 2 + $params['billing_state_province_id-99'] = '1000'; $addFormat = '{contact.state_province_name}'; Civi::settings()->set('address_format', $addFormat); $formatted_address = CRM_Utils_Address::getFormattedBillingAddressFieldsFromParameters($params, '99'); diff --git a/tests/phpunit/CRM/Utils/ArrayTest.php b/tests/phpunit/CRM/Utils/ArrayTest.php index 212b523ceb..c4d56cbe51 100644 --- a/tests/phpunit/CRM/Utils/ArrayTest.php +++ b/tests/phpunit/CRM/Utils/ArrayTest.php @@ -279,7 +279,7 @@ class CRM_Utils_ArrayTest extends CiviUnitTestCase { [NULL, ['wrong' => NULL, 'right' => ['foo' => 1, 'bar' => 2]]], [1, 'wrong'], 'nada', 'nada', ], [ - [NULL, ['wrong' => NULL, 'right' => ['foo' => 1, 'bar' => 2]]], [1, 'right'], NULL, ['foo' => 1, 'bar' => 2] + [NULL, ['wrong' => NULL, 'right' => ['foo' => 1, 'bar' => 2]]], [1, 'right'], NULL, ['foo' => 1, 'bar' => 2], ], [ [NULL, ['wrong' => NULL, 'right' => ['foo' => 1, 'bar' => 2]]], [1, 'right', 'foo'], NULL, 1, @@ -290,6 +290,7 @@ class CRM_Utils_ArrayTest extends CiviUnitTestCase { /** * @param $array * @param $path + * @param $default * @param $expected * @dataProvider getRecursiveValueExamples */ @@ -318,6 +319,7 @@ class CRM_Utils_ArrayTest extends CiviUnitTestCase { /** * Test the build recursive function. * + * @param $source * @param $path * @param $expected * @@ -339,13 +341,13 @@ class CRM_Utils_ArrayTest extends CiviUnitTestCase { '2' => 'boz', ], 'my_complex' => [ - 'dog' => 'woof', - 'asdf' => [ - 'my_zero' => 0, - 'my_int' => 1, - 'my_null' => NULL, - 'my_empty' => '', - ], + 'dog' => 'woof', + 'asdf' => [ + 'my_zero' => 0, + 'my_int' => 1, + 'my_null' => NULL, + 'my_empty' => '', + ], ], 'my_simple' => 999, ]; diff --git a/tests/phpunit/CRM/Utils/Cache/SqlGroupTest.php b/tests/phpunit/CRM/Utils/Cache/SqlGroupTest.php index 77f31a26b4..130eaa5334 100644 --- a/tests/phpunit/CRM/Utils/Cache/SqlGroupTest.php +++ b/tests/phpunit/CRM/Utils/Cache/SqlGroupTest.php @@ -5,6 +5,7 @@ * @group headless */ class CRM_Utils_Cache_SqlGroupTest extends CiviUnitTestCase { + public function setUp() { parent::setUp(); } @@ -76,17 +77,22 @@ class CRM_Utils_Cache_SqlGroupTest extends CiviUnitTestCase { 'group' => 'testPrefetch', 'prefetch' => TRUE, )); - $this->assertEquals($fooValue, $b->getFromFrontCache('foo')); // should work b/c value was prefetched - $this->assertEquals($fooValue, $b->get('foo')); // should work b/c value was prefetched + // should work b/c value was prefetched + $this->assertEquals($fooValue, $b->getFromFrontCache('foo')); + // should work b/c value was prefetched + $this->assertEquals($fooValue, $b->get('foo')); // 3. see what happens when prefetch is FALSE $c = new CRM_Utils_Cache_SqlGroup(array( 'group' => 'testPrefetch', 'prefetch' => FALSE, )); - $this->assertEquals(NULL, $c->getFromFrontCache('foo')); // should be NULL b/c value was NOT prefetched - $this->assertEquals($fooValue, $c->get('foo')); // should work b/c value is fetched on demand - $this->assertEquals($fooValue, $c->getFromFrontCache('foo')); // should work b/c value was fetched on demand + // should be NULL b/c value was NOT prefetched + $this->assertEquals(NULL, $c->getFromFrontCache('foo')); + // should work b/c value is fetched on demand + $this->assertEquals($fooValue, $c->get('foo')); + // should work b/c value was fetched on demand + $this->assertEquals($fooValue, $c->getFromFrontCache('foo')); } } diff --git a/tests/phpunit/CRM/Utils/DateTest.php b/tests/phpunit/CRM/Utils/DateTest.php index dbe2d3b644..c7828ea166 100644 --- a/tests/phpunit/CRM/Utils/DateTest.php +++ b/tests/phpunit/CRM/Utils/DateTest.php @@ -101,7 +101,7 @@ class CRM_Utils_DateTest extends CiviUnitTestCase { $date = CRM_Utils_Date::relativeToAbsolute($relativeString, 'fiscal_year'); $this->assertEquals([ 'from' => $fiscalYearStartYear . '0701', - 'to' => ($fiscalYearStartYear + 1) . '0630' + 'to' => ($fiscalYearStartYear + 1) . '0630', ], $date, 'relative term is ' . $relativeString); $fiscalYearStartYear--; @@ -182,7 +182,7 @@ class CRM_Utils_DateTest extends CiviUnitTestCase { $offset = (substr($relativeString, -1, 1)) - 1; $this->assertEquals([ 'from' => $lastYear - $offset . '0101', - 'to' => $lastYear . '1231', + 'to' => $lastYear . '1231', ], $date, 'relative term is ' . $relativeString); } } @@ -205,7 +205,7 @@ class CRM_Utils_DateTest extends CiviUnitTestCase { $offset = (substr($relativeString, -1, 1)); $this->assertEquals([ 'from' => $lastFiscalYearEnd - $offset . '0701', - 'to' => $lastFiscalYearEnd . '0630', + 'to' => $lastFiscalYearEnd . '0630', ], $date, 'relative term is ' . $relativeString); } } diff --git a/tests/phpunit/CRM/Utils/FileTest.php b/tests/phpunit/CRM/Utils/FileTest.php index 8a6a4eb674..f52784ae4f 100644 --- a/tests/phpunit/CRM/Utils/FileTest.php +++ b/tests/phpunit/CRM/Utils/FileTest.php @@ -23,6 +23,7 @@ class CRM_Utils_FileTest extends CiviUnitTestCase { )); } } + public function testStripComment() { $strings = array( "\nab\n-- cd\nef" => "\nab\nef", diff --git a/tests/phpunit/CRM/Utils/HTMLTest.php b/tests/phpunit/CRM/Utils/HTMLTest.php index 0d2831983a..f0baa01662 100644 --- a/tests/phpunit/CRM/Utils/HTMLTest.php +++ b/tests/phpunit/CRM/Utils/HTMLTest.php @@ -30,6 +30,7 @@ * @group headless */ class CRM_Utils_HTMLTest extends CiviUnitTestCase { + /** * @return array */ @@ -39,67 +40,83 @@ class CRM_Utils_HTMLTest extends CiviUnitTestCase { '', array(), ); - $cases[] = array(// missing ts + // missing ts + $cases[] = array( '
Hello world
', array(), ); - $cases[] = array(// text, no arg + // text, no arg + $cases[] = array( '
{{ts("Hello world")}}
', array('Hello world'), ); - $cases[] = array(// text, no arg, alternate text + // text, no arg, alternate text + $cases[] = array( '
{{ts("Good morning, Dave")}}
', array('Good morning, Dave'), ); - $cases[] = array(// text, with arg + // text, with arg + $cases[] = array( '
{{ts("Hello world", {1: "whiz"})}}
', array('Hello world'), ); - $cases[] = array(// text, not really ts(), no arg + // text, not really ts(), no arg + $cases[] = array( '
{{clients("Hello world")}}
', array(), ); - $cases[] = array(// text, not really ts(), with arg + // text, not really ts(), with arg + $cases[] = array( '
{{clients("Hello world", {1: "whiz"})}}
', array(), ); - $cases[] = array(// two strings, duplicate + // two strings, duplicate + $cases[] = array( '
{{ts("Hello world")}}

{{ts("Hello world")}}

', array('Hello world'), ); - $cases[] = array(// two strings, addition + // two strings, addition + $cases[] = array( '
{{ts("Hello world") + "-" + ts("How do you do?")}}

', array('Hello world', 'How do you do?'), ); - $cases[] = array(// two strings, separate calls + // two strings, separate calls + $cases[] = array( '
{{ts("Hello world")}}

{{ts("How do you do?")}}

', array('Hello world', 'How do you do?'), ); - $cases[] = array(// single quoted + // single quoted + $cases[] = array( '
{{ts(\'Hello world\')}}
', array('Hello world'), ); - $cases[] = array(// unclear string + // unclear string + $cases[] = array( '
{{ts(message)}}
', array(), ); - $cases[] = array(// ts() within a string + // ts() within a string + $cases[] = array( '
{{ts("Does the ts(\'example\') notation work?")}}
', array('Does the ts(\'example\') notation work?'), ); - $cases[] = array(// attribute, no arg + // attribute, no arg + $cases[] = array( '
', array('Hello world'), ); - $cases[] = array(// attribute, with arg + // attribute, with arg + $cases[] = array( '
', array('Hello world'), ); - $cases[] = array(// attribute, two strings, with arg + // attribute, two strings, with arg + $cases[] = array( '
', array('Hello world', 'How do you do, %1?'), ); - $cases[] = array(// trick question! Not used on Smarty templates. + // trick question! Not used on Smarty templates. + $cases[] = array( '
{ts}Hello world{/ts}
', array(), ); diff --git a/tests/phpunit/CRM/Utils/HookTest.php b/tests/phpunit/CRM/Utils/HookTest.php index 358ac5edeb..a1e0e6329a 100644 --- a/tests/phpunit/CRM/Utils/HookTest.php +++ b/tests/phpunit/CRM/Utils/HookTest.php @@ -6,11 +6,11 @@ */ class CRM_Utils_HookTest extends CiviUnitTestCase { - static $activeTest = NULL; + protected static $activeTest = NULL; - var $fakeModules; + public $fakeModules; - var $log; + public $log; public function setUp() { parent::setUp(); diff --git a/tests/phpunit/CRM/Utils/HtmlToTextTest.php b/tests/phpunit/CRM/Utils/HtmlToTextTest.php index 982580d609..928bc7147d 100644 --- a/tests/phpunit/CRM/Utils/HtmlToTextTest.php +++ b/tests/phpunit/CRM/Utils/HtmlToTextTest.php @@ -14,7 +14,8 @@ class CRM_Utils_HtmlToTextTest extends CiviUnitTestCase { * @return array */ public function htmlToTextExamples() { - $cases = array(); // array(0 => string $html, 1 => string $text) + // array(0 => string $html, 1 => string $text) + $cases = array(); $cases[] = array( '

', diff --git a/tests/phpunit/CRM/Utils/ICalendarTest.php b/tests/phpunit/CRM/Utils/ICalendarTest.php index fad955750d..1ed549e67b 100644 --- a/tests/phpunit/CRM/Utils/ICalendarTest.php +++ b/tests/phpunit/CRM/Utils/ICalendarTest.php @@ -37,10 +37,12 @@ class CRM_Utils_ICalendarTest extends CiviUnitTestCase { public function escapeExamples() { $cases = array(); $cases[] = array("Hello - this is, a test!"); + this is, a test!", + ); $cases[] = array("Hello!! - this is, a \"test\"!"); + this is, a \"test\"!", + ); return $cases; } diff --git a/tests/phpunit/CRM/Utils/JSTest.php b/tests/phpunit/CRM/Utils/JSTest.php index 8a35e9419f..612f8be094 100644 --- a/tests/phpunit/CRM/Utils/JSTest.php +++ b/tests/phpunit/CRM/Utils/JSTest.php @@ -30,6 +30,7 @@ * @group headless */ class CRM_Utils_JSTest extends CiviUnitTestCase { + /** * @return array */ @@ -39,27 +40,33 @@ class CRM_Utils_JSTest extends CiviUnitTestCase { '', array(), ); - $cases[] = array(// missing ts + // missing ts + $cases[] = array( 'alert("Hello world")', array(), ); - $cases[] = array(// basic function call + // basic function call + $cases[] = array( 'alert(ts("Hello world"));', array('Hello world'), ); - $cases[] = array(// with arg + // with arg + $cases[] = array( 'alert(ts("Hello world", {1: "whiz"}));', array('Hello world'), ); - $cases[] = array(// not really ts() + // not really ts() + $cases[] = array( 'alert(clients("Hello world"));', array(), ); - $cases[] = array(// not really ts() + // not really ts() + $cases[] = array( 'alert(clients("Hello world", {1: "whiz"}));', array(), ); - $cases[] = array(// with arg + // with arg + $cases[] = array( "\n" . "public function whits() {\n" . " for (a in b) {\n" . @@ -70,15 +77,18 @@ class CRM_Utils_JSTest extends CiviUnitTestCase { "}\n", array('Hello'), ); - $cases[] = array(// duplicate + // duplicate + $cases[] = array( 'alert(ts("Hello world") + "-" + ts("Hello world"));', array('Hello world'), ); - $cases[] = array(// two strings, addition + // two strings, addition + $cases[] = array( 'alert(ts("Hello world") + "-" + ts("How do you do?"));', array('Hello world', 'How do you do?'), ); - $cases[] = array(// two strings, separate calls + // two strings, separate calls + $cases[] = array( 'alert(ts("Hello world");\nalert(ts("How do you do?"));', array('Hello world', 'How do you do?'), ); @@ -86,11 +96,13 @@ class CRM_Utils_JSTest extends CiviUnitTestCase { 'alert(ts(\'Single quoted\'));', array('Single quoted'), ); - $cases[] = array(// unclear string + // unclear string + $cases[] = array( 'alert(ts(message));', array(), ); - $cases[] = array(// ts() within a string + // ts() within a string + $cases[] = array( 'alert(ts("Does the ts(\'example\') notation work?"));', array('Does the ts(\'example\') notation work?'), ); diff --git a/tests/phpunit/CRM/Utils/Mail/EmailProcessorTest.php b/tests/phpunit/CRM/Utils/Mail/EmailProcessorTest.php index 9b1d189fff..8abebc844a 100644 --- a/tests/phpunit/CRM/Utils/Mail/EmailProcessorTest.php +++ b/tests/phpunit/CRM/Utils/Mail/EmailProcessorTest.php @@ -4,7 +4,6 @@ * Class CRM_Utils_Mail_EmailProcessorTest * @group headless */ - class CRM_Utils_Mail_EmailProcessorTest extends CiviUnitTestCase { /** @@ -61,7 +60,7 @@ class CRM_Utils_Mail_EmailProcessorTest extends CiviUnitTestCase { $this->setUpMailing(); $mail = 'test_invalid_character.eml'; - copy(__DIR__ . '/data/bounces/' . $mail, __DIR__ . '/data/mail/' . $mail); + copy(__DIR__ . '/data/bounces/' . $mail, __DIR__ . '/data/mail/' . $mail); $this->callAPISuccess('job', 'fetch_bounces', array()); $this->assertFalse(file_exists(__DIR__ . '/data/mail/' . $mail)); $this->checkMailingBounces(1); @@ -74,7 +73,7 @@ class CRM_Utils_Mail_EmailProcessorTest extends CiviUnitTestCase { $this->setUpMailing(); $mail = 'test_utf8mb4_character.txt'; - copy(__DIR__ . '/data/bounces/' . $mail, __DIR__ . '/data/mail/' . $mail); + copy(__DIR__ . '/data/bounces/' . $mail, __DIR__ . '/data/mail/' . $mail); $this->callAPISuccess('job', 'fetch_bounces', array()); $this->assertFalse(file_exists(__DIR__ . '/data/mail/' . $mail)); $this->checkMailingBounces(1); @@ -89,7 +88,7 @@ class CRM_Utils_Mail_EmailProcessorTest extends CiviUnitTestCase { $this->setUpMailing(); $mail = 'test_sample_message.eml'; - copy(__DIR__ . '/data/bounces/' . $mail, __DIR__ . '/data/mail/' . $mail); + copy(__DIR__ . '/data/bounces/' . $mail, __DIR__ . '/data/mail/' . $mail); $this->callAPISuccess('job', 'fetch_bounces', array()); $this->assertFalse(file_exists(__DIR__ . '/data/mail/' . $mail)); $this->checkMailingBounces(1); diff --git a/tests/phpunit/CRM/Utils/QueryFormatterTest.php b/tests/phpunit/CRM/Utils/QueryFormatterTest.php index 04ff5dc283..68072e3cab 100644 --- a/tests/phpunit/CRM/Utils/QueryFormatterTest.php +++ b/tests/phpunit/CRM/Utils/QueryFormatterTest.php @@ -109,11 +109,11 @@ class CRM_Utils_QueryFormatterTest extends CiviUnitTestCase { // If user supplies wildcards, then ignore mode. foreach (array( - 'simple', - 'wildphrase', - 'wildwords', - 'wildwords-suffix', - ) as $mode) { + 'simple', + 'wildphrase', + 'wildwords', + 'wildwords-suffix', + ) as $mode) { $cases[] = array('first% second', 'like', $mode, 'first% second', array(3, 7)); $cases[] = array('first% second', 'fts', $mode, 'first* second', array(3, 7)); $cases[] = array('first% second', 'ftsbool', $mode, '+first* +second', array(3, 7)); @@ -134,6 +134,7 @@ class CRM_Utils_QueryFormatterTest extends CiviUnitTestCase { * @param string $language * @param string $mode * @param string $expectedText + * @param array|NULL $expectedRowIds * * @dataProvider dataProvider */ diff --git a/tests/phpunit/CRM/Utils/RuleTest.php b/tests/phpunit/CRM/Utils/RuleTest.php index edf81083b2..188089faaa 100644 --- a/tests/phpunit/CRM/Utils/RuleTest.php +++ b/tests/phpunit/CRM/Utils/RuleTest.php @@ -146,7 +146,7 @@ class CRM_Utils_RuleTest extends CiviUnitTestCase { '-', '_foo', 'one-two', - 'f00' + 'f00', ]; $expectFalse = [ ' ', @@ -157,7 +157,7 @@ class CRM_Utils_RuleTest extends CiviUnitTestCase { "", '(foo)', 'foo;', - '[foo]' + '[foo]', ]; $data = []; foreach ($expectTrue as $value) { diff --git a/tests/phpunit/CRM/Utils/SQL/InsertTest.php b/tests/phpunit/CRM/Utils/SQL/InsertTest.php index 5a502243f6..ba997cca80 100644 --- a/tests/phpunit/CRM/Utils/SQL/InsertTest.php +++ b/tests/phpunit/CRM/Utils/SQL/InsertTest.php @@ -5,6 +5,7 @@ * @group headless */ class CRM_Utils_SQL_InsertTest extends CiviUnitTestCase { + public function testRow_twice() { $insert = CRM_Utils_SQL_Insert::into('foo') ->row(array('first' => '1', 'second' => '2')) diff --git a/tests/phpunit/CRM/Utils/SQL/SelectTest.php b/tests/phpunit/CRM/Utils/SQL/SelectTest.php index ba4d8d29dd..5cecf42c6e 100644 --- a/tests/phpunit/CRM/Utils/SQL/SelectTest.php +++ b/tests/phpunit/CRM/Utils/SQL/SelectTest.php @@ -5,6 +5,7 @@ * @group headless */ class CRM_Utils_SQL_SelectTest extends CiviUnitTestCase { + public function testGetDefault() { $select = CRM_Utils_SQL_Select::from('foo bar'); $this->assertLike('SELECT * FROM foo bar', $select->toSQL()); diff --git a/tests/phpunit/CRM/Utils/SignerTest.php b/tests/phpunit/CRM/Utils/SignerTest.php index 109f5aaaed..51de429319 100644 --- a/tests/phpunit/CRM/Utils/SignerTest.php +++ b/tests/phpunit/CRM/Utils/SignerTest.php @@ -131,11 +131,13 @@ class CRM_Utils_SignerTest extends CiviUnitTestCase { ); $cases[] = array( 'signParams' => array( - 'a' => 1, // int + // int + 'a' => 1, 'b' => 'bee', ), 'validateParams' => array( - 'a' => '1', // string + // string + 'a' => '1', 'b' => 'bee', ), 'isValid' => TRUE, @@ -144,9 +146,11 @@ class CRM_Utils_SignerTest extends CiviUnitTestCase { foreach ($cases as $caseId => $case) { $signer = new CRM_Utils_Signer('secret', array('a', 'b', 'c')); $signature = $signer->sign($case['signParams']); - $this->assertTrue(!empty($signature) && is_string($signature)); // arbitrary + // arbitrary + $this->assertTrue(!empty($signature) && is_string($signature)); - $validator = new CRM_Utils_Signer('secret', array('a', 'b', 'c')); // same as $signer but physically separate + // same as $signer but physically separate + $validator = new CRM_Utils_Signer('secret', array('a', 'b', 'c')); $isValid = $validator->validate($signature, $case['validateParams']); if ($isValid !== $case['isValid']) { diff --git a/tests/phpunit/CRM/Utils/StringTest.php b/tests/phpunit/CRM/Utils/StringTest.php index 472655b06b..4bc1bd3ade 100644 --- a/tests/phpunit/CRM/Utils/StringTest.php +++ b/tests/phpunit/CRM/Utils/StringTest.php @@ -131,7 +131,8 @@ class CRM_Utils_StringTest extends CiviUnitTestCase { * @return array */ public function booleanDataProvider() { - $cases = array(); // array(0 => $input, 1 => $expectedOutput) + // array(0 => $input, 1 => $expectedOutput) + $cases = array(); $cases[] = array(TRUE, TRUE); $cases[] = array(FALSE, FALSE); $cases[] = array(1, TRUE); diff --git a/tests/phpunit/CRM/Utils/SystemTest.php b/tests/phpunit/CRM/Utils/SystemTest.php index 633abc64eb..66bab81091 100644 --- a/tests/phpunit/CRM/Utils/SystemTest.php +++ b/tests/phpunit/CRM/Utils/SystemTest.php @@ -1,6 +1,5 @@ $parsedUrl, - 'original' => $url + 'original' => $url, ]); } catch (CRM_Core_Exception $e) { @@ -65,7 +64,7 @@ class CRM_Utils_SystemTest extends CiviUnitTestCase { * * We do some checks here. * - * @param UriInterface $urlQuery + * @param \Psr\Http\Message\UriInterface $urlQuery * @param array $context * * @throws \CRM_Core_Exception @@ -90,7 +89,8 @@ class CRM_Utils_SystemTest extends CiviUnitTestCase { 'scheme' => 'https', 'host' => 'example.com', 'query' => 'ab=cd', - ]], + ], + ], ['http://myuser:mypass@foo.bar:123/whiz?a=b&c=d', [ 'scheme' => 'http', 'host' => 'foo.bar', @@ -99,10 +99,12 @@ class CRM_Utils_SystemTest extends CiviUnitTestCase { 'pass' => 'mypass', 'path' => '/whiz', 'query' => 'a=b&c=d', - ]], + ], + ], ['/foo/bar', [ - 'path' => '/foo/bar' - ]], + 'path' => '/foo/bar', + ], + ], ]; } diff --git a/tests/phpunit/CRM/Utils/TimeTest.php b/tests/phpunit/CRM/Utils/TimeTest.php index 2f919def91..55c647d1bd 100644 --- a/tests/phpunit/CRM/Utils/TimeTest.php +++ b/tests/phpunit/CRM/Utils/TimeTest.php @@ -5,13 +5,15 @@ * @group headless */ class CRM_Utils_TimeTest extends CiviUnitTestCase { + /** * Equal cases. * * @return array */ public function equalCases() { - $cases = array(); // array(0 => $timeA, 1 => $timeB, 2 => $threshold, 3 => $expectedResult) + // array(0 => $timeA, 1 => $timeB, 2 => $threshold, 3 => $expectedResult) + $cases = array(); $cases[] = array('2012-04-01 12:00:00', '2012-04-01 12:00:00', 0, 1); $cases[] = array('2012-04-01 12:00:00', '2012-04-01 12:00:01', 0, 0); $cases[] = array('2012-04-01 12:00:00', '2012-04-01 12:00:50', 60, 1); diff --git a/tests/phpunit/CRMTraits/ACL/PermissionTrait.php b/tests/phpunit/CRMTraits/ACL/PermissionTrait.php index 2382636352..01a1afd146 100644 --- a/tests/phpunit/CRMTraits/ACL/PermissionTrait.php +++ b/tests/phpunit/CRMTraits/ACL/PermissionTrait.php @@ -32,7 +32,16 @@ */ trait CRMTraits_ACL_PermissionTrait { + /** + * ContactID of allowed Contact + * @var int + */ protected $allowedContactId = 0; + + /** + * Array of allowed contactIds + * @var array + */ protected $allowedContacts = []; /** diff --git a/tests/phpunit/CRMTraits/PCP/PCPTestTrait.php b/tests/phpunit/CRMTraits/PCP/PCPTestTrait.php index 522a553d41..17454df591 100644 --- a/tests/phpunit/CRMTraits/PCP/PCPTestTrait.php +++ b/tests/phpunit/CRMTraits/PCP/PCPTestTrait.php @@ -31,6 +31,7 @@ * Traits for testing PCP pages. */ trait CRMTraits_PCP_PCPTestTrait { + /** * Build and return pcpBlock params. * diff --git a/tests/phpunit/CRMTraits/Page/PageTestTrait.php b/tests/phpunit/CRMTraits/Page/PageTestTrait.php index 8b2a2f5db3..bf8cc69c17 100644 --- a/tests/phpunit/CRMTraits/Page/PageTestTrait.php +++ b/tests/phpunit/CRMTraits/Page/PageTestTrait.php @@ -122,7 +122,7 @@ trait CRMTraits_Page_PageTestTrait { protected function listenForPageContent() { $this->hookClass->setHook('civicrm_alterContent', [ $this, - 'checkPageContent' + 'checkPageContent', ]); } diff --git a/tests/phpunit/Civi/API/KernelTest.php b/tests/phpunit/Civi/API/KernelTest.php index 00168d5a30..995c26dc17 100644 --- a/tests/phpunit/Civi/API/KernelTest.php +++ b/tests/phpunit/Civi/API/KernelTest.php @@ -1,7 +1,7 @@ array('name' => string $eventName, 'type' => string $className)) */ - var $actualEventSequence; + public $actualEventSequence; /** - * @var EventDispatcher + * @var \Symfony\Component\EventDispatcher\EventDispatcher */ - var $dispatcher; + public $dispatcher; /** * @var Kernel */ - var $kernel; + public $kernel; protected function setUp() { parent::setUp(); diff --git a/tests/phpunit/Civi/API/Subscriber/DynamicFKAuthorizationTest.php b/tests/phpunit/Civi/API/Subscriber/DynamicFKAuthorizationTest.php index 3e0a32f470..0576ddeb53 100644 --- a/tests/phpunit/Civi/API/Subscriber/DynamicFKAuthorizationTest.php +++ b/tests/phpunit/Civi/API/Subscriber/DynamicFKAuthorizationTest.php @@ -1,8 +1,8 @@ cronSchedule = array( 'start' => '2015-01-20 00:00:00', 'end' => '2015-03-01 00:00:00', - 'interval' => 24 * 60 * 60, // seconds + // seconds + 'interval' => 24 * 60 * 60, ); $this->schedule = new \CRM_Core_DAO_ActionSchedule(); diff --git a/tests/phpunit/Civi/Angular/ManagerTest.php b/tests/phpunit/Civi/Angular/ManagerTest.php index abe88a40ee..2635469a93 100644 --- a/tests/phpunit/Civi/Angular/ManagerTest.php +++ b/tests/phpunit/Civi/Angular/ManagerTest.php @@ -214,7 +214,7 @@ class ManagerTest extends \CiviUnitTestCase { public function hook_civicrm_alterAngular($angular) { $angular->add(ChangeSet::create('cat-stevens') ->requires('crmMailing', 'crmCatStevens') - ->alterHtml('~/crmMailing/EditMailingCtrl/2step.html', function(\phpQueryObject $doc){ + ->alterHtml('~/crmMailing/EditMailingCtrl/2step.html', function(\phpQueryObject $doc) { $doc->find('[ng-form="crmMailingSubform"]')->attr('cat-stevens', 'ts(\'wild world\')'); }) ); diff --git a/tests/phpunit/Civi/CCase/SequenceListenerTest.php b/tests/phpunit/Civi/CCase/SequenceListenerTest.php index 01307a59b2..72ac7fd511 100644 --- a/tests/phpunit/Civi/CCase/SequenceListenerTest.php +++ b/tests/phpunit/Civi/CCase/SequenceListenerTest.php @@ -84,11 +84,11 @@ class SequenceListenerTest extends \CiviCaseTestCase { //Add an Activity before the case is closed \CRM_Utils_Time::setTime('2013-11-30 04:00:00'); $this->callApiSuccess('Activity', 'create', array( - 'activity_name' => 'Follow up', - 'activity_type_id' => $actTypes['Follow up'], - 'status_id' => $actStatuses['Scheduled'], - 'case_id' => $case['id'], - 'activity_date_time' => \CRM_Utils_Time::getTime(), + 'activity_name' => 'Follow up', + 'activity_type_id' => $actTypes['Follow up'], + 'status_id' => $actStatuses['Scheduled'], + 'case_id' => $case['id'], + 'activity_date_time' => \CRM_Utils_Time::getTime(), )); $analyzer->flush(); $this->assertApproxTime('2013-11-30 01:00:00', self::ag($analyzer->getSingleActivity('Medical evaluation'), 'activity_date_time')); @@ -120,8 +120,8 @@ class SequenceListenerTest extends \CiviCaseTestCase { // Complete the additional Activity; Case closed \CRM_Utils_Time::setTime('2013-11-30 04:00:00'); $this->callApiSuccess('Activity', 'create', array( - 'id' => self::ag($analyzer->getSingleActivity('Follow up'), 'id'), - 'status_id' => $actStatuses['Completed'], + 'id' => self::ag($analyzer->getSingleActivity('Follow up'), 'id'), + 'status_id' => $actStatuses['Completed'], )); $analyzer->flush(); $this->assertApproxTime('2013-11-30 01:00:00', self::ag($analyzer->getSingleActivity('Medical evaluation'), 'activity_date_time')); diff --git a/tests/phpunit/Civi/Core/ResolverTest.php b/tests/phpunit/Civi/Core/ResolverTest.php index 4c0466a2b5..0f5f3c551a 100644 --- a/tests/phpunit/Civi/Core/ResolverTest.php +++ b/tests/phpunit/Civi/Core/ResolverTest.php @@ -17,7 +17,8 @@ namespace Civi\Core { * Test setup. */ protected function setUp() { - parent::setUp(); // TODO: Change the autogenerated stub + // TODO: Change the autogenerated stub + parent::setUp(); $this->resolver = new Resolver(); } @@ -169,6 +170,7 @@ namespace Civi\Core { } namespace { + /** * @param string $arg1 * Dummy value to pass through. @@ -186,4 +188,5 @@ namespace { function civicrm_api3_resolvertest_ping($params) { return civicrm_api3_create_success("api dummy received " . $params['first']); } + } diff --git a/tests/phpunit/Civi/Test/ExampleTransactionalTest.php b/tests/phpunit/Civi/Test/ExampleTransactionalTest.php index 7c54db29d1..bf50230031 100644 --- a/tests/phpunit/Civi/Test/ExampleTransactionalTest.php +++ b/tests/phpunit/Civi/Test/ExampleTransactionalTest.php @@ -15,7 +15,7 @@ class ExampleTransactionalTest extends \PHPUnit_Framework_TestCase implements He * @var array * Array(int $id). */ - static $contactIds = array(); + protected static $contactIds = array(); public function setUpHeadless() { return \Civi\Test::headless()->apply(); diff --git a/tests/phpunit/Civi/Token/TokenProcessorTest.php b/tests/phpunit/Civi/Token/TokenProcessorTest.php index 38d02d44c1..808e490693 100644 --- a/tests/phpunit/Civi/Token/TokenProcessorTest.php +++ b/tests/phpunit/Civi/Token/TokenProcessorTest.php @@ -8,7 +8,7 @@ use Symfony\Component\EventDispatcher\EventDispatcher; class TokenProcessorTest extends \CiviUnitTestCase { /** - * @var EventDispatcher + * @var \Symfony\Component\EventDispatcher\EventDispatcher */ protected $dispatcher; @@ -154,7 +154,7 @@ class TokenProcessorTest extends \CiviUnitTestCase { ); $expectText = array( - 0 => 'Good morning, What. #0123 is a good number. Trickster {contact.display_name}. Bye!' , + 0 => 'Good morning, What. #0123 is a good number. Trickster {contact.display_name}. Bye!', 1 => 'Good morning, Who. #0004 is a good number. Trickster {contact.display_name}. Bye!', 2 => 'Good morning, Darth Vader. #0010 is a good number. Trickster {contact.display_name}. Bye!', ); @@ -168,7 +168,8 @@ class TokenProcessorTest extends \CiviUnitTestCase { $rowCount++; } $this->assertEquals(3, $rowCount); - $this->assertEquals(0, $this->counts['onListTokens']); // This may change in the future. + // This may change in the future. + $this->assertEquals(0, $this->counts['onListTokens']); $this->assertEquals(1, $this->counts['onEvalTokens']); } diff --git a/tests/phpunit/CiviTest/CiviCaseTestCase.php b/tests/phpunit/CiviTest/CiviCaseTestCase.php index f47395e526..299f541165 100644 --- a/tests/phpunit/CiviTest/CiviCaseTestCase.php +++ b/tests/phpunit/CiviTest/CiviCaseTestCase.php @@ -51,10 +51,9 @@ class CiviCaseTestCase extends CiviUnitTestCase { // & was really hard to troubleshoot as involved truncating option_value table to mitigate this & not leaving DB in a // state where tests could run afterwards without re-loading. $this->caseStatusGroup = $this->callAPISuccess('option_group', 'get', array( - 'name' => 'case_status', - 'format.only_id' => 1, - ) - ); + 'name' => 'case_status', + 'format.only_id' => 1, + )); $optionValues = array( 'Medical evaluation' => 'Medical evaluation', 'Mental health evaluation' => "Mental health evaluation", diff --git a/tests/phpunit/CiviTest/CiviReportTestCase.php b/tests/phpunit/CiviTest/CiviReportTestCase.php index 641a5f36d7..84fed16315 100644 --- a/tests/phpunit/CiviTest/CiviReportTestCase.php +++ b/tests/phpunit/CiviTest/CiviReportTestCase.php @@ -29,6 +29,7 @@ * Class CiviReportTestCase */ class CiviReportTestCase extends CiviUnitTestCase { + public function setUp() { parent::setUp(); $this->_sethtmlGlobals(); diff --git a/tests/phpunit/CiviTest/CiviTestSuite.php b/tests/phpunit/CiviTest/CiviTestSuite.php index 4dd175274b..43e6150fce 100644 --- a/tests/phpunit/CiviTest/CiviTestSuite.php +++ b/tests/phpunit/CiviTest/CiviTestSuite.php @@ -119,7 +119,8 @@ class CiviTestSuite extends PHPUnit_Framework_TestSuite { } // Pass 1: Check all *Tests.php files - $addTests = array(); // array(callable) + // array(callable) + $addTests = array(); //echo "start Pass 1 on {$dirInfo->getRealPath()}\n"; $dir = new DirectoryIterator($dirInfo->getRealPath()); foreach ($dir as $fileInfo) { @@ -155,7 +156,8 @@ class CiviTestSuite extends PHPUnit_Framework_TestSuite { } // Pass 2: Scan all subdirectories - $addAllTests = array(); // array(array(0 => $suite, 1 => $file, 2 => SplFileinfo)) + // array(array(0 => $suite, 1 => $file, 2 => SplFileinfo)) + $addAllTests = array(); $dir = new DirectoryIterator($dirInfo->getRealPath()); //echo "start Pass 2 on {$dirInfo->getRealPath()}\n"; foreach ($dir as $fileInfo) { @@ -176,7 +178,8 @@ class CiviTestSuite extends PHPUnit_Framework_TestSuite { // Pass 3: Check all *Test.php files in this directory //echo "start Pass 3 on {$dirInfo->getRealPath()}\n"; - $addTestSuites = array(); // array(className) + // array(className) + $addTestSuites = array(); $dir = new DirectoryIterator($dirInfo->getRealPath()); foreach ($dir as $fileInfo) { if ($fileInfo->isReadable() && $fileInfo->isFile() diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index c3f62042e4..39ab293589 100644 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -78,6 +78,7 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { /** * Track tables we have modified during a test. + * @var array */ protected $_tablesToTruncate = array(); @@ -292,7 +293,8 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { $session = CRM_Core_Session::singleton(); $session->set('userID', NULL); - $this->errorScope = CRM_Core_TemporaryErrorScope::useException(); // REVERT + // REVERT + $this->errorScope = CRM_Core_TemporaryErrorScope::useException(); // Use a temporary file for STDIN $GLOBALS['stdin'] = tmpfile(); if ($GLOBALS['stdin'] === FALSE) { @@ -320,7 +322,8 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { // initialize the object once db is loaded \Civi::reset(); - $config = CRM_Core_Config::singleton(TRUE, TRUE); // ugh, performance + // ugh, performance + $config = CRM_Core_Config::singleton(TRUE, TRUE); // when running unit tests, use mockup user framework $this->hookClass = CRM_Utils_Hook::singleton(); @@ -815,6 +818,7 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { * enum contact type: Individual, Organization * @param int $seq * sequence number for the values of this type + * @param bool $random * * @return array * properties of sample contact (ie. $params for API call) @@ -1029,15 +1033,13 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { */ public function relationshipTypeCreate($params = array()) { $params = array_merge(array( - 'name_a_b' => 'Relation 1 for relationship type create', - 'name_b_a' => 'Relation 2 for relationship type create', - 'contact_type_a' => 'Individual', - 'contact_type_b' => 'Organization', - 'is_reserved' => 1, - 'is_active' => 1, - ), - $params - ); + 'name_a_b' => 'Relation 1 for relationship type create', + 'name_b_a' => 'Relation 2 for relationship type create', + 'contact_type_a' => 'Individual', + 'contact_type_b' => 'Organization', + 'is_reserved' => 1, + 'is_active' => 1, + ), $params); $result = $this->callAPISuccess('relationship_type', 'create', $params); CRM_Core_PseudoConstant::flush('relationshipType'); @@ -1174,7 +1176,7 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { * @param array $processorParams * * @return \CRM_Core_Payment_Dummy - * Instance of Dummy Payment Processor + * Instance of Dummy Payment Processor */ public function dummyProcessorCreate($processorParams = array()) { $paymentProcessorID = $this->processorCreate($processorParams); @@ -1628,6 +1630,7 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { $config = CRM_Core_Config::singleton(); unset($config->userPermissionClass->permissions); } + /** * Create a smart group. * @@ -1657,7 +1660,7 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { * @param int $totalCount * @param bool $random * @return int - * groupId of created group + * groupId of created group */ public function groupContactCreate($groupID, $totalCount = 10, $random = FALSE) { $params = array('group_id' => $groupID); @@ -1997,7 +2000,6 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { return array('custom_group_id' => $customGroup['id'], 'custom_field_id' => $customField['id'], 'custom_field_option_group_id' => $custom_field_api_result['values'][0]['option_group_id'], 'custom_field_group_options' => $options); } - /** * Delete custom group. * @@ -2238,6 +2240,7 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) CRM_Core_DAO::executeQuery("INSERT INTO `civicrm_price_field` (`id`, `price_set_id`, `name`, `label`, `html_type`, `is_enter_qty`, `help_pre`, `help_post`, `weight`, `is_display_amounts`, `options_per_line`, `is_active`, `is_required`, `active_on`, `expire_on`, `javascript`, `visibility_id`) VALUES (1, 1, 'contribution_amount', 'Contribution Amount', 'Text', 0, NULL, NULL, 1, 1, 1, 1, 1, NULL, NULL, NULL, 1)"); CRM_Core_DAO::executeQuery("INSERT INTO `civicrm_price_field_value` (`id`, `price_field_id`, `name`, `label`, `description`, `amount`, `count`, `max_value`, `weight`, `membership_type_id`, `membership_num_terms`, `is_default`, `is_active`, `financial_type_id`, `non_deductible_amount`) VALUES (1, 1, 'contribution_amount', 'Contribution Amount', NULL, '1', NULL, NULL, 1, NULL, NULL, 0, 1, 1, 0.00)"); } + /* * Function does a 'Get' on the entity & compares the fields in the Params with those returned * Default behaviour is to also delete the entity @@ -2252,6 +2255,7 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) * @param string $errorText * Text to print on error. */ + /** * @param array $params * @param int $id @@ -2776,26 +2780,25 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) */ public function paymentProcessorCreate($params = array()) { $params = array_merge(array( - 'name' => 'demo', - 'domain_id' => CRM_Core_Config::domainID(), - 'payment_processor_type_id' => 'PayPal', - 'is_active' => 1, - 'is_default' => 0, - 'is_test' => 1, - 'user_name' => 'sunil._1183377782_biz_api1.webaccess.co.in', - 'password' => '1183377788', - 'signature' => 'APixCoQ-Zsaj-u3IH7mD5Do-7HUqA9loGnLSzsZga9Zr-aNmaJa3WGPH', - 'url_site' => 'https://www.sandbox.paypal.com/', - 'url_api' => 'https://api-3t.sandbox.paypal.com/', - 'url_button' => 'https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif', - 'class_name' => 'Payment_PayPalImpl', - 'billing_mode' => 3, - 'financial_type_id' => 1, - 'financial_account_id' => 12, - // Credit card = 1 so can pass 'by accident'. - 'payment_instrument_id' => 'Debit Card', - ), - $params); + 'name' => 'demo', + 'domain_id' => CRM_Core_Config::domainID(), + 'payment_processor_type_id' => 'PayPal', + 'is_active' => 1, + 'is_default' => 0, + 'is_test' => 1, + 'user_name' => 'sunil._1183377782_biz_api1.webaccess.co.in', + 'password' => '1183377788', + 'signature' => 'APixCoQ-Zsaj-u3IH7mD5Do-7HUqA9loGnLSzsZga9Zr-aNmaJa3WGPH', + 'url_site' => 'https://www.sandbox.paypal.com/', + 'url_api' => 'https://api-3t.sandbox.paypal.com/', + 'url_button' => 'https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif', + 'class_name' => 'Payment_PayPalImpl', + 'billing_mode' => 3, + 'financial_type_id' => 1, + 'financial_account_id' => 12, + // Credit card = 1 so can pass 'by accident'. + 'payment_instrument_id' => 'Debit Card', + ), $params); if (!is_numeric($params['payment_processor_type_id'])) { // really the api should handle this through getoptions but it's not exactly api call so lets just sort it //here @@ -2816,18 +2819,16 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) */ public function setupRecurringPaymentProcessorTransaction($recurParams = [], $contributionParams = []) { $contributionParams = array_merge([ - 'total_amount' => '200', - 'invoice_id' => $this->_invoiceID, - 'financial_type_id' => 'Donation', - 'contribution_status_id' => 'Pending', - 'contact_id' => $this->_contactID, - 'contribution_page_id' => $this->_contributionPageID, - 'payment_processor_id' => $this->_paymentProcessorID, - 'is_test' => 0, - 'skipCleanMoney' => TRUE, - ], - $contributionParams - ); + 'total_amount' => '200', + 'invoice_id' => $this->_invoiceID, + 'financial_type_id' => 'Donation', + 'contribution_status_id' => 'Pending', + 'contact_id' => $this->_contactID, + 'contribution_page_id' => $this->_contributionPageID, + 'payment_processor_id' => $this->_paymentProcessorID, + 'is_test' => 0, + 'skipCleanMoney' => TRUE, + ], $contributionParams); $contributionRecur = $this->callAPISuccess('contribution_recur', 'create', array_merge(array( 'contact_id' => $this->_contactID, 'amount' => 1000, @@ -3127,6 +3128,7 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) * * @param string $component * @param int $componentId + * @param array $priceFieldOptions * * @return array */ @@ -3393,9 +3395,7 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) 'label' => 'Payment Instrument -' . substr(sha1(rand()), 0, 7), 'option_group_id' => 'payment_instrument', 'is_active' => 1, - ), - $params - ); + ), $params); $newPaymentInstrument = $this->callAPISuccess('OptionValue', 'create', $params)['id']; $relationTypeID = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Asset Account is' ")); @@ -3522,36 +3522,33 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) 'html_type' => 'Radio', )); $priceFieldValue = $this->callAPISuccess('price_field_value', 'create', array( - 'price_set_id' => $priceSetID, - 'price_field_id' => $priceField['id'], - 'label' => 'Long Haired Goat', - 'amount' => 20, - 'financial_type_id' => 'Donation', - 'membership_type_id' => $membershipTypeID, - 'membership_num_terms' => 1, - ) - ); + 'price_set_id' => $priceSetID, + 'price_field_id' => $priceField['id'], + 'label' => 'Long Haired Goat', + 'amount' => 20, + 'financial_type_id' => 'Donation', + 'membership_type_id' => $membershipTypeID, + 'membership_num_terms' => 1, + )); $this->_ids['price_field_value'] = array($priceFieldValue['id']); $priceFieldValue = $this->callAPISuccess('price_field_value', 'create', array( - 'price_set_id' => $priceSetID, - 'price_field_id' => $priceField['id'], - 'label' => 'Shoe-eating Goat', - 'amount' => 10, - 'financial_type_id' => 'Donation', - 'membership_type_id' => $membershipTypeID, - 'membership_num_terms' => 2, - ) - ); + 'price_set_id' => $priceSetID, + 'price_field_id' => $priceField['id'], + 'label' => 'Shoe-eating Goat', + 'amount' => 10, + 'financial_type_id' => 'Donation', + 'membership_type_id' => $membershipTypeID, + 'membership_num_terms' => 2, + )); $this->_ids['price_field_value'][] = $priceFieldValue['id']; $priceFieldValue = $this->callAPISuccess('price_field_value', 'create', array( - 'price_set_id' => $priceSetID, - 'price_field_id' => $priceField['id'], - 'label' => 'Shoe-eating Goat', - 'amount' => 10, - 'financial_type_id' => 'Donation', - ) - ); + 'price_set_id' => $priceSetID, + 'price_field_id' => $priceField['id'], + 'label' => 'Shoe-eating Goat', + 'amount' => 10, + 'financial_type_id' => 'Donation', + )); $this->_ids['price_field_value']['cont'] = $priceFieldValue['id']; $this->_ids['price_set'] = $priceSetID; @@ -3613,7 +3610,6 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) } } - /** * Instantiate form object. * @@ -3662,7 +3658,6 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) return CRM_Utils_Money::format($amount, NULL, '%a'); } - /** * Get the contribution object. * diff --git a/tests/phpunit/E2E/Cache/TieredTest.php b/tests/phpunit/E2E/Cache/TieredTest.php index ac31a41639..a2c11fea60 100644 --- a/tests/phpunit/E2E/Cache/TieredTest.php +++ b/tests/phpunit/E2E/Cache/TieredTest.php @@ -35,7 +35,12 @@ class E2E_Cache_TieredTest extends E2E_Cache_CacheTestCase { /** * @var CRM_Utils_Cache_ArrayCache */ - protected $a, $b; + protected $a; + + /** + * @var CRM_Utils_Cache_ArrayCache + */ + protected $b; protected function tearDown() { if (function_exists('timecop_return')) { @@ -53,7 +58,7 @@ class E2E_Cache_TieredTest extends E2E_Cache_CacheTestCase { $this->b = CRM_Utils_Cache::create([ 'name' => 'e2e tiered test b', 'type' => ['ArrayCache'], - ]) + ]), ], $maxTimeouts); } diff --git a/tests/phpunit/E2E/Cache/TwoInstancesTest.php b/tests/phpunit/E2E/Cache/TwoInstancesTest.php index 579a839739..93e712e327 100644 --- a/tests/phpunit/E2E/Cache/TwoInstancesTest.php +++ b/tests/phpunit/E2E/Cache/TwoInstancesTest.php @@ -34,7 +34,12 @@ class E2E_Cache_TwoInstancesTest extends CiviEndToEndTestCase { /** * @var Psr\SimpleCache\CacheInterface; */ - protected $a, $b; + protected $a; + + /** + * @var Psr\SimpleCache\CacheInterface; + */ + protected $b; protected function setUp() { parent::setUp(); diff --git a/tests/phpunit/E2E/Core/AssetBuilderTest.php b/tests/phpunit/E2E/Core/AssetBuilderTest.php index 5d5766d9ac..19df9a3c1c 100644 --- a/tests/phpunit/E2E/Core/AssetBuilderTest.php +++ b/tests/phpunit/E2E/Core/AssetBuilderTest.php @@ -5,7 +5,6 @@ namespace E2E\Core; use Civi\Core\AssetBuilder; use Civi\Core\Event\GenericHookEvent; - /** * Class AssetBuilderTest * @package E2E\Core diff --git a/tests/phpunit/E2E/Core/PrevNextTest.php b/tests/phpunit/E2E/Core/PrevNextTest.php index ed1fdebae6..97e020865e 100644 --- a/tests/phpunit/E2E/Core/PrevNextTest.php +++ b/tests/phpunit/E2E/Core/PrevNextTest.php @@ -15,7 +15,12 @@ class PrevNextTest extends \CiviEndToEndTestCase { /** * @var string */ - protected $cacheKey, $cacheKeyB; + protected $cacheKey; + + /** + * @var string + */ + protected $cacheKeyB; /** * @var \CRM_Core_PrevNextCache_Interface @@ -313,12 +318,13 @@ class PrevNextTest extends \CiviEndToEndTestCase { $this->assertSelections([], 'getall', $this->cacheKeyB); } - /** * Assert that the current cacheKey has a list of selected contact IDs. * * @param array $ids * Contact IDs that should be selected. + * @param string $action + * @param string|NULL $cacheKey */ protected function assertSelections($ids, $action = 'get', $cacheKey = NULL) { if ($cacheKey === NULL) { diff --git a/tests/phpunit/E2E/Extern/RestTest.php b/tests/phpunit/E2E/Extern/RestTest.php index 0d9d963157..a288acc568 100644 --- a/tests/phpunit/E2E/Extern/RestTest.php +++ b/tests/phpunit/E2E/Extern/RestTest.php @@ -96,104 +96,122 @@ class E2E_Extern_RestTest extends CiviEndToEndTestCase { // entity,action: omit apiKey, valid entity+action $cases[] = array( - array(// query + // query + array( "entity" => "Contact", "action" => "get", "key" => $GLOBALS['_CV']['CIVI_SITE_KEY'], "json" => "1", ), - 1, // is_error + // is_error + 1, ); // entity,action: valid apiKey, valid entity+action $cases[] = array( - array(// query + // query + array( "entity" => "Contact", "action" => "get", "key" => $GLOBALS['_CV']['CIVI_SITE_KEY'], "json" => "1", "api_key" => self::getApiKey(), ), - 0, // is_error + // is_error + 0, ); // entity,action: bad apiKey, valid entity+action $cases[] = array( - array(// query + // query + array( "entity" => "Contact", "action" => "get", "key" => $GLOBALS['_CV']['CIVI_SITE_KEY'], "json" => "1", "api_key" => 'garbage_' . self::getApiKey(), ), - 1, // is_error + // is_error + 1, ); // entity,action: valid apiKey, invalid entity+action $cases[] = array( - array(// query + // query + array( "entity" => "Contactses", "action" => "get", "key" => $GLOBALS['_CV']['CIVI_SITE_KEY'], "json" => "1", "api_key" => self::getApiKey(), ), - 1, // is_error + // is_error + 1, ); // q=civicrm/entity/action: omit apiKey, valid entity+action $cases[] = array( - array(// query + // query + array( "q" => "civicrm/contact/get", "key" => $GLOBALS['_CV']['CIVI_SITE_KEY'], "json" => "1", ), - 1, // is_error + // is_error + 1, ); // q=civicrm/entity/action: valid apiKey, valid entity+action $cases[] = array( - array(// query + // query + array( "q" => "civicrm/contact/get", "key" => $GLOBALS['_CV']['CIVI_SITE_KEY'], "json" => "1", "api_key" => self::getApiKey(), ), - 0, // is_error + // is_error + 0, ); // q=civicrm/entity/action: invalid apiKey, valid entity+action $cases[] = array( - array(// query + // query + array( "q" => "civicrm/contact/get", "key" => $GLOBALS['_CV']['CIVI_SITE_KEY'], "json" => "1", "api_key" => 'garbage_' . self::getApiKey(), ), - 1, // is_error + // is_error + 1, ); // q=civicrm/entity/action: valid apiKey, invalid entity+action $cases[] = array( - array(// query + // query + array( "q" => "civicrm/contactses/get", "key" => $GLOBALS['_CV']['CIVI_SITE_KEY'], "json" => "1", "api_key" => self::getApiKey(), ), - 1, // is_error + // is_error + 1, ); // q=civicrm/entity/action: valid apiKey, invalid entity+action // XXX Actually Ping is valid, no? $cases[] = array( - array(// query + // query + array( "q" => "civicrm/ping", "key" => $GLOBALS['_CV']['CIVI_SITE_KEY'], "json" => "1", "api_key" => self::getApiKey(), ), - 0, // is_error + // is_error + 0, ); return $cases; diff --git a/tests/phpunit/E2E/Extern/SoapTest.php b/tests/phpunit/E2E/Extern/SoapTest.php index 8f556c0364..7f618da5a7 100644 --- a/tests/phpunit/E2E/Extern/SoapTest.php +++ b/tests/phpunit/E2E/Extern/SoapTest.php @@ -33,7 +33,17 @@ class E2E_Extern_SoapTest extends CiviEndToEndTestCase { /** * @var string */ - var $url, $adminUser, $adminPass; + public $url; + + /** + * @var string + */ + public $adminUser; + + /** + * @var string + */ + public $adminPass; public function setUp() { CRM_Core_Config::singleton(1, 1); @@ -91,11 +101,10 @@ class E2E_Extern_SoapTest extends CiviEndToEndTestCase { */ protected function createClient() { return new SoapClient(NULL, array( - 'location' => $this->url, - 'uri' => 'urn:civicrm', - 'trace' => 1, - ) - ); + 'location' => $this->url, + 'uri' => 'urn:civicrm', + 'trace' => 1, + )); } } diff --git a/tests/phpunit/EnvTests.php b/tests/phpunit/EnvTests.php index 9bfa80f8db..18ef4d3a0e 100644 --- a/tests/phpunit/EnvTests.php +++ b/tests/phpunit/EnvTests.php @@ -11,6 +11,7 @@ * (eg "MyFirstTest::testFoo"). */ class EnvTests extends \PHPUnit_Framework_TestSuite { + /** * @return \EnvTests */ diff --git a/tests/phpunit/HelloTest.php b/tests/phpunit/HelloTest.php index af4b139744..74e3ad5bcb 100644 --- a/tests/phpunit/HelloTest.php +++ b/tests/phpunit/HelloTest.php @@ -43,8 +43,11 @@ * Class HelloTest */ class HelloTest extends PHPUnit_Framework_TestCase { - // contains the object handle of the string class - var $abc; + /** + * contains the object handle of the string class + * @var string + */ + public $abc; /** * @param string|null $name diff --git a/tests/phpunit/api/v3/ACLPermissionTest.php b/tests/phpunit/api/v3/ACLPermissionTest.php index 1e4e4a5cc2..f72b0a8818 100644 --- a/tests/phpunit/api/v3/ACLPermissionTest.php +++ b/tests/phpunit/api/v3/ACLPermissionTest.php @@ -510,7 +510,8 @@ class api_v3_ACLPermissionTest extends CiviUnitTestCase { return [ ['contribution'], ['participant'], - ];// @todo array('pledge' => 'pledge') + // @todo array('pledge' => 'pledge') + ]; } /** @@ -684,10 +685,10 @@ class api_v3_ACLPermissionTest extends CiviUnitTestCase { ], ]); foreach ([ - 'source_contact', - 'target_contact', - 'assignee_contact', - ] as $roleName) { + 'source_contact', + 'target_contact', + 'assignee_contact', + ] as $roleName) { $roleKey = $roleName . '_id'; if ($role !== $roleKey) { $this->assertTrue(empty($result[$roleKey]), "Only contact in $role is permissioned to be returned, not $roleKey"); @@ -829,9 +830,8 @@ class api_v3_ACLPermissionTest extends CiviUnitTestCase { $contacts = []; $activityContacts = $this->callAPISuccess('ActivityContact', 'get', [ - 'activity_id' => $activity['id'], - ] - ); + 'activity_id' => $activity['id'], + ]); $activityRecordTypes = $this->callAPISuccess('ActivityContact', 'getoptions', ['field' => 'record_type_id']); foreach ($activityContacts['values'] as $activityContact) { diff --git a/tests/phpunit/api/v3/APIWrapperTest.php b/tests/phpunit/api/v3/APIWrapperTest.php index d256a294ec..56c688b915 100644 --- a/tests/phpunit/api/v3/APIWrapperTest.php +++ b/tests/phpunit/api/v3/APIWrapperTest.php @@ -89,6 +89,7 @@ class api_v3_APIWrapperTest extends CiviUnitTestCase { * Class api_v3_APIWrapperTest_Impl */ class api_v3_APIWrapperTest_Impl implements API_Wrapper { + /** * @inheritDoc */ diff --git a/tests/phpunit/api/v3/ActivityContactTest.php b/tests/phpunit/api/v3/ActivityContactTest.php index bbe878d15d..737f4c0e5d 100644 --- a/tests/phpunit/api/v3/ActivityContactTest.php +++ b/tests/phpunit/api/v3/ActivityContactTest.php @@ -39,7 +39,6 @@ class api_v3_ActivityContactTest extends CiviUnitTestCase { protected $_activityID; protected $_params; - public function setUp() { $this->_apiversion = 3; parent::setUp(); diff --git a/tests/phpunit/api/v3/ActivityTest.php b/tests/phpunit/api/v3/ActivityTest.php index 8345c0bdcc..6e1b3f602e 100644 --- a/tests/phpunit/api/v3/ActivityTest.php +++ b/tests/phpunit/api/v3/ActivityTest.php @@ -268,7 +268,6 @@ class api_v3_ActivityTest extends CiviUnitTestCase { $this->assertEquals('priority_id', $result['error_field']); } - /** * Test create succeeds with valid string for priority. */ @@ -560,7 +559,6 @@ class api_v3_ActivityTest extends CiviUnitTestCase { "'Invalid' is not a valid option for field status_id"); } - /** * Test civicrm_activity_create() with using a text status_id. */ @@ -655,7 +653,6 @@ class api_v3_ActivityTest extends CiviUnitTestCase { $this->callAPISuccess('Activity', 'Delete', array('id' => $result['id'])); } - /** * Test civicrm_activity_get() with filter target_contact_id */ @@ -768,7 +765,6 @@ class api_v3_ActivityTest extends CiviUnitTestCase { $this->assertEquals($tagDescription, $activityget['tag_id'][$tag['id']]['tag_id.description']); } - /** * Test that activity.get api works to filter on and return files. */ @@ -1391,15 +1387,13 @@ class api_v3_ActivityTest extends CiviUnitTestCase { */ public function testGetOverdue() { $overdueAct = $this->callAPISuccess('Activity', 'create', array( - 'activity_date_time' => 'now - 1 week', - 'status_id' => 'Scheduled', - ) + $this->_params - ); + 'activity_date_time' => 'now - 1 week', + 'status_id' => 'Scheduled', + ) + $this->_params); $completedAct = $this->callAPISuccess('Activity', 'create', array( - 'activity_date_time' => 'now - 1 week', - 'status_id' => 'Completed', - ) + $this->_params - ); + 'activity_date_time' => 'now - 1 week', + 'status_id' => 'Completed', + ) + $this->_params); $ids = array($overdueAct['id'], $completedAct['id']); // Test sorting diff --git a/tests/phpunit/api/v3/AddressTest.php b/tests/phpunit/api/v3/AddressTest.php index 0307114ccc..bbbc21cf9a 100644 --- a/tests/phpunit/api/v3/AddressTest.php +++ b/tests/phpunit/api/v3/AddressTest.php @@ -416,7 +416,8 @@ class api_v3_AddressTest extends CiviUnitTestCase { public function testCreateAddressStateProvinceIDCorrectForCountry() { $params = $this->_params; $params['sequential'] = 1; - $params['country_id'] = '1228'; // United States country id + // United States country id + $params['country_id'] = '1228'; $params['state_province_id'] = 'Maryland'; $params['city'] = 'Baltimore'; $params['street_address'] = '600 N Charles St.'; @@ -430,7 +431,8 @@ class api_v3_AddressTest extends CiviUnitTestCase { // Now try it in Liberia $params = $this->_params; $params['sequential'] = 1; - $params['country_id'] = '1122'; // Liberia country id + // Liberia country id + $params['country_id'] = '1122'; $params['state_province_id'] = 'Maryland'; $address2 = $this->callAPISuccess('address', 'create', $params); $this->assertEquals('3497', $address2['values'][0]['state_province_id']); @@ -466,8 +468,10 @@ class api_v3_AddressTest extends CiviUnitTestCase { 'location_type_id' => 1, 'street_address' => '123 Some St', 'city' => 'Hereville', - 'country_id' => $inputCountry, //'US', - 'state_province_id' => $inputState, // 'California', + //'US', + 'country_id' => $inputCountry, + // 'California', + 'state_province_id' => $inputState, 'postal_code' => '94100', ]); $created = CRM_Utils_Array::first($r['values']); diff --git a/tests/phpunit/api/v3/AttachmentTest.php b/tests/phpunit/api/v3/AttachmentTest.php index 9e313db638..9bb5c29dc7 100644 --- a/tests/phpunit/api/v3/AttachmentTest.php +++ b/tests/phpunit/api/v3/AttachmentTest.php @@ -45,7 +45,6 @@ class api_v3_AttachmentTest extends CiviUnitTestCase { return self::$filePrefix; } - protected function setUp() { parent::setUp(); $this->useTransaction(TRUE); @@ -64,7 +63,8 @@ class api_v3_AttachmentTest extends CiviUnitTestCase { * @return array */ public function okCreateProvider() { - $cases = array(); // array($entityClass, $createParams, $expectedContent) + // array($entityClass, $createParams, $expectedContent) + $cases = array(); $cases[] = array( 'CRM_Activity_DAO_Activity', @@ -108,7 +108,8 @@ class api_v3_AttachmentTest extends CiviUnitTestCase { * @return array */ public function badCreateProvider() { - $cases = array(); // array($entityClass, $createParams, $expectedError) + // array($entityClass, $createParams, $expectedError) + $cases = array(); $cases[] = array( 'CRM_Activity_DAO_Activity', @@ -172,7 +173,8 @@ class api_v3_AttachmentTest extends CiviUnitTestCase { * @return array */ public function badUpdateProvider() { - $cases = array(); // array($entityClass, $createParams, $updateParams, $expectedError) + // array($entityClass, $createParams, $updateParams, $expectedError) + $cases = array(); $readOnlyFields = array( 'name' => 'newname.txt', @@ -204,7 +206,8 @@ class api_v3_AttachmentTest extends CiviUnitTestCase { * @return array */ public function okGetProvider() { - $cases = array(); // array($getParams, $expectedNames) + // array($getParams, $expectedNames) + $cases = array(); // Each search runs in a DB which contains these attachments: // Activity #123: example_123.txt (text/plain) and example_123.csv (text/csv) @@ -256,7 +259,8 @@ class api_v3_AttachmentTest extends CiviUnitTestCase { * @return array */ public function badGetProvider() { - $cases = array(); // array($getParams, $expectedNames) + // array($getParams, $expectedNames) + $cases = array(); // Each search runs in a DB which contains these attachments: // Activity #123: example_123.txt (text/plain) and example_123.csv (text/csv) @@ -309,9 +313,9 @@ class api_v3_AttachmentTest extends CiviUnitTestCase { $this->assertTrue(is_numeric($entity->id)); $createResult = $this->callAPISuccess('Attachment', 'create', $createParams + array( - 'entity_table' => $entity_table, - 'entity_id' => $entity->id, - )); + 'entity_table' => $entity_table, + 'entity_id' => $entity->id, + )); $fileId = $createResult['id']; $this->assertTrue(is_numeric($fileId)); $this->assertEquals($entity_table, $createResult['values'][$fileId]['entity_table']); @@ -355,9 +359,9 @@ class api_v3_AttachmentTest extends CiviUnitTestCase { $this->assertTrue(is_numeric($entity->id)); $createResult = $this->callAPIFailure('Attachment', 'create', $createParams + array( - 'entity_table' => $entity_table, - 'entity_id' => $entity->id, - )); + 'entity_table' => $entity_table, + 'entity_id' => $entity->id, + )); $this->assertRegExp($expectedError, $createResult['error_message']); } @@ -374,15 +378,15 @@ class api_v3_AttachmentTest extends CiviUnitTestCase { $this->assertTrue(is_numeric($entity->id)); $createResult = $this->callAPISuccess('Attachment', 'create', $createParams + array( - 'entity_table' => $entity_table, - 'entity_id' => $entity->id, - )); + 'entity_table' => $entity_table, + 'entity_id' => $entity->id, + )); $fileId = $createResult['id']; $this->assertTrue(is_numeric($fileId)); $updateResult = $this->callAPIFailure('Attachment', 'create', $updateParams + array( - 'id' => $fileId, - )); + 'id' => $fileId, + )); $this->assertRegExp($expectedError, $updateResult['error_message']); } diff --git a/tests/phpunit/api/v3/CaseTest.php b/tests/phpunit/api/v3/CaseTest.php index 873f37e829..5e53e3967c 100644 --- a/tests/phpunit/api/v3/CaseTest.php +++ b/tests/phpunit/api/v3/CaseTest.php @@ -380,9 +380,9 @@ class api_v3_CaseTest extends CiviCaseTestCase { // Fetch case based on an activity id $result = $this->callAPISuccess('case', 'get', array( - 'activity_id' => $activity, - 'return' => 'activities', - )); + 'activity_id' => $activity, + 'return' => 'activities', + )); $this->assertEquals(FALSE, empty($result['values'][$id])); $this->assertEquals($result['values'][$id], $case); } @@ -400,9 +400,9 @@ class api_v3_CaseTest extends CiviCaseTestCase { // Fetch case based on client contact id $result = $this->callAPISuccess('case', 'get', array( - 'client_id' => $this->_params['contact_id'], - 'return' => array('activities', 'contacts'), - )); + 'client_id' => $this->_params['contact_id'], + 'return' => array('activities', 'contacts'), + )); $this->assertAPIArrayComparison($result['values'][$id], $case); } @@ -419,9 +419,9 @@ class api_v3_CaseTest extends CiviCaseTestCase { // Fetch case based on client contact id $result = $this->callAPISuccess('case', 'get', array( - 'subject' => $this->_params['subject'], - 'return' => array('subject'), - )); + 'subject' => $this->_params['subject'], + 'return' => array('subject'), + )); $this->assertAPIArrayComparison($result['values'][$id], $case); } @@ -433,9 +433,9 @@ class api_v3_CaseTest extends CiviCaseTestCase { // 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'), - )); + 'subject' => $this->_params['subject'] . 'wrong', + 'return' => array('activities', 'contacts'), + )); $this->assertEquals(0, $result['count']); } diff --git a/tests/phpunit/api/v3/CaseTypeTest.php b/tests/phpunit/api/v3/CaseTypeTest.php index 7546c73ac7..9a64c1ce91 100644 --- a/tests/phpunit/api/v3/CaseTypeTest.php +++ b/tests/phpunit/api/v3/CaseTypeTest.php @@ -127,7 +127,8 @@ class api_v3_CaseTypeTest extends CiviCaseTestCase { // Create Case Type $params = array( 'title' => 'Application', - 'name' => 'Appl ication', // spaces are not allowed + // spaces are not allowed + 'name' => 'Appl ication', 'is_active' => 1, 'weight' => 4, ); @@ -135,7 +136,6 @@ class api_v3_CaseTypeTest extends CiviCaseTestCase { $this->callAPIFailure('CaseType', 'create', $params); } - /** * Test update (create with id) function with valid parameters. */ diff --git a/tests/phpunit/api/v3/ContactTest.php b/tests/phpunit/api/v3/ContactTest.php index a427729382..818068d036 100644 --- a/tests/phpunit/api/v3/ContactTest.php +++ b/tests/phpunit/api/v3/ContactTest.php @@ -611,8 +611,8 @@ class api_v3_ContactTest extends CiviUnitTestCase { $this->callAPISuccess('Contact', 'create', array( 'first_name' => 'Snoop', 'last_name' => 'Dog', - 'contact_type' => 'Individual') - ); + 'contact_type' => 'Individual', + )); $result = $this->callAPISuccessGetSingle('Contact', array('last_name' => 'Dog')); $this->assertEquals('en_US', $result['preferred_language']); } @@ -637,11 +637,10 @@ class api_v3_ContactTest extends CiviUnitTestCase { public function testCreatePreferredLanguageNull() { $this->callAPISuccess('Setting', 'create', array('contact_default_language' => 'null')); $this->callAPISuccess('Contact', 'create', array( - 'first_name' => 'Snoop', - 'last_name' => 'Dog', - 'contact_type' => 'Individual', - ) - ); + 'first_name' => 'Snoop', + 'last_name' => 'Dog', + 'contact_type' => 'Individual', + )); $result = $this->callAPISuccessGetSingle('Contact', array('last_name' => 'Dog')); $this->assertEquals(NULL, $result['preferred_language']); } @@ -731,7 +730,6 @@ class api_v3_ContactTest extends CiviUnitTestCase { $this->callAPISuccess('Contact', 'create', $params); } - /** * Test creating a current employer through API. */ @@ -743,21 +741,18 @@ class api_v3_ContactTest extends CiviUnitTestCase { )); $this->assertEquals(0, $count); $employerResult = $this->callAPISuccess('contact', 'create', array_merge($this->_params, array( - 'current_employer' => 'new employer org', - ) - )); + 'current_employer' => 'new employer org', + ))); // do it again as an update to check it doesn't cause an error $employerResult = $this->callAPISuccess('contact', 'create', array_merge($this->_params, array( - 'current_employer' => 'new employer org', - 'id' => $employerResult['id'], - ) - )); + 'current_employer' => 'new employer org', + 'id' => $employerResult['id'], + ))); $expectedCount = 1; $this->callAPISuccess('contact', 'getcount', array( - 'organization_name' => 'new employer org', - 'contact_type' => 'Organization', - ), - $expectedCount); + 'organization_name' => 'new employer org', + 'contact_type' => 'Organization', + ), $expectedCount); $result = $this->callAPISuccess('contact', 'getsingle', array( 'id' => $employerResult['id'], @@ -775,8 +770,8 @@ class api_v3_ContactTest extends CiviUnitTestCase { public function testContactCreateDuplicateCurrentEmployerEnables() { // Set up - create employer relationship. $employerResult = $this->callAPISuccess('contact', 'create', array_merge($this->_params, array( - 'current_employer' => 'new employer org', - ) + 'current_employer' => 'new employer org', + ) )); $relationship = $this->callAPISuccess('relationship', 'get', array( 'contact_id_a' => $employerResult['id'], @@ -791,9 +786,9 @@ class api_v3_ContactTest extends CiviUnitTestCase { // Re-set the current employer - thus enabling the relationship. $this->callAPISuccess('contact', 'create', array_merge($this->_params, array( - 'current_employer' => 'new employer org', - 'id' => $employerResult['id'], - ) + 'current_employer' => 'new employer org', + 'id' => $employerResult['id'], + ) )); //check is_active is now 1 $relationship = $this->callAPISuccess('relationship', 'getsingle', array( @@ -993,7 +988,8 @@ class api_v3_ContactTest extends CiviUnitTestCase { 'options' => array( 'limit' => '1', 'sort' => 'start_date DESC', - )), + ), + ), ); $get_result = $this->callAPISuccess('contact', 'getsingle', $get_params); @@ -1047,7 +1043,7 @@ class api_v3_ContactTest extends CiviUnitTestCase { 'skip_greeting_processing' => 1, 'addressee_id' => 'null', 'email_greeting_id' => 'null', - 'postal_greeting_id' => 'null' + 'postal_greeting_id' => 'null', ]); $individual2ID = $this->individualCreate(); @@ -1350,10 +1346,10 @@ class api_v3_ContactTest extends CiviUnitTestCase { // Clean up first. $this->callAPISuccess('contact', 'delete', array( 'id' => $create_result_1['id'], - )); + )); $this->callAPISuccess('contact', 'delete', array( 'id' => $create_result_2['id'], - )); + )); $this->callAPISuccess('contact', 'delete', array( 'id' => $create_result_2['id'], )); @@ -1569,9 +1565,8 @@ class api_v3_ContactTest extends CiviUnitTestCase { $organizationID1 = $this->organizationCreate(array(), 0); $organizationID2 = $this->organizationCreate(array(), 1); $contact = $this->callAPISuccess('contact', 'create', array_merge($this->_params, array( - 'employer_id' => $organizationID1, - ) - )); + 'employer_id' => $organizationID1, + ))); $contact = $contact["values"][$contact["id"]]; $membershipType = $this->createEmployerOfMembership(); @@ -1941,7 +1936,6 @@ class api_v3_ContactTest extends CiviUnitTestCase { ), $result['preferred_communication_method']); } - /** * Test birth date parameters. * @@ -3807,7 +3801,8 @@ class api_v3_ContactTest extends CiviUnitTestCase { $this->callAPISuccess('Contact', 'create', array( 'first_name' => 'John', 'last_name' => 'Doe', - 'contact_type' => 'Individual') + 'contact_type' => 'Individual', + ) ); $result = $this->callAPISuccessGetSingle('Contact', array('last_name' => 'Doe')); $this->assertEquals(1, $result['communication_style_id']); @@ -3934,37 +3929,43 @@ class api_v3_ContactTest extends CiviUnitTestCase { 'contact_id_a' => $c1, 'contact_id_b' => $c2, 'is_active' => 1, - 'relationship_type_id' => $rtype1['id'], // Child of + // Child of + 'relationship_type_id' => $rtype1['id'], )); $this->callAPISuccess('relationship', 'create', array( 'contact_id_a' => $c1, 'contact_id_b' => $h1, 'is_active' => 1, - 'relationship_type_id' => $rtype2['id'], // Household Member of + // Household Member of + 'relationship_type_id' => $rtype2['id'], )); $this->callAPISuccess('relationship', 'create', array( 'contact_id_a' => $c2, 'contact_id_b' => $h1, 'is_active' => 1, - 'relationship_type_id' => $rtype2['id'], // Household Member of + // Household Member of + 'relationship_type_id' => $rtype2['id'], )); $ssParams = array( 'formValues' => array( - 'display_relationship_type' => $rtype1['id'] . '_a_b', // Child of + // Child of + 'display_relationship_type' => $rtype1['id'] . '_a_b', 'sort_name' => 'Adams', ), ); $g1ID = $this->smartGroupCreate($ssParams, array('name' => uniqid(), 'title' => uniqid())); $ssParams = array( 'formValues' => array( - 'display_relationship_type' => $rtype2['id'] . '_a_b', // Household Member of + // Household Member of + 'display_relationship_type' => $rtype2['id'] . '_a_b', ), ); $g2ID = $this->smartGroupCreate($ssParams, array('name' => uniqid(), 'title' => uniqid())); $ssParams = array( 'formValues' => array( - 'display_relationship_type' => $rtype2['id'] . '_b_a', // Household Member is + // Household Member is + 'display_relationship_type' => $rtype2['id'] . '_b_a', ), ); // the reverse of g2 which adds another layer for overlap at related contact filter @@ -4023,7 +4024,7 @@ class api_v3_ContactTest extends CiviUnitTestCase { $tags = []; foreach (['Tag A', 'Tag B'] as $name) { $tags[] = $this->callApiSuccess('Tag', 'create', [ - 'name' => $name + 'name' => $name, ]); } @@ -4066,7 +4067,7 @@ class api_v3_ContactTest extends CiviUnitTestCase { } $this->callAPISuccess('Contact', 'delete', [ 'id' => $contact['id'], - 'skip_undelete' => TRUE + 'skip_undelete' => TRUE, ]); } diff --git a/tests/phpunit/api/v3/ContactTypeTest.php b/tests/phpunit/api/v3/ContactTypeTest.php index 0219a3e410..61fc14926e 100644 --- a/tests/phpunit/api/v3/ContactTypeTest.php +++ b/tests/phpunit/api/v3/ContactTypeTest.php @@ -110,7 +110,6 @@ class api_v3_ContactTypeTest extends CiviUnitTestCase { $this->callAPISuccess('contact', 'delete', $params); } - /** * Test add with invalid data. */ @@ -134,7 +133,6 @@ class api_v3_ContactTypeTest extends CiviUnitTestCase { $contact = $this->callAPIFailure('contact', 'create', $contactParams); } - /** * Test update with no subtype to valid subtype. * success expected @@ -200,7 +198,6 @@ class api_v3_ContactTypeTest extends CiviUnitTestCase { $this->callAPISuccess('contact', 'delete', $params); } - /** * Test update with no subtype to invalid subtype. */ diff --git a/tests/phpunit/api/v3/ContributionPageTest.php b/tests/phpunit/api/v3/ContributionPageTest.php index e773ba39f0..2c663e924f 100644 --- a/tests/phpunit/api/v3/ContributionPageTest.php +++ b/tests/phpunit/api/v3/ContributionPageTest.php @@ -112,7 +112,8 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase { $createResult = $this->callAPISuccess($this->_entity, 'create', $this->params); $this->id = $createResult['id']; $getParams = array( - 'amount' => '' . $this->testAmount, // 3456 + // 3456 + 'amount' => '' . $this->testAmount, 'currency' => 'NZD', 'financial_type_id' => 1, ); @@ -133,7 +134,6 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase { $this->assertEquals(12, $result['values']['start_date']['type']); } - /** * Test form submission with basic price set. */ @@ -438,13 +438,11 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase { $this->assertCount(1, $msgs); $mut->checkMailLog(array( - 'Membership Type: General', - 'Gruffier', - ), - array( - 'Amount', - ) - ); + 'Membership Type: General', + 'Gruffier', + ), array( + 'Amount', + )); $mut->stop(); $mut->clearMessages(); } @@ -504,7 +502,6 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase { $this->assertEquals($membership['contact_id'], $contributions['values'][$membershipPayment['contribution_id']]['contact_id']); } - /** * Test submit with a membership block in place. */ @@ -1277,23 +1274,21 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase { $membership = $this->callAPISuccessGetSingle('membership', array('id' => $membershipPayment['membership_id'])); //renew it with processor setting completed - should extend membership $submitParams = array_merge($submitParams, array( - 'contact_id' => $contribution['contact_id'], - 'is_recur' => 1, - 'frequency_interval' => 1, - 'frequency_unit' => $this->params['recur_frequency_unit'], - ) - ); + 'contact_id' => $contribution['contact_id'], + 'is_recur' => 1, + 'frequency_interval' => 1, + 'frequency_unit' => $this->params['recur_frequency_unit'], + )); $dummyPP->setDoDirectPaymentResult(array('payment_status_id' => 2)); $this->callAPISuccess('contribution_page', 'submit', $submitParams); $newContribution = $this->callAPISuccess('contribution', 'getsingle', array( - 'id' => array( - 'NOT IN' => array($contribution['id']), - ), - 'contribution_page_id' => $this->_ids['contribution_page'], - 'contribution_status_id' => 2, - ) - ); + 'id' => array( + 'NOT IN' => array($contribution['id']), + ), + 'contribution_page_id' => $this->_ids['contribution_page'], + 'contribution_status_id' => 2, + )); $line = $this->callAPISuccess('line_item', 'getsingle', array('contribution_id' => $newContribution['id'])); $this->assertEquals('civicrm_membership', $line['entity_table']); $this->assertEquals($membership['id'], $line['entity_id']); @@ -1339,7 +1334,6 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase { $this->assertEmpty($recur['count']); } - /** * Set up membership contribution page. * @param bool $isSeparatePayment @@ -1502,34 +1496,31 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase { } if (empty($this->_ids['price_field_value'])) { $this->callAPISuccess('price_field_value', 'create', array( - 'price_set_id' => $priceSetID, - 'price_field_id' => $priceField['id'], - 'label' => 'Long Haired Goat', - 'financial_type_id' => 'Donation', - 'amount' => 20, - 'non_deductible_amount' => 15, - ) - ); + 'price_set_id' => $priceSetID, + 'price_field_id' => $priceField['id'], + 'label' => 'Long Haired Goat', + 'financial_type_id' => 'Donation', + 'amount' => 20, + 'non_deductible_amount' => 15, + )); $priceFieldValue = $this->callAPISuccess('price_field_value', 'create', array( - 'price_set_id' => $priceSetID, - 'price_field_id' => $priceField['id'], - 'label' => 'Shoe-eating Goat', - 'financial_type_id' => 'Donation', - 'amount' => 10, - 'non_deductible_amount' => 5, - ) - ); + 'price_set_id' => $priceSetID, + 'price_field_id' => $priceField['id'], + 'label' => 'Shoe-eating Goat', + 'financial_type_id' => 'Donation', + 'amount' => 10, + 'non_deductible_amount' => 5, + )); $this->_ids['price_field_value'] = array($priceFieldValue['id']); $this->_ids['price_field_value']['cheapskate'] = $this->callAPISuccess('price_field_value', 'create', array( - 'price_set_id' => $priceSetID, - 'price_field_id' => $priceField['id'], - 'label' => 'Stingy Goat', - 'financial_type_id' => 'Donation', - 'amount' => 0, - 'non_deductible_amount' => 0, - ) - )['id']; + 'price_set_id' => $priceSetID, + 'price_field_id' => $priceField['id'], + 'label' => 'Stingy Goat', + 'financial_type_id' => 'Donation', + 'amount' => 0, + 'non_deductible_amount' => 0, + ))['id']; } $this->_ids['contribution_page'] = $contributionPageResult['id']; } @@ -1544,7 +1535,8 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase { $this->_ids['contribution_page'] = $contributionPage['id']; $this->_ids['membership_type'] = $this->membershipTypeCreate(array( - 'auto_renew' => 2, // force auto-renew + // force auto-renew + 'auto_renew' => 2, 'duration_unit' => 'month', )); @@ -1696,7 +1688,8 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase { // Check if contribution created. $contribution = $this->callAPISuccess('contribution', 'getsingle', array( 'contribution_page_id' => $this->_ids['contribution_page'], - 'contribution_status_id' => 'Completed', // Will be pending when actual payment processor is used (dummy processor does not support future payments). + // Will be pending when actual payment processor is used (dummy processor does not support future payments). + 'contribution_status_id' => 'Completed', )); $this->assertEquals('create_first_success', $contribution['trxn_id']); @@ -1714,13 +1707,15 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase { $this->assertEquals($pledgePayment['count'], 3); $this->assertEquals(date('Ymd', strtotime($pledgePayment['values'][1]['scheduled_date'])), date('Ymd', strtotime("+1 month"))); $this->assertEquals($pledgePayment['values'][1]['scheduled_amount'], 100.00); - $this->assertEquals($pledgePayment['values'][1]['status_id'], 1); // Will be pending when actual payment processor is used (dummy processor does not support future payments). + // Will be pending when actual payment processor is used (dummy processor does not support future payments). + $this->assertEquals($pledgePayment['values'][1]['status_id'], 1); // Check contribution recur record. $recur = $this->callAPISuccess('contribution_recur', 'getsingle', array('id' => $contribution['contribution_recur_id'])); $this->assertEquals(date('Ymd', strtotime($recur['start_date'])), date('Ymd', strtotime("+1 month"))); $this->assertEquals($recur['amount'], 100.00); - $this->assertEquals($recur['contribution_status_id'], 5); // In progress status. + // In progress status. + $this->assertEquals($recur['contribution_status_id'], 5); } /** @@ -1912,7 +1907,6 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase { $this->assertEquals($lineItem_TaxAmount, round(180 * 16.95 * 0.10, 2), 'Wrong Sales Tax Amount is calculated and stored.'); } - /** * Test validating a contribution page submit. */ diff --git a/tests/phpunit/api/v3/ContributionSoftTest.php b/tests/phpunit/api/v3/ContributionSoftTest.php index d335202902..fe23a97172 100644 --- a/tests/phpunit/api/v3/ContributionSoftTest.php +++ b/tests/phpunit/api/v3/ContributionSoftTest.php @@ -61,7 +61,6 @@ class api_v3_ContributionSoftTest extends CiviUnitTestCase { public $debug = 0; protected $_params; - public function setUp() { parent::setUp(); $this->useTransaction(TRUE); @@ -148,9 +147,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']); $this->callAPISuccess('contribution_soft', 'Delete', array( @@ -168,7 +166,6 @@ class api_v3_ContributionSoftTest extends CiviUnitTestCase { )); } - /** * civicrm_contribution_soft. */ diff --git a/tests/phpunit/api/v3/ContributionTest.php b/tests/phpunit/api/v3/ContributionTest.php index 9b99b42f9f..70d339f052 100644 --- a/tests/phpunit/api/v3/ContributionTest.php +++ b/tests/phpunit/api/v3/ContributionTest.php @@ -34,9 +34,6 @@ */ class api_v3_ContributionTest extends CiviUnitTestCase { - /** - * Assume empty database with just civicrm_data. - */ protected $_individualId; protected $_contribution; protected $_financialTypeId = 1; @@ -979,7 +976,6 @@ class api_v3_ContributionTest extends CiviUnitTestCase { $this->_checkFinancialRecords($contribution, 'feeAmount'); } - /** * Function tests that additional financial records are created when online contribution is created. */ @@ -1188,10 +1184,9 @@ class api_v3_ContributionTest extends CiviUnitTestCase { $contribution = $this->callAPISuccess('contribution', 'create', $contribParams); $newParams = array_merge($contribParams, array( - 'id' => $contribution['id'], - 'contribution_status_id' => 1, - ) - ); + 'id' => $contribution['id'], + 'contribution_status_id' => 1, + )); $contribution = $this->callAPISuccess('contribution', 'create', $newParams); $contribution = $contribution['values'][$contribution['id']]; $this->assertEquals($contribution['contribution_status_id'], '1'); @@ -1215,10 +1210,9 @@ class api_v3_ContributionTest extends CiviUnitTestCase { $contribution = $this->callAPISuccess('contribution', 'create', $contribParams); $newParams = array_merge($contribParams, array( - 'id' => $contribution['id'], - 'payment_instrument_id' => $instrumentId, - ) - ); + 'id' => $contribution['id'], + 'payment_instrument_id' => $instrumentId, + )); $contribution = $this->callAPISuccess('contribution', 'create', $newParams); $this->assertAPISuccess($contribution); $this->checkFinancialTrxnPaymentInstrumentChange($contribution['id'], 4, $instrumentId); @@ -1243,10 +1237,9 @@ class api_v3_ContributionTest extends CiviUnitTestCase { $contribution = $this->callAPISuccess('contribution', 'create', $contribParams); $newParams = array_merge($contribParams, array( - 'id' => $contribution['id'], - 'payment_instrument_id' => $instrumentId, - ) - ); + 'id' => $contribution['id'], + 'payment_instrument_id' => $instrumentId, + )); $contribution = $this->callAPISuccess('contribution', 'create', $newParams); $this->assertAPISuccess($contribution); $this->checkFinancialTrxnPaymentInstrumentChange($contribution['id'], 4, $instrumentId, -100); @@ -1270,12 +1263,11 @@ class api_v3_ContributionTest extends CiviUnitTestCase { ); $contribution = $this->callAPISuccess('contribution', 'create', $contributionParams); $newParams = array_merge($contributionParams, array( - 'id' => $contribution['id'], - 'contribution_status_id' => 'Refunded', - 'cancel_date' => '2015-01-01 09:00', - 'refund_trxn_id' => 'the refund', - ) - ); + 'id' => $contribution['id'], + 'contribution_status_id' => 'Refunded', + 'cancel_date' => '2015-01-01 09:00', + 'refund_trxn_id' => 'the refund', + )); $contribution = $this->callAPISuccess('contribution', 'create', $newParams); $this->_checkFinancialTrxn($contribution, 'refund'); @@ -1406,12 +1398,11 @@ class api_v3_ContributionTest extends CiviUnitTestCase { ); $contribution = $this->callAPISuccess('contribution', 'create', $contributionParams); $newParams = array_merge($contributionParams, array( - 'id' => $contribution['id'], - 'contribution_status_id' => 'Refunded', - 'cancel_date' => '2015-01-01 09:00', - 'trxn_id' => 'the refund', - ) - ); + 'id' => $contribution['id'], + 'contribution_status_id' => 'Refunded', + 'cancel_date' => '2015-01-01 09:00', + 'trxn_id' => 'the refund', + )); $contribution = $this->callAPISuccess('contribution', 'create', $newParams); $this->_checkFinancialTrxn($contribution, 'refund'); @@ -1441,13 +1432,12 @@ class api_v3_ContributionTest extends CiviUnitTestCase { ); $contribution = $this->callAPISuccess('contribution', 'create', $contributionParams); $newParams = array_merge($contributionParams, array( - 'id' => $contribution['id'], - 'contribution_status_id' => 'Refunded', - 'cancel_date' => '2015-01-01 09:00', - 'trxn_id' => 'cont id', - 'refund_trxn_id' => 'the refund', - ) - ); + 'id' => $contribution['id'], + 'contribution_status_id' => 'Refunded', + 'cancel_date' => '2015-01-01 09:00', + 'trxn_id' => 'cont id', + 'refund_trxn_id' => 'the refund', + )); $contribution = $this->callAPISuccess('contribution', 'create', $newParams); $this->_checkFinancialTrxn($contribution, 'refund'); @@ -1477,13 +1467,12 @@ class api_v3_ContributionTest extends CiviUnitTestCase { ); $contribution = $this->callAPISuccess('contribution', 'create', $contributionParams); $newParams = array_merge($contributionParams, array( - 'id' => $contribution['id'], - 'contribution_status_id' => 'Refunded', - 'cancel_date' => '2015-01-01 09:00', - 'trxn_id' => 'cont id', - 'refund_trxn_id' => '', - ) - ); + 'id' => $contribution['id'], + 'contribution_status_id' => 'Refunded', + 'cancel_date' => '2015-01-01 09:00', + 'trxn_id' => 'cont id', + 'refund_trxn_id' => '', + )); $contribution = $this->callAPISuccess('contribution', 'create', $newParams); $this->_checkFinancialTrxn($contribution, 'refund', NULL, array('trxn_id' => NULL)); @@ -1508,10 +1497,9 @@ class api_v3_ContributionTest extends CiviUnitTestCase { ); $contribution = $this->callAPISuccess('contribution', 'create', $contribParams); $newParams = array_merge($contribParams, array( - 'id' => $contribution['id'], - 'contribution_status_id' => 2, - ) - ); + 'id' => $contribution['id'], + 'contribution_status_id' => 2, + )); $this->callAPIFailure('contribution', 'create', $newParams, ts('Cannot change contribution status from Completed to Pending.')); } @@ -1532,11 +1520,10 @@ class api_v3_ContributionTest extends CiviUnitTestCase { ); $contribution = $this->callAPISuccess('contribution', 'create', $contribParams); $newParams = array_merge($contribParams, array( - 'id' => $contribution['id'], - 'contribution_status_id' => 3, - 'cancel_date' => '2012-02-02 09:00', - ) - ); + 'id' => $contribution['id'], + 'contribution_status_id' => 3, + 'cancel_date' => '2012-02-02 09:00', + )); //Check if trxn_date is same as cancel_date. $checkTrxnDate = array( 'trxn_date' => '2012-02-02 09:00:00', @@ -1561,10 +1548,9 @@ class api_v3_ContributionTest extends CiviUnitTestCase { ); $contribution = $this->callAPISuccess('contribution', 'create', $contribParams); $newParams = array_merge($contribParams, array( - 'id' => $contribution['id'], - 'financial_type_id' => 3, - ) - ); + 'id' => $contribution['id'], + 'financial_type_id' => 3, + )); $contribution = $this->callAPISuccess('contribution', 'create', $newParams); $this->_checkFinancialTrxn($contribution, 'changeFinancial'); $this->_checkFinancialItem($contribution['id'], 'changeFinancial'); @@ -1632,7 +1618,6 @@ class api_v3_ContributionTest extends CiviUnitTestCase { $new_params = array( 'contribution_id' => $contribution['id'], - ); $contribution = $this->callAPISuccessGetSingle('contribution', $new_params); @@ -1652,7 +1637,6 @@ class api_v3_ContributionTest extends CiviUnitTestCase { $params = array( 'contribution_id' => $contributionID, - ); $result = $this->callAPISuccess('contribution', 'delete', $params); $this->assertAPISuccess($result); @@ -1706,7 +1690,7 @@ class api_v3_ContributionTest extends CiviUnitTestCase { $this->callAPISuccess('Contribution', 'create', [ 'id' => $contributionID, - 'payment_instrument' => 'Cash' + 'payment_instrument' => 'Cash', ]); $contribution = $this->callAPISuccessGetSingle('Contribution', [ 'id' => $contributionID, @@ -1734,7 +1718,6 @@ class api_v3_ContributionTest extends CiviUnitTestCase { public function testDeleteWrongParamContribution() { $params = array( 'contribution_source' => 'SSF', - ); $this->callAPIFailure('contribution', 'delete', $params); } @@ -1770,7 +1753,6 @@ class api_v3_ContributionTest extends CiviUnitTestCase { 'invoice_id' => 78910, 'source' => 'SSF', 'contribution_status_id' => 1, - ); $contribution = $this->callAPISuccess('contribution', 'create', $p); @@ -1804,7 +1786,6 @@ class api_v3_ContributionTest extends CiviUnitTestCase { 'financial_type_id' => $this->_financialTypeId, 'non_deductible_amount' => 10.00, 'contribution_status_id' => 1, - ); $contribution1 = $this->callAPISuccess('contribution', 'create', $p1); @@ -1819,13 +1800,11 @@ class api_v3_ContributionTest extends CiviUnitTestCase { 'fee_amount' => 50.00, 'net_amount' => 60.00, 'contribution_status_id' => 2, - ); $contribution2 = $this->callAPISuccess('contribution', 'create', $p2); $params = array( 'contribution_id' => $contribution2['id'], - ); $result = $this->callAPISuccess('contribution', 'get', $params); $res = $result['values'][$contribution2['id']]; @@ -2007,7 +1986,7 @@ class api_v3_ContributionTest extends CiviUnitTestCase { $params = array_merge($this->_params, array( 'contribution_status_id' => 2, 'address_id' => $address['id'], - ) + ) ); $contribution = $this->callAPISuccess('contribution', 'create', $params); $this->callAPISuccess('contribution', 'completetransaction', array( @@ -2075,14 +2054,14 @@ class api_v3_ContributionTest extends CiviUnitTestCase { 'is_active' => 1, )); $financialAccount = $this->callAPISuccess('financial_account', 'create', array( - 'name' => 'Test Tax financial account ', - 'contact_id' => $contact, - 'financial_account_type_id' => 2, - 'is_tax' => 1, - 'tax_rate' => 5.00, - 'is_reserved' => 0, - 'is_active' => 1, - 'is_default' => 0, + 'name' => 'Test Tax financial account ', + 'contact_id' => $contact, + 'financial_account_type_id' => 2, + 'is_tax' => 1, + 'tax_rate' => 5.00, + 'is_reserved' => 0, + 'is_active' => 1, + 'is_default' => 0, )); $financialTypeId = $financialType['id']; $financialAccountId = $financialAccount['id']; @@ -2098,9 +2077,9 @@ class api_v3_ContributionTest extends CiviUnitTestCase { $contribution = $this->callAPISuccess('contribution', 'create', $params); $contribution1 = $this->callAPISuccess('contribution', 'get', array('id' => $contribution['id'], 'return' => 'tax_amount', 'sequential' => 1)); $this->callAPISuccess('contribution', 'completetransaction', array( - 'id' => $contribution['id'], - 'trxn_id' => '777788888', - 'fee_amount' => '6.00', + 'id' => $contribution['id'], + 'trxn_id' => '777788888', + 'fee_amount' => '6.00', )); $contribution2 = $this->callAPISuccess('contribution', 'get', array('id' => $contribution['id'], 'return' => array('tax_amount', 'fee_amount', 'net_amount'), 'sequential' => 1)); $this->assertEquals($contribution1['values'][0]['tax_amount'], $contribution2['values'][0]['tax_amount']); @@ -2309,15 +2288,15 @@ class api_v3_ContributionTest extends CiviUnitTestCase { )); $this->callAPISuccess('membership', 'create', array( - 'id' => $membership['id'], - 'end_date' => 'yesterday', - 'status_id' => 'Expired', + 'id' => $membership['id'], + 'end_date' => 'yesterday', + 'status_id' => 'Expired', )); $contribution = $this->callAPISuccess('contribution', 'repeattransaction', array( - 'contribution_recur_id' => $originalContribution['values'][1]['contribution_recur_id'], - 'contribution_status_id' => 'Completed', - 'trxn_id' => 'bobsled', + 'contribution_recur_id' => $originalContribution['values'][1]['contribution_recur_id'], + 'contribution_status_id' => 'Completed', + 'trxn_id' => 'bobsled', )); $membershipStatusId = $this->callAPISuccess('membership', 'getvalue', array( @@ -2710,7 +2689,6 @@ class api_v3_ContributionTest extends CiviUnitTestCase { $this->assertEquals($expectedLineItem, $lineItem2['values'][0]); } - /** * Test completing a transaction does not 'mess' with net amount (CRM-15960). */ @@ -2797,6 +2775,7 @@ class api_v3_ContributionTest extends CiviUnitTestCase { $this->mut->stop(); $this->revertTemplateToReservedTemplate(); } + /** * CRM-19710 - Test to ensure that completetransaction respects the input for is_email_receipt setting. * @@ -3036,8 +3015,8 @@ class api_v3_ContributionTest extends CiviUnitTestCase { $this->_individualId = $this->createLoggedInUser(); $contributionID = $this->createPendingParticipantContribution(); $this->callAPISuccess('contribution', 'completetransaction', array( - 'id' => $contributionID, - ) + 'id' => $contributionID, + ) ); $participantStatus = $this->callAPISuccessGetValue('participant', array( 'id' => $this->_ids['participant'], @@ -3069,7 +3048,8 @@ class api_v3_ContributionTest extends CiviUnitTestCase { $this->createPriceSetWithPage('membership'); $stateOfGrace = $this->callAPISuccess('MembershipStatus', 'getvalue', array( 'name' => 'Grace', - 'return' => 'id') + 'return' => 'id', + ) ); $this->setUpPendingContribution($this->_ids['price_field_value'][0]); $membership = $this->callAPISuccess('membership', 'getsingle', array('id' => $this->_ids['membership'])); @@ -3249,6 +3229,7 @@ class api_v3_ContributionTest extends CiviUnitTestCase { * Set up a pending transaction with a specific price field id. * * @param int $priceFieldValueID + * @param array $contriParams */ public function setUpPendingContribution($priceFieldValueID, $contriParams = array()) { $contactID = $this->individualCreate(); @@ -3298,18 +3279,16 @@ class api_v3_ContributionTest extends CiviUnitTestCase { $mut = new CiviMailUtils($this, TRUE); $contribution = $this->callAPISuccess('contribution', 'create', $this->_params); $this->callAPISuccess('contribution', 'sendconfirmation', array( - 'id' => $contribution['id'], - 'receipt_from_email' => 'api@civicrm.org', - ) - ); + 'id' => $contribution['id'], + 'receipt_from_email' => 'api@civicrm.org', + )); $mut->checkMailLog(array( - '$ 100.00', - 'Contribution Information', - 'Please print this confirmation for your records', - ), array( - 'Event', - ) - ); + '$ 100.00', + 'Contribution Information', + 'Please print this confirmation for your records', + ), array( + 'Event', + )); $this->checkCreditCardDetails($mut, $contribution['id']); $mut->stop(); @@ -3360,10 +3339,9 @@ class api_v3_ContributionTest extends CiviUnitTestCase { // Create email try { civicrm_api3('contribution', 'sendconfirmation', array( - 'id' => $contribution['id'], - 'receipt_from_email' => 'api@civicrm.org', - ) - ); + 'id' => $contribution['id'], + 'receipt_from_email' => 'api@civicrm.org', + )); } catch (Exception $e) { // Need to figure out how to stop this some other day @@ -3377,16 +3355,14 @@ class api_v3_ContributionTest extends CiviUnitTestCase { // Retrieve mail & check it has the pay_later_receipt info $mut->getMostRecentEmail('raw'); $mut->checkMailLog(array( - (string) $contribParams['total_amount'], - $pageParams['pay_later_receipt'], - ), array( - 'Event', - ) - ); + (string) $contribParams['total_amount'], + $pageParams['pay_later_receipt'], + ), array( + 'Event', + )); $mut->stop(); } - /** * Check credit card details in sent mail via API * @@ -3397,19 +3373,20 @@ class api_v3_ContributionTest extends CiviUnitTestCase { public function checkCreditCardDetails($mut, $contributionID) { $contribution = $this->callAPISuccess('contribution', 'create', $this->_params); $this->callAPISuccess('contribution', 'sendconfirmation', array( - 'id' => $contributionID, - 'receipt_from_email' => 'api@civicrm.org', - 'payment_processor_id' => $this->paymentProcessorID, - ) - ); + 'id' => $contributionID, + 'receipt_from_email' => 'api@civicrm.org', + 'payment_processor_id' => $this->paymentProcessorID, + )); $mut->checkMailLog(array( - 'Credit Card Information', // credit card header - 'Billing Name and Address', // billing header - 'anthony_anderson@civicrm.org', // billing name - ), array( - 'Event', - ) - ); + // credit card header + 'Credit Card Information', + // billing header + 'Billing Name and Address', + // billing name + 'anthony_anderson@civicrm.org', + ), array( + 'Event', + )); } /** @@ -3439,17 +3416,15 @@ class api_v3_ContributionTest extends CiviUnitTestCase { 'contribution_id' => $contribution['id'], )); $this->callAPISuccess('contribution', 'sendconfirmation', array( - 'id' => $contribution['id'], - 'receipt_from_email' => 'api@civicrm.org', - ) - ); + 'id' => $contribution['id'], + 'receipt_from_email' => 'api@civicrm.org', + )); $mut->checkMailLog(array( - 'Annual CiviCRM meet', - 'Event', - 'To: "Mr. Anthony Anderson II" ', - ), array() - ); + 'Annual CiviCRM meet', + 'Event', + 'To: "Mr. Anthony Anderson II" ', + ), array()); $mut->stop(); } @@ -3466,7 +3441,6 @@ class api_v3_ContributionTest extends CiviUnitTestCase { $contribution = $this->callAPISuccess('Contribution', 'Get', array( 'id' => $id, - )); if ($delete) { @@ -3493,9 +3467,8 @@ class api_v3_ContributionTest extends CiviUnitTestCase { $this->_ids['pledge'] = $pledgeID; $contribution = $this->callAPISuccess('contribution', 'create', array_merge($this->_params, array( 'contribution_status_id' => 'Pending', - 'total_amount' => 500, - )) - ); + 'total_amount' => 500, + ))); $paymentID = $this->callAPISuccessGetValue('PledgePayment', array( 'options' => array('limit' => 1), 'return' => 'id', @@ -3644,6 +3617,7 @@ class api_v3_ContributionTest extends CiviUnitTestCase { * @param int $contributionID * @param int $originalInstrumentID * @param int $newInstrumentID + * @param int $amount */ public function checkFinancialTrxnPaymentInstrumentChange($contributionID, $originalInstrumentID, $newInstrumentID, $amount = 100) { @@ -3853,17 +3827,17 @@ class api_v3_ContributionTest extends CiviUnitTestCase { */ protected function setUpAutoRenewMembership($generalParams = array(), $recurParams = array()) { $newContact = $this->callAPISuccess('Contact', 'create', array( - 'contact_type' => 'Individual', - 'sort_name' => 'McTesterson, Testy', - 'display_name' => 'Testy McTesterson', - 'preferred_language' => 'en_US', - 'preferred_mail_format' => 'Both', - 'first_name' => 'Testy', - 'last_name' => 'McTesterson', - 'contact_is_deleted' => '0', - 'email_id' => '4', - 'email' => 'tmctesterson@example.com', - 'on_hold' => '0', + 'contact_type' => 'Individual', + 'sort_name' => 'McTesterson, Testy', + 'display_name' => 'Testy McTesterson', + 'preferred_language' => 'en_US', + 'preferred_mail_format' => 'Both', + 'first_name' => 'Testy', + 'last_name' => 'McTesterson', + 'contact_is_deleted' => '0', + 'email_id' => '4', + 'email' => 'tmctesterson@example.com', + 'on_hold' => '0', )); $membershipType = $this->callAPISuccess('MembershipType', 'create', array( 'domain_id' => "Default Domain Name", @@ -3915,11 +3889,13 @@ class api_v3_ContributionTest extends CiviUnitTestCase { return array($originalContribution, $membership); } + /** * Set up a repeat transaction. * * @param array $recurParams - * + * @param mixed $flag + * @param array $contributionParams * @return array */ protected function setUpRepeatTransaction($recurParams = array(), $flag, $contributionParams = array()) { @@ -4067,13 +4043,12 @@ class api_v3_ContributionTest extends CiviUnitTestCase { 'receipt_from_name' => 'CiviCRM LLC', )); $mut->checkMailLog(array( - 'From: CiviCRM LLC ', - 'Contribution Information', - 'Please print this confirmation for your records', - ), array( - 'Event', - ) - ); + 'From: CiviCRM LLC ', + 'Contribution Information', + 'Please print this confirmation for your records', + ), array( + 'Event', + )); $mut->stop(); } @@ -4089,13 +4064,12 @@ class api_v3_ContributionTest extends CiviUnitTestCase { )); $domain = $this->callAPISuccess('domain', 'getsingle', array('id' => 1)); $mut->checkMailLog(array( - 'From: ' . $domain['from_name'] . ' <' . $domain['from_email'] . '>', - 'Contribution Information', - 'Please print this confirmation for your records', - ), array( - 'Event', - ) - ); + 'From: ' . $domain['from_name'] . ' <' . $domain['from_email'] . '>', + 'Contribution Information', + 'Please print this confirmation for your records', + ), array( + 'Event', + )); $mut->stop(); } @@ -4113,12 +4087,12 @@ class api_v3_ContributionTest extends CiviUnitTestCase { )); $domain = $this->callAPISuccess('domain', 'getsingle', array('id' => 1)); $mut->checkMailLog(array( - 'From: ' . $domain['from_name'] . ' <' . $domain['from_email'] . '>', - 'Contribution Information', - 'Please print this confirmation for your records', - ), array( - 'Event', - ) + 'From: ' . $domain['from_name'] . ' <' . $domain['from_email'] . '>', + 'Contribution Information', + 'Please print this confirmation for your records', + ), array( + 'Event', + ) ); $mut->stop(); } @@ -4145,22 +4119,22 @@ class api_v3_ContributionTest extends CiviUnitTestCase { $this->_params, array( 'contribution_recur_id' => $contributionRecur['id'], - 'contribution_page_id' => $contributionPage['id'])) + 'contribution_page_id' => $contributionPage['id'], + )) ); $this->callAPISuccess('contribution', 'repeattransaction', array( 'contribution_status_id' => 'Completed', 'trxn_id' => uniqid(), 'original_contribution_id' => $originalContribution, - ) + ) ); $mut->checkMailLog(array( - 'From: CiviCRM LLC ', - 'Contribution Information', - 'Please print this confirmation for your records', - ), array( - 'Event', - ) - ); + 'From: CiviCRM LLC ', + 'Contribution Information', + 'Please print this confirmation for your records', + ), array( + 'Event', + )); $mut->stop(); } @@ -4179,16 +4153,14 @@ class api_v3_ContributionTest extends CiviUnitTestCase { 'contribution_status_id' => 'Completed', 'trxn_id' => uniqid(), 'original_contribution_id' => $originalContribution, - ) - ); + )); $mut->checkMailLog(array( - 'From: ' . $domain['name'] . ' <' . $domain['domain_email'] . '>', - 'Contribution Information', - 'Please print this confirmation for your records', - ), array( - 'Event', - ) - ); + 'From: ' . $domain['name'] . ' <' . $domain['domain_email'] . '>', + 'Contribution Information', + 'Please print this confirmation for your records', + ), array( + 'Event', + )); $mut->stop(); } diff --git a/tests/phpunit/api/v3/CountryTest.php b/tests/phpunit/api/v3/CountryTest.php index 1722d740ca..3e02d38d50 100644 --- a/tests/phpunit/api/v3/CountryTest.php +++ b/tests/phpunit/api/v3/CountryTest.php @@ -36,7 +36,6 @@ class api_v3_CountryTest extends CiviUnitTestCase { protected $_apiversion; protected $_params; - public function setUp() { $this->_apiversion = 3; parent::setUp(); diff --git a/tests/phpunit/api/v3/CustomApiTest.php b/tests/phpunit/api/v3/CustomApiTest.php index acd34eac67..a6cd684936 100644 --- a/tests/phpunit/api/v3/CustomApiTest.php +++ b/tests/phpunit/api/v3/CustomApiTest.php @@ -63,12 +63,10 @@ class api_v3_CustomApiTest extends CiviUnitTestCase { $this->assertEquals('xyzabx2017-01-01 00:00:00', $result['id']); $this->assertEquals('xyzabx2017-01-01 00:00:00', $result['id']); $this->assertEquals(array( - 'contact_identifier' => 'xyz', - 'mailing_identifier' => 'abx', - 'mailing_identifier.name' => 'CiviMail', - ), - reset($result['values']) - ); + 'contact_identifier' => 'xyz', + 'mailing_identifier' => 'abx', + 'mailing_identifier.name' => 'CiviMail', + ), reset($result['values'])); } /** diff --git a/tests/phpunit/api/v3/CustomFieldTest.php b/tests/phpunit/api/v3/CustomFieldTest.php index 9aedd3a473..df8a988642 100644 --- a/tests/phpunit/api/v3/CustomFieldTest.php +++ b/tests/phpunit/api/v3/CustomFieldTest.php @@ -144,9 +144,11 @@ class api_v3_CustomFieldTest extends CiviUnitTestCase { $n++; } } + /* * Can't figure out the point of this? */ + /** * @param array $params */ @@ -466,16 +468,16 @@ 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', - )); + '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', - )); + 'custom_group_id' => $activityGroup['id'], + 'label' => 'For Activities', + )); // Check getfields $this->assertEquals( @@ -568,7 +570,6 @@ class api_v3_CustomFieldTest extends CiviUnitTestCase { $result = $this->callAPISuccess('CustomField', 'create', $params); } - /** * @param $getFieldsResult * diff --git a/tests/phpunit/api/v3/CustomValueContactTypeTest.php b/tests/phpunit/api/v3/CustomValueContactTypeTest.php index 2c9a18e401..a163eef788 100644 --- a/tests/phpunit/api/v3/CustomValueContactTypeTest.php +++ b/tests/phpunit/api/v3/CustomValueContactTypeTest.php @@ -118,14 +118,14 @@ class api_v3_CustomValueContactTypeTest extends CiviUnitTestCase { $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__); + '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', - )); + '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']); @@ -140,7 +140,8 @@ 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 + // so that undefined_fields is returned + 'debug' => 1, ); $contact = $this->callAPISuccess('contact', 'create', $params); @@ -187,7 +188,8 @@ class api_v3_CustomValueContactTypeTest extends CiviUnitTestCase { 'contact_id' => $this->organizationSponsor, 'contact_type' => 'Organization', "custom_{$this->IndiStudentField['id']}" => 'Test String', - 'debug' => 1, // so that undefined_fields is returned + // so that undefined_fields is returned + 'debug' => 1, ); $contact = $this->callAPISuccess('contact', 'create', $params); @@ -225,7 +227,8 @@ 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 + // so that undefined_fields is returned + 'debug' => 1, ); $contact = $this->callAPISuccess('contact', 'create', $params); $this->assertTrue(is_array($contact['undefined_fields']), __LINE__); diff --git a/tests/phpunit/api/v3/DashboardContactTest.php b/tests/phpunit/api/v3/DashboardContactTest.php index 6f95516ff2..1d639a81e4 100644 --- a/tests/phpunit/api/v3/DashboardContactTest.php +++ b/tests/phpunit/api/v3/DashboardContactTest.php @@ -54,12 +54,11 @@ class api_v3_DashboardContactTest extends CiviUnitTestCase { ); $dashresult = $this->callAPISuccess('dashboard', 'create', $dashParams); $contact = $this->callAPISuccess('contact', 'create', array( - 'first_name' => 'abc1', - 'contact_type' => 'Individual', - 'last_name' => 'xyz1', - 'email' => 'abc@abc.com', - ) - ); + 'first_name' => 'abc1', + 'contact_type' => 'Individual', + 'last_name' => 'xyz1', + 'email' => 'abc@abc.com', + )); $oldCount = CRM_Core_DAO::singleValueQuery("select count(*) from civicrm_dashboard_contact where contact_id = {$contact['id']} AND is_active = 1 AND dashboard_id = {$dashresult['id']}"); $params = array( 'version' => 3, diff --git a/tests/phpunit/api/v3/DomainTest.php b/tests/phpunit/api/v3/DomainTest.php index 78541ddd30..6291f4a769 100644 --- a/tests/phpunit/api/v3/DomainTest.php +++ b/tests/phpunit/api/v3/DomainTest.php @@ -34,9 +34,11 @@ */ class api_v3_DomainTest extends CiviUnitTestCase { - /* This test case doesn't require DB reset - apart from - where cleanDB() is called. */ - + /** + * This test case doesn't require DB reset - apart from + * where cleanDB() is called. + * @var bool + */ public $DBResetRequired = FALSE; protected $_apiversion = 3; @@ -56,29 +58,27 @@ class api_v3_DomainTest extends CiviUnitTestCase { $params['entity_table'] = CRM_Core_BAO_Domain::getTableName(); $defaultLocationType = CRM_Core_BAO_LocationType::getDefault(); $domContact = $this->callAPISuccess('contact', 'create', array( - 'contact_type' => 'Organization', - 'organization_name' => 'new org', - 'api.phone.create' => array( - 'location_type_id' => $defaultLocationType->id, - 'phone_type_id' => 1, - 'phone' => '456-456', - ), - 'api.address.create' => array( - 'location_type_id' => $defaultLocationType->id, - 'street_address' => '45 Penny Lane', - ), - 'api.email.create' => array( - 'location_type_id' => $defaultLocationType->id, - 'email' => 'my@email.com', - ), - ) - ); + 'contact_type' => 'Organization', + 'organization_name' => 'new org', + 'api.phone.create' => array( + 'location_type_id' => $defaultLocationType->id, + 'phone_type_id' => 1, + 'phone' => '456-456', + ), + 'api.address.create' => array( + 'location_type_id' => $defaultLocationType->id, + 'street_address' => '45 Penny Lane', + ), + 'api.email.create' => array( + 'location_type_id' => $defaultLocationType->id, + 'email' => 'my@email.com', + ), + )); $this->callAPISuccess('domain', 'create', array( - 'id' => 1, - 'contact_id' => $domContact['id'], - ) - ); + 'id' => 1, + 'contact_id' => $domContact['id'], + )); $this->params = array( 'name' => 'A-team domain', 'description' => 'domain of chaos', diff --git a/tests/phpunit/api/v3/EmailTest.php b/tests/phpunit/api/v3/EmailTest.php index 5cb68bc1e1..489319f9d5 100644 --- a/tests/phpunit/api/v3/EmailTest.php +++ b/tests/phpunit/api/v3/EmailTest.php @@ -87,9 +87,9 @@ class api_v3_EmailTest extends CiviUnitTestCase { //now we check & make sure it has been set to primary $expected = 1; $check = $this->callAPISuccess('email', 'getcount', array( - 'is_primary' => 1, - 'id' => $email1['id'], - ), + 'is_primary' => 1, + 'id' => $email1['id'], + ), $expected ); } diff --git a/tests/phpunit/api/v3/EntityTagACLTest.php b/tests/phpunit/api/v3/EntityTagACLTest.php index aa16888bf3..1102a3ef8e 100644 --- a/tests/phpunit/api/v3/EntityTagACLTest.php +++ b/tests/phpunit/api/v3/EntityTagACLTest.php @@ -81,8 +81,7 @@ class api_v3_EntityTagACLTest extends CiviUnitTestCase { 'used_for' => $key, 'name' => $entity, 'description' => $entity, - ) - ); + )); } CRM_Core_Config::singleton()->userPermissionClass->permissions = array('access CiviCRM'); } @@ -108,6 +107,7 @@ class api_v3_EntityTagACLTest extends CiviUnitTestCase { $options = $this->getTagOptions(); return array_search($entity, $options); } + /** * Get entities which can be tagged in data provider format. */ diff --git a/tests/phpunit/api/v3/EventTest.php b/tests/phpunit/api/v3/EventTest.php index 4c4157789b..0bf26f3a82 100644 --- a/tests/phpunit/api/v3/EventTest.php +++ b/tests/phpunit/api/v3/EventTest.php @@ -192,6 +192,7 @@ class api_v3_EventTest extends CiviUnitTestCase { $this->assertEquals(1, $result['id'], ' in line ' . __LINE__); } + /* * Getting the id back of an event. * Does not work yet, bug in API @@ -207,7 +208,6 @@ class api_v3_EventTest extends CiviUnitTestCase { } */ - /** * Test 'is.Current' option. Existing event is 'old' so only current should be returned */ @@ -274,11 +274,11 @@ class api_v3_EventTest extends CiviUnitTestCase { $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_status' => 1, + 'role_id' => 1, + 'contact_id' => $contactID, + 'event_id' => $this->_eventIds[0], + )); $currentEvent = $this->callAPIAndDocument('Event', 'getsingle', $getEventParams, __FUNCTION__, __FILE__, $description, $subfile); $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__); @@ -356,7 +356,7 @@ class api_v3_EventTest extends CiviUnitTestCase { 'id' => $result['id'], // this chaining request should not break things: 'api.LocBlock.get' => array('id' => '$value.loc_block_id'), - )); + )); $this->assertEquals($result['id'], $check['id']); $this->callAPISuccess($this->_entity, 'Delete', array('id' => $result['id'])); @@ -378,9 +378,9 @@ 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'], - )); + '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']); @@ -400,8 +400,8 @@ class api_v3_EventTest extends CiviUnitTestCase { // Search for events having CRM-16036 as the value for this custom // field. This should not return anything. $check = $this->callAPISuccess($this->_entity, 'get', array( - 'custom_' . $ids['custom_field_id'] => 'CRM-16036', - )); + 'custom_' . $ids['custom_field_id'] => 'CRM-16036', + )); $this->assertEquals(0, $check['count']); @@ -421,8 +421,8 @@ class api_v3_EventTest extends CiviUnitTestCase { // Search for events having NULL as the value for this custom // field. This should return all events created in setUp. $check = $this->callAPISuccess($this->_entity, 'get', array( - 'custom_' . $ids['custom_field_id'] => array('IS NULL' => 1), - )); + 'custom_' . $ids['custom_field_id'] => array('IS NULL' => 1), + )); $this->assertGreaterThan(0, $check['count']); @@ -565,7 +565,6 @@ class api_v3_EventTest extends CiviUnitTestCase { )); } - /** * Test that an event with a price set can be created. */ @@ -649,7 +648,6 @@ class api_v3_EventTest extends CiviUnitTestCase { $this->callAPISuccess($this->_entity, 'Delete', array('id' => $result['id'])); } - public function testDeleteEmptyParams() { $result = $this->callAPIFailure('Event', 'Delete', array()); } diff --git a/tests/phpunit/api/v3/FinancialTypeACLTest.php b/tests/phpunit/api/v3/FinancialTypeACLTest.php index b275df4e06..ccccba6bc2 100644 --- a/tests/phpunit/api/v3/FinancialTypeACLTest.php +++ b/tests/phpunit/api/v3/FinancialTypeACLTest.php @@ -35,9 +35,6 @@ class api_v3_FinancialTypeACLTest extends CiviUnitTestCase { use CRMTraits_Financial_FinancialACLTrait; - /** - * Assume empty database with just civicrm_data. - */ protected $_individualId; protected $_contribution; protected $_financialTypeId = 1; diff --git a/tests/phpunit/api/v3/GroupTest.php b/tests/phpunit/api/v3/GroupTest.php index 7b11588187..07af06f501 100644 --- a/tests/phpunit/api/v3/GroupTest.php +++ b/tests/phpunit/api/v3/GroupTest.php @@ -74,7 +74,6 @@ class api_v3_GroupTest extends CiviUnitTestCase { $this->callAPIFailure('group', 'create', $params, 'Mandatory key(s) missing from params array: title'); } - public function testGetGroupWithEmptyParams() { $group = $this->callAPISuccess('group', 'get', array()); @@ -173,11 +172,10 @@ class api_v3_GroupTest extends CiviUnitTestCase { //Pass group_type param in checkbox format. $params = array_merge($params, array( - 'name' => 'Test Checkbox Format', - 'title' => 'Test Checkbox Format', - 'group_type' => array(2 => 1), - ) - ); + 'name' => 'Test Checkbox Format', + 'title' => 'Test Checkbox Format', + 'group_type' => array(2 => 1), + )); $result = $this->callAPISuccess('Group', 'create', $params); $group = $result['values'][$result['id']]; $this->assertEquals($group['name'], "Test Checkbox Format"); @@ -185,13 +183,12 @@ class api_v3_GroupTest extends CiviUnitTestCase { //assert single value for group_type and parent $params = array_merge($params, array( - 'name' => 'Test Group 2', - 'title' => 'Test Group 2', - 'group_type' => 2, - 'parents' => $result['id'], - 'sequential' => 1, - ) - ); + 'name' => 'Test Group 2', + 'title' => 'Test Group 2', + 'group_type' => 2, + 'parents' => $result['id'], + 'sequential' => 1, + )); $group2 = $this->callAPISuccess('Group', 'create', $params)['values'][0]; $this->assertEquals($group2['group_type'], array($params['group_type'])); @@ -199,11 +196,10 @@ class api_v3_GroupTest extends CiviUnitTestCase { // Test array format for parents. $params = array_merge($params, array( - 'name' => 'Test Group 3', - 'title' => 'Test Group 3', - 'parents' => [$result['id'], $group2['id']], - ) - ); + 'name' => 'Test Group 3', + 'title' => 'Test Group 3', + 'parents' => [$result['id'], $group2['id']], + )); $group3 = $this->callAPISuccess('Group', 'create', $params)['values'][0]; $parents = $this->callAPISuccess('Group', 'getvalue', ['return' => 'parents', 'id' => $group3['id']]); diff --git a/tests/phpunit/api/v3/JobProcessMailingTest.php b/tests/phpunit/api/v3/JobProcessMailingTest.php index 7bf7396b77..c96a3f1e5f 100644 --- a/tests/phpunit/api/v3/JobProcessMailingTest.php +++ b/tests/phpunit/api/v3/JobProcessMailingTest.php @@ -60,7 +60,8 @@ class api_v3_JobProcessMailingTest extends CiviUnitTestCase { public function setUp() { $this->cleanupMailingTest(); parent::setUp(); - CRM_Mailing_BAO_MailingJob::$mailsProcessed = 0; // DGW + // DGW + CRM_Mailing_BAO_MailingJob::$mailsProcessed = 0; $this->_groupID = $this->groupCreate(); $this->_email = 'test@test.test'; $this->_params = array( @@ -72,15 +73,24 @@ class api_v3_JobProcessMailingTest extends CiviUnitTestCase { 'scheduled_date' => 'now', ); $this->defaultSettings = array( - 'mailings' => 1, // int, #mailings to send - 'recipients' => 20, // int, #contacts to receive mailing - 'workers' => 1, // int, #concurrent cron jobs - 'iterations' => 1, // int, #times to spawn all the workers - 'lockHold' => 0, // int, #extra seconds each cron job should hold lock - 'mailerBatchLimit' => 0, // int, max# recipients to send in a given cron run - 'mailerJobsMax' => 0, // int, max# concurrent jobs - 'mailerJobSize' => 0, // int, max# recipients in each job - 'mailThrottleTime' => 0, // int, microseconds separating messages + // int, #mailings to send + 'mailings' => 1, + // int, #contacts to receive mailing + 'recipients' => 20, + // int, #concurrent cron jobs + 'workers' => 1, + // int, #times to spawn all the workers + 'iterations' => 1, + // int, #extra seconds each cron job should hold lock + 'lockHold' => 0, + // int, max# recipients to send in a given cron run + 'mailerBatchLimit' => 0, + // int, max# concurrent jobs + 'mailerJobsMax' => 0, + // int, max# recipients in each job + 'mailerJobSize' => 0, + // int, microseconds separating messages + 'mailThrottleTime' => 0, ); $this->_mut = new CiviMailUtils($this, TRUE); $this->callAPISuccess('mail_settings', 'get', array('api.mail_settings.create' => array('domain' => 'chaos.org'))); @@ -92,7 +102,8 @@ class api_v3_JobProcessMailingTest extends CiviUnitTestCase { //$this->_mut->clearMessages(); $this->_mut->stop(); CRM_Utils_Hook::singleton()->reset(); - CRM_Mailing_BAO_MailingJob::$mailsProcessed = 0; // DGW + // DGW + CRM_Mailing_BAO_MailingJob::$mailsProcessed = 0; //$this->cleanupMailingTest(); parent::tearDown(); } @@ -211,15 +222,18 @@ class api_v3_JobProcessMailingTest extends CiviUnitTestCase { 'mailerJobsMax' => 1, ), array( - 0 => 2, // 2 jobs which produce 0 messages - 4 => 1, // 1 job which produces 4 messages + // 2 jobs which produce 0 messages + 0 => 2, + // 1 job which produces 4 messages + 4 => 1, ), 4, ); // Launch 3 workers, but mailerJobsMax limits us to 2 workers. $es[1] = array( - array(// Settings. + // Settings. + array( 'recipients' => 20, 'workers' => 3, // FIXME: lockHold is unrealistic/unrepresentative. In reality, this situation fails because @@ -230,90 +244,121 @@ class api_v3_JobProcessMailingTest extends CiviUnitTestCase { 'mailerBatchLimit' => 5, 'mailerJobsMax' => 2, ), - array(// Tallies. - 0 => 1, // 1 job which produce 0 messages - 5 => 2, // 2 jobs which produce 5 messages + // Tallies. + array( + // 1 job which produce 0 messages + 0 => 1, + // 2 jobs which produce 5 messages + 5 => 2, ), - 10, // Total sent. + // Total sent. + 10, ); // Launch 3 workers and saturate them (mailerJobsMax=3) $es[2] = array( - array(// Settings. + // Settings. + array( 'recipients' => 20, 'workers' => 3, 'mailerBatchLimit' => 6, 'mailerJobsMax' => 3, ), - array(// Tallies. - 6 => 3, // 3 jobs which produce 6 messages + // Tallies. + array( + // 3 jobs which produce 6 messages + 6 => 3, ), - 18, // Total sent. + // Total sent. + 18, ); // Launch 4 workers and saturate them (mailerJobsMax=0) $es[3] = array( - array(// Settings. + // Settings. + array( 'recipients' => 20, 'workers' => 4, 'mailerBatchLimit' => 6, 'mailerJobsMax' => 0, ), - array(// Tallies. - 6 => 3, // 3 jobs which produce 6 messages - 2 => 1, // 1 job which produces 2 messages + // Tallies. + array( + // 3 jobs which produce 6 messages + 6 => 3, + // 1 job which produces 2 messages + 2 => 1, ), - 20, // Total sent. + // Total sent. + 20, ); // Launch 1 worker, 3 times in a row. Deliver everything. $es[4] = array( - array(// Settings. + // Settings. + array( 'recipients' => 10, 'workers' => 1, 'iterations' => 3, 'mailerBatchLimit' => 7, ), - array(// Tallies. - 7 => 1, // 1 job which produces 7 messages - 3 => 1, // 1 job which produces 3 messages - 0 => 1, // 1 job which produces 0 messages + // Tallies. + array( + // 1 job which produces 7 messages + 7 => 1, + // 1 job which produces 3 messages + 3 => 1, + // 1 job which produces 0 messages + 0 => 1, ), - 10, // Total sent. + // Total sent. + 10, ); // Launch 2 worker, 3 times in a row. Deliver everything. $es[5] = array( - array(// Settings. + // Settings. + array( 'recipients' => 10, 'workers' => 2, 'iterations' => 3, 'mailerBatchLimit' => 3, ), - array(// Tallies. - 3 => 3, // 3 jobs which produce 3 messages - 1 => 1, // 1 job which produces 1 messages - 0 => 2, // 2 jobs which produce 0 messages + // Tallies. + array( + // 3 jobs which produce 3 messages + 3 => 3, + // 1 job which produces 1 messages + 1 => 1, + // 2 jobs which produce 0 messages + 0 => 2, ), - 10, // Total sent. + // Total sent. + 10, ); // For two mailings, launch 1 worker, 5 times in a row. Deliver everything. $es[6] = array( - array(// Settings. + // Settings. + array( 'mailings' => 2, 'recipients' => 10, 'workers' => 1, 'iterations' => 5, 'mailerBatchLimit' => 6, ), - array(// Tallies. + // Tallies. + array( // x6 => x4+x2 => x6 => x2 => x0 - 6 => 3, // 3 jobs which produce 6 messages - 2 => 1, // 1 job which produces 2 messages - 0 => 1, // 1 job which produces 0 messages + // 3 jobs which produce 6 messages + 6 => 3, + // 1 job which produces 2 messages + 2 => 1, + // 1 job which produces 0 messages + 0 => 1, ), - 20, // Total sent. + // Total sent. + 20, ); return $es; @@ -370,10 +415,10 @@ class api_v3_JobProcessMailingTest extends CiviUnitTestCase { $actualTallies = $this->tallyApiResults($allApiResults); $this->assertEquals($expectedTallies, $actualTallies, 'API tallies should match.' . print_r(array( - 'expectedTallies' => $expectedTallies, - 'actualTallies' => $actualTallies, - 'apiResults' => $allApiResults, - ), TRUE)); + 'expectedTallies' => $expectedTallies, + 'actualTallies' => $actualTallies, + 'apiResults' => $allApiResults, + ), TRUE)); $this->_mut->assertRecipients($this->getRecipients(1, $expectedTotal / $settings['mailings'], 'nul.example.com', $settings['mailings'])); $this->assertEquals(0, $apiCalls->getRunningCount()); } diff --git a/tests/phpunit/api/v3/JobTest.php b/tests/phpunit/api/v3/JobTest.php index de6d2885e1..a9308ef639 100644 --- a/tests/phpunit/api/v3/JobTest.php +++ b/tests/phpunit/api/v3/JobTest.php @@ -49,7 +49,7 @@ class api_v3_JobTest extends CiviUnitTestCase { * * Must be created outside the transaction due to it breaking the transaction. * - * @var + * @var int */ public $membershipTypeID; @@ -264,12 +264,11 @@ class api_v3_JobTest extends CiviUnitTestCase { } if ($i > 1) { $this->callAPISuccess('membership', 'create', array( - 'contact_id' => $contactID, - 'membership_type_id' => $membershipTypeID, - 'join_date' => 'now', - 'start_date' => '+ 1 day', - ) - ); + 'contact_id' => $contactID, + 'membership_type_id' => $membershipTypeID, + 'join_date' => 'now', + 'start_date' => '+ 1 day', + )); } } $this->callAPISuccess('action_schedule', 'create', array( @@ -697,10 +696,12 @@ class api_v3_JobTest extends CiviUnitTestCase { $data = $this->getMergeLocations($address1, $address2, 'Address'); $data = array_merge($data, $this->getMergeLocations(array('phone' => '12345', 'phone_type_id' => 1), array('phone' => '678910', 'phone_type_id' => 1), 'Phone')); $data = array_merge($data, $this->getMergeLocations(array('phone' => '12345'), array('phone' => '678910'), 'Phone')); - $data = array_merge($data, $this->getMergeLocations(array('email' => 'mini@me.com'), array('email' => 'mini@me.org'), 'Email', array(array( - 'email' => 'anthony_anderson@civicrm.org', - 'location_type_id' => 'Home', - )))); + $data = array_merge($data, $this->getMergeLocations(array('email' => 'mini@me.com'), array('email' => 'mini@me.org'), 'Email', array( + array( + 'email' => 'anthony_anderson@civicrm.org', + 'location_type_id' => 'Home', + ), + ))); return $data; } @@ -780,6 +781,7 @@ class api_v3_JobTest extends CiviUnitTestCase { * * @param string $contactType * @param string $used + * @param string $name * @param bool $isReserved * @param int $threshold */ @@ -1381,7 +1383,7 @@ class api_v3_JobTest extends CiviUnitTestCase { * @param array $locationParams1 * @param array $locationParams2 * @param string $entity - * + * @param array $additionalExpected * @return array */ public function getMergeLocations($locationParams1, $locationParams2, $entity, $additionalExpected = array()) { @@ -1819,7 +1821,8 @@ class api_v3_JobTest extends CiviUnitTestCase { // Default params, which we'll expand on below. $params = [ 'membership_type_id' => $membershipTypeId, - 'skipStatusCal' => 1, // Don't calculate status. + // Don't calculate status. + 'skipStatusCal' => 1, 'source' => 'Test', 'sequential' => 1, ]; @@ -1835,7 +1838,8 @@ class api_v3_JobTest extends CiviUnitTestCase { $params['join_date'] = date('Y-m-d'); $params['start_date'] = date('Y-m-d'); $params['end_date'] = date('Y-m-d', strtotime('now + 1 year')); - $params['status_id'] = 'Current'; // Intentionally incorrect status. + // Intentionally incorrect status. + $params['status_id'] = 'Current'; $resultNew = $this->callAPISuccess('Membership', 'create', $params); $this->assertEquals(array_search('Current', $memStatus), $resultNew['values'][0]['status_id']); @@ -1844,7 +1848,8 @@ class api_v3_JobTest extends CiviUnitTestCase { $params['join_date'] = date('Y-m-d', strtotime('now - 6 month')); $params['start_date'] = date('Y-m-d', strtotime('now - 6 month')); $params['end_date'] = date('Y-m-d', strtotime('now + 6 month')); - $params['status_id'] = 'New'; // Intentionally incorrect status. + // Intentionally incorrect status. + $params['status_id'] = 'New'; $resultCurrent = $this->callAPISuccess('Membership', 'create', $params); $this->assertEquals(array_search('New', $memStatus), $resultCurrent['values'][0]['status_id']); @@ -1853,7 +1858,8 @@ class api_v3_JobTest extends CiviUnitTestCase { $params['join_date'] = date('Y-m-d', strtotime('now - 53 week')); $params['start_date'] = date('Y-m-d', strtotime('now - 53 week')); $params['end_date'] = date('Y-m-d', strtotime('now - 1 week')); - $params['status_id'] = 'Current'; // Intentionally incorrect status. + // Intentionally incorrect status. + $params['status_id'] = 'Current'; $resultGrace = $this->callAPISuccess('Membership', 'create', $params); $this->assertEquals(array_search('Current', $memStatus), $resultGrace['values'][0]['status_id']); @@ -1862,7 +1868,8 @@ class api_v3_JobTest extends CiviUnitTestCase { $params['join_date'] = date('Y-m-d', strtotime('now - 16 month')); $params['start_date'] = date('Y-m-d', strtotime('now - 16 month')); $params['end_date'] = date('Y-m-d', strtotime('now - 4 month')); - $params['status_id'] = 'Grace'; // Intentionally incorrect status. + // Intentionally incorrect status. + $params['status_id'] = 'Grace'; $resultExpired = $this->callAPISuccess('Membership', 'create', $params); $this->assertEquals(array_search('Grace', $memStatus), $resultExpired['values'][0]['status_id']); @@ -1940,8 +1947,10 @@ class api_v3_JobTest extends CiviUnitTestCase { 'join_date' => date('Y-m-d', strtotime('now - 16 month')), 'start_date' => date('Y-m-d', strtotime('now - 16 month')), 'end_date' => date('Y-m-d', strtotime('now - 4 month')), - 'status_id' => 'Grace', // Intentionally incorrect status. - 'skipStatusCal' => 1, // Don't calculate status. + // Intentionally incorrect status. + 'status_id' => 'Grace', + // Don't calculate status. + 'skipStatusCal' => 1, ]; $organizationMembershipID = $this->contactMembershipCreate($params); diff --git a/tests/phpunit/api/v3/JobTestCustomDataTest.php b/tests/phpunit/api/v3/JobTestCustomDataTest.php index 0389b78791..d7c5e9dedc 100644 --- a/tests/phpunit/api/v3/JobTestCustomDataTest.php +++ b/tests/phpunit/api/v3/JobTestCustomDataTest.php @@ -218,6 +218,7 @@ class api_v3_JobTestCustomDataTest extends CiviUnitTestCase { ); return $data; } + /** * Test the batch merge does not bork on custom date fields. * diff --git a/tests/phpunit/api/v3/LoggingTest.php b/tests/phpunit/api/v3/LoggingTest.php index 23ff335dab..17d0fc9415 100644 --- a/tests/phpunit/api/v3/LoggingTest.php +++ b/tests/phpunit/api/v3/LoggingTest.php @@ -218,7 +218,8 @@ class api_v3_LoggingTest extends CiviUnitTestCase { 'index_id' => 'id', 'index_log_conn_id' => 'log_conn_id', 'index_log_date' => 'log_date', - 'index_log_user_id' => 'log_user_id', // new index + // new index + 'index_log_user_id' => 'log_user_id', ), ); } @@ -304,7 +305,8 @@ class api_v3_LoggingTest extends CiviUnitTestCase { $this->callAPISuccess('Contact', 'create', array( 'id' => $contactId, 'first_name' => 'Dopey', - 'api.email.create' => array('email' => 'dopey@mail.com')) + 'api.email.create' => array('email' => 'dopey@mail.com'), + ) ); $email = $this->callAPISuccessGetSingle('email', array('email' => 'dopey@mail.com')); $this->callAPIAndDocument('Logging', 'revert', array('log_conn_id' => 'woot', 'log_date' => $timeStamp), __FILE__, 'Revert'); @@ -323,10 +325,10 @@ class api_v3_LoggingTest extends CiviUnitTestCase { sleep(1); CRM_Core_DAO::executeQuery("SET @uniqueID = 'Wot woot'"); $this->callAPISuccess('Contact', 'create', array( - 'id' => $contactId, - 'first_name' => 'Dopey', - 'api.email.create' => array('email' => 'dopey@mail.com')) - ); + 'id' => $contactId, + 'first_name' => 'Dopey', + 'api.email.create' => array('email' => 'dopey@mail.com'), + )); $email = $this->callAPISuccessGetSingle('email', array('email' => 'dopey@mail.com')); $this->callAPISuccess('Logging', 'revert', array('log_conn_id' => 'Wot woot')); $this->assertEquals('Anthony', $this->callAPISuccessGetValue('contact', array('id' => $contactId, 'return' => 'first_name'))); @@ -356,13 +358,12 @@ class api_v3_LoggingTest extends CiviUnitTestCase { sleep(1); CRM_Core_DAO::executeQuery("SET @uniqueID = 'bitty bot bot'"); $this->callAPISuccess('Contact', 'create', array( - 'id' => $contactId, - 'first_name' => 'Dopey', - 'address' => array(array('street_address' => '25 Dorky way', 'location_type_id' => 1)), - 'email' => array('email' => array('email' => 'dopey@mail.com', 'location_type_id' => 1)), - 'api.contribution.create' => array('financial_type_id' => 'Donation', 'receive_date' => 'now', 'total_amount' => 10), - ) - ); + 'id' => $contactId, + 'first_name' => 'Dopey', + 'address' => array(array('street_address' => '25 Dorky way', 'location_type_id' => 1)), + 'email' => array('email' => array('email' => 'dopey@mail.com', 'location_type_id' => 1)), + 'api.contribution.create' => array('financial_type_id' => 'Donation', 'receive_date' => 'now', 'total_amount' => 10), + )); $contact = $this->callAPISuccessGetSingle('contact', array('id' => $contactId, 'return' => array('first_name', 'email', 'modified_date', 'street_address'))); $this->assertEquals('Dopey', $contact['first_name']); $this->assertEquals('dopey@mail.com', $contact['email']); @@ -393,10 +394,10 @@ class api_v3_LoggingTest extends CiviUnitTestCase { $this->callAPISuccess('Setting', 'create', array('logging' => TRUE)); CRM_Core_DAO::executeQuery("SET @uniqueID = 'Wopity woot'"); $this->callAPISuccess('Contact', 'create', array( - 'id' => $contactId, - 'first_name' => 'Dopey', - 'api.email.create' => array('email' => 'dopey@mail.com')) - ); + 'id' => $contactId, + 'first_name' => 'Dopey', + 'api.email.create' => array('email' => 'dopey@mail.com'), + )); $this->callAPISuccess('Setting', 'create', array('logging_all_tables_uniquid' => FALSE)); $this->callAPISuccess('Setting', 'create', array('logging_uniqueid_date' => date('Y-m-d H:i:s', strtotime('+ 1 hour')))); $this->callAPIFailure( @@ -418,11 +419,11 @@ class api_v3_LoggingTest extends CiviUnitTestCase { sleep(1); $timeStamp = date('Y-m-d H:i:s'); $this->callAPISuccess('Contact', 'create', array( - 'id' => $contactId, - 'first_name' => 'Dopey', - 'last_name' => 'Dwarf', - 'api.email.create' => array('email' => 'dopey@mail.com')) - ); + 'id' => $contactId, + 'first_name' => 'Dopey', + 'last_name' => 'Dwarf', + 'api.email.create' => array('email' => 'dopey@mail.com'), + )); $this->callAPISuccessGetSingle('email', array('email' => 'dopey@mail.com')); $diffs = $this->callAPISuccess('Logging', 'get', array('log_conn_id' => 'wooty woot', 'log_date' => $timeStamp), __FUNCTION__, __FILE__); $this->assertLoggingIncludes($diffs['values'], array('to' => 'Dwarf, Dopey')); @@ -441,11 +442,11 @@ class api_v3_LoggingTest extends CiviUnitTestCase { // 1 second delay sleep(1); $this->callAPISuccess('Contact', 'create', array( - 'id' => $contactId, - 'first_name' => 'Dopey', - 'last_name' => 'Dwarf', - 'api.email.create' => array('email' => 'dopey@mail.com')) - ); + 'id' => $contactId, + 'first_name' => 'Dopey', + 'last_name' => 'Dwarf', + 'api.email.create' => array('email' => 'dopey@mail.com'), + )); $this->callAPISuccessGetSingle('email', array('email' => 'dopey@mail.com')); $diffs = $this->callAPIAndDocument('Logging', 'get', array('log_conn_id' => 'wooty wop wop'), __FUNCTION__, __FILE__); $this->assertLoggingIncludes($diffs['values'], array('to' => 'Dwarf, Dopey')); diff --git a/tests/phpunit/api/v3/MailingABTest.php b/tests/phpunit/api/v3/MailingABTest.php index 823b0d5dbf..61f089c350 100644 --- a/tests/phpunit/api/v3/MailingABTest.php +++ b/tests/phpunit/api/v3/MailingABTest.php @@ -98,7 +98,8 @@ class api_v3_MailingABTest extends CiviUnitTestCase { * @return array */ public function groupPctProvider() { - $cases = array(); // array(int $totalSize, int $groupPct, int $expectedCountA, $expectedCountB, $expectedCountC) + // array(int $totalSize, int $groupPct, int $expectedCountA, $expectedCountB, $expectedCountC) + $cases = array(); $cases[] = array(400, 7, 28, 28, 344); $cases[] = array(100, 10, 10, 10, 80); $cases[] = array(50, 20, 10, 10, 30); diff --git a/tests/phpunit/api/v3/MailingContactTest.php b/tests/phpunit/api/v3/MailingContactTest.php index fdab465961..a9e00c9ea3 100644 --- a/tests/phpunit/api/v3/MailingContactTest.php +++ b/tests/phpunit/api/v3/MailingContactTest.php @@ -74,9 +74,8 @@ class api_v3_MailingContactTest extends CiviUnitTestCase { public function testMailingContactGetFields() { $result = $this->callAPISuccess('MailingContact', 'getfields', array( - 'action' => 'get', - ) - ); + 'action' => 'get', + )); $this->assertEquals('Delivered', $result['values']['type']['api.default']); } @@ -165,7 +164,6 @@ class api_v3_MailingContactTest extends CiviUnitTestCase { $this->assertEquals($result['values'][1]['creator_name'], "xyz1, abc1"); } - /** * Test that the API returns only the "Bounced" mailings when instructed to do so. */ diff --git a/tests/phpunit/api/v3/MailingTest.php b/tests/phpunit/api/v3/MailingTest.php index f208df94b0..d543a2919c 100644 --- a/tests/phpunit/api/v3/MailingTest.php +++ b/tests/phpunit/api/v3/MailingTest.php @@ -47,7 +47,8 @@ class api_v3_MailingTest extends CiviUnitTestCase { public function setUp() { parent::setUp(); $this->useTransaction(); - CRM_Mailing_BAO_MailingJob::$mailsProcessed = 0; // DGW + // DGW + CRM_Mailing_BAO_MailingJob::$mailsProcessed = 0; $this->_contactID = $this->individualCreate(); $this->_groupID = $this->groupCreate(); $this->_email = 'test@test.test'; @@ -70,7 +71,8 @@ class api_v3_MailingTest extends CiviUnitTestCase { } public function tearDown() { - CRM_Mailing_BAO_MailingJob::$mailsProcessed = 0; // DGW + // DGW + CRM_Mailing_BAO_MailingJob::$mailsProcessed = 0; parent::tearDown(); } @@ -81,7 +83,8 @@ class api_v3_MailingTest extends CiviUnitTestCase { $result = $this->callAPIAndDocument('mailing', 'create', $this->_params + array('scheduled_date' => 'now'), __FUNCTION__, __FILE__); $jobs = $this->callAPISuccess('mailing_job', 'get', array('mailing_id' => $result['id'])); $this->assertEquals(1, $jobs['count']); - unset($this->_params['created_id']); // return isn't working on this in getAndCheck so lets not check it for now + // return isn't working on this in getAndCheck so lets not check it for now + unset($this->_params['created_id']); $this->getAndCheck($this->_params, $result['id'], 'mailing'); } @@ -91,7 +94,7 @@ class api_v3_MailingTest extends CiviUnitTestCase { public function testSkipAutoSchedule() { $this->callAPISuccess('Mailing', 'create', array_merge($this->_params, [ '_skip_evil_bao_auto_schedule_' => TRUE, - 'scheduled_date' => 'now' + 'scheduled_date' => 'now', ])); $this->callAPISuccessGetCount('Mailing', [], 1); $this->callAPISuccessGetCount('MailingJob', [], 0); @@ -107,7 +110,8 @@ class api_v3_MailingTest extends CiviUnitTestCase { $jobs = $this->callAPISuccess('mailing_job', 'get', array('mailing_id' => $result['id'])); $this->assertEquals(1, $jobs['count']); $this->assertEquals('Complete', $jobs['values'][$jobs['id']]['status']); - unset($this->_params['created_id']); // return isn't working on this in getAndCheck so lets not check it for now + // return isn't working on this in getAndCheck so lets not check it for now + unset($this->_params['created_id']); $this->getAndCheck($this->_params, $result['id'], 'mailing'); } @@ -175,22 +179,22 @@ class api_v3_MailingTest extends CiviUnitTestCase { $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', - )); + 'email' => 'include.me@example.org', + 'first_name' => 'Includer', + 'last_name' => 'Person', + )); $contactIDs['b'] = $this->individualCreate(array( - 'email' => 'exclude.me@example.org', - 'last_name' => 'Excluder', - )); + 'email' => 'exclude.me@example.org', + 'last_name' => 'Excluder', + )); $this->callAPISuccess('GroupContact', 'create', array( - 'group_id' => $groupIDs['a'], - 'contact_id' => $contactIDs['a'], - )); + 'group_id' => $groupIDs['a'], + 'contact_id' => $contactIDs['a'], + )); $this->callAPISuccess('GroupContact', 'create', array( - 'group_id' => $groupIDs['b'], - 'contact_id' => $contactIDs['b'], - )); + 'group_id' => $groupIDs['b'], + 'contact_id' => $contactIDs['b'], + )); // END SAMPLE DATA // ** Pass 1: Create @@ -257,10 +261,14 @@ class api_v3_MailingTest extends CiviUnitTestCase { 'recipient' => CRM_Core_DAO::singleValueQuery('SELECT MAX(id) FROM civicrm_mailing_recipients'), ); $result = $this->callAPISuccess('mailing', 'create', $params); - $this->assertDBQuery($maxIDs['mailing'], 'SELECT MAX(id) FROM civicrm_mailing'); // 'Preview should not create any mailing records' - $this->assertDBQuery($maxIDs['job'], 'SELECT MAX(id) FROM civicrm_mailing_job'); // 'Preview should not create any mailing_job record' - $this->assertDBQuery($maxIDs['group'], 'SELECT MAX(id) FROM civicrm_mailing_group'); // 'Preview should not create any mailing_group records' - $this->assertDBQuery($maxIDs['recipient'], 'SELECT MAX(id) FROM civicrm_mailing_recipients'); // 'Preview should not create any mailing_recipient records' + // 'Preview should not create any mailing records' + $this->assertDBQuery($maxIDs['mailing'], 'SELECT MAX(id) FROM civicrm_mailing'); + // 'Preview should not create any mailing_job record' + $this->assertDBQuery($maxIDs['job'], 'SELECT MAX(id) FROM civicrm_mailing_job'); + // 'Preview should not create any mailing_group records' + $this->assertDBQuery($maxIDs['group'], 'SELECT MAX(id) FROM civicrm_mailing_group'); + // 'Preview should not create any mailing_recipient records' + $this->assertDBQuery($maxIDs['recipient'], 'SELECT MAX(id) FROM civicrm_mailing_recipients'); $previewResult = $result['values'][$result['id']]['api.Mailing.preview']; $this->assertEquals("Hello $displayName", $previewResult['values']['subject']); @@ -273,26 +281,26 @@ class api_v3_MailingTest extends CiviUnitTestCase { $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['include_me'] = $this->individualCreate(array( - 'email' => 'include.me@example.org', - 'first_name' => 'Includer', - 'last_name' => 'Person', - )); + 'email' => 'include.me@example.org', + 'first_name' => 'Includer', + 'last_name' => 'Person', + )); $contactIDs['exclude_me'] = $this->individualCreate(array( - 'email' => 'exclude.me@example.org', - 'last_name' => 'Excluder', - )); + 'email' => 'exclude.me@example.org', + 'last_name' => 'Excluder', + )); $this->callAPISuccess('GroupContact', 'create', array( - 'group_id' => $groupIDs['inc'], - 'contact_id' => $contactIDs['include_me'], - )); + 'group_id' => $groupIDs['inc'], + 'contact_id' => $contactIDs['include_me'], + )); $this->callAPISuccess('GroupContact', 'create', array( - 'group_id' => $groupIDs['inc'], - 'contact_id' => $contactIDs['exclude_me'], - )); + 'group_id' => $groupIDs['inc'], + 'contact_id' => $contactIDs['exclude_me'], + )); $this->callAPISuccess('GroupContact', 'create', array( - 'group_id' => $groupIDs['exc'], - 'contact_id' => $contactIDs['exclude_me'], - )); + 'group_id' => $groupIDs['exc'], + 'contact_id' => $contactIDs['exclude_me'], + )); $params = $this->_params; $params['groups']['include'] = array($groupIDs['inc']); @@ -316,8 +324,10 @@ class api_v3_MailingTest extends CiviUnitTestCase { 'group' => CRM_Core_DAO::singleValueQuery('SELECT MAX(id) FROM civicrm_mailing_group'), ); $create = $this->callAPIAndDocument('Mailing', 'create', $params, __FUNCTION__, __FILE__); - $this->assertDBQuery($maxIDs['mailing'], 'SELECT MAX(id) FROM civicrm_mailing'); // 'Preview should not create any mailing records' - $this->assertDBQuery($maxIDs['group'], 'SELECT MAX(id) FROM civicrm_mailing_group'); // 'Preview should not create any mailing_group records' + // 'Preview should not create any mailing records' + $this->assertDBQuery($maxIDs['mailing'], 'SELECT MAX(id) FROM civicrm_mailing'); + // 'Preview should not create any mailing_group records' + $this->assertDBQuery($maxIDs['group'], 'SELECT MAX(id) FROM civicrm_mailing_group'); $preview = $create['values'][$create['id']]['api.MailingRecipients.get']; $previewIds = array_values(CRM_Utils_Array::collect('contact_id', $preview['values'])); @@ -335,21 +345,21 @@ class api_v3_MailingTest extends CiviUnitTestCase { // BEGIN SAMPLE DATA $groupIDs['grp'] = $this->groupCreate(array('name' => 'Example group', 'title' => 'Example group')); $contactIDs['include_me'] = $this->individualCreate(array( - 'email' => 'include.me@example.org', - 'first_name' => 'Includer', - 'last_name' => 'Person', - )); + 'email' => 'include.me@example.org', + 'first_name' => 'Includer', + 'last_name' => 'Person', + )); $contactIDs['include_me_duplicate'] = $this->individualCreate(array( - 'email' => 'include.me@example.org', - 'first_name' => 'IncluderDuplicate', - 'last_name' => 'Person', - )); + 'email' => 'include.me@example.org', + 'first_name' => 'IncluderDuplicate', + 'last_name' => 'Person', + )); $contactIDs['include_me_onhold'] = $this->individualCreate(array( - 'email' => 'onholdinclude.me@example.org', - 'first_name' => 'Onhold', - 'last_name' => 'Person', - )); + 'email' => 'onholdinclude.me@example.org', + 'first_name' => 'Onhold', + 'last_name' => 'Person', + )); $emailId = $this->callAPISuccessGetValue('Email', array( 'return' => 'id', 'contact_id' => $contactIDs['include_me_onhold'], @@ -360,17 +370,17 @@ class api_v3_MailingTest extends CiviUnitTestCase { )); $this->callAPISuccess('GroupContact', 'create', array( - 'group_id' => $groupIDs['grp'], - 'contact_id' => $contactIDs['include_me'], - )); + 'group_id' => $groupIDs['grp'], + 'contact_id' => $contactIDs['include_me'], + )); $this->callAPISuccess('GroupContact', 'create', array( - 'group_id' => $groupIDs['grp'], - 'contact_id' => $contactIDs['include_me_duplicate'], - )); + 'group_id' => $groupIDs['grp'], + 'contact_id' => $contactIDs['include_me_duplicate'], + )); $this->callAPISuccess('GroupContact', 'create', array( - 'group_id' => $groupIDs['grp'], - 'contact_id' => $contactIDs['include_me_onhold'], - )); + 'group_id' => $groupIDs['grp'], + 'contact_id' => $contactIDs['include_me_onhold'], + )); $params = $this->_params; $params['groups']['include'] = array($groupIDs['grp']); @@ -402,10 +412,10 @@ 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', - )); + 'email' => 'alice@example.org', + 'first_name' => 'Alice', + 'last_name' => 'Person', + )); $mail = $this->callAPISuccess('mailing', 'create', $this->_params); @@ -414,7 +424,8 @@ class api_v3_MailingTest extends CiviUnitTestCase { // Per https://lab.civicrm.org/dev/mail/issues/32 test non-lowercase email $params['id'] = $mail['id']; $deliveredInfo = $this->callAPISuccess($this->_entity, 'send_test', $params); - $this->assertEquals(1, $deliveredInfo['count']); // verify mail has been sent to user by count + // verify mail has been sent to user by count + $this->assertEquals(1, $deliveredInfo['count']); $deliveredContacts = array_values(CRM_Utils_Array::collect('contact_id', $deliveredInfo['values'])); $this->assertEquals(array($contactIDs['alice']), $deliveredContacts); @@ -430,32 +441,32 @@ class api_v3_MailingTest extends CiviUnitTestCase { // 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', - )); + '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', - )); + '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', - )); + 'email' => 'carol@example.org', + 'first_name' => 'Carol', + 'last_name' => 'Person', + )); $this->callAPISuccess('GroupContact', 'create', array( - 'group_id' => $groupIDs['inc'], - 'contact_id' => $contactIDs['alice'], - )); + 'group_id' => $groupIDs['inc'], + 'contact_id' => $contactIDs['alice'], + )); $this->callAPISuccess('GroupContact', 'create', array( - 'group_id' => $groupIDs['inc'], - 'contact_id' => $contactIDs['bob'], - )); + 'group_id' => $groupIDs['inc'], + 'contact_id' => $contactIDs['bob'], + )); $this->callAPISuccess('GroupContact', 'create', array( - 'group_id' => $groupIDs['inc'], - 'contact_id' => $contactIDs['carol'], - )); + 'group_id' => $groupIDs['inc'], + 'contact_id' => $contactIDs['carol'], + )); // END SAMPLE DATA $mail = $this->callAPISuccess('mailing', 'create', $this->_params); @@ -464,7 +475,8 @@ class api_v3_MailingTest extends CiviUnitTestCase { 'test_email' => NULL, 'test_group' => $groupIDs['inc'], )); - $this->assertEquals(3, $deliveredInfo['count'], "in line " . __LINE__); // verify mail has been sent to user by count + // verify mail has been sent to user by count + $this->assertEquals(3, $deliveredInfo['count'], "in line " . __LINE__); $deliveredContacts = array_values(CRM_Utils_Array::collect('contact_id', $deliveredInfo['values'])); $this->assertEquals(array($contactIDs['alice'], $contactIDs['bob'], $contactIDs['carol']), $deliveredContacts); @@ -477,76 +489,117 @@ class api_v3_MailingTest extends CiviUnitTestCase { * @return array */ public function submitProvider() { - $cases = array(); // $useLogin, $params, $expectedFailure, $expectedJobCount + // $useLogin, $params, $expectedFailure, $expectedJobCount + $cases = array(); $cases[] = array( - TRUE, //useLogin - array(), // createParams + //useLogin + TRUE, + // createParams + array(), array('scheduled_date' => '2014-12-13 10:00:00', 'approval_date' => '2014-12-13 00:00:00'), - FALSE, // expectedFailure - 1, // expectedJobCount + // expectedFailure + FALSE, + // expectedJobCount + 1, ); $cases[] = array( - FALSE, //useLogin - array(), // createParams + //useLogin + FALSE, + // createParams + array(), array('scheduled_date' => '2014-12-13 10:00:00', 'approval_date' => '2014-12-13 00:00:00'), - "/Failed to determine current user/", // expectedFailure - 0, // expectedJobCount + // expectedFailure + "/Failed to determine current user/", + // expectedJobCount + 0, ); $cases[] = array( - TRUE, //useLogin - array(), // createParams + //useLogin + TRUE, + // createParams + array(), array('scheduled_date' => '2014-12-13 10:00:00'), - FALSE, // expectedFailure - 1, // expectedJobCount + // expectedFailure + FALSE, + // expectedJobCount + 1, ); $cases[] = array( - TRUE, //useLogin - array(), // createParams + //useLogin + TRUE, + // createParams + array(), array(), - "/Missing parameter scheduled_date and.or approval_date/", // expectedFailure - 0, // expectedJobCount + // expectedFailure + "/Missing parameter scheduled_date and.or approval_date/", + // expectedJobCount + 0, ); $cases[] = array( - TRUE, //useLogin - array('name' => ''), // createParams + //useLogin + TRUE, + // createParams + array('name' => ''), array('scheduled_date' => '2014-12-13 10:00:00', 'approval_date' => '2014-12-13 00:00:00'), - "/Mailing cannot be sent. There are missing or invalid fields \\(name\\)./", // expectedFailure - 0, // expectedJobCount + // expectedFailure + "/Mailing cannot be sent. There are missing or invalid fields \\(name\\)./", + // expectedJobCount + 0, ); $cases[] = array( - TRUE, //useLogin - array('body_html' => '', 'body_text' => ''), // createParams + //useLogin + TRUE, + // createParams + array('body_html' => '', 'body_text' => ''), array('scheduled_date' => '2014-12-13 10:00:00', 'approval_date' => '2014-12-13 00:00:00'), - "/Mailing cannot be sent. There are missing or invalid fields \\(body\\)./", // expectedFailure - 0, // expectedJobCount + // expectedFailure + "/Mailing cannot be sent. There are missing or invalid fields \\(body\\)./", + // expectedJobCount + 0, ); $cases[] = array( - TRUE, //useLogin - array('body_html' => 'Oops, did I leave my tokens at home?'), // createParams + //useLogin + TRUE, + // createParams + array('body_html' => 'Oops, did I leave my tokens at home?'), array('scheduled_date' => '2014-12-13 10:00:00', 'approval_date' => '2014-12-13 00:00:00'), - "/Mailing cannot be sent. There are missing or invalid fields \\(.*body_html.*optOut.*\\)./", // expectedFailure - 0, // expectedJobCount + // expectedFailure + "/Mailing cannot be sent. There are missing or invalid fields \\(.*body_html.*optOut.*\\)./", + // expectedJobCount + 0, ); $cases[] = array( - TRUE, //useLogin - array('body_text' => 'Oops, did I leave my tokens at home?'), // createParams + //useLogin + TRUE, + // createParams + array('body_text' => 'Oops, did I leave my tokens at home?'), array('scheduled_date' => '2014-12-13 10:00:00', 'approval_date' => '2014-12-13 00:00:00'), - "/Mailing cannot be sent. There are missing or invalid fields \\(.*body_text.*optOut.*\\)./", // expectedFailure - 0, // expectedJobCount + // expectedFailure + "/Mailing cannot be sent. There are missing or invalid fields \\(.*body_text.*optOut.*\\)./", + // expectedJobCount + 0, ); $cases[] = array( - TRUE, //useLogin - array('body_text' => 'Look ma, magic tokens in the text!', 'footer_id' => '%FOOTER%'), // createParams + //useLogin + TRUE, + // createParams + array('body_text' => 'Look ma, magic tokens in the text!', 'footer_id' => '%FOOTER%'), array('scheduled_date' => '2014-12-13 10:00:00', 'approval_date' => '2014-12-13 00:00:00'), - FALSE, // expectedFailure - 1, // expectedJobCount + // expectedFailure + FALSE, + // expectedJobCount + 1, ); $cases[] = array( - TRUE, //useLogin - array('body_html' => '

Look ma, magic tokens in the markup!

', 'footer_id' => '%FOOTER%'), // createParams + //useLogin + TRUE, + // createParams + array('body_html' => '

Look ma, magic tokens in the markup!

', 'footer_id' => '%FOOTER%'), array('scheduled_date' => '2014-12-13 10:00:00', 'approval_date' => '2014-12-13 00:00:00'), - FALSE, // expectedFailure - 1, // expectedJobCount + // expectedFailure + FALSE, + // expectedJobCount + 1, ); return $cases; } @@ -645,7 +698,8 @@ class api_v3_MailingTest extends CiviUnitTestCase { */ public function testMailerStats() { $result = $this->groupContactCreate($this->_groupID, 100); - $this->assertEquals(100, $result['added']); //verify if 100 contacts are added for group + //verify if 100 contacts are added for group + $this->assertEquals(100, $result['added']); //Create and send test mail first and change the mail job to live, //because stats api only works on live mail @@ -683,7 +737,8 @@ SELECT event_queue_id, time_stamp FROM mail_{$type}_temp"; $result = $this->callAPISuccess('mailing', 'stats', array('mailing_id' => $mail['id'])); $expectedResult = array( - 'Delivered' => 80, //since among 100 mails 20 has been bounced + //since among 100 mails 20 has been bounced + 'Delivered' => 80, 'Bounces' => 20, 'Opened' => 20, 'Unique Clicks' => 0, @@ -831,7 +886,6 @@ SELECT event_queue_id, time_stamp FROM mail_{$type}_temp"; ); } - //----------- civicrm_mailing_event_forward methods ---------- /** diff --git a/tests/phpunit/api/v3/MembershipPaymentTest.php b/tests/phpunit/api/v3/MembershipPaymentTest.php index 26f5e83b46..59bea92ed9 100644 --- a/tests/phpunit/api/v3/MembershipPaymentTest.php +++ b/tests/phpunit/api/v3/MembershipPaymentTest.php @@ -105,7 +105,6 @@ class api_v3_MembershipPaymentTest extends CiviUnitTestCase { } - ///////////////// civicrm_membershipPayment_get methods /** diff --git a/tests/phpunit/api/v3/MembershipStatusTest.php b/tests/phpunit/api/v3/MembershipStatusTest.php index 001a7adc94..7fd9f6714d 100644 --- a/tests/phpunit/api/v3/MembershipStatusTest.php +++ b/tests/phpunit/api/v3/MembershipStatusTest.php @@ -56,7 +56,6 @@ class api_v3_MembershipStatusTest extends CiviUnitTestCase { ///////////////// civicrm_membership_status_get methods - /** * Test civicrm_membership_status_get with empty params. */ @@ -130,7 +129,6 @@ class api_v3_MembershipStatusTest extends CiviUnitTestCase { $this->membershipStatusDelete($result['id']); } - ///////////////// civicrm_membership_status_delete methods /** diff --git a/tests/phpunit/api/v3/MembershipTest.php b/tests/phpunit/api/v3/MembershipTest.php index 36f3a84c8b..1cfd52ad02 100644 --- a/tests/phpunit/api/v3/MembershipTest.php +++ b/tests/phpunit/api/v3/MembershipTest.php @@ -90,11 +90,11 @@ class api_v3_MembershipTest extends CiviUnitTestCase { */ public function tearDown() { $this->quickCleanup(array( - 'civicrm_membership', - 'civicrm_membership_payment', - 'civicrm_membership_log', - 'civicrm_uf_match', - ), + 'civicrm_membership', + 'civicrm_membership_payment', + 'civicrm_membership_log', + 'civicrm_uf_match', + ), TRUE ); $this->membershipStatusDelete($this->_membershipStatusID); @@ -137,8 +137,10 @@ class api_v3_MembershipTest extends CiviUnitTestCase { * Test membership deletion and with the preserve contribution param. */ public function testMembershipDeletePreserveContribution() { - $membershipID = $this->contactMembershipCreate($this->_params); //DELETE - $this->assertDBRowExist('CRM_Member_DAO_Membership', $membershipID); //DELETE + //DELETE + $membershipID = $this->contactMembershipCreate($this->_params); + //DELETE + $this->assertDBRowExist('CRM_Member_DAO_Membership', $membershipID); $ContributionCreate = $this->callAPISuccess('Contribution', 'create', array( 'sequential' => 1, 'financial_type_id' => "Member Dues", @@ -388,7 +390,6 @@ class api_v3_MembershipTest extends CiviUnitTestCase { $this->assertEquals($result['is_override'], 1); } - /** * Test civicrm_membership_get with proper params. * Memberships expected. @@ -705,6 +706,7 @@ class api_v3_MembershipTest extends CiviUnitTestCase { $this->assertEquals(array('id', 'end_date'), array_keys($membership)); } } + ///////////////// civicrm_membership_create methods /** @@ -1538,7 +1540,6 @@ class api_v3_MembershipTest extends CiviUnitTestCase { $this->assertEquals('2010-01-20', $result['end_date']); } - /** * Test that if dates are set they not over-ridden if id is passed in */ diff --git a/tests/phpunit/api/v3/MessageTemplateTest.php b/tests/phpunit/api/v3/MessageTemplateTest.php index 1c44852b1c..bb45d30187 100644 --- a/tests/phpunit/api/v3/MessageTemplateTest.php +++ b/tests/phpunit/api/v3/MessageTemplateTest.php @@ -32,13 +32,10 @@ * @group headless */ class api_v3_MessageTemplateTest extends CiviUnitTestCase { - /** - * Assume empty database with just civicrm_data. - */ + protected $entity = 'MessageTemplate'; protected $params; - public function setUp() { $this->_apiversion = 3; parent::setUp(); diff --git a/tests/phpunit/api/v3/MultilingualTest.php b/tests/phpunit/api/v3/MultilingualTest.php index 3ef14e0785..05343641ea 100644 --- a/tests/phpunit/api/v3/MultilingualTest.php +++ b/tests/phpunit/api/v3/MultilingualTest.php @@ -121,9 +121,12 @@ class api_v3_MultilingualTest extends CiviUnitTestCase { 'Location', 'Pcp', 'Survey', - 'UFField', // throw error for help_post column - 'UFGroup', //throw error for title - 'User', // need loggedIn user id + // throw error for help_post column + 'UFField', + //throw error for title + 'UFGroup', + // need loggedIn user id + 'User', ); // fetch all entities $entities = $this->callAPISuccess('Entity', 'get', array()); diff --git a/tests/phpunit/api/v3/OptionGroupTest.php b/tests/phpunit/api/v3/OptionGroupTest.php index 448782c1fc..a503e7d4be 100644 --- a/tests/phpunit/api/v3/OptionGroupTest.php +++ b/tests/phpunit/api/v3/OptionGroupTest.php @@ -124,15 +124,16 @@ 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, 'name' => 'civicrm_rolback_test', 'is_reserved' => 1, 'is_active' => 1, - 'is_transactional' => 'nest', // executing within useTransactional() test case + // executing within useTransactional() test case + 'is_transactional' => 'nest', 'api.OptionValue.create' => array( 'label' => 'invalid entry', 'value' => 35, @@ -143,9 +144,8 @@ 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, 'Count of option groups should not have changed due to rollback triggered by option value In line ' . __LINE__ ); diff --git a/tests/phpunit/api/v3/OptionValueTest.php b/tests/phpunit/api/v3/OptionValueTest.php index 154cb18222..f2f3720460 100644 --- a/tests/phpunit/api/v3/OptionValueTest.php +++ b/tests/phpunit/api/v3/OptionValueTest.php @@ -329,7 +329,6 @@ class api_v3_OptionValueTest extends CiviUnitTestCase { $this->assertFalse(in_array($newOption, $fields['values'])); } - /** * Update option value with 'id' parameter and the value to update * and not passing option group id diff --git a/tests/phpunit/api/v3/OrderTest.php b/tests/phpunit/api/v3/OrderTest.php index 7f18041fdd..f1302a844f 100644 --- a/tests/phpunit/api/v3/OrderTest.php +++ b/tests/phpunit/api/v3/OrderTest.php @@ -34,9 +34,6 @@ */ class api_v3_OrderTest extends CiviUnitTestCase { - /** - * Assume empty database with just civicrm_data. - */ protected $_individualId; protected $_financialTypeId = 1; protected $_apiversion; @@ -557,7 +554,7 @@ class api_v3_OrderTest extends CiviUnitTestCase { 'financial_type_id' => 1, 'entity_table' => 'civicrm_contribution', ], - ] + ], ], ], ]; @@ -592,7 +589,7 @@ class api_v3_OrderTest extends CiviUnitTestCase { 'entity_table' => 'civicrm_contribution', 'tax_amount' => 15, ], - ] + ], ], ], ]; @@ -623,7 +620,7 @@ class api_v3_OrderTest extends CiviUnitTestCase { 'entity_table' => 'civicrm_contribution', 'tax_amount' => 15, ], - ] + ], ], ], ]; diff --git a/tests/phpunit/api/v3/ParticipantPaymentTest.php b/tests/phpunit/api/v3/ParticipantPaymentTest.php index f9492f96de..df0f3f7585 100644 --- a/tests/phpunit/api/v3/ParticipantPaymentTest.php +++ b/tests/phpunit/api/v3/ParticipantPaymentTest.php @@ -56,24 +56,24 @@ class api_v3_ParticipantPaymentTest extends CiviUnitTestCase { $this->_financialTypeId = 1; $this->_participantID = $this->participantCreate(array( - 'contactID' => $this->_contactID, - 'eventID' => $this->_eventID, - )); + 'contactID' => $this->_contactID, + 'eventID' => $this->_eventID, + )); $this->_contactID2 = $this->individualCreate(); $this->_participantID2 = $this->participantCreate(array( - 'contactID' => $this->_contactID2, - 'eventID' => $this->_eventID, - )); + 'contactID' => $this->_contactID2, + 'eventID' => $this->_eventID, + )); $this->_participantID3 = $this->participantCreate(array( - 'contactID' => $this->_contactID2, - 'eventID' => $this->_eventID, - )); + 'contactID' => $this->_contactID2, + 'eventID' => $this->_eventID, + )); $this->_contactID3 = $this->individualCreate(); $this->_participantID4 = $this->participantCreate(array( - 'contactID' => $this->_contactID3, - 'eventID' => $this->_eventID, - )); + 'contactID' => $this->_contactID3, + 'eventID' => $this->_eventID, + )); } /** @@ -144,7 +144,6 @@ class api_v3_ParticipantPaymentTest extends CiviUnitTestCase { $this->assertEquals('100.00', $paymentInfo['total']); } - ///////////////// civicrm_participant_payment_create methods /** @@ -285,7 +284,6 @@ class api_v3_ParticipantPaymentTest extends CiviUnitTestCase { $this->callAPISuccess('participant_payment', 'delete', $params); } - /** * Test civicrm_participant_payment_delete with wrong params type. */ diff --git a/tests/phpunit/api/v3/ParticipantTest.php b/tests/phpunit/api/v3/ParticipantTest.php index 60ed6ab695..2c438ea597 100644 --- a/tests/phpunit/api/v3/ParticipantTest.php +++ b/tests/phpunit/api/v3/ParticipantTest.php @@ -60,19 +60,19 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { $this->_individualId = $this->individualCreate(); $this->_participantID = $this->participantCreate(array( - 'contact_id' => $this->_contactID, - 'event_id' => $this->_eventID, - )); + '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, - 'registered_by_id' => $this->_participantID, - )); + 'contact_id' => $this->_contactID2, + 'event_id' => $this->_eventID, + 'registered_by_id' => $this->_participantID, + )); $this->_participantID3 = $this->participantCreate(array( - 'contact_id' => $this->_contactID2, - 'event_id' => $this->_eventID, - )); + 'contact_id' => $this->_contactID2, + 'event_id' => $this->_eventID, + )); $this->_params = array( 'contact_id' => $this->_contactID, 'event_id' => $this->_eventID, @@ -226,7 +226,6 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { $this->assertEquals($result['is_error'], 0); } - /** * Check with params id. */ @@ -248,9 +247,9 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { //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, - )); + 'event_id' => $event['id'], + 'contact_id' => $this->_contactID, + )); $description = "Demonstrates use of nested get to fetch event data with participant records."; $subfile = "NestedEventGet"; @@ -632,6 +631,7 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { ); $this->getAndCheck($update, $participant['id'], 'participant'); } + ///////////////// civicrm_participant_update methods /** diff --git a/tests/phpunit/api/v3/PaymentProcessorTypeTest.php b/tests/phpunit/api/v3/PaymentProcessorTypeTest.php index 02a1488934..1c111296f5 100644 --- a/tests/phpunit/api/v3/PaymentProcessorTypeTest.php +++ b/tests/phpunit/api/v3/PaymentProcessorTypeTest.php @@ -174,7 +174,8 @@ class api_v3_PaymentProcessorTypeTest extends CiviUnitTestCase { $params = array( 'id' => $this->_ppTypeID, - 'name' => 'API_Test_PP', // keep the same + // keep the same + 'name' => 'API_Test_PP', 'title' => 'API Test Payment Processor 2', 'class_name' => 'CRM_Core_Payment_APITest 2', 'billing_mode' => 2, diff --git a/tests/phpunit/api/v3/PaymentTest.php b/tests/phpunit/api/v3/PaymentTest.php index 0c49ce88f4..129495aa78 100644 --- a/tests/phpunit/api/v3/PaymentTest.php +++ b/tests/phpunit/api/v3/PaymentTest.php @@ -34,9 +34,6 @@ */ class api_v3_PaymentTest extends CiviUnitTestCase { - /** - * Assume empty database with just civicrm_data. - */ protected $_individualId; protected $_financialTypeId = 1; protected $_apiversion; @@ -135,7 +132,8 @@ class api_v3_PaymentTest extends CiviUnitTestCase { 'Dear Anthony,', 'Total Fees: $ 300.00', 'This Payment Amount: $ 50.00', - 'Balance Owed: $ 100.00', //150 was paid in the 1st payment. + //150 was paid in the 1st payment. + 'Balance Owed: $ 100.00', 'Event Information and Location', 'Paid By: Check', 'Check Number: 345', diff --git a/tests/phpunit/api/v3/PcpTest.php b/tests/phpunit/api/v3/PcpTest.php index eeb50621bd..21ac18ac3c 100644 --- a/tests/phpunit/api/v3/PcpTest.php +++ b/tests/phpunit/api/v3/PcpTest.php @@ -55,7 +55,8 @@ class api_v3_PcpTest extends CiviUnitTestCase { 'title' => "Pcp title", 'contact_id' => 1, 'page_id' => 1, - 'pcp_block_id' => 1); + 'pcp_block_id' => 1, + ); parent::setUp(); } diff --git a/tests/phpunit/api/v3/PhoneTest.php b/tests/phpunit/api/v3/PhoneTest.php index 5d32a51482..f8aff7aad3 100644 --- a/tests/phpunit/api/v3/PhoneTest.php +++ b/tests/phpunit/api/v3/PhoneTest.php @@ -38,7 +38,6 @@ class api_v3_PhoneTest extends CiviUnitTestCase { protected $_locationType; protected $_params; - public function setUp() { $this->_apiversion = 3; parent::setUp(); diff --git a/tests/phpunit/api/v3/PledgePaymentTest.php b/tests/phpunit/api/v3/PledgePaymentTest.php index 4f2a3e88c1..fbf0f7b2ce 100644 --- a/tests/phpunit/api/v3/PledgePaymentTest.php +++ b/tests/phpunit/api/v3/PledgePaymentTest.php @@ -33,9 +33,6 @@ */ class api_v3_PledgePaymentTest extends CiviUnitTestCase { - /** - * Assume empty database with just civicrm_data. - */ protected $_individualId; protected $_pledgeID; protected $_apiversion = 3; @@ -169,7 +166,6 @@ class api_v3_PledgePaymentTest extends CiviUnitTestCase { $this->assertEquals(array_search('Completed', $paymentStatusTypes), $checkPaymentStatus['status_id']); } - /** * Test that passing in a single variable works:: status_id */ diff --git a/tests/phpunit/api/v3/PledgeTest.php b/tests/phpunit/api/v3/PledgeTest.php index b0adbd69ed..507987b67b 100644 --- a/tests/phpunit/api/v3/PledgeTest.php +++ b/tests/phpunit/api/v3/PledgeTest.php @@ -33,9 +33,6 @@ */ class api_v3_PledgeTest extends CiviUnitTestCase { - /** - * Assume empty database with just civicrm_data. - */ protected $_individualId; protected $_pledge; protected $_apiversion; @@ -322,7 +319,6 @@ class api_v3_PledgeTest extends CiviUnitTestCase { $apiResult = $this->callAPISuccess('pledge', 'create', $params); } - /** * Test creation of pledge with only one payment. * @@ -505,7 +501,6 @@ class api_v3_PledgeTest extends CiviUnitTestCase { $this->callAPIFailure('pledge', 'delete', array(), 'Mandatory key(s) missing from params array: id'); } - /** * Failure test for invalid pledge id. */ diff --git a/tests/phpunit/api/v3/ProfileTest.php b/tests/phpunit/api/v3/ProfileTest.php index ce7af69fdf..6e2e88f782 100644 --- a/tests/phpunit/api/v3/ProfileTest.php +++ b/tests/phpunit/api/v3/ProfileTest.php @@ -161,17 +161,17 @@ class api_v3_ProfileTest extends CiviUnitTestCase { $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, - )); + '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, - )); + 'contact_id' => $contactId, + 'email' => 'big@once.com', + 'location_type_id' => 2, + 'is_billing' => 1, + )); $params = array( 'profile_id' => array($this->_profileID, 1, 'Billing'), @@ -289,9 +289,9 @@ class api_v3_ProfileTest extends CiviUnitTestCase { $this->_createIndividualProfile(); $this->_addCustomFieldToProfile($this->_profileID); $result = $this->callAPIAndDocument('profile', 'getfields', array( - 'action' => 'submit', - 'profile_id' => $this->_profileID, - ), __FUNCTION__, __FILE__, + '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']); @@ -306,11 +306,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]); $this->assertEquals(array('participant_status'), $result['values']['participant_status_id']['api.aliases']); @@ -322,18 +321,17 @@ 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']); + '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']); } @@ -347,11 +345,10 @@ class api_v3_ProfileTest extends CiviUnitTestCase { $profileIDs = array_keys($result['values']); foreach ($profileIDs as $profileID) { $this->callAPISuccess('profile', 'getfields', array( - 'action' => 'submit', - 'profile_id' => $profileID, - 'get_options' => 'all', - ) - ); + 'action' => 'submit', + 'profile_id' => $profileID, + 'get_options' => 'all', + )); } } @@ -451,14 +448,14 @@ class api_v3_ProfileTest extends CiviUnitTestCase { $membershipTypes = $this->callAPISuccess('membership_type', 'get', array()); $profileFields = $this->callAPISuccess('profile', 'getfields', array( - 'get_options' => 'all', - 'action' => 'submit', - 'profile_id' => 'membership_batch_entry', - )); + 'get_options' => 'all', + 'action' => 'submit', + 'profile_id' => 'membership_batch_entry', + )); $getoptions = $this->callAPISuccess('membership', 'getoptions', array( - 'field' => 'membership_type', - 'context' => 'validate', - )); + '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'])); @@ -469,9 +466,9 @@ class api_v3_ProfileTest extends CiviUnitTestCase { */ public function testMembershipGetFieldsOrder() { $result = $this->callAPISuccess('profile', 'getfields', array( - 'action' => 'submit', - 'profile_id' => 'membership_batch_entry', - )); + 'action' => 'submit', + 'profile_id' => 'membership_batch_entry', + )); $weight = 1; foreach ($result['values'] as $fieldName => $field) { if ($fieldName == 'profile_id') { @@ -691,10 +688,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})" @@ -810,31 +807,30 @@ 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', - 'supplemental_address_3' => 'My Town', - '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', + 'supplemental_address_3' => 'My Town', + '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); $this->_createIndividualProfile(); @@ -1005,10 +1001,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', - )); + '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 2ee40f064b..469624da27 100644 --- a/tests/phpunit/api/v3/RelationshipTest.php +++ b/tests/phpunit/api/v3/RelationshipTest.php @@ -300,7 +300,6 @@ class api_v3_RelationshipTest extends CiviUnitTestCase { } - /** * Check relationship creation. */ @@ -1123,9 +1122,8 @@ class api_v3_RelationshipTest extends CiviUnitTestCase { $this->_ids['relationship'] = $this->callAPISuccess($this->_entity, 'create', array('format.only_id' => TRUE) + $this->_params); $this->callAPISuccess($this->_entity, 'getcount', array( - 'contact_id_a' => $this->_cId_a, - ), - 1); + 'contact_id_a' => $this->_cId_a, + ), 1); $result = $this->callAPISuccess($this->_entity, 'get', array( 'contact_id_a' => $this->_cId_a, 'relationship_type_id' => $this->_relTypeID, @@ -1148,8 +1146,10 @@ class api_v3_RelationshipTest extends CiviUnitTestCase { public function testGetRelationshipByTypeArrayDAO() { $this->callAPISuccess($this->_entity, 'create', $this->_params); $org3 = $this->organizationCreate(); - $relType2 = 5; // lets just assume built in ones aren't being messed with! - $relType3 = 6; // lets just assume built in ones aren't being messed with! + // lets just assume built in ones aren't being messed with! + $relType2 = 5; + // lets just assume built in ones aren't being messed with! + $relType3 = 6; // Relationship 2. $this->callAPISuccess($this->_entity, 'create', @@ -1232,8 +1232,10 @@ class api_v3_RelationshipTest extends CiviUnitTestCase { $this->callAPISuccess($this->_entity, 'create', $this->_params); $org3 = $this->organizationCreate(); - $relType2 = 5; // lets just assume built in ones aren't being messed with! - $relType3 = 6; // lets just assume built in ones aren't being messed with! + // lets just assume built in ones aren't being messed with! + $relType2 = 5; + // lets just assume built in ones aren't being messed with! + $relType3 = 6; $relType1 = 1; $memberType = $this->membershipTypeCreate(array( 'relationship_type_id' => CRM_Core_DAO::VALUE_SEPARATOR . $relType1 . CRM_Core_DAO::VALUE_SEPARATOR . $relType3 . CRM_Core_DAO::VALUE_SEPARATOR, diff --git a/tests/phpunit/api/v3/ReportTemplateTest.php b/tests/phpunit/api/v3/ReportTemplateTest.php index c9e212e0a8..b2eb935a18 100644 --- a/tests/phpunit/api/v3/ReportTemplateTest.php +++ b/tests/phpunit/api/v3/ReportTemplateTest.php @@ -559,8 +559,8 @@ class api_v3_ReportTemplateTest extends CiviUnitTestCase { $this->callAPISuccess('report_template', 'getrows', [ 'report_id' => 'case/detail', 'fields' => ['subject' => 1, 'client_sort_name' => 1], - 'order_bys' => [ - 1 => [ + 'order_bys' => [ + 1 => [ 'column' => 'case_type_title', 'order' => 'ASC', 'section' => '1', @@ -844,11 +844,11 @@ class api_v3_ReportTemplateTest extends CiviUnitTestCase { )); foreach (array( - $addedToBothIndividualID, - $removedFromBothIndividualID, - $addedToSmartGroupRemovedFromOtherIndividualID, - $removedFromSmartGroupAddedToOtherIndividualID, - ) as $contactID) { + $addedToBothIndividualID, + $removedFromBothIndividualID, + $addedToSmartGroupRemovedFromOtherIndividualID, + $removedFromSmartGroupAddedToOtherIndividualID, + ) as $contactID) { $this->contributionCreate(array( 'contact_id' => $contactID, 'invoice_id' => '', @@ -1083,7 +1083,7 @@ class api_v3_ReportTemplateTest extends CiviUnitTestCase { 'financial_type_id' => '1', 'receive_date' => '1', 'total_amount' => '1', - ], + ], 'order_bys' => [['column' => 'sort_name', 'order' => 'ASC', 'section' => '1']], 'options' => array('metadata' => array('sql')), )); @@ -1219,7 +1219,7 @@ class api_v3_ReportTemplateTest extends CiviUnitTestCase { 'fields' => [ 'amount_1' => '1', 'soft_id' => '1', - ], + ], )); $values = $rows['values'][0]; $this->assertEquals(100.00, $values['civicrm_contribution_soft_amount_1_sum'], "Total commited should be $100"); diff --git a/tests/phpunit/api/v3/SettingTest.php b/tests/phpunit/api/v3/SettingTest.php index 3536f25955..aa75cf7115 100644 --- a/tests/phpunit/api/v3/SettingTest.php +++ b/tests/phpunit/api/v3/SettingTest.php @@ -158,7 +158,8 @@ class api_v3_SettingTest extends CiviUnitTestCase { 'is_contact' => 0, 'description' => NULL, 'help_text' => NULL, - 'on_change' => array(// list of callbacks + // list of callbacks + 'on_change' => array( array(__CLASS__, '_testOnChange_onChangeExample'), ), ), @@ -365,10 +366,9 @@ class api_v3_SettingTest extends CiviUnitTestCase { */ public function testGetConfigSetting() { $settings = $this->callAPISuccess('setting', 'get', array( - 'name' => 'defaultCurrency', - 'sequential' => 1, - ) - ); + 'name' => 'defaultCurrency', + 'sequential' => 1, + )); $this->assertEquals('USD', $settings['values'][0]['defaultCurrency']); } @@ -377,20 +377,17 @@ class api_v3_SettingTest extends CiviUnitTestCase { */ public function testGetSetConfigSettingMultipleDomains() { $settings = $this->callAPISuccess('setting', 'create', array( - 'defaultCurrency' => 'USD', - 'domain_id' => $this->_currentDomain, - ) - ); + 'defaultCurrency' => 'USD', + 'domain_id' => $this->_currentDomain, + )); $settings = $this->callAPISuccess('setting', 'create', array( - 'defaultCurrency' => 'CAD', - 'domain_id' => $this->_domainID2, - ) - ); + 'defaultCurrency' => 'CAD', + 'domain_id' => $this->_domainID2, + )); $settings = $this->callAPISuccess('setting', 'get', array( - 'return' => 'defaultCurrency', - 'domain_id' => 'all', - ) - ); + 'return' => 'defaultCurrency', + 'domain_id' => 'all', + )); $this->assertEquals('USD', $settings['values'][$this->_currentDomain]['defaultCurrency']); $this->assertEquals('CAD', $settings['values'][$this->_domainID2]['defaultCurrency'], "second domain (id {$this->_domainID2} ) should be set to CAD. First dom was {$this->_currentDomain} & was USD"); diff --git a/tests/phpunit/api/v3/StatusPreferenceTest.php b/tests/phpunit/api/v3/StatusPreferenceTest.php index 31104eb688..994f12f230 100644 --- a/tests/phpunit/api/v3/StatusPreferenceTest.php +++ b/tests/phpunit/api/v3/StatusPreferenceTest.php @@ -37,7 +37,6 @@ class api_v3_StatusPreferenceTest extends CiviUnitTestCase { protected $_locationType; protected $_params; - public function setUp() { $this->_apiversion = 3; parent::setUp(); diff --git a/tests/phpunit/api/v3/SurveyRespondantTest.php b/tests/phpunit/api/v3/SurveyRespondantTest.php index 04a0a2c08c..60bf07e4c7 100644 --- a/tests/phpunit/api/v3/SurveyRespondantTest.php +++ b/tests/phpunit/api/v3/SurveyRespondantTest.php @@ -33,7 +33,6 @@ class api_v3_SurveyRespondantTest extends CiviUnitTestCase { protected $_apiversion = 3; protected $params; - public function setUp() { parent::setUp(); $this->useTransaction(TRUE); diff --git a/tests/phpunit/api/v3/SurveyTest.php b/tests/phpunit/api/v3/SurveyTest.php index 213de30d0d..9ba7369477 100644 --- a/tests/phpunit/api/v3/SurveyTest.php +++ b/tests/phpunit/api/v3/SurveyTest.php @@ -49,12 +49,11 @@ class api_v3_SurveyTest extends CiviUnitTestCase { protected $entity = 'survey'; public $DBResetRequired = FALSE; - public function setUp() { $phoneBankActivityTypeID = $this->callAPISuccessGetValue('Option_value', array( - 'label' => 'PhoneBank', - 'return' => 'value', - ), 'integer'); + 'label' => 'PhoneBank', + 'return' => 'value', + ), 'integer'); $this->useTransaction(); $this->enableCiviCampaign(); $this->params = array( diff --git a/tests/phpunit/api/v3/SyntaxConformanceTest.php b/tests/phpunit/api/v3/SyntaxConformanceTest.php index e16d1e7e7d..76d31f0015 100644 --- a/tests/phpunit/api/v3/SyntaxConformanceTest.php +++ b/tests/phpunit/api/v3/SyntaxConformanceTest.php @@ -47,6 +47,7 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { /** * This test case doesn't require DB reset. + * @var bool */ public $DBResetRequired = FALSE; @@ -54,8 +55,9 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { /** * Map custom group entities to civicrm components. + * @var array */ - static $componentMap = array( + protected static $componentMap = array( 'Contribution' => 'CiviContribute', 'Membership' => 'CiviMember', 'Participant' => 'CiviEvent', @@ -81,7 +83,8 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { parent::setUp(); $this->enableCiviCampaign(); $this->toBeImplemented['get'] = array( - 'CxnApp', // CxnApp.get exists but relies on remote data outside our control; QA w/UtilsTest::testBasicArrayGet + // CxnApp.get exists but relies on remote data outside our control; QA w/UtilsTest::testBasicArrayGet + 'CxnApp', 'Profile', 'CustomValue', 'Constant', @@ -107,7 +110,8 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { 'User', 'Payment', 'Order', - 'SavedSearch', //work fine in local + //work fine in local + 'SavedSearch', 'Logging', ); $this->toBeImplemented['delete'] = array( @@ -567,12 +571,18 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { */ public static function toBeSkipped_getSqlOperators() { $entitiesWithout = array( - 'Case', //case api has non-std mandatory fields one of (case_id, contact_id, activity_id, contact_id) - 'Contact', // on the todo list! - 'EntityTag', // non-standard api - has inappropriate mandatory fields & doesn't implement limit - 'Extension', // can't handle creating 25 - 'Note', // note has a default get that isn't implemented in createTestObject -meaning you don't 'get' them - 'Setting', //a bit of a pseudoapi - keys by domain + //case api has non-std mandatory fields one of (case_id, contact_id, activity_id, contact_id) + 'Case', + // on the todo list! + 'Contact', + // non-standard api - has inappropriate mandatory fields & doesn't implement limit + 'EntityTag', + // can't handle creating 25 + 'Extension', + // note has a default get that isn't implemented in createTestObject -meaning you don't 'get' them + 'Note', + //a bit of a pseudoapi - keys by domain + 'Setting', ); return $entitiesWithout; } @@ -599,15 +609,18 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { ), 'Address' => array( 'cant_update' => array( - 'state_province_id', //issues with country id - need to ensure same country + //issues with country id - need to ensure same country + 'state_province_id', 'world_region', - 'master_id', //creates relationship + //creates relationship + 'master_id', ), 'cant_return' => ['street_parsing', 'skip_geocode', 'fix_address'], ), 'Batch' => array( 'cant_update' => array( - 'entity_table', // believe this field is defined in error + // believe this field is defined in error + 'entity_table', ), 'cant_return' => array( 'entity_table', @@ -660,9 +673,11 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { 'installments', 'original_installment_amount', 'next_pay_date', - 'amount', // can't be changed through API, + // can't be changed through API, + 'amount', ), - 'break_return' => array(// if these are passed in they are retrieved from the wrong table + // if these are passed in they are retrieved from the wrong table + 'break_return' => array( 'honor_contact_id', 'cancel_date', 'contribution_page_id', @@ -670,8 +685,10 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { 'financial_type_id', 'currency', ), - 'cant_return' => array(// can't be retrieved from api - 'honor_type_id', //due to uniquename missing + // can't be retrieved from api + 'cant_return' => array( + //due to uniquename missing + 'honor_type_id', 'end_date', 'modified_date', 'acknowledge_date', @@ -697,7 +714,8 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { ), 'PriceFieldValue' => array( 'cant_update' => array( - 'weight', //won't update as there is no 1 in the same price set + //won't update as there is no 1 in the same price set + 'weight', ), ), 'ReportInstance' => array( @@ -842,7 +860,8 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { $this->markTestIncomplete('Note can not be processed here because of a vagary in the note api, it adds entity_table=contact to the get params when id is not present - which makes sense almost always but kills this test'); } $this->quickCleanup(array('civicrm_uf_match')); - $this->createLoggedInUser();// so subsidiary activities are created + // so subsidiary activities are created + $this->createLoggedInUser(); $entitiesWithNamingIssues = [ 'SmsProvider' => 'Provider', @@ -946,7 +965,6 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { $this->callAPISuccess($Entity, 'getlist', ['label_field' => 'id']); } - /** * Test getlist works when entity is lowercase * @dataProvider entities_get @@ -1016,7 +1034,8 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { * @param string $entityName */ public function testLimit($entityName) { - $cases = array(); // each case is array(0 => $inputtedApiOptions, 1 => $expectedResultCount) + // each case is array(0 => $inputtedApiOptions, 1 => $expectedResultCount) + $cases = array(); $cases[] = array( array('options' => array('limit' => NULL)), 30, @@ -1218,7 +1237,7 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { /** * @dataProvider toBeSkipped_create - entities that don't need a create action + * entities that don't need a create action * @param $Entity */ public function testNotImplemented_create($Entity) { @@ -1272,7 +1291,8 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { 'id desc' => '_id desc', 'id DESC' => '_id DESC', 'id ASC' => '_id ASC', - 'id asc' => '_id asc'); + 'id asc' => '_id asc', + ); foreach ($tests as $test => $expected) { if (in_array($Entity, $invalidEntitys)) { $this->markTestSkipped('It seems OK for ' . $Entity . ' to skip here as it silently ignores passed in params'); @@ -1406,10 +1426,9 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { } // typecast with array to satisfy changes made in CRM-13160 if ($entityName == 'MembershipType' && in_array($fieldName, array( - 'relationship_type_id', - 'relationship_direction', - )) - ) { + 'relationship_type_id', + 'relationship_direction', + ))) { $entity[$fieldName] = (array) $entity[$fieldName]; } } @@ -1459,10 +1478,10 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { //eg. pdf_format id doesn't ship with any if (isset($specs['pseudoconstant']['optionGroupName'])) { $optionValue = $this->callAPISuccess('option_value', 'create', array( - 'option_group_id' => $specs['pseudoconstant']['optionGroupName'], - 'label' => 'new option value', - 'sequential' => 1, - )); + 'option_group_id' => $specs['pseudoconstant']['optionGroupName'], + 'label' => 'new option value', + 'sequential' => 1, + )); $optionValue = $optionValue['values']; $keyColumn = CRM_Utils_Array::value('keyColumn', $specs['pseudoconstant'], 'value'); $options[$optionValue[0][$keyColumn]] = 'new option value'; @@ -1518,12 +1537,12 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { } $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)); + '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); @@ -1548,7 +1567,7 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { /** * @dataProvider toBeSkipped_delete - entities that don't need a delete action + * entities that don't need a delete action * @param $Entity */ public function testNotImplemented_delete($Entity) { diff --git a/tests/phpunit/api/v3/SystemCheckTest.php b/tests/phpunit/api/v3/SystemCheckTest.php index b17cf6d485..ebd1a3f9fb 100644 --- a/tests/phpunit/api/v3/SystemCheckTest.php +++ b/tests/phpunit/api/v3/SystemCheckTest.php @@ -41,7 +41,6 @@ class api_v3_SystemCheckTest extends CiviUnitTestCase { protected $_locationType; protected $_params; - public function setUp() { $this->_apiversion = 3; parent::setUp(); diff --git a/tests/phpunit/api/v3/TagTest.php b/tests/phpunit/api/v3/TagTest.php index 27aeb873c9..c85d742719 100644 --- a/tests/phpunit/api/v3/TagTest.php +++ b/tests/phpunit/api/v3/TagTest.php @@ -35,6 +35,7 @@ class api_v3_TagTest extends CiviUnitTestCase { protected $_apiversion = 3; /** + * @var array * @ids array of values to be cleaned up in the tear down */ protected $ids = array(); @@ -54,6 +55,7 @@ class api_v3_TagTest extends CiviUnitTestCase { } ///////////////// civicrm_tag_get methods + /** * Test civicrm_tag_get with wrong params. */ @@ -149,6 +151,7 @@ class api_v3_TagTest extends CiviUnitTestCase { $params['used_for'] = 'civicrm_activity'; $this->getAndCheck($params, $result['id'], 'tag', 1, __FUNCTION__ . ' tag updated in line ' . __LINE__); } + ///////////////// civicrm_tag_delete methods /** diff --git a/tests/phpunit/api/v3/TaxContributionPageTest.php b/tests/phpunit/api/v3/TaxContributionPageTest.php index 8c3e704ff1..7ceef97bd6 100644 --- a/tests/phpunit/api/v3/TaxContributionPageTest.php +++ b/tests/phpunit/api/v3/TaxContributionPageTest.php @@ -383,7 +383,8 @@ 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 + // without tax rate i.e Donation + 'financial_type_id' => 1, 'total_amount' => '300', ); $contribution = $this->callAPISuccess('contribution', 'create', $newParams); diff --git a/tests/phpunit/api/v3/UFFieldTest.php b/tests/phpunit/api/v3/UFFieldTest.php index 8e39fa1411..945bc52725 100644 --- a/tests/phpunit/api/v3/UFFieldTest.php +++ b/tests/phpunit/api/v3/UFFieldTest.php @@ -33,7 +33,10 @@ * @group headless */ class api_v3_UFFieldTest extends CiviUnitTestCase { - // ids from the uf_group_test.xml fixture + /** + * ids from the uf_group_test.xml fixture + * @var int + */ protected $_ufGroupId = 11; protected $_ufFieldId; protected $_contactId = 69; diff --git a/tests/phpunit/api/v3/UFGroupTest.php b/tests/phpunit/api/v3/UFGroupTest.php index 8d1ad601f9..fd335b02fa 100644 --- a/tests/phpunit/api/v3/UFGroupTest.php +++ b/tests/phpunit/api/v3/UFGroupTest.php @@ -33,7 +33,10 @@ * @group headless */ class api_v3_UFGroupTest extends CiviUnitTestCase { - // ids from the uf_group_test.xml fixture + /** + * ids from the uf_group_test.xml fixture + * @var int + */ protected $_ufGroupId; protected $_ufFieldId; protected $_contactId; diff --git a/tests/phpunit/api/v3/UFJoinTest.php b/tests/phpunit/api/v3/UFJoinTest.php index ca35606be9..381c5e281e 100644 --- a/tests/phpunit/api/v3/UFJoinTest.php +++ b/tests/phpunit/api/v3/UFJoinTest.php @@ -33,7 +33,10 @@ * @group headless */ class api_v3_UFJoinTest extends CiviUnitTestCase { - // ids from the uf_group_test.xml fixture + /** + * ids from the uf_group_test.xml fixture + * @var int + */ protected $_ufGroupId = 11; protected $_ufFieldId; protected $_contactId = 69; @@ -97,7 +100,6 @@ class api_v3_UFJoinTest extends CiviUnitTestCase { } } - public function testUFJoinEditWrongParamsType() { $params = 'a string'; $result = $this->callAPIFailure('uf_join', 'create', $params); diff --git a/tests/phpunit/api/v3/UFMatchTest.php b/tests/phpunit/api/v3/UFMatchTest.php index 65b937f58a..b7c4ee776a 100644 --- a/tests/phpunit/api/v3/UFMatchTest.php +++ b/tests/phpunit/api/v3/UFMatchTest.php @@ -33,14 +33,16 @@ * @group headless */ class api_v3_UFMatchTest extends CiviUnitTestCase { - // ids from the uf_group_test.xml fixture + /** + * ids from the uf_group_test.xml fixture + * @var int + */ protected $_ufGroupId = 11; protected $_ufFieldId; protected $_contactId; protected $_apiversion; protected $_params = array(); - protected function setUp() { parent::setUp(); $this->_apiversion = 3; diff --git a/tests/phpunit/api/v3/UtilsTest.php b/tests/phpunit/api/v3/UtilsTest.php index 6e13cdde81..9de6307fb0 100644 --- a/tests/phpunit/api/v3/UtilsTest.php +++ b/tests/phpunit/api/v3/UtilsTest.php @@ -324,14 +324,18 @@ class api_v3_UtilsTest extends CiviUnitTestCase { $cases[] = array( $records, - array('version' => 3), // params - array('a', 'b', 'c', 'd', 'e'), // expected results + // params + array('version' => 3), + // expected results + array('a', 'b', 'c', 'd', 'e'), ); $cases[] = array( $records, - array('version' => 3, 'fruit' => 'apple'), // params - array('a', 'c', 'd', 'e'), // expected results + // params + array('version' => 3, 'fruit' => 'apple'), + // expected results + array('a', 'c', 'd', 'e'), ); $cases[] = array( diff --git a/tests/phpunit/api/v3/ValidateTest.php b/tests/phpunit/api/v3/ValidateTest.php index fc0ed1e806..0a25ac6c40 100644 --- a/tests/phpunit/api/v3/ValidateTest.php +++ b/tests/phpunit/api/v3/ValidateTest.php @@ -32,6 +32,7 @@ * @group headless */ class api_v3_ValidateTest extends CiviUnitTestCase { + /** * This method is called before a test is executed. */ diff --git a/tests/phpunit/api/v3/custom_api/MailingProviderData.php b/tests/phpunit/api/v3/custom_api/MailingProviderData.php index 26c2838d45..f01bf6ec98 100644 --- a/tests/phpunit/api/v3/custom_api/MailingProviderData.php +++ b/tests/phpunit/api/v3/custom_api/MailingProviderData.php @@ -43,13 +43,13 @@ class CRM_Omnimail_DAO_MailingProviderData extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_mailing_provider_data'; + protected static $_tableName = 'civicrm_mailing_provider_data'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var boolean */ - static $_log = FALSE; + protected static $_log = FALSE; /** * External reference for the contact * @@ -100,6 +100,7 @@ class CRM_Omnimail_DAO_MailingProviderData extends CRM_Core_DAO { $this->__table = 'civicrm_mailing_provider_data'; parent::__construct(); } + /** * Returns all the column names of this table * @@ -165,7 +166,7 @@ class CRM_Omnimail_DAO_MailingProviderData extends CRM_Core_DAO { 'entity' => 'MailingProviderData', 'bao' => 'CRM_Omnimail_DAO_MailingProviderData', 'localizable' => 0, - ) , + ), 'contact_id' => array( 'name' => 'contact_id', 'type' => CRM_Utils_Type::T_INT, @@ -189,6 +190,7 @@ class CRM_Omnimail_DAO_MailingProviderData extends CRM_Core_DAO { } return Civi::$statics[__CLASS__]['fields']; } + /** * Return a mapping from field-name to the corresponding key (as used in fields()). * @@ -201,6 +203,7 @@ class CRM_Omnimail_DAO_MailingProviderData extends CRM_Core_DAO { } return Civi::$statics[__CLASS__]['fieldKeys']; } + /** * Returns the names of this table * @@ -209,6 +212,7 @@ class CRM_Omnimail_DAO_MailingProviderData extends CRM_Core_DAO { public static function getTableName() { return self::$_tableName; } + /** * Returns if this table needs to be logged * @@ -217,6 +221,7 @@ class CRM_Omnimail_DAO_MailingProviderData extends CRM_Core_DAO { public function getLog() { return self::$_log; } + /** * Returns the list of fields that can be imported * @@ -228,6 +233,7 @@ class CRM_Omnimail_DAO_MailingProviderData extends CRM_Core_DAO { $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'mailing_provider_data', $prefix, array()); return $r; } + /** * Returns the list of fields that can be exported * @@ -239,6 +245,7 @@ class CRM_Omnimail_DAO_MailingProviderData extends CRM_Core_DAO { $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'mailing_provider_data', $prefix, array()); return $r; } + /** * Returns the list of indices */ diff --git a/tests/qunit/crm-translate/test.php b/tests/qunit/crm-translate/test.php index ddf4723b90..8090b119e2 100644 --- a/tests/qunit/crm-translate/test.php +++ b/tests/qunit/crm-translate/test.php @@ -1,14 +1,13 @@ addSetting(array( - 'strings' => array( - 'One, two, three' => 'Un, deux, trois', - 'I know' => 'Je sais', - ), - 'strings::org.example.foo' => array( - 'I know' => 'Je connais', - ), - ) -); + 'strings' => array( + 'One, two, three' => 'Un, deux, trois', + 'I know' => 'Je sais', + ), + 'strings::org.example.foo' => array( + 'I know' => 'Je connais', + ), +)); // CRM_Core_Resources::singleton()->addScriptFile(...); // CRM_Core_Resources::singleton()->addStyleFile(...); // CRM_Core_Resources::singleton()->addSetting(...); -- 2.25.1