From 511e9a2127c5f9149cfda8c01d0065cc3a41bef3 Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 17 Mar 2020 16:26:24 +1300 Subject: [PATCH] [REF] Replace coalesce pattern with coalesce operator This replaces the innstances in the test folder. --- .../test.extension.manager.paymenttest/main.php | 10 +++++----- tests/phpunit/Civi/Core/ThemesTest.php | 2 +- tests/phpunit/api/v3/SyntaxConformanceTest.php | 2 +- tests/phpunit/api/v4/Traits/TestDataLoaderTrait.php | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/extensions/test.extension.manager.paymenttest/main.php b/tests/extensions/test.extension.manager.paymenttest/main.php index e6affe4bc9..313db799b1 100644 --- a/tests/extensions/test.extension.manager.paymenttest/main.php +++ b/tests/extensions/test.extension.manager.paymenttest/main.php @@ -8,22 +8,22 @@ class test_extension_manager_paymenttest extends CRM_Core_Payment { public static $counts = array(); public function install() { - self::$counts['install'] = isset(self::$counts['install']) ? self::$counts['install'] : 0; + self::$counts['install'] = self::$counts['install'] ?? 0; self::$counts['install'] = 1 + (int) self::$counts['install']; } public function uninstall() { - self::$counts['uninstall'] = isset(self::$counts['uninstall']) ? self::$counts['uninstall'] : 0; + self::$counts['uninstall'] = self::$counts['uninstall'] ?? 0; self::$counts['uninstall'] = 1 + (int) self::$counts['uninstall']; } public function disable() { - self::$counts['disable'] = isset(self::$counts['disable']) ? self::$counts['disable'] : 0; + self::$counts['disable'] = self::$counts['disable'] ?? 0; self::$counts['disable'] = 1 + (int) self::$counts['disable']; } public function enable() { - self::$counts['enable'] = isset(self::$counts['enable']) ? self::$counts['enable'] : 0; + self::$counts['enable'] = self::$counts['enable'] ?? 0; self::$counts['enable'] = 1 + (int) self::$counts['enable']; } @@ -38,7 +38,7 @@ class test_extension_manager_paymenttest extends CRM_Core_Payment { * @return int */ public static function getCount($type) { - return isset(self::$counts[$type]) ? self::$counts[$type] : 0; + return self::$counts[$type] ?? 0; } } diff --git a/tests/phpunit/Civi/Core/ThemesTest.php b/tests/phpunit/Civi/Core/ThemesTest.php index 6278f60674..f252078921 100644 --- a/tests/phpunit/Civi/Core/ThemesTest.php +++ b/tests/phpunit/Civi/Core/ThemesTest.php @@ -192,7 +192,7 @@ class ThemesTest extends \CiviUnitTestCase { $map['bluemarine']['civicrm']['css/civicrm.css'] = ['http://example.com/blue/civicrm.css']; $map['bluemarine']['test.extension.uitest']['files/foo.css'] = ['http://example.com/blue/foobar/foo.css']; $map['aquamarine']['civicrm']['css/civicrm.css'] = ['http://example.com/aqua/civicrm.css']; - return isset($map[$themeKey][$cssExt][$cssFile]) ? $map[$themeKey][$cssExt][$cssFile] : Themes::PASSTHRU; + return $map[$themeKey][$cssExt][$cssFile] ?? Themes::PASSTHRU; } public function testGetAll() { diff --git a/tests/phpunit/api/v3/SyntaxConformanceTest.php b/tests/phpunit/api/v3/SyntaxConformanceTest.php index e4b0f35b91..364baf7681 100644 --- a/tests/phpunit/api/v3/SyntaxConformanceTest.php +++ b/tests/phpunit/api/v3/SyntaxConformanceTest.php @@ -1465,7 +1465,7 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { } $updateParams = [ 'id' => $entity['id'], - $field => isset($entity[$field]) ? $entity[$field] : NULL, + $field => $entity[$field] ?? NULL, ]; if (isset($updateParams['financial_type_id']) && in_array($entityName, ['Grant'])) { //api has special handling on these 2 fields for backward compatibility reasons diff --git a/tests/phpunit/api/v4/Traits/TestDataLoaderTrait.php b/tests/phpunit/api/v4/Traits/TestDataLoaderTrait.php index 875a017f4b..d440f30a4b 100644 --- a/tests/phpunit/api/v4/Traits/TestDataLoaderTrait.php +++ b/tests/phpunit/api/v4/Traits/TestDataLoaderTrait.php @@ -63,7 +63,7 @@ trait TestDataLoaderTrait { * @return null|mixed */ protected function getReference($name) { - return isset($this->references[$name]) ? $this->references[$name] : NULL; + return $this->references[$name] ?? NULL; } /** -- 2.25.1