From b9466f097f2f25418a80d4e803dcce73f71dafc1 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Fri, 29 Oct 2021 12:04:46 +1300 Subject: [PATCH] [NFC] [Tests] remove code smell - unnecessary double quotes This is an IDE cleanup. It touches a few files but 1) only test files and 2) only that specific change, made via an IDE is in here So I think it should be possible to merge based on test outcome --- .../CRM/Contribute/BAO/ContributionTest.php | 38 ++-- .../CRM/Contribute/Form/ContributionTest.php | 178 +++++++++--------- .../Import/Parser/ContributionTest.php | 14 +- .../CRM/Core/BAO/ActionScheduleTest.php | 2 +- .../CRM/Core/Resources/StringsTest.php | 4 +- tests/phpunit/CRM/Core/TransactionTest.php | 2 +- .../CRM/Utils/TokenConsistencyTest.php | 8 +- .../ActionSchedule/AbstractMappingTest.php | 2 +- .../phpunit/Civi/Token/TokenProcessorTest.php | 2 +- tests/phpunit/api/v3/ActionScheduleTest.php | 4 +- tests/phpunit/api/v3/ActivityCaseTest.php | 2 +- tests/phpunit/api/v3/ContributionTest.php | 30 +-- tests/phpunit/api/v3/UFFieldTest.php | 2 +- .../api/v4/Entity/WorkflowMessageTest.php | 4 +- 14 files changed, 146 insertions(+), 146 deletions(-) diff --git a/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php b/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php index e32f8620b1..8cad0ad89f 100644 --- a/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php +++ b/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php @@ -376,7 +376,7 @@ class CRM_Contribute_BAO_ContributionTest extends CiviUnitTestCase { if ($entity != 'Contribution') { return; } - $clauses['id'] = "NOT IN (0)"; + $clauses['id'] = 'NOT IN (0)'; } /** @@ -1172,8 +1172,8 @@ WHERE eft.entity_id = %1 AND ft.to_financial_account_id <> %2"; $originalContactId = $contactID = $this->individualCreate(); $orgId = $this->organizationCreate(['organization_name' => 'testorg1']); $orgCount = $this->callAPISuccessGetCount('Contact', [ - 'contact_type' => "Organization", - 'organization_name' => "testorg1", + 'contact_type' => 'Organization', + 'organization_name' => 'testorg1', ]); $this->assertEquals($orgCount, 1); @@ -1219,8 +1219,8 @@ WHERE eft.entity_id = %1 AND ft.to_financial_account_id <> %2"; //Check whether new organisation is created. $result = $this->callAPISuccess('Contact', 'get', [ - 'contact_type' => "Organization", - 'organization_name' => "testorg1", + 'contact_type' => 'Organization', + 'organization_name' => 'testorg1', ]); $this->assertEquals($result['count'], 1); @@ -1297,7 +1297,7 @@ WHERE eft.entity_id = %1 AND ft.to_financial_account_id <> %2"; TRUE ); - $this->assertEquals('Contribution Amount: € 100.00', $contributionDetails[$contactId1]['text'], "The text does not match"); + $this->assertEquals('Contribution Amount: € 100.00', $contributionDetails[$contactId1]['text'], 'The text does not match'); $this->assertEquals('

Contribution Source: ABC


Contribution Invoice ID: 12345


Contribution Receive Date: May 11th, 2015 12:00 AM


@@ -1320,12 +1320,12 @@ WHERE eft.entity_id = %1 AND ft.to_financial_account_id <> %2"; 'invoice_id' => 67890, 'source' => 'SSF', 'contribution_status_id' => 'Completed', - 'revenue_recognition_date' => date('Ymd', strtotime("+3 month")), + 'revenue_recognition_date' => date('Ymd', strtotime('+3 month')), ]; $contribution = $this->callAPISuccess('contribution', 'create', $params); $this->callAPISuccessGetCount('EntityFinancialTrxn', [ - 'entity_table' => "civicrm_contribution", + 'entity_table' => 'civicrm_contribution', 'entity_id' => $contribution['id'], ], 2); @@ -1336,17 +1336,17 @@ WHERE eft.entity_id = %1 AND ft.to_financial_account_id <> %2"; ]; $result = $this->callAPISuccessGetSingle('EntityFinancialTrxn', [ 'return' => [ - "financial_trxn_id.from_financial_account_id.name", - "financial_trxn_id.to_financial_account_id.name", - "financial_trxn_id", + 'financial_trxn_id.from_financial_account_id.name', + 'financial_trxn_id.to_financial_account_id.name', + 'financial_trxn_id', ], - 'entity_table' => "civicrm_contribution", + 'entity_table' => 'civicrm_contribution', 'entity_id' => $contribution['id'], 'financial_trxn_id.is_payment' => 0, ], $checkAgainst); $result = $this->callAPISuccessGetSingle('EntityFinancialTrxn', [ - 'entity_table' => "civicrm_financial_item", + 'entity_table' => 'civicrm_financial_item', 'financial_trxn_id' => $result['financial_trxn_id'], 'return' => ['entity_id'], ]); @@ -1357,7 +1357,7 @@ WHERE eft.entity_id = %1 AND ft.to_financial_account_id <> %2"; ]; $result = $this->callAPISuccessGetSingle('FinancialItem', [ 'id' => $result['entity_id'], - 'return' => ["financial_account_id.name"], + 'return' => ['financial_account_id.name'], ], $checkAgainst); } @@ -1391,7 +1391,7 @@ WHERE eft.entity_id = %1 AND ft.to_financial_account_id <> %2"; // Get line item $lineItem = $this->callAPISuccessGetSingle('LineItem', [ 'contribution_id' => $contributionId, - 'return' => ["financial_type_id.name", "line_total"], + 'return' => ['financial_type_id.name', 'line_total'], ]); $this->assertEquals( @@ -1411,8 +1411,8 @@ WHERE eft.entity_id = %1 AND ft.to_financial_account_id <> %2"; 'entity_id' => $lineItem['id'], 'sequential' => 1, 'entity_table' => 'civicrm_line_item', - 'options' => ['sort' => "id"], - 'return' => ["financial_account_id.name", "amount", "description"], + 'options' => ['sort' => 'id'], + 'return' => ['financial_account_id.name', 'amount', 'description'], ]); $this->assertEquals($financialItems['count'], 3, 'Count mismatch.'); @@ -1443,8 +1443,8 @@ WHERE eft.entity_id = %1 AND ft.to_financial_account_id <> %2"; // Check transactions. $financialTransactions = $this->callAPISuccess('EntityFinancialTrxn', 'get', [ - 'return' => ["financial_trxn_id"], - 'entity_table' => "civicrm_contribution", + 'return' => ['financial_trxn_id'], + 'entity_table' => 'civicrm_contribution', 'entity_id' => $contributionId, 'sequential' => 1, ]); diff --git a/tests/phpunit/CRM/Contribute/Form/ContributionTest.php b/tests/phpunit/CRM/Contribute/Form/ContributionTest.php index 58068dc673..f9f6bce903 100644 --- a/tests/phpunit/CRM/Contribute/Form/ContributionTest.php +++ b/tests/phpunit/CRM/Contribute/Form/ContributionTest.php @@ -1515,45 +1515,45 @@ Price Field - Price Field 1 1 $ 100.00 $ 100.00 'group_type' => 'Membership,Individual', 'title' => 'Membership Custom Fields', 'add_captcha' => 0, - 'is_map' => "0", - "is_edit_link" => "0", - "is_uf_link" => "0", - "is_update_dupe" => "0", + 'is_map' => '0', + 'is_edit_link' => '0', + 'is_uf_link' => '0', + 'is_update_dupe' => '0', ]); // add custom fields to profile civicrm_api3('UFField', 'create', [ - "uf_group_id" => $membershipCustomFieldsProfile['id'], - "field_name" => "custom_" . $membershipCustomField['id'], - "is_active" => "1", - "visibility" => "User and User Admin Only", - "in_selector" => "0", - "is_searchable" => "0", - "label" => "custom text field on membership", - "field_type" => "Membership", + 'uf_group_id' => $membershipCustomFieldsProfile['id'], + 'field_name' => 'custom_' . $membershipCustomField['id'], + 'is_active' => '1', + 'visibility' => 'User and User Admin Only', + 'in_selector' => '0', + 'is_searchable' => '0', + 'label' => 'custom text field on membership', + 'field_type' => 'Membership', ]); $contribPage = civicrm_api3('ContributionPage', 'create', [ - "title" => "Membership", - "financial_type_id" => 1, + 'title' => 'Membership', + 'financial_type_id' => 1, 'financial_account_id' => 1, - "is_credit_card_only" => "0", - "is_monetary" => "0", - "is_recur" => "0", - "is_confirm_enabled" => "1", - "is_recur_interval" => "0", - "is_recur_installments" => "0", - "adjust_recur_start_date" => "0", - "is_pay_later" => "1", - "pay_later_text" => "I will send payment by check", - "is_partial_payment" => "0", - "is_email_receipt" => "0", - "is_active" => "1", - "amount_block_is_active" => "0", - "currency" => "USD", - "is_share" => "0", - "is_billing_required" => "0", - "contribution_type_id" => "2", + 'is_credit_card_only' => '0', + 'is_monetary' => '0', + 'is_recur' => '0', + 'is_confirm_enabled' => '1', + 'is_recur_interval' => '0', + 'is_recur_installments' => '0', + 'adjust_recur_start_date' => '0', + 'is_pay_later' => '1', + 'pay_later_text' => 'I will send payment by check', + 'is_partial_payment' => '0', + 'is_email_receipt' => '0', + 'is_active' => '1', + 'amount_block_is_active' => '0', + 'currency' => 'USD', + 'is_share' => '0', + 'is_billing_required' => '0', + 'contribution_type_id' => '2', 'is_allow_other_amount' => 1, 'min_amount' => 10, 'max_amount' => 1000, @@ -1562,78 +1562,78 @@ Price Field - Price Field 1 1 $ 100.00 $ 100.00 //create price set with two options for the two different memberships $priceSet = civicrm_api3('PriceSet', 'create', [ - 'title' => "Two Membership Type Checkbox", + 'title' => 'Two Membership Type Checkbox', 'extends' => 'CiviMember', 'is_active' => 1, - "financial_type_id" => "1", + 'financial_type_id' => '1', ]); CRM_Core_DAO::executeQuery("INSERT INTO civicrm_price_set_entity (entity_table, entity_id, price_set_id) VALUES('civicrm_contribution_page', $contribPage1, {$priceSet['id']})"); $priceField = civicrm_api3('PriceField', 'create', [ 'price_set_id' => $priceSet['id'], 'name' => 'mt', - "label" => "Membership Types", - "html_type" => "CheckBox", - "is_enter_qty" => "0", - "weight" => "1", - "is_display_amounts" => "1", - "options_per_line" => "1", - "is_active" => "1", - "is_required" => "0", - "visibility_id" => "1", + 'label' => 'Membership Types', + 'html_type' => 'CheckBox', + 'is_enter_qty' => '0', + 'weight' => '1', + 'is_display_amounts' => '1', + 'options_per_line' => '1', + 'is_active' => '1', + 'is_required' => '0', + 'visibility_id' => '1', ]); $priceFieldOption1 = civicrm_api3('PriceFieldValue', 'create', [ - "price_field_id" => $priceField['id'], - "name" => "membership_type_one", - "label" => "Membership Type One", - "amount" => "50", - "weight" => "1", - "membership_type_id" => $membershipTypeOne['id'], - "membership_num_terms" => "1", - "is_default" => "0", - "is_active" => "1", - "financial_type_id" => "1", - "non_deductible_amount" => "0.00", - "contribution_type_id" => "2", + 'price_field_id' => $priceField['id'], + 'name' => 'membership_type_one', + 'label' => 'Membership Type One', + 'amount' => '50', + 'weight' => '1', + 'membership_type_id' => $membershipTypeOne['id'], + 'membership_num_terms' => '1', + 'is_default' => '0', + 'is_active' => '1', + 'financial_type_id' => '1', + 'non_deductible_amount' => '0.00', + 'contribution_type_id' => '2', ]); $priceFieldOption2 = civicrm_api3('PriceFieldValue', 'create', [ - "price_field_id" => $priceField['id'], - "name" => "membership_type_two", - "label" => "Membership Type Two", - "amount" => "50", - "weight" => "1", - "membership_type_id" => $membershipTypeTwo['id'], - "membership_num_terms" => "1", - "is_default" => "0", - "is_active" => "1", - "financial_type_id" => "1", - "non_deductible_amount" => "0.00", - "contribution_type_id" => "2", + 'price_field_id' => $priceField['id'], + 'name' => 'membership_type_two', + 'label' => 'Membership Type Two', + 'amount' => '50', + 'weight' => '1', + 'membership_type_id' => $membershipTypeTwo['id'], + 'membership_num_terms' => '1', + 'is_default' => '0', + 'is_active' => '1', + 'financial_type_id' => '1', + 'non_deductible_amount' => '0.00', + 'contribution_type_id' => '2', ]); // assign profile with custom fields to contribution page civicrm_api3('UFJoin', 'create', [ - 'module' => "CiviContribute", - 'weight' => "1", + 'module' => 'CiviContribute', + 'weight' => '1', 'uf_group_id' => $membershipCustomFieldsProfile['id'], - "entity_table" => "civicrm_contribution_page", - "entity_id" => $contribPage1, + 'entity_table' => 'civicrm_contribution_page', + 'entity_id' => $contribPage1, ]); $form = new CRM_Contribute_Form_Contribution_Confirm(); $form->_params = [ 'id' => $contribPage1, - 'qfKey' => "donotcare", - "custom_{$membershipCustomField['id']}" => "Hello", - "priceSetId" => $priceSet['id'], + 'qfKey' => 'donotcare', + "custom_{$membershipCustomField['id']}" => 'Hello', + 'priceSetId' => $priceSet['id'], 'price_set_id' => $priceSet['id'], - "price_" . $priceField['id'] => [$priceFieldOption1['id'] => 1, $priceFieldOption2['id'] => 1], - 'invoiceID' => "9a6f7b49358dc31c3604e463b225c5be", - 'email' => "admin@example.com", - "currencyID" => "USD", - 'description' => "Membership Contribution", + 'price_' . $priceField['id'] => [$priceFieldOption1['id'] => 1, $priceFieldOption2['id'] => 1], + 'invoiceID' => '9a6f7b49358dc31c3604e463b225c5be', + 'email' => 'admin@example.com', + 'currencyID' => 'USD', + 'description' => 'Membership Contribution', 'contact_id' => $contactID, 'skipLineItem' => 0, 'email-5' => 'test@test.com', @@ -1647,13 +1647,13 @@ Price Field - Price Field 1 1 $ 100.00 $ 100.00 'contact_id' => $contactID, 'membership_type_id' => $membershipTypeOne['id'], ]); - $this->assertEquals("Hello", $membership1["custom_{$membershipCustomField['id']}"]); + $this->assertEquals('Hello', $membership1["custom_{$membershipCustomField['id']}"]); $membership2 = civicrm_api3('Membership', 'getsingle', [ 'contact_id' => $contactID, 'membership_type_id' => $membershipTypeTwo['id'], ]); - $this->assertEquals("Hello", $membership2["custom_{$membershipCustomField['id']}"]); + $this->assertEquals('Hello', $membership2["custom_{$membershipCustomField['id']}"]); } /** @@ -1667,14 +1667,14 @@ Price Field - Price Field 1 1 $ 100.00 $ 100.00 $form->controller = new CRM_Core_Controller(); $form->_params = [ 'id' => $this->_ids['contribution_page'], - "qfKey" => "donotcare", - "priceSetId" => $this->_ids['price_set'], + 'qfKey' => 'donotcare', + 'priceSetId' => $this->_ids['price_set'], 'price_set_id' => $this->_ids['price_set'], - "price_" . $this->_ids['price_field'][0] => $this->_ids['price_field_value']['cont'], - "invoiceID" => "9a6f7b49358dc31c3604e463b225c5be", - "email" => "admin@example.com", - "currencyID" => "USD", - 'description' => "Membership Contribution", + 'price_' . $this->_ids['price_field'][0] => $this->_ids['price_field_value']['cont'], + 'invoiceID' => '9a6f7b49358dc31c3604e463b225c5be', + 'email' => 'admin@example.com', + 'currencyID' => 'USD', + 'description' => 'Membership Contribution', 'contact_id' => $contactID, 'select_contact_id' => $contactID, 'useForMember' => 1, @@ -1698,7 +1698,7 @@ Price Field - Price Field 1 1 $ 100.00 $ 100.00 //Choose Membership Priceset $form->_params["price_{$this->_ids['price_field'][0]}"] = $this->_ids['price_field_value'][0]; - $form->_params["amount"] = 20; + $form->_params['amount'] = 20; $form->submit($form->_params); $contribution = $this->callAPISuccessGetSingle('Contribution', [ @@ -1765,7 +1765,7 @@ Price Field - Price Field 1 1 $ 100.00 $ 100.00 // The page contents load later by ajax, so there's just the surrounding // html available now, but we can check at least one thing while we're here. - $this->assertStringContainsString("mainTabContainer", $contents); + $this->assertStringContainsString('mainTabContainer', $contents); } /** diff --git a/tests/phpunit/CRM/Contribute/Import/Parser/ContributionTest.php b/tests/phpunit/CRM/Contribute/Import/Parser/ContributionTest.php index 009bb8a48f..4121cbfb94 100644 --- a/tests/phpunit/CRM/Contribute/Import/Parser/ContributionTest.php +++ b/tests/phpunit/CRM/Contribute/Import/Parser/ContributionTest.php @@ -56,13 +56,13 @@ class CRM_Contribute_Import_Parser_ContributionTest extends CiviUnitTestCase { $contact1Id = $this->individualCreate($contact1Params); $contact2Id = $this->individualCreate($contact2Params); $values = [ - "total_amount" => $this->formatMoneyInput(1230.99), - "financial_type" => "Donation", - "external_identifier" => "ext-1", - "soft_credit" => "ext-2", + 'total_amount' => $this->formatMoneyInput(1230.99), + 'financial_type' => 'Donation', + 'external_identifier' => 'ext-1', + 'soft_credit' => 'ext-2', ]; - $mapperSoftCredit = [NULL, NULL, NULL, "external_identifier"]; - $mapperSoftCreditType = [NULL, NULL, NULL, "1"]; + $mapperSoftCredit = [NULL, NULL, NULL, 'external_identifier']; + $mapperSoftCreditType = [NULL, NULL, NULL, '1']; $this->runImport($values, CRM_Import_Parser::DUPLICATE_UPDATE, CRM_Contribute_Import_Parser::SOFT_CREDIT, $mapperSoftCredit, NULL, $mapperSoftCreditType); $params = ['contact_id' => $contact1Id]; $values = []; @@ -71,7 +71,7 @@ class CRM_Contribute_Import_Parser_ContributionTest extends CiviUnitTestCase { $this->assertEquals(1230.99, $contributionsOfMainContact->net_amount); $this->assertEquals(0, $contributionsOfMainContact->fee_amount); - $params["contact_id"] = $contact2Id; + $params['contact_id'] = $contact2Id; $contributionsOfSoftContact = CRM_Contribute_BAO_ContributionSoft::retrieve($params, $values); $this->assertEquals(1, $contributionsOfMainContact->N, 'Contribution not added for primary contact'); $this->assertEquals(1, $contributionsOfSoftContact->N, 'Soft Contribution not added for secondary contact'); diff --git a/tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php b/tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php index 7d9b2a4d89..71efdb46f8 100644 --- a/tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php +++ b/tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php @@ -998,7 +998,7 @@ class CRM_Core_BAO_ActionScheduleTest extends CiviUnitTestCase { 'subject' => 'Phone call', 'details' => 'A phone call about a bear', ]; - $activityTokensExpected = "Phone call;;A phone call about a bear;;June 15th, 2012 10:00 AM"; + $activityTokensExpected = 'Phone call;;A phone call about a bear;;June 15th, 2012 10:00 AM'; $cases[4] = [ // Schedule definition. [ diff --git a/tests/phpunit/CRM/Core/Resources/StringsTest.php b/tests/phpunit/CRM/Core/Resources/StringsTest.php index 0e68f718e0..0ff41ebf6b 100644 --- a/tests/phpunit/CRM/Core/Resources/StringsTest.php +++ b/tests/phpunit/CRM/Core/Resources/StringsTest.php @@ -26,11 +26,11 @@ class CRM_Core_Resources_StringsTest extends CiviUnitTestCase { ); $this->assertEquals( ['Hello from Javascript'], - $strings->get('example', "$basedir/hello.js", "text/javascript") + $strings->get('example', "$basedir/hello.js", 'text/javascript') ); $this->assertEquals( ['Hello from HTML'], - $strings->get('example', "$basedir/hello.html", "text/html") + $strings->get('example', "$basedir/hello.html", 'text/html') ); } diff --git a/tests/phpunit/CRM/Core/TransactionTest.php b/tests/phpunit/CRM/Core/TransactionTest.php index de41e640c3..f23f0cbe6b 100644 --- a/tests/phpunit/CRM/Core/TransactionTest.php +++ b/tests/phpunit/CRM/Core/TransactionTest.php @@ -305,7 +305,7 @@ class CRM_Core_TransactionTest extends CiviUnitTestCase { CRM_Core_Transaction::create(TRUE)->run(function ($tx) use (&$test, $createStyle, $commitStyle) { $test->createContactWithTransaction('nest-tx', $createStyle, $commitStyle); $test->assertContactsExistByOffset([0 => TRUE]); - throw new Exception("Ruh-roh"); + throw new Exception('Ruh-roh'); }); } catch (Exception $ex) { diff --git a/tests/phpunit/CRM/Utils/TokenConsistencyTest.php b/tests/phpunit/CRM/Utils/TokenConsistencyTest.php index a3169345fd..672af5d059 100644 --- a/tests/phpunit/CRM/Utils/TokenConsistencyTest.php +++ b/tests/phpunit/CRM/Utils/TokenConsistencyTest.php @@ -976,16 +976,16 @@ December 21st, 2007 // The `first_name` does not allow HTML. Any funny characters are presented like literal text. $messages['contact_text'] = 'Hello {contact.first_name}!'; - $expected['contact_text'] = "Hello igilly brackets!"; + $expected['contact_text'] = 'Hello igilly brackets!'; - $messages['contact_html'] = "

Hello {contact.first_name}!

"; - $expected['contact_html'] = "

Hello <b>ig</b>illy brackets!

"; + $messages['contact_html'] = '

Hello {contact.first_name}!

'; + $expected['contact_html'] = '

Hello <b>ig</b>illy brackets!

'; // The `description` does allow HTML. Any funny characters are filtered out of text. $messages['event_text'] = 'You signed up for this event: {event.title}: {event.description}'; $expected['event_text'] = 'You signed up for this event: The Webinar: Some online webinar thingy. Attendees will need to install the TeleFoo app.'; - $messages['event_html'] = "

You signed up for this event:

{event.title}

{event.description}"; + $messages['event_html'] = '

You signed up for this event:

{event.title}

{event.description}'; $expected['event_html'] = '

You signed up for this event:

The Webinar

Some online webinar thingy.

Attendees will need to install the TeleFoo app.

'; $rendered = CRM_Core_TokenSmarty::render($messages, $context); diff --git a/tests/phpunit/Civi/ActionSchedule/AbstractMappingTest.php b/tests/phpunit/Civi/ActionSchedule/AbstractMappingTest.php index dc9bbf1b7b..3b803422a1 100644 --- a/tests/phpunit/Civi/ActionSchedule/AbstractMappingTest.php +++ b/tests/phpunit/Civi/ActionSchedule/AbstractMappingTest.php @@ -298,7 +298,7 @@ abstract class AbstractMappingTest extends \CiviUnitTestCase { } } - $errorText = "Incorrect messages: " . print_r([ + $errorText = 'Incorrect messages: ' . print_r([ 'actualMessages' => $actualMessages, 'expectMessages' => $expectMessages, ], 1); diff --git a/tests/phpunit/Civi/Token/TokenProcessorTest.php b/tests/phpunit/Civi/Token/TokenProcessorTest.php index a9eec679dc..f6409adbc6 100644 --- a/tests/phpunit/Civi/Token/TokenProcessorTest.php +++ b/tests/phpunit/Civi/Token/TokenProcessorTest.php @@ -366,7 +366,7 @@ class TokenProcessorTest extends \CiviUnitTestCase { foreach ($e->getRows() as $row) { /** @var TokenRow $row */ $row->format('text/html'); - $row->tokens['custom']['foobar'] = sprintf("#%04d is a good number. Trickster {contact.display_name}.", $row->context['contact_id']); + $row->tokens['custom']['foobar'] = sprintf('#%04d is a good number. Trickster {contact.display_name}.', $row->context['contact_id']); } } diff --git a/tests/phpunit/api/v3/ActionScheduleTest.php b/tests/phpunit/api/v3/ActionScheduleTest.php index 28abe07070..860d9cccbe 100644 --- a/tests/phpunit/api/v3/ActionScheduleTest.php +++ b/tests/phpunit/api/v3/ActionScheduleTest.php @@ -54,7 +54,7 @@ class api_v3_ActionScheduleTest extends CiviUnitTestCase { $oldCount = CRM_Core_DAO::singleValueQuery('select count(*) from civicrm_action_schedule'); $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); - $title = "simpleActionSchedule" . substr(sha1(rand()), 0, 7); + $title = 'simpleActionSchedule' . substr(sha1(rand()), 0, 7); $params = [ 'title' => $title, 'recipient' => $assigneeID, @@ -97,7 +97,7 @@ class api_v3_ActionScheduleTest extends CiviUnitTestCase { $oldCount = CRM_Core_DAO::singleValueQuery('select count(*) from civicrm_action_schedule'); $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); - $title = "simpleActionSchedule" . substr(sha1(rand()), 0, 7); + $title = 'simpleActionSchedule' . substr(sha1(rand()), 0, 7); $params = [ 'title' => $title, 'recipient' => $assigneeID, diff --git a/tests/phpunit/api/v3/ActivityCaseTest.php b/tests/phpunit/api/v3/ActivityCaseTest.php index 81a9b4b42d..98243164e6 100644 --- a/tests/phpunit/api/v3/ActivityCaseTest.php +++ b/tests/phpunit/api/v3/ActivityCaseTest.php @@ -65,7 +65,7 @@ class api_v3_ActivityCaseTest extends CiviCaseTestCase { 'activity_type_id' => 'Phone Call', 'subject' => $subject, ]); - $case = $this->callAPISuccessGetSingle('Activity', ['return' => ["case_id"], 'id' => $activity['id']]); + $case = $this->callAPISuccessGetSingle('Activity', ['return' => ['case_id'], 'id' => $activity['id']]); //Check if case id is present for the activity. $this->assertEquals($this->_case['id'], $case['case_id'][0]); } diff --git a/tests/phpunit/api/v3/ContributionTest.php b/tests/phpunit/api/v3/ContributionTest.php index ece83491bd..0fc48fdca9 100644 --- a/tests/phpunit/api/v3/ContributionTest.php +++ b/tests/phpunit/api/v3/ContributionTest.php @@ -347,7 +347,7 @@ class api_v3_ContributionTest extends CiviUnitTestCase { if ($returnField === 'contribution_contact_id') { $returnField = 'contact_id'; } - $this->assertTrue((!empty($contribution[$returnField]) || $contribution[$returnField] === "0"), $returnField); + $this->assertTrue((!empty($contribution[$returnField]) || $contribution[$returnField] === '0'), $returnField); } $entityFinancialTrxn = $this->callAPISuccess('EntityFinancialTrxn', 'get', [ 'entity_id' => $contributionID, @@ -485,7 +485,7 @@ class api_v3_ContributionTest extends CiviUnitTestCase { $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, __FILE__); $params = $this->_params; - $params['custom_' . $ids['custom_field_id']] = "custom string"; + $params['custom_' . $ids['custom_field_id']] = 'custom string'; $result = $this->callAPIAndDocument($this->entity, 'create', $params, __FUNCTION__, __FILE__); $this->assertEquals($result['id'], $result['values'][$result['id']]['id']); @@ -1019,8 +1019,8 @@ class api_v3_ContributionTest extends CiviUnitTestCase { * This is the test for creating soft credits. */ public function testCreateContributionWithSoftCredit() { - $description = "Demonstrates creating contribution with SoftCredit."; - $subfile = "ContributionCreateWithSoftCredit"; + $description = 'Demonstrates creating contribution with SoftCredit.'; + $subfile = 'ContributionCreateWithSoftCredit'; $contact2 = $this->callAPISuccess('Contact', 'create', [ 'display_name' => 'superman', 'contact_type' => 'Individual', @@ -1044,8 +1044,8 @@ class api_v3_ContributionTest extends CiviUnitTestCase { } public function testCreateContributionWithSoftCreditDefaults() { - $description = "Demonstrates creating contribution with Soft Credit defaults for amount and type."; - $subfile = "ContributionCreateWithSoftCreditDefaults"; + $description = 'Demonstrates creating contribution with Soft Credit defaults for amount and type.'; + $subfile = 'ContributionCreateWithSoftCreditDefaults'; $contact2 = $this->callAPISuccess('Contact', 'create', [ 'display_name' => 'superman', 'contact_type' => 'Individual', @@ -1059,7 +1059,7 @@ class api_v3_ContributionTest extends CiviUnitTestCase { $this->assertEquals($contact2['id'], $result['values'][0]['soft_credit'][1]['contact_id']); // Default soft credit amount = contribution.total_amount $this->assertEquals($this->_params['total_amount'], $result['values'][0]['soft_credit'][1]['amount']); - $this->assertEquals(CRM_Core_OptionGroup::getDefaultValue("soft_credit_type"), $result['values'][0]['soft_credit'][1]['soft_credit_type']); + $this->assertEquals(CRM_Core_OptionGroup::getDefaultValue('soft_credit_type'), $result['values'][0]['soft_credit'][1]['soft_credit_type']); $this->callAPISuccess('contribution', 'delete', ['id' => $contribution['id']]); $this->callAPISuccess('contact', 'delete', ['id' => $contact2['id']]); @@ -1069,8 +1069,8 @@ class api_v3_ContributionTest extends CiviUnitTestCase { * Test creating contribution with Soft Credit by passing in honor_contact_id. */ public function testCreateContributionWithHonoreeContact() { - $description = "Demonstrates creating contribution with Soft Credit by passing in honor_contact_id."; - $subfile = "ContributionCreateWithHonoreeContact"; + $description = 'Demonstrates creating contribution with Soft Credit by passing in honor_contact_id.'; + $subfile = 'ContributionCreateWithHonoreeContact'; $contact2 = $this->callAPISuccess('Contact', 'create', [ 'display_name' => 'superman', 'contact_type' => 'Individual', @@ -2645,8 +2645,8 @@ class api_v3_ContributionTest extends CiviUnitTestCase { */ public function contributionStatusProvider() { $contributionStatuses = civicrm_api3('OptionValue', 'get', [ - 'return' => ["id", "name"], - 'option_group_id' => "contribution_status", + 'return' => ['id', 'name'], + 'option_group_id' => 'contribution_status', ]); foreach ($contributionStatuses['values'] as $statusName) { $statuses[] = [$statusName]; @@ -3198,7 +3198,7 @@ class api_v3_ContributionTest extends CiviUnitTestCase { $contributionPage = $this->callAPISuccess('ContributionPage', 'create', [ 'receipt_from_name' => 'Mickey Mouse', 'receipt_from_email' => 'mickey@mouse.com', - 'title' => "Test Contribution Page", + 'title' => 'Test Contribution Page', 'financial_type_id' => 1, 'currency' => 'NZD', 'goal_amount' => 50, @@ -3719,7 +3719,7 @@ class api_v3_ContributionTest extends CiviUnitTestCase { // Need to figure out how to stop this some other day // We don't care about the Payment Processor because this is Pay Later // The point of this test is to check we get the pay_later version of the mail - if ($e->getMessage() !== "Undefined variable: CRM16923AnUnreliableMethodHasBeenUserToDeterminePaymentProcessorFromContributionPage") { + if ($e->getMessage() !== 'Undefined variable: CRM16923AnUnreliableMethodHasBeenUserToDeterminePaymentProcessorFromContributionPage') { throw $e; } } @@ -4598,7 +4598,7 @@ class api_v3_ContributionTest extends CiviUnitTestCase { $contributionPage = $this->callAPISuccess('ContributionPage', 'create', array_merge([ 'receipt_from_name' => 'Mickey Mouse', 'receipt_from_email' => 'mickey@mouse.com', - 'title' => "Test Contribution Page", + 'title' => 'Test Contribution Page', 'financial_type_id' => 1, 'currency' => 'CAD', 'is_monetary' => TRUE, @@ -4747,7 +4747,7 @@ class api_v3_ContributionTest extends CiviUnitTestCase { $this->assertNotContains('$', $result['values']); $result = $this->callAPISuccess('Contribution', 'getoptions', [ 'field' => 'currency', - 'context' => "abbreviate", + 'context' => 'abbreviate', ]); $this->assertEquals('$', $result['values']['USD']); $this->assertNotContains('US Dollar', $result['values']); diff --git a/tests/phpunit/api/v3/UFFieldTest.php b/tests/phpunit/api/v3/UFFieldTest.php index a65cd8d5a7..c52aab89fa 100644 --- a/tests/phpunit/api/v3/UFFieldTest.php +++ b/tests/phpunit/api/v3/UFFieldTest.php @@ -230,7 +230,7 @@ class api_v3_UFFieldTest extends CiviUnitTestCase { $inUfField = $inputsByName[$outUfField['field_name']]; foreach ($inUfField as $key => $inValue) { $this->assertEquals($inValue, $outUfField[$key], - sprintf("field_name=[%s] key=[%s] expected=[%s] actual=[%s]", + sprintf('field_name=[%s] key=[%s] expected=[%s] actual=[%s]', $outUfField['field_name'], $key, $inValue, diff --git a/tests/phpunit/api/v4/Entity/WorkflowMessageTest.php b/tests/phpunit/api/v4/Entity/WorkflowMessageTest.php index 43cef7085b..4560aea934 100644 --- a/tests/phpunit/api/v4/Entity/WorkflowMessageTest.php +++ b/tests/phpunit/api/v4/Entity/WorkflowMessageTest.php @@ -72,8 +72,8 @@ class WorkflowMessageTest extends UnitTestCase { ->execute(); $this->assertTrue($examples->rowCount >= 1); foreach ($examples as $example) { - $this->assertTrue(!empty($example['data']['modelProps']), sprintf("Example (%s) is tagged phpunit. It should have modelProps.", $example['name'])); - $this->assertTrue(!empty($example['asserts']['default']), sprintf("Example (%s) is tagged phpunit. It should have assertions.", $example['name'])); + $this->assertTrue(!empty($example['data']['modelProps']), sprintf('Example (%s) is tagged phpunit. It should have modelProps.', $example['name'])); + $this->assertTrue(!empty($example['asserts']['default']), sprintf('Example (%s) is tagged phpunit. It should have assertions.', $example['name'])); $result = \Civi\Api4\WorkflowMessage::render(0) ->setWorkflow($example['data']['workflow']) ->setValues($example['data']['modelProps']) -- 2.25.1