From: Tim Otten Date: Fri, 26 Aug 2022 21:49:38 +0000 (-0700) Subject: (NFC) tests/ - Autoformat big clumps of `list()` statements X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=6cedc2bebcae4d8c33e83b338e4cd4511f99dc71;p=civicrm-core.git (NFC) tests/ - Autoformat big clumps of `list()` statements Based on a quick grep, these files had a lot of `list()` statements, so I let PHPStorm clean them up. --- diff --git a/tests/phpunit/CRM/Contact/BAO/ActivitySearchTest.php b/tests/phpunit/CRM/Contact/BAO/ActivitySearchTest.php index 03e2288909..8f0f521b55 100644 --- a/tests/phpunit/CRM/Contact/BAO/ActivitySearchTest.php +++ b/tests/phpunit/CRM/Contact/BAO/ActivitySearchTest.php @@ -119,7 +119,7 @@ class CRM_Contact_BAO_ActivitySearchTest extends CiviUnitTestCase { 'expected_contact' => [$this->_contactID], ]; $query = new CRM_Contact_BAO_Query(CRM_Contact_BAO_Query::convertFormValues($case['form_value'])); - list($select, $from, $where, $having) = $query->query(); + [$select, $from, $where, $having] = $query->query(); $groupContacts = CRM_Core_DAO::executeQuery("SELECT DISTINCT contact_a.id $from $where")->fetchAll(); foreach ($groupContacts as $key => $value) { $groupContacts[$key] = $value['id']; @@ -146,7 +146,7 @@ class CRM_Contact_BAO_ActivitySearchTest extends CiviUnitTestCase { 'expected_contact' => [$this->_contactID], ]; $query = new CRM_Contact_BAO_Query(CRM_Contact_BAO_Query::convertFormValues($case['form_value'])); - list($select, $from, $where, $having) = $query->query(); + [$select, $from, $where, $having] = $query->query(); $groupContacts = CRM_Core_DAO::executeQuery("SELECT DISTINCT contact_a.id $from $where")->fetchAll(); foreach ($groupContacts as $key => $value) { $groupContacts[$key] = $value['id']; @@ -173,7 +173,7 @@ class CRM_Contact_BAO_ActivitySearchTest extends CiviUnitTestCase { 'expected_contact' => [$this->_contactID], ]; $query = new CRM_Contact_BAO_Query(CRM_Contact_BAO_Query::convertFormValues($case['form_value'])); - list($select, $from, $where, $having) = $query->query(); + [$select, $from, $where, $having] = $query->query(); $groupContacts = CRM_Core_DAO::executeQuery("SELECT DISTINCT contact_a.id $from $where")->fetchAll(); foreach ($groupContacts as $key => $value) { $groupContacts[$key] = $value['id']; @@ -200,7 +200,7 @@ class CRM_Contact_BAO_ActivitySearchTest extends CiviUnitTestCase { 'expected_contact' => [$this->_contactID], ]; $query = new CRM_Contact_BAO_Query(CRM_Contact_BAO_Query::convertFormValues($case['form_value'])); - list($select, $from, $where, $having) = $query->query(); + [$select, $from, $where, $having] = $query->query(); $groupContacts = CRM_Core_DAO::executeQuery("SELECT DISTINCT contact_a.id $from $where")->fetchAll(); foreach ($groupContacts as $key => $value) { $groupContacts[$key] = $value['id']; @@ -238,7 +238,7 @@ class CRM_Contact_BAO_ActivitySearchTest extends CiviUnitTestCase { 'expected_contact' => [$this->_contactID], ]; $query = new CRM_Contact_BAO_Query(CRM_Contact_BAO_Query::convertFormValues($case['form_value'])); - list($select, $from, $where, $having) = $query->query(); + [$select, $from, $where, $having] = $query->query(); $expectedQill = [ 0 => [ @@ -292,7 +292,7 @@ class CRM_Contact_BAO_ActivitySearchTest extends CiviUnitTestCase { 'expected_contact' => [$this->_contactID], ]; $query = new CRM_Contact_BAO_Query(CRM_Contact_BAO_Query::convertFormValues($case['form_value'])); - list($select, $from, $where, $having) = $query->query(); + [$select, $from, $where, $having] = $query->query(); $expectedQill = [ 0 => [ diff --git a/tests/phpunit/CRM/Contact/BAO/QueryTest.php b/tests/phpunit/CRM/Contact/BAO/QueryTest.php index cbd75314e5..b46e799f93 100644 --- a/tests/phpunit/CRM/Contact/BAO/QueryTest.php +++ b/tests/phpunit/CRM/Contact/BAO/QueryTest.php @@ -405,7 +405,7 @@ class CRM_Contact_BAO_QueryTest extends CiviUnitTestCase { $queryObj = new CRM_Contact_BAO_Query($params, $returnProperties); try { $this->assertLike($expectedSQL, $queryObj->getSearchSQL()); - list($select, $from, $where, $having) = $queryObj->query(); + [$select, $from, $where, $having] = $queryObj->query(); $dao = CRM_Core_DAO::executeQuery("$select $from $where $having"); $dao->fetch(); $this->assertEquals('Anderson, Anthony', $dao->sort_name); @@ -500,7 +500,7 @@ class CRM_Contact_BAO_QueryTest extends CiviUnitTestCase { TRUE, FALSE ); - list($select) = $query->query(); + [$select] = $query->query(); $this->assertEquals('SELECT contact_a.id as contact_id', $select); } @@ -1203,7 +1203,7 @@ civicrm_relationship.is_active = 1 AND TRUE, FALSE ); - list($select, $from, $where, $having) = $query->query(); + [$select, $from, $where, $having] = $query->query(); $this->assertEquals($expectedWhere, $where); } @@ -1395,13 +1395,13 @@ civicrm_relationship.is_active = 1 AND ], ]; $query = new CRM_Contact_BAO_Query($params); - list($select, $from, $where) = $query->query(); + [$select, $from, $where] = $query->query(); $this->assertStringContainsString("contact_a.sort_name LIKE '%John%Doe%'", $where); //Check for NO wildcard due to comma $params[0][2] = 'Doe, John'; $query = new CRM_Contact_BAO_Query($params); - list($select, $from, $where) = $query->query(); + [$select, $from, $where] = $query->query(); $this->assertStringContainsString("contact_a.sort_name LIKE '%Doe, John%'", $where); } diff --git a/tests/phpunit/CRM/Contribute/Form/SearchTest.php b/tests/phpunit/CRM/Contribute/Form/SearchTest.php index 60df89f99e..f30fd1633a 100644 --- a/tests/phpunit/CRM/Contribute/Form/SearchTest.php +++ b/tests/phpunit/CRM/Contribute/Form/SearchTest.php @@ -106,7 +106,7 @@ class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase { foreach ($entities['values'] as $value) { $ids[] = $value['entity_id']; } - list($batchContriID1, $batchContriID2) = $ids; + [$batchContriID1, $batchContriID2] = $ids; $useCases = [ // Case 1: Search for ONLY those contributions which are created from batch @@ -135,7 +135,7 @@ class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase { $fv = $case['form_value']; CRM_Contact_BAO_Query::processSpecialFormValue($fv, ['contribution_batch_id']); $query = new CRM_Contact_BAO_Query(CRM_Contact_BAO_Query::convertFormValues($fv)); - list($select, $from, $where) = $query->query(); + [$select, $from, $where] = $query->query(); // get and assert contribution count $contributions = CRM_Core_DAO::executeQuery(sprintf('SELECT DISTINCT civicrm_contribution.id %s %s AND civicrm_contribution.id IS NOT NULL', $from, $where))->fetchAll(); @@ -237,7 +237,7 @@ class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase { $fv = $case['form_value']; CRM_Contact_BAO_Query::processSpecialFormValue($fv, ['financial_trxn_card_type_id']); $query = new CRM_Contact_BAO_Query(CRM_Contact_BAO_Query::convertFormValues($fv)); - list($select, $from, $where) = $query->query(); + [$select, $from, $where] = $query->query(); // get and assert contribution count $contributions = CRM_Core_DAO::executeQuery(sprintf('SELECT DISTINCT civicrm_contribution.id %s %s AND civicrm_contribution.id IS NOT NULL', $from, $where))->fetchAll(); @@ -334,7 +334,7 @@ class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase { $fv = $case['form_value']; CRM_Contact_BAO_Query::processSpecialFormValue($fv, ['financial_trxn_pan_truncation']); $query = new CRM_Contact_BAO_Query(CRM_Contact_BAO_Query::convertFormValues($fv)); - list($select, $from, $where) = $query->query(); + [$select, $from, $where] = $query->query(); // get and assert contribution count $contributions = CRM_Core_DAO::executeQuery(sprintf('SELECT DISTINCT civicrm_contribution.id %s %s AND civicrm_contribution.id IS NOT NULL', $from, $where))->fetchAll(); @@ -359,7 +359,7 @@ class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase { $fv = ['contact_id' => $contactID]; $queryParams = CRM_Contact_BAO_Query::convertFormValues($fv); $selector = new CRM_Contribute_Selector_Search($queryParams, CRM_Core_Action::ADD); - list($select, $from, $where) = $selector->getQuery()->query(); + [$select, $from, $where] = $selector->getQuery()->query(); // get and assert contribution count $contributions = CRM_Core_DAO::executeQuery("{$select} {$from} {$where}")->fetchAll(); @@ -372,7 +372,7 @@ class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase { 'contact_id' => $contactID, ]); $selector = new CRM_Contribute_Selector_Search($queryParams, CRM_Core_Action::ADD); - list($select, $from, $where) = $selector->getQuery()->query(); + [$select, $from, $where] = $selector->getQuery()->query(); // get and assert contribution count $contributions = CRM_Core_DAO::executeQuery("{$select} {$from} {$where}")->fetchAll(); @@ -388,7 +388,7 @@ class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase { $this->setUpRecurringContributions(); $query = new CRM_Contact_BAO_Query(CRM_Contact_BAO_Query::convertFormValues($formValues)); - list($select, $from, $where, $having) = $query->query(); + [$select, $from, $where, $having] = $query->query(); // get and assert contribution count $contacts = CRM_Core_DAO::executeQuery(sprintf('SELECT DISTINCT contact_a.id, contact_a.display_name %s %s AND contact_a.id IS NOT NULL', $from, $where))->fetchAll(); @@ -478,7 +478,7 @@ class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase { $fv = $case['form_value']; CRM_Contact_BAO_Query::processSpecialFormValue($fv, ['cancel_reason']); $query = new CRM_Contact_BAO_Query(CRM_Contact_BAO_Query::convertFormValues($fv)); - list($select, $from, $where) = $query->query(); + [$select, $from, $where] = $query->query(); // get and assert contribution count $contributions = CRM_Core_DAO::executeQuery(sprintf('SELECT DISTINCT civicrm_contribution.id %s %s AND civicrm_contribution.id IS NOT NULL AND civicrm_contribution.contribution_status_id = 3', $from, $where))->fetchAll(); diff --git a/tests/phpunit/CRM/Extension/Container/BasicTest.php b/tests/phpunit/CRM/Extension/Container/BasicTest.php index 43cac07d3c..9529e868d4 100644 --- a/tests/phpunit/CRM/Extension/Container/BasicTest.php +++ b/tests/phpunit/CRM/Extension/Container/BasicTest.php @@ -13,12 +13,12 @@ class CRM_Extension_Container_BasicTest extends CiviUnitTestCase { } public function testGetKeys() { - list($basedir, $c) = $this->_createContainer(); + [$basedir, $c] = $this->_createContainer(); $this->assertEquals($c->getKeys(), ['test.foo', 'test.foo.bar']); } public function testGetPath() { - list($basedir, $c) = $this->_createContainer(); + [$basedir, $c] = $this->_createContainer(); try { $c->getPath('un.kno.wn'); } @@ -32,7 +32,7 @@ class CRM_Extension_Container_BasicTest extends CiviUnitTestCase { } public function testGetPath_extraSlashFromConfig() { - list($basedir, $c) = $this->_createContainer(NULL, NULL, '/'); + [$basedir, $c] = $this->_createContainer(NULL, NULL, '/'); try { $c->getPath('un.kno.wn'); } @@ -46,7 +46,7 @@ class CRM_Extension_Container_BasicTest extends CiviUnitTestCase { } public function testGetResUrl() { - list($basedir, $c) = $this->_createContainer(); + [$basedir, $c] = $this->_createContainer(); try { $c->getResUrl('un.kno.wn'); } @@ -60,7 +60,7 @@ class CRM_Extension_Container_BasicTest extends CiviUnitTestCase { } public function testGetResUrl_extraSlashFromConfig() { - list($basedir, $c) = $this->_createContainer(NULL, NULL, '/'); + [$basedir, $c] = $this->_createContainer(NULL, NULL, '/'); try { $c->getResUrl('un.kno.wn'); } @@ -76,7 +76,7 @@ class CRM_Extension_Container_BasicTest extends CiviUnitTestCase { public function testCaching() { $cache = new CRM_Utils_Cache_Arraycache([]); $this->assertTrue(!is_array($cache->get('basic-scan'))); - list($basedir, $c) = $this->_createContainer($cache, 'basic-scan'); + [$basedir, $c] = $this->_createContainer($cache, 'basic-scan'); $this->assertEquals('http://example/basedir/foo', $c->getResUrl('test.foo')); $this->assertTrue(is_array($cache->get('basic-scan'))); diff --git a/tests/phpunit/CRM/Mailing/BaseMailingSystemTest.php b/tests/phpunit/CRM/Mailing/BaseMailingSystemTest.php index 492fdebe49..141c1c208e 100644 --- a/tests/phpunit/CRM/Mailing/BaseMailingSystemTest.php +++ b/tests/phpunit/CRM/Mailing/BaseMailingSystemTest.php @@ -138,7 +138,7 @@ abstract class CRM_Mailing_BaseMailingSystemTest extends CiviUnitTestCase { $this->assertTrue($message->body instanceof ezcMailMultipartAlternative); - list($textPart, $htmlPart) = $message->body->getParts(); + [$textPart, $htmlPart] = $message->body->getParts(); $this->assertEquals('html', $htmlPart->subType); $this->assertRegExp( @@ -195,7 +195,7 @@ abstract class CRM_Mailing_BaseMailingSystemTest extends CiviUnitTestCase { $this->assertTrue($message->body instanceof ezcMailMultipartAlternative); - list($textPart, $htmlPart) = $message->body->getParts(); + [$textPart, $htmlPart] = $message->body->getParts(); $this->assertEquals('html', $htmlPart->subType); $this->assertRegExp( @@ -339,7 +339,7 @@ abstract class CRM_Mailing_BaseMailingSystemTest extends CiviUnitTestCase { $this->assertTrue($message->body instanceof ezcMailMultipartAlternative); - list($textPart, $htmlPart) = $message->body->getParts(); + [$textPart, $htmlPart] = $message->body->getParts(); if ($htmlUrlRegex) { $caseName = print_r(['inputHtml' => $inputHtml, 'params' => $params, 'htmlUrlRegex' => $htmlUrlRegex, 'htmlPart' => $htmlPart->text], 1); diff --git a/tests/phpunit/CRM/Utils/HttpClientTest.php b/tests/phpunit/CRM/Utils/HttpClientTest.php index 599bc6d153..1e607ab943 100644 --- a/tests/phpunit/CRM/Utils/HttpClientTest.php +++ b/tests/phpunit/CRM/Utils/HttpClientTest.php @@ -79,19 +79,19 @@ class CRM_Utils_HttpClientTest extends CiviUnitTestCase { } public function testGetHttp() { - list($status, $data) = $this->client->get(self::VALID_HTTP_URL); + [$status, $data] = $this->client->get(self::VALID_HTTP_URL); $this->assertEquals(CRM_Utils_HttpClient::STATUS_OK, $status); $this->assertRegExp(self::VALID_HTTP_REGEX, $data); } public function testGetHttps_valid() { - list($status, $data) = $this->client->get(self::VALID_HTTPS_URL); + [$status, $data] = $this->client->get(self::VALID_HTTPS_URL); $this->assertEquals(CRM_Utils_HttpClient::STATUS_OK, $status); $this->assertRegExp(self::VALID_HTTPS_REGEX, $data); } public function testGetHttps_invalid_verify() { - list($status, $data) = $this->client->get(self::SELF_SIGNED_HTTPS_URL); + [$status, $data] = $this->client->get(self::SELF_SIGNED_HTTPS_URL); $this->assertEquals(CRM_Utils_HttpClient::STATUS_DL_ERROR, $status); $this->assertEquals('', $data); } @@ -103,7 +103,7 @@ class CRM_Utils_HttpClientTest extends CiviUnitTestCase { ]); $this->assertAPISuccess($result); - list($status, $data) = $this->client->get(self::SELF_SIGNED_HTTPS_URL); + [$status, $data] = $this->client->get(self::SELF_SIGNED_HTTPS_URL); $this->assertEquals(CRM_Utils_HttpClient::STATUS_OK, $status); $this->assertRegExp(self::SELF_SIGNED_HTTPS_REGEX, $data); } diff --git a/tests/phpunit/E2E/Cache/TwoInstancesTest.php b/tests/phpunit/E2E/Cache/TwoInstancesTest.php index 2c8760a7f2..dc3069bccf 100644 --- a/tests/phpunit/E2E/Cache/TwoInstancesTest.php +++ b/tests/phpunit/E2E/Cache/TwoInstancesTest.php @@ -108,7 +108,7 @@ class E2E_Cache_TwoInstancesTest extends CiviEndToEndTestCase { * @dataProvider getTwoGenerators */ public function testDiff_clearA($cacheA, $cacheB) { - list($a, $b) = $this->createTwoCaches($cacheA, $cacheB); + [$a, $b] = $this->createTwoCaches($cacheA, $cacheB); $a->set('foo', 1234); $b->set('foo', 5678); $this->assertEquals(1234, $a->get('foo'), 'Check value A after initial setup'); @@ -129,7 +129,7 @@ class E2E_Cache_TwoInstancesTest extends CiviEndToEndTestCase { * @dataProvider getTwoGenerators */ public function testDiff_clearB($cacheA, $cacheB) { - list($a, $b) = $this->createTwoCaches($cacheA, $cacheB); + [$a, $b] = $this->createTwoCaches($cacheA, $cacheB); $a->set('foo', 1234); $b->set('foo', 5678); $this->assertEquals(1234, $a->get('foo'), 'Check value A after initial setup'); @@ -150,13 +150,13 @@ class E2E_Cache_TwoInstancesTest extends CiviEndToEndTestCase { * @dataProvider getTwoGenerators */ public function testDiff_reload($cacheA, $cacheB) { - list($a, $b) = $this->createTwoCaches($cacheA, $cacheB); + [$a, $b] = $this->createTwoCaches($cacheA, $cacheB); $a->set('foo', 1234); $b->set('foo', 5678); $this->assertEquals(1234, $a->get('foo'), 'Check value A after initial setup'); $this->assertEquals(5678, $b->get('foo'), 'Check value B after initial setup'); - list($a, $b) = $this->createTwoCaches($cacheA, $cacheB); + [$a, $b] = $this->createTwoCaches($cacheA, $cacheB); $this->assertEquals(1234, $a->get('foo'), 'Check value A after initial setup'); $this->assertEquals(5678, $b->get('foo'), 'Check value B after initial setup'); }