From df347a8c6cbc6c6cc7d897a04cc871ecbae287a1 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sat, 22 May 2021 14:48:08 +1000 Subject: [PATCH] [NFC] Fix PHPUnit8 Deprecation warnings in the api_v4 Test Suite --- tests/phpunit/api/v4/Action/BasicActionsTest.php | 2 +- tests/phpunit/api/v4/Action/ContactApiKeyTest.php | 6 +++--- tests/phpunit/api/v4/Action/IndexTest.php | 4 ++-- tests/phpunit/api/v4/Action/SqlExpressionTest.php | 4 ++-- tests/phpunit/api/v4/Entity/ConformanceTest.php | 11 ++++++----- tests/phpunit/api/v4/Entity/ParticipantTest.php | 2 +- tests/phpunit/api/v4/Entity/SettingTest.php | 2 +- tests/phpunit/api/v4/Query/PermissionCheckTest.php | 2 +- .../phpunit/api/v4/Query/SqlExpressionParserTest.php | 2 +- 9 files changed, 18 insertions(+), 17 deletions(-) diff --git a/tests/phpunit/api/v4/Action/BasicActionsTest.php b/tests/phpunit/api/v4/Action/BasicActionsTest.php index 9e54d3b6f9..fa011b06d3 100644 --- a/tests/phpunit/api/v4/Action/BasicActionsTest.php +++ b/tests/phpunit/api/v4/Action/BasicActionsTest.php @@ -371,7 +371,7 @@ class BasicActionsTest extends UnitTestCase { } catch (\API_Exception $createError) { } - $this->assertContains('Illegal expression', $createError->getMessage()); + $this->assertStringContainsString('Illegal expression', $createError->getMessage()); } } diff --git a/tests/phpunit/api/v4/Action/ContactApiKeyTest.php b/tests/phpunit/api/v4/Action/ContactApiKeyTest.php index 11bcb58d24..19202a52c5 100644 --- a/tests/phpunit/api/v4/Action/ContactApiKeyTest.php +++ b/tests/phpunit/api/v4/Action/ContactApiKeyTest.php @@ -108,7 +108,7 @@ class ContactApiKeyTest extends \api\v4\UnitTestCase { catch (\Exception $e) { $error = $e->getMessage(); } - $this->assertContains('key', $error); + $this->assertStringContainsString('key', $error); } public function testGetApiKeyViaJoin() { @@ -179,7 +179,7 @@ class ContactApiKeyTest extends \api\v4\UnitTestCase { ->execute() ->first(); - $this->assertContains('key', $error); + $this->assertStringContainsString('key', $error); // Assert key is still the same $this->assertEquals($result['api_key'], $key); @@ -225,7 +225,7 @@ class ContactApiKeyTest extends \api\v4\UnitTestCase { $error = $e->getMessage(); } - $this->assertContains('key', $error); + $this->assertStringContainsString('key', $error); $result = Contact::get(FALSE) ->addWhere('id', '=', $contact['id']) diff --git a/tests/phpunit/api/v4/Action/IndexTest.php b/tests/phpunit/api/v4/Action/IndexTest.php index 4f8778a977..41f535a95c 100644 --- a/tests/phpunit/api/v4/Action/IndexTest.php +++ b/tests/phpunit/api/v4/Action/IndexTest.php @@ -48,7 +48,7 @@ class IndexTest extends UnitTestCase { catch (\API_Exception $e) { $error = $e->getMessage(); } - $this->assertContains('not found', $error); + $this->assertStringContainsString('not found', $error); } public function testBadIndexString() { @@ -59,7 +59,7 @@ class IndexTest extends UnitTestCase { catch (\API_Exception $e) { $error = $e->getMessage(); } - $this->assertContains('not found', $error); + $this->assertStringContainsString('not found', $error); } public function testIndexWithSelect() { diff --git a/tests/phpunit/api/v4/Action/SqlExpressionTest.php b/tests/phpunit/api/v4/Action/SqlExpressionTest.php index 416d953e66..1de05f18e2 100644 --- a/tests/phpunit/api/v4/Action/SqlExpressionTest.php +++ b/tests/phpunit/api/v4/Action/SqlExpressionTest.php @@ -80,7 +80,7 @@ class SqlExpressionTest extends UnitTestCase { catch (\API_Exception $e) { $msg = $e->getMessage(); } - $this->assertContains('alias', $msg); + $this->assertStringContainsString('alias', $msg); try { Contact::get() ->addSelect('55 AS sort_name') @@ -89,7 +89,7 @@ class SqlExpressionTest extends UnitTestCase { catch (\API_Exception $e) { $msg = $e->getMessage(); } - $this->assertContains('existing field name', $msg); + $this->assertStringContainsString('existing field name', $msg); Contact::get() ->addSelect('55 AS ok_alias') ->execute(); diff --git a/tests/phpunit/api/v4/Entity/ConformanceTest.php b/tests/phpunit/api/v4/Entity/ConformanceTest.php index 6af37e8e13..ea870e93bb 100644 --- a/tests/phpunit/api/v4/Entity/ConformanceTest.php +++ b/tests/phpunit/api/v4/Entity/ConformanceTest.php @@ -173,7 +173,8 @@ class ConformanceTest extends UnitTestCase { $errMsg = sprintf('%s is missing required ID field', $entity); $subset = ['data_type' => 'Integer']; - $this->assertArraySubset($subset, $fields['id'], $errMsg); + $this->assertArrayHasKey('data_type', $fields['id'], $errMsg); + $this->assertEquals('Integer', $fields['id']['data_type']); } /** @@ -228,7 +229,7 @@ class ConformanceTest extends UnitTestCase { catch (\API_Exception $e) { $exceptionThrown = $e->getMessage(); } - $this->assertContains('id', $exceptionThrown); + $this->assertStringContainsString('id', $exceptionThrown); } /** @@ -278,7 +279,7 @@ class ConformanceTest extends UnitTestCase { catch (\API_Exception $e) { $exceptionThrown = $e->getMessage(); } - $this->assertContains('required', $exceptionThrown); + $this->assertStringContainsString('required', $exceptionThrown); } /** @@ -294,8 +295,8 @@ class ConformanceTest extends UnitTestCase { catch (\API_Exception $e) { $exceptionThrown = $e->getMessage(); } - $this->assertContains('debug', $exceptionThrown); - $this->assertContains('type', $exceptionThrown); + $this->assertStringContainsString('debug', $exceptionThrown); + $this->assertStringContainsString('type', $exceptionThrown); } /** diff --git a/tests/phpunit/api/v4/Entity/ParticipantTest.php b/tests/phpunit/api/v4/Entity/ParticipantTest.php index 76bbeda9a0..3de8b5bb40 100644 --- a/tests/phpunit/api/v4/Entity/ParticipantTest.php +++ b/tests/phpunit/api/v4/Entity/ParticipantTest.php @@ -47,7 +47,7 @@ class ParticipantTest extends UnitTestCase { $whereDescription = 'Criteria for selecting Participants'; $this->assertEquals(TRUE, $getParams['checkPermissions']['default']); - $this->assertContains($whereDescription, $getParams['where']['description']); + $this->assertStringContainsString($whereDescription, $getParams['where']['description']); } public function testGet() { diff --git a/tests/phpunit/api/v4/Entity/SettingTest.php b/tests/phpunit/api/v4/Entity/SettingTest.php index 9db05160a8..e0daa11f1d 100644 --- a/tests/phpunit/api/v4/Entity/SettingTest.php +++ b/tests/phpunit/api/v4/Entity/SettingTest.php @@ -47,7 +47,7 @@ class SettingTest extends UnitTestCase { catch (\API_Exception $e) { $message = $e->getMessage(); } - $this->assertContains('setting', $message); + $this->assertStringContainsString('setting', $message); } public function testSerailizedSetting() { diff --git a/tests/phpunit/api/v4/Query/PermissionCheckTest.php b/tests/phpunit/api/v4/Query/PermissionCheckTest.php index 790e08c6fb..4a6c233c04 100644 --- a/tests/phpunit/api/v4/Query/PermissionCheckTest.php +++ b/tests/phpunit/api/v4/Query/PermissionCheckTest.php @@ -62,7 +62,7 @@ class PermissionCheckTest extends UnitTestCase { catch (UnauthorizedException $e) { $err = $e->getMessage(); } - $this->assertContains('Authorization failed', $err); + $this->assertStringContainsString('Authorization failed', $err); } /** diff --git a/tests/phpunit/api/v4/Query/SqlExpressionParserTest.php b/tests/phpunit/api/v4/Query/SqlExpressionParserTest.php index 9532529250..edb3053807 100644 --- a/tests/phpunit/api/v4/Query/SqlExpressionParserTest.php +++ b/tests/phpunit/api/v4/Query/SqlExpressionParserTest.php @@ -81,7 +81,7 @@ class SqlExpressionParserTest extends UnitTestCase { } } catch (\API_Exception $e) { - $this->assertContains('Illegal', $e->getMessage()); + $this->assertStringContainsString('Illegal', $e->getMessage()); } } -- 2.25.1