From: Tim Otten Date: Fri, 5 Apr 2019 20:16:23 +0000 (-0700) Subject: (NFC) tests/ - Update to pass new phpcs X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=420384a058a18b230102483b4cb9f2abfdc413db;p=civicrm-core.git (NFC) tests/ - Update to pass new phpcs --- diff --git a/tests/phpunit/CRM/Export/BAO/ExportTest.php b/tests/phpunit/CRM/Export/BAO/ExportTest.php index f1341e1f18..00626abc0f 100644 --- a/tests/phpunit/CRM/Export/BAO/ExportTest.php +++ b/tests/phpunit/CRM/Export/BAO/ExportTest.php @@ -1724,14 +1724,14 @@ class CRM_Export_BAO_ExportTest extends CiviUnitTestCase { $selectedFields = $this->getAllSpecifiableParticipantReturnFields(); foreach ($selectedFields as $index => $field) { if (substr($field[1], 0, 22) === 'componentPaymentField_') { - unset ($selectedFields[$index]); + unset($selectedFields[$index]); } } $expected = $this->getAllSpecifiableParticipantReturnFields(); foreach ($expected as $index => $field) { if (substr($index, 0, 22) === 'componentPaymentField_') { - unset ($expected[$index]); + unset($expected[$index]); } } diff --git a/tests/phpunit/CRM/Price/Form/FieldTest.php b/tests/phpunit/CRM/Price/Form/FieldTest.php index d1c13513bc..08ede64999 100644 --- a/tests/phpunit/CRM/Price/Form/FieldTest.php +++ b/tests/phpunit/CRM/Price/Form/FieldTest.php @@ -1,85 +1,85 @@ -visibilityOptionsKeys = CRM_Price_BAO_PriceFieldValue::buildOptions('visibility_id', NULL, array( - 'labelColumn' => 'name', - 'flip' => TRUE, - )); - - $this->publicFieldParams = $this->initializeFieldParameters(array( - 'label' => 'Public Price Field', - 'name' => 'public_price', - 'visibility_id' => $this->visibilityOptionsKeys['public'], - )); - - $this->adminFieldParams = $this->initializeFieldParameters(array( - 'label' => 'Public Price Field', - 'name' => 'public_price', - 'visibility_id' => $this->visibilityOptionsKeys['admin'], - )); - } - - public function testPublicFieldWithOnlyAdminOptionsIsNotAllowed() { - $this->publicFieldParams['option_label'][1] = 'Admin Price'; - $this->publicFieldParams['option_amount'][1] = 10; - $this->publicFieldParams['option_visibility_id'][1] = $this->visibilityOptionsKeys['admin']; - - $form = new CRM_Price_Form_Field(); - $form->_action = CRM_Core_Action::ADD; - $files = array(); - - $validationResult = $form->formRule($this->publicFieldParams, $files, $form); - $this->assertType('array', $validationResult); - $this->assertTrue(array_key_exists('visibility_id', $validationResult)); - } - - public function testAdminFieldDoesNotAllowPublicOptions() { - $this->adminFieldParams['option_label'][1] = 'Admin Price'; - $this->adminFieldParams['option_amount'][1] = 10; - $this->adminFieldParams['option_visibility_id'][1] = $this->visibilityOptionsKeys['public']; - - $form = new CRM_Price_Form_Field(); - $form->_action = CRM_Core_Action::ADD; - $files = array(); - - $validationResult = $form->formRule($this->adminFieldParams, $files, $form); - $this->assertType('array', $validationResult); - $this->assertTrue(array_key_exists('visibility_id', $validationResult)); - } - - private function initializeFieldParameters($params) { - $defaultParams = array( - 'label' => 'Price Field', - 'name' => CRM_Utils_String::titleToVar('Price Field'), - 'html_type' => 'Select', - 'is_display_amounts' => 1, - 'weight' => 1, - 'options_per_line' => 1, - 'is_enter_qty' => 1, - 'financial_type_id' => $this->getFinancialTypeId('Event Fee'), - 'visibility_id' => $this->visibilityOptionsKeys['public'], - ); - - for ($index = 1; $index <= CRM_Price_Form_Field::NUM_OPTION; $index++) { - $defaultParams['option_label'][$index] = NULL; - $defaultParams['option_value'][$index] = NULL; - $defaultParams['option_name'][$index] = NULL; - $defaultParams['option_weight'][$index] = NULL; - $defaultParams['option_amount'][$index] = NULL; - $defaultParams['option_visibility_id'][$index] = NULL; - } - - return array_merge($defaultParams, $params); - } - -} +visibilityOptionsKeys = CRM_Price_BAO_PriceFieldValue::buildOptions('visibility_id', NULL, array( + 'labelColumn' => 'name', + 'flip' => TRUE, + )); + + $this->publicFieldParams = $this->initializeFieldParameters(array( + 'label' => 'Public Price Field', + 'name' => 'public_price', + 'visibility_id' => $this->visibilityOptionsKeys['public'], + )); + + $this->adminFieldParams = $this->initializeFieldParameters(array( + 'label' => 'Public Price Field', + 'name' => 'public_price', + 'visibility_id' => $this->visibilityOptionsKeys['admin'], + )); + } + + public function testPublicFieldWithOnlyAdminOptionsIsNotAllowed() { + $this->publicFieldParams['option_label'][1] = 'Admin Price'; + $this->publicFieldParams['option_amount'][1] = 10; + $this->publicFieldParams['option_visibility_id'][1] = $this->visibilityOptionsKeys['admin']; + + $form = new CRM_Price_Form_Field(); + $form->_action = CRM_Core_Action::ADD; + $files = array(); + + $validationResult = $form->formRule($this->publicFieldParams, $files, $form); + $this->assertType('array', $validationResult); + $this->assertTrue(array_key_exists('visibility_id', $validationResult)); + } + + public function testAdminFieldDoesNotAllowPublicOptions() { + $this->adminFieldParams['option_label'][1] = 'Admin Price'; + $this->adminFieldParams['option_amount'][1] = 10; + $this->adminFieldParams['option_visibility_id'][1] = $this->visibilityOptionsKeys['public']; + + $form = new CRM_Price_Form_Field(); + $form->_action = CRM_Core_Action::ADD; + $files = array(); + + $validationResult = $form->formRule($this->adminFieldParams, $files, $form); + $this->assertType('array', $validationResult); + $this->assertTrue(array_key_exists('visibility_id', $validationResult)); + } + + private function initializeFieldParameters($params) { + $defaultParams = array( + 'label' => 'Price Field', + 'name' => CRM_Utils_String::titleToVar('Price Field'), + 'html_type' => 'Select', + 'is_display_amounts' => 1, + 'weight' => 1, + 'options_per_line' => 1, + 'is_enter_qty' => 1, + 'financial_type_id' => $this->getFinancialTypeId('Event Fee'), + 'visibility_id' => $this->visibilityOptionsKeys['public'], + ); + + for ($index = 1; $index <= CRM_Price_Form_Field::NUM_OPTION; $index++) { + $defaultParams['option_label'][$index] = NULL; + $defaultParams['option_value'][$index] = NULL; + $defaultParams['option_name'][$index] = NULL; + $defaultParams['option_weight'][$index] = NULL; + $defaultParams['option_amount'][$index] = NULL; + $defaultParams['option_visibility_id'][$index] = NULL; + } + + return array_merge($defaultParams, $params); + } + +} diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index 08762b0ca6..c3f62042e4 100644 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -164,7 +164,7 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { * @param array $data * @param string $dataName */ - public function __construct($name = NULL, array$data = array(), $dataName = '') { + public function __construct($name = NULL, array $data = array(), $dataName = '') { parent::__construct($name, $data, $dataName); // we need full error reporting diff --git a/tests/phpunit/E2E/Extern/RestTest.php b/tests/phpunit/E2E/Extern/RestTest.php index 56e1b0e2d1..0d9d963157 100644 --- a/tests/phpunit/E2E/Extern/RestTest.php +++ b/tests/phpunit/E2E/Extern/RestTest.php @@ -292,10 +292,9 @@ class E2E_Extern_RestTest extends CiviEndToEndTestCase { 'return' => 'id', )); - $this->old_api_keys[$adminContactId] = CRM_Core_DAO::singleValueQuery('SELECT api_key FROM civicrm_contact WHERE id = %1', - array( - 1 => array($adminContactId, 'Positive'), - )); + $this->old_api_keys[$adminContactId] = CRM_Core_DAO::singleValueQuery('SELECT api_key FROM civicrm_contact WHERE id = %1', [ + 1 => [$adminContactId, 'Positive'], + ]); //$this->old_admin_api_key = civicrm_api3('Contact', 'get', array( // 'id' => $adminContactId,