From 275686a34ca7bf5e9c4d6653cd8cca5cf15e36cf Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sat, 22 May 2021 08:33:18 +1000 Subject: [PATCH] [NFC] Fix PHPUnit8 deprecation warnings in the CRM_AllTests suite --- .../phpunit/CRM/Activity/BAO/ActivityTest.php | 9 +++--- .../CRM/Activity/Form/ActivityTest.php | 2 +- .../Form/Task/PDFLetterCommonTest.php | 2 +- tests/phpunit/CRM/Case/BAO/CaseTest.php | 2 +- tests/phpunit/CRM/Case/Form/SearchTest.php | 2 +- .../CRM/Contact/BAO/GroupContactCacheTest.php | 14 ++++----- tests/phpunit/CRM/Contact/BAO/QueryTest.php | 22 +++++++------- .../Form/Search/Custom/PriceSetTest.php | 2 +- .../CRM/Contact/Form/Task/EmailCommonTest.php | 2 +- .../Form/Task/PrintMailingLabelTest.php | 2 +- .../View/UserDashboard/GroupContactTest.php | 8 ++--- tests/phpunit/CRM/Contact/SelectorTest.php | 4 +-- .../Contribute/BAO/ContributionPageTest.php | 2 +- .../CRM/Contribute/BAO/ContributionTest.php | 20 ++++++------- .../phpunit/CRM/Contribute/BAO/QueryTest.php | 2 +- .../CRM/Contribute/Form/ContributionTest.php | 4 +-- .../CRM/Contribute/Form/Task/InvoiceTest.php | 30 +++++++++---------- .../Form/Task/PDFLetterCommonTest.php | 2 +- .../CRM/Contribute/Selector/SearchTest.php | 4 +-- .../CRM/Core/BAO/ActionScheduleTest.php | 2 +- .../phpunit/CRM/Core/BAO/CustomFieldTest.php | 4 +-- tests/phpunit/CRM/Core/BAO/EmailTest.php | 6 ++-- .../CRM/Core/BAO/MessageTemplateTest.php | 4 +-- .../CRM/Core/BAO/SchemaHandlerTest.php | 6 ++-- tests/phpunit/CRM/Core/ErrorTest.php | 2 +- tests/phpunit/CRM/Core/I18n/SchemaTest.php | 4 +-- .../phpunit/CRM/Core/Payment/BaseIPNTest.php | 20 ++++++------- .../Event/Form/Registration/ConfirmTest.php | 14 ++++----- tests/phpunit/CRM/Extension/ManagerTest.php | 3 +- tests/phpunit/CRM/Logging/SchemaTest.php | 6 ++-- tests/phpunit/CRM/Mailing/BAO/SpoolTest.php | 8 ++--- .../CRM/Member/Form/MembershipTest.php | 18 +++++------ .../Member/Form/Task/PDFLetterCommonTest.php | 2 +- .../CRM/Pledge/BAO/PledgePaymentTest.php | 2 +- tests/phpunit/CRM/Price/Form/FieldTest.php | 4 +-- tests/phpunit/CRM/Price/Form/OptionTest.php | 4 +-- .../CRM/Report/Form/Member/DetailTest.php | 4 +-- .../phpunit/CRM/UF/Page/ProfileEditorTest.php | 3 +- .../CRM/Upgrade/Incremental/BaseTest.php | 4 +-- tests/phpunit/CRM/Utils/SystemTest.php | 16 +++++----- .../phpunit/CRMTraits/Page/PageTestTrait.php | 2 +- 41 files changed, 135 insertions(+), 138 deletions(-) diff --git a/tests/phpunit/CRM/Activity/BAO/ActivityTest.php b/tests/phpunit/CRM/Activity/BAO/ActivityTest.php index 3a0f49e6a5..dc541e69cb 100644 --- a/tests/phpunit/CRM/Activity/BAO/ActivityTest.php +++ b/tests/phpunit/CRM/Activity/BAO/ActivityTest.php @@ -510,7 +510,7 @@ class CRM_Activity_BAO_ActivityTest extends CiviUnitTestCase { $this->checkArrayEquals($expectedFilters, $activityFilter); // This should include activities of type Meeting only. foreach ($activities['data'] as $value) { - $this->assertContains('Meeting', $value['activity_type']); + $this->assertStringContainsString('Meeting', $value['activity_type']); } unset($_GET['activity_type_id']); @@ -525,7 +525,7 @@ class CRM_Activity_BAO_ActivityTest extends CiviUnitTestCase { $this->assertEquals(['activity_type_exclude_filter_id' => 1], $activityFilter); // None of the activities should be of type Meeting. foreach ($activities['data'] as $value) { - $this->assertNotContains('Meeting', $value['activity_type']); + $this->assertStringNotContainsString('Meeting', $value['activity_type']); } } @@ -1299,14 +1299,13 @@ $text } /** - * @expectedException CRM_Core_Exception - * @expectedExceptionMessage You do not have the 'send SMS' permission */ public function testSendSMSWithoutPermission() { $dummy = NULL; $session = CRM_Core_Session::singleton(); CRM_Core_Config::singleton()->userPermissionClass->permissions = ['access CiviCRM']; - + $this->expectException(CRM_Core_Exception::class); + $this->expectExceptionMessage('You do not have the \'send SMS\' permission'); CRM_Activity_BAO_Activity::sendSMS( $dummy, $dummy, diff --git a/tests/phpunit/CRM/Activity/Form/ActivityTest.php b/tests/phpunit/CRM/Activity/Form/ActivityTest.php index 23969a1216..cd788ae4ce 100644 --- a/tests/phpunit/CRM/Activity/Form/ActivityTest.php +++ b/tests/phpunit/CRM/Activity/Form/ActivityTest.php @@ -376,7 +376,7 @@ ENDBODY; // This kind of suffers from the same problem as the old webtests. It's // a bit brittle and tied to the UI. - $this->assertContains("Hi,
\n
\nWassup!?!?
\n
\nLet's check if the output when viewing the form has legible line breaks in the output.
\n
\nThanks!", $output); + $this->assertStringContainsString("Hi,
\n
\nWassup!?!?
\n
\nLet's check if the output when viewing the form has legible line breaks in the output.
\n
\nThanks!", $output); // Put label back $this->callAPISuccess('OptionValue', 'create', [ diff --git a/tests/phpunit/CRM/Activity/Form/Task/PDFLetterCommonTest.php b/tests/phpunit/CRM/Activity/Form/Task/PDFLetterCommonTest.php index c52fc64740..ab93c002a6 100644 --- a/tests/phpunit/CRM/Activity/Form/Task/PDFLetterCommonTest.php +++ b/tests/phpunit/CRM/Activity/Form/Task/PDFLetterCommonTest.php @@ -39,7 +39,7 @@ class CRM_Activity_Form_Task_PDFLetterCommonTest extends CiviUnitTestCase { // Check some basic fields foreach ($data as $line) { - $this->assertContains("\n" . $line[1] . "\n", $output[0]); + $this->assertStringContainsString("\n" . $line[1] . "\n", $output[0]); } } diff --git a/tests/phpunit/CRM/Case/BAO/CaseTest.php b/tests/phpunit/CRM/Case/BAO/CaseTest.php index 43b42d3d98..588162c30d 100644 --- a/tests/phpunit/CRM/Case/BAO/CaseTest.php +++ b/tests/phpunit/CRM/Case/BAO/CaseTest.php @@ -226,7 +226,7 @@ class CRM_Case_BAO_CaseTest extends CiviUnitTestCase { ]; $sortedActualContactNames = CRM_Utils_Array::collect('sort_name', $cases); foreach ($sortedExpectedContactNames as $key => $name) { - $this->assertContains($name, $sortedActualContactNames[$key]); + $this->assertStringContainsString($name, $sortedActualContactNames[$key]); } } diff --git a/tests/phpunit/CRM/Case/Form/SearchTest.php b/tests/phpunit/CRM/Case/Form/SearchTest.php index 2266f1b3b1..e8166be7c9 100644 --- a/tests/phpunit/CRM/Case/Form/SearchTest.php +++ b/tests/phpunit/CRM/Case/Form/SearchTest.php @@ -36,7 +36,7 @@ class CRM_Case_Form_SearchTest extends CiviCaseTestCase { // as webtests. Mostly what we're doing in this test is checking that it // doesn't generate any E_NOTICES/WARNINGS or other errors. But let's do // one check. - $this->assertContains('