diff --git a/framework/base/Module.php b/framework/base/Module.php index 42ca66a..20f6ca6 100644 --- a/framework/base/Module.php +++ b/framework/base/Module.php @@ -723,7 +723,7 @@ class Module extends ServiceLocator if (!isset($this->module)) { return parent::get($id, $throwException); } - + $component = parent::get($id, false); if ($component === null) { $component = $this->module->get($id, $throwException); diff --git a/framework/base/StaticInstanceTrait.php b/framework/base/StaticInstanceTrait.php index 0969324..106ba86 100644 --- a/framework/base/StaticInstanceTrait.php +++ b/framework/base/StaticInstanceTrait.php @@ -38,4 +38,4 @@ trait StaticInstanceTrait } return self::$_instances[$className]; } -} \ No newline at end of file +} diff --git a/framework/data/ActiveDataFilter.php b/framework/data/ActiveDataFilter.php index b755074..264c613 100644 --- a/framework/data/ActiveDataFilter.php +++ b/framework/data/ActiveDataFilter.php @@ -145,7 +145,7 @@ class ActiveDataFilter extends DataFilter } return [ $operator, - $this->buildCondition($condition) + $this->buildCondition($condition), ]; } diff --git a/framework/data/DataFilter.php b/framework/data/DataFilter.php index 899a7b7..173757a 100644 --- a/framework/data/DataFilter.php +++ b/framework/data/DataFilter.php @@ -340,7 +340,7 @@ class DataFilter extends Model } if ($type !== null) { - foreach ((array)$validator->attributes as $attribute) { + foreach ((array) $validator->attributes as $attribute) { $attributeTypes[$attribute] = $type; } } @@ -414,7 +414,7 @@ class DataFilter extends Model $params = array_merge( [ - 'filter' => $this->getAttributeLabel($this->filterAttributeName) + 'filter' => $this->getAttributeLabel($this->filterAttributeName), ], $params ); @@ -430,7 +430,7 @@ class DataFilter extends Model public function attributes() { return [ - $this->filterAttributeName + $this->filterAttributeName, ]; } @@ -448,7 +448,7 @@ class DataFilter extends Model public function rules() { return [ - [$this->filterAttributeName, 'validateFilter', 'skipOnEmpty' => false] + [$this->filterAttributeName, 'validateFilter', 'skipOnEmpty' => false], ]; } @@ -657,7 +657,7 @@ class DataFilter extends Model /** * Builds actual filter specification form [[filter]] value. - * @param boolean $runValidation whether to perform validation (calling [[validate()]]) + * @param bool $runValidation whether to perform validation (calling [[validate()]]) * before building the filter. Defaults to `true`. If the validation fails, no filter will * be built and this method will return `false`. * @return mixed|false built actual filter value, or `false` if validation fails. diff --git a/framework/db/Migration.php b/framework/db/Migration.php index 253a78d..63345cc 100644 --- a/framework/db/Migration.php +++ b/framework/db/Migration.php @@ -542,7 +542,7 @@ class Migration extends Component implements MigrationInterface } /** - * Prepares for a command to be executed, and outputs to the console + * Prepares for a command to be executed, and outputs to the console. * * @param string $description the description for the command, to be output to the console. * @return float the time before the command is executed, for the time elapsed to be calculated. @@ -557,7 +557,7 @@ class Migration extends Component implements MigrationInterface } /** - * Finalizes after the command has been executed, and outputs to the console the time elapsed + * Finalizes after the command has been executed, and outputs to the console the time elapsed. * * @param float $time the time before the command was executed. * @since 2.0.13 diff --git a/framework/filters/AccessRule.php b/framework/filters/AccessRule.php index 7b0b82f..49f2ecd 100644 --- a/framework/filters/AccessRule.php +++ b/framework/filters/AccessRule.php @@ -216,13 +216,13 @@ class AccessRule extends Component $items = empty($this->roles) ? [] : $this->roles; if (!empty($this->permissions)) { - $items = array_merge($items, $this->permissions); + $items = array_merge($items, $this->permissions); } if (empty($items)) { return true; } - + if ($user === false) { throw new InvalidConfigException('The user application component must be available to specify roles in AccessRule.'); } diff --git a/framework/filters/auth/HttpBasicAuth.php b/framework/filters/auth/HttpBasicAuth.php index 6949d96..d30f5e3 100644 --- a/framework/filters/auth/HttpBasicAuth.php +++ b/framework/filters/auth/HttpBasicAuth.php @@ -7,8 +7,6 @@ namespace yii\filters\auth; -use yii\web\Request; - /** * HttpBasicAuth is an action filter that supports the HTTP Basic authentication method. * diff --git a/framework/log/Target.php b/framework/log/Target.php index f1a6d3a..760d5de 100644 --- a/framework/log/Target.php +++ b/framework/log/Target.php @@ -353,14 +353,14 @@ abstract class Target extends Component /** * Returns formatted ('Y-m-d H:i:s') timestamp for message. - * If [[microtime]] is configured to true it will return format 'Y-m-d H:i:s.u' + * If [[microtime]] is configured to true it will return format 'Y-m-d H:i:s.u'. * @param float $timestamp * @return string * @since 2.0.13 */ protected function getTime($timestamp) { - list ($timestamp, $usec) = explode('.', StringHelper::floatToString($timestamp)); + list($timestamp, $usec) = explode('.', StringHelper::floatToString($timestamp)); return date('Y-m-d H:i:s', $timestamp) . ($this->microtime ? ('.' . $usec) : ''); } diff --git a/framework/rbac/migrations/m170907_052038_rbac_add_index_on_auth_assignment_user_id.php b/framework/rbac/migrations/m170907_052038_rbac_add_index_on_auth_assignment_user_id.php index e9d803f..08848d1 100644 --- a/framework/rbac/migrations/m170907_052038_rbac_add_index_on_auth_assignment_user_id.php +++ b/framework/rbac/migrations/m170907_052038_rbac_add_index_on_auth_assignment_user_id.php @@ -5,9 +5,9 @@ * @license http://www.yiiframework.com/license/ */ +use yii\base\InvalidConfigException; use yii\db\Migration; use yii\rbac\DbManager; -use yii\base\InvalidConfigException; /** * Adds index on `user_id` column in `auth_assignment` table for performance reasons. @@ -43,7 +43,6 @@ class m170907_052038_rbac_add_index_on_auth_assignment_user_id extends Migration { $authManager = $this->getAuthManager(); $this->createIndex($this->index, $authManager->assignmentTable, $this->column); - } /** diff --git a/framework/rest/IndexAction.php b/framework/rest/IndexAction.php index 182130f..f291c76 100644 --- a/framework/rest/IndexAction.php +++ b/framework/rest/IndexAction.php @@ -120,10 +120,10 @@ class IndexAction extends Action 'class' => ActiveDataProvider::className(), 'query' => $query, 'pagination' => [ - 'params' => $requestParams + 'params' => $requestParams, ], 'sort' => [ - 'params' => $requestParams + 'params' => $requestParams, ], ]); } diff --git a/framework/widgets/ActiveField.php b/framework/widgets/ActiveField.php index 833e48c..6e7d951 100644 --- a/framework/widgets/ActiveField.php +++ b/framework/widgets/ActiveField.php @@ -236,7 +236,7 @@ class ActiveField extends Component $inputID = $this->getInputId(); $attribute = Html::getAttributeName($this->attribute); $options = $this->options; - $class = isset($options['class']) ? (array)$options['class'] : []; + $class = isset($options['class']) ? (array) $options['class'] : []; $class[] = "field-$inputID"; if ($this->model->isAttributeRequired($attribute)) { $class[] = $this->form->requiredCssClass; diff --git a/framework/widgets/InputWidget.php b/framework/widgets/InputWidget.php index a44ea76..eed6744 100644 --- a/framework/widgets/InputWidget.php +++ b/framework/widgets/InputWidget.php @@ -89,7 +89,7 @@ class InputWidget extends Widget } /** - * Render a HTML input tag + * Render a HTML input tag. * * This will call [[Html::activeInput()]] if the input widget is [[hasModel()|tied to a model]], * or [[Html::input()]] if not. @@ -104,8 +104,7 @@ class InputWidget extends Widget { if ($this->hasModel()) { return Html::activeInput($type, $this->model, $this->attribute, $this->options); - } else { - return Html::input($type, $this->name, $this->value, $this->options); } + return Html::input($type, $this->name, $this->value, $this->options); } } diff --git a/tests/compatibility.php b/tests/compatibility.php index 82d0d4b..5e379b3 100644 --- a/tests/compatibility.php +++ b/tests/compatibility.php @@ -21,7 +21,6 @@ namespace PHPUnit\TextUI { if (!class_exists('\PHPUnit\TextUI\ResultPrinter') && class_exists('PHPUnit_TextUI_ResultPrinter')) { class ResultPrinter extends \PHPUnit_TextUI_ResultPrinter { - } } } @@ -30,7 +29,6 @@ namespace PHPUnit\Framework\Error { if (!class_exists('PHPUnit\Framework\Error\Notice') && class_exists('PHPUnit_Framework_Error_Notice')) { class Notice extends \PHPUnit_Framework_Error_Notice { - } } } diff --git a/tests/data/ar/Animal.php b/tests/data/ar/Animal.php index 7f7d866..1fc1103 100644 --- a/tests/data/ar/Animal.php +++ b/tests/data/ar/Animal.php @@ -1,5 +1,4 @@ hasOne(ProfileWithConstructor::className(), ['id' => 'profile_id']); } -} \ No newline at end of file +} diff --git a/tests/data/ar/Dog.php b/tests/data/ar/Dog.php index 17cac2e..02bd4bf 100644 --- a/tests/data/ar/Dog.php +++ b/tests/data/ar/Dog.php @@ -1,5 +1,4 @@ hasOne(OrderWithConstructor::className(), ['id' => 'order_id']); } -} \ No newline at end of file +} diff --git a/tests/data/ar/OrderWithConstructor.php b/tests/data/ar/OrderWithConstructor.php index e5fc058..82853d2 100644 --- a/tests/data/ar/OrderWithConstructor.php +++ b/tests/data/ar/OrderWithConstructor.php @@ -1,9 +1,14 @@ hasMany(OrderItemWithConstructor::className(), ['order_id' => 'id'])->inverseOf('order'); } -} \ No newline at end of file +} diff --git a/tests/data/ar/ProfileWithConstructor.php b/tests/data/ar/ProfileWithConstructor.php index d94a122..57ecb13 100644 --- a/tests/data/ar/ProfileWithConstructor.php +++ b/tests/data/ar/ProfileWithConstructor.php @@ -1,9 +1,14 @@ newInstanceWithoutConstructor(); } -} \ No newline at end of file +} diff --git a/tests/data/modules/magic/Module.php b/tests/data/modules/magic/Module.php index 453af2c..9041005 100644 --- a/tests/data/modules/magic/Module.php +++ b/tests/data/modules/magic/Module.php @@ -1,8 +1,12 @@ assertSame($speakerModel, Speaker::instance()); $this->assertNotSame($speakerModel, Speaker::instance(true)); } -} \ No newline at end of file +} diff --git a/tests/framework/base/WidgetTest.php b/tests/framework/base/WidgetTest.php index 0b7a82e..54a5b50 100644 --- a/tests/framework/base/WidgetTest.php +++ b/tests/framework/base/WidgetTest.php @@ -99,4 +99,4 @@ class TestWidget extends Widget { return 'id . '>'; } -} \ No newline at end of file +} diff --git a/tests/framework/data/ActiveDataFilterTest.php b/tests/framework/data/ActiveDataFilterTest.php index c74df3c..179f592 100644 --- a/tests/framework/data/ActiveDataFilterTest.php +++ b/tests/framework/data/ActiveDataFilterTest.php @@ -1,4 +1,9 @@ [ ['name' => 'some'], ['number' => '2'], - ] + ], ], [ 'AND', ['name' => 'some'], ['number' => '2'], - ] + ], ], [ [ @@ -59,7 +64,7 @@ class ActiveDataFilterTest extends TestCase [ [ 'number' => [ - 'in' => [1, 5, 8] + 'in' => [1, 5, 8], ], ], ['IN', 'number', [1, 5, 8]], @@ -67,7 +72,7 @@ class ActiveDataFilterTest extends TestCase [ [ 'not' => [ - 'number' => 10 + 'number' => 10, ], ], ['NOT', ['number' => 10]], @@ -94,7 +99,7 @@ class ActiveDataFilterTest extends TestCase ], ], ], - ] + ], ], [ 'OR', @@ -177,7 +182,7 @@ class ActiveDataFilterTest extends TestCase 'or' => [ ['name' => 'some'], ['name' => 'another'], - ] + ], ]; $expectedResult = [ 'CALLBACK-OR', @@ -190,10 +195,10 @@ class ActiveDataFilterTest extends TestCase $builder->filter = [ 'name' => [ - 'like' => 'foo' + 'like' => 'foo', ], ]; $expectedResult = ['CALLBACK-LIKE', 'LIKE', 'foo', 'name']; $this->assertEquals($expectedResult, $builder->build()); } -} \ No newline at end of file +} diff --git a/tests/framework/data/DataFilterTest.php b/tests/framework/data/DataFilterTest.php index 5cfe145..45005eb 100644 --- a/tests/framework/data/DataFilterTest.php +++ b/tests/framework/data/DataFilterTest.php @@ -1,4 +1,9 @@ 'value' + 'name' => 'value', ]; $builder = new DataFilter(); @@ -86,19 +91,19 @@ class DataFilterTest extends TestCase [ [], true, - [] + [], ], [ null, true, - [] + [], ], [ '', false, [ - 'The format of Filter is invalid.' - ] + 'The format of Filter is invalid.', + ], ], [ [ @@ -106,7 +111,7 @@ class DataFilterTest extends TestCase 'number' => '10', ], true, - [] + [], ], [ [ @@ -115,14 +120,14 @@ class DataFilterTest extends TestCase ], false, [ - "Unknown filter attribute 'fake'" - ] + "Unknown filter attribute 'fake'", + ], ], [ [ 'and' => [ [ - 'name' => ['eq' => 'foo'] + 'name' => ['eq' => 'foo'], ], [ 'number' => ['in' => [1, 5, 8]], @@ -130,7 +135,7 @@ class DataFilterTest extends TestCase ], ], true, - [] + [], ], [ [ @@ -141,21 +146,21 @@ class DataFilterTest extends TestCase ], false, [ - "Operator 'and' requires multiple operands." - ] + "Operator 'and' requires multiple operands.", + ], ], [ [ - 'not' => ['name' => 'foo'] + 'not' => ['name' => 'foo'], ], true, - [] + [], ], [ [ 'and' => [ [ - 'not' => ['name' => 'foo'] + 'not' => ['name' => 'foo'], ], [ 'number' => ['in' => [1, 5, 8]], @@ -163,7 +168,7 @@ class DataFilterTest extends TestCase ], ], true, - [] + [], ], [ [ @@ -171,8 +176,8 @@ class DataFilterTest extends TestCase ], false, [ - "Name must be a string." - ] + 'Name must be a string.', + ], ], [ [ @@ -182,7 +187,7 @@ class DataFilterTest extends TestCase ], ], true, - [] + [], ], [ [ @@ -190,8 +195,8 @@ class DataFilterTest extends TestCase ], false, [ - "Operator 'gt' must be used with a search attribute." - ] + "Operator 'gt' must be used with a search attribute.", + ], ], ]; } @@ -202,7 +207,7 @@ class DataFilterTest extends TestCase * @dataProvider dataProviderValidate * * @param array $filter - * @param boolean $expectedResult + * @param bool $expectedResult * @param array $expectedErrors */ public function testValidate($filter, $expectedResult, $expectedErrors) @@ -268,20 +273,20 @@ class DataFilterTest extends TestCase [ 'and' => [ [ - 'name' => ['eq' => 'foo'] + 'name' => ['eq' => 'foo'], ], [ - 'number' => ['gte' => 15] + 'number' => ['gte' => 15], ], ], ], [ 'AND' => [ [ - 'name' => ['=' => 'foo'] + 'name' => ['=' => 'foo'], ], [ - 'number' => ['>=' => 15] + 'number' => ['>=' => 15], ], ], ], @@ -318,7 +323,7 @@ class DataFilterTest extends TestCase $builder->setSearchModel($searchModel); $builder->attributeMap = [ - 'authorName' => '{{author}}.[[name]]' + 'authorName' => '{{author}}.[[name]]', ]; $builder->filter = $filter; @@ -329,7 +334,7 @@ class DataFilterTest extends TestCase { $builder = new DataFilter(); $builder->setErrorMessages([ - 'unsupportedOperatorType' => 'Test message' + 'unsupportedOperatorType' => 'Test message', ]); $errorMessages = $builder->getErrorMessages(); @@ -338,7 +343,7 @@ class DataFilterTest extends TestCase $builder->setErrorMessages(function () { return [ - 'unsupportedOperatorType' => 'Test message callback' + 'unsupportedOperatorType' => 'Test message callback', ]; }); $errorMessages = $builder->getErrorMessages(); diff --git a/tests/framework/db/ActiveRecordTest.php b/tests/framework/db/ActiveRecordTest.php index 989644d..e62219a 100644 --- a/tests/framework/db/ActiveRecordTest.php +++ b/tests/framework/db/ActiveRecordTest.php @@ -1587,7 +1587,7 @@ abstract class ActiveRecordTest extends DatabaseTestCase $this->assertNotNull($order->customerJoinedWithProfile); $customerWithProfile = $order->customerJoinedWithProfile; - $this->assertInstanceOf(CustomerWithConstructor::className(), $customerWithProfile); + $this->assertInstanceOf(CustomerWithConstructor::className(), $customerWithProfile); $this->assertEquals(1, $customerWithProfile->id); $this->assertNotNull($customerProfile = $customerWithProfile->profile); diff --git a/tests/framework/db/CommandTest.php b/tests/framework/db/CommandTest.php index abd3c12..bad86d7 100644 --- a/tests/framework/db/CommandTest.php +++ b/tests/framework/db/CommandTest.php @@ -376,7 +376,7 @@ SQL; ['int_col', 'float_col', 'char_col'], [['', '', 'Kyiv {{city}}, Ukraine']], - 'expected' => "INSERT INTO `type` (`int_col`, `float_col`, `char_col`) VALUES (NULL, NULL, 'Kyiv {{city}}, Ukraine')" + 'expected' => "INSERT INTO `type` (`int_col`, `float_col`, `char_col`) VALUES (NULL, NULL, 'Kyiv {{city}}, Ukraine')", // See https://github.com/yiisoft/yii2/issues/11242 // Make sure curly bracelets (`{{..}}`) in values will not be escaped ], @@ -385,7 +385,7 @@ SQL; ['{{%type}}.[[int_col]]', '[[float_col]]', 'char_col'], [['', '', 'Kyiv {{city}}, Ukraine']], - 'expected' => "INSERT INTO `type` (`type`.`int_col`, `float_col`, `char_col`) VALUES ('', '', 'Kyiv {{city}}, Ukraine')" + 'expected' => "INSERT INTO `type` (`type`.`int_col`, `float_col`, `char_col`) VALUES ('', '', 'Kyiv {{city}}, Ukraine')", /* Test covers potentially wrong behavior and marks it as expected! * In case table name or table column is passed with curly or square bracelets, * QueryBuilder can not determine the table schema and typecast values properly. @@ -397,16 +397,19 @@ SQL; /** * Make sure that `{{something}}` in values will not be encoded - * https://github.com/yiisoft/yii2/issues/11242 + * https://github.com/yiisoft/yii2/issues/11242. * * @dataProvider batchInsertSqlProvider + * @param mixed $table + * @param mixed $columns + * @param mixed $values + * @param mixed $expected */ public function testBatchInsertSQL($table, $columns, $values, $expected) { $command = $this->getConnection()->createCommand(); $command->batchInsert($table, $columns, $values); $this->assertEquals($expected, $command->getSql()); - } public function testInsert() diff --git a/tests/framework/db/QueryBuilderTest.php b/tests/framework/db/QueryBuilderTest.php index 5a3d992..a66d049 100644 --- a/tests/framework/db/QueryBuilderTest.php +++ b/tests/framework/db/QueryBuilderTest.php @@ -1777,7 +1777,7 @@ abstract class QueryBuilderTest extends DatabaseTestCase 'is_active' => false, 'related_id' => null, ], - $this->replaceQuotes("INSERT INTO [[customer]] ([[email]], [[name]], [[address]], [[is_active]], [[related_id]]) VALUES (:qp0, :qp1, :qp2, :qp3, :qp4)"), + $this->replaceQuotes('INSERT INTO [[customer]] ([[email]], [[name]], [[address]], [[is_active]], [[related_id]]) VALUES (:qp0, :qp1, :qp2, :qp3, :qp4)'), [ ':qp0' => 'test@example.com', ':qp1' => 'silverfire', @@ -1795,7 +1795,7 @@ abstract class QueryBuilderTest extends DatabaseTestCase 'INSERT INTO {{%type}} ({{%type}}.[[related_id]], [[time]]) VALUES (:qp0, now())', [ ':qp0' => null, - ] + ], ], ]; } @@ -1922,12 +1922,12 @@ abstract class QueryBuilderTest extends DatabaseTestCase 'user', [ 'is_enabled' => false, - 'power' => new Expression('WRONG_POWER()') + 'power' => new Expression('WRONG_POWER()'), ], $this->replaceQuotes('DELETE FROM [[user]] WHERE ([[is_enabled]]=:qp0) AND ([[power]]=WRONG_POWER())'), [ ':qp0' => false, - ] + ], ], ]; } diff --git a/tests/framework/di/stubs/Variadic.php b/tests/framework/di/stubs/Variadic.php index ce52251..e822c96 100644 --- a/tests/framework/di/stubs/Variadic.php +++ b/tests/framework/di/stubs/Variadic.php @@ -15,8 +15,5 @@ class Variadic { public function __construct(QuxInterface ...$quxes) { - } - - } diff --git a/tests/framework/di/testContainerWithVariadicCallable.php b/tests/framework/di/testContainerWithVariadicCallable.php index c034643..c6fd0c8 100644 --- a/tests/framework/di/testContainerWithVariadicCallable.php +++ b/tests/framework/di/testContainerWithVariadicCallable.php @@ -9,7 +9,7 @@ use yii\di\Container; use yiiunit\framework\di\stubs\QuxInterface; $container = new Container(); -$func = function(QuxInterface ...$quxes) { +$func = function (QuxInterface ...$quxes) { return "That's a whole lot of quxes!"; }; $container->invoke($func); diff --git a/tests/framework/filters/AccessRuleTest.php b/tests/framework/filters/AccessRuleTest.php index ee1bd90..bc93bd1 100644 --- a/tests/framework/filters/AccessRuleTest.php +++ b/tests/framework/filters/AccessRuleTest.php @@ -299,7 +299,7 @@ class AccessRuleTest extends \yiiunit\TestCase $this->expectException('yii\base\InvalidConfigException'); $rule->allows($action, false, $request); } - + public function testMatchRolesAndPermissions() { $action = $this->mockAction(); diff --git a/tests/framework/helpers/HtmlTest.php b/tests/framework/helpers/HtmlTest.php index e4e22e2..992d4c6 100644 --- a/tests/framework/helpers/HtmlTest.php +++ b/tests/framework/helpers/HtmlTest.php @@ -145,7 +145,7 @@ class HtmlTest extends TestCase 'request' => [ 'class' => 'yii\web\Request', 'enableCsrfValidation' => true, - ] + ], ], ]); $this->expectException('yii\base\InvalidConfigException'); diff --git a/tests/framework/i18n/FormatterTest.php b/tests/framework/i18n/FormatterTest.php index b7d502f..1621d3a 100644 --- a/tests/framework/i18n/FormatterTest.php +++ b/tests/framework/i18n/FormatterTest.php @@ -8,7 +8,6 @@ namespace yiiunit\framework\i18n; use Yii; -use yii\base\InvalidConfigException; use yii\i18n\Formatter; use yiiunit\TestCase; @@ -233,66 +232,71 @@ class FormatterTest extends TestCase return [ [ 'Empty value gets proper output', - [null], '(not set)', '(not set)' + [null], '(not set)', '(not set)', ], [ 'Wrong value is casted properly', ['NaN'], '0 millimeters', '0 mm', - ['yii\base\InvalidParamException', "'NaN' is not a numeric value"] + ['yii\base\InvalidParamException', "'NaN' is not a numeric value"], ], [ 'Negative value works', - [-3], '-3 meters', '-3 m' + [-3], '-3 meters', '-3 m', ], [ 'Zero value works', - [0], '0 millimeters', '0 mm' + [0], '0 millimeters', '0 mm', ], [ 'Decimal value is resolved in base units', - [0.001], '1 millimeter', '1 mm' + [0.001], '1 millimeter', '1 mm', ], [ 'Decimal value smaller than minimum base unit gets rounded (#1)', - [0.0004], '0 millimeters', '0 mm' + [0.0004], '0 millimeters', '0 mm', ], [ 'Decimal value smaller than minimum base unit gets rounded (#2)', - [0.00169], '2 millimeters', '2 mm' + [0.00169], '2 millimeters', '2 mm', ], [ 'Integer value #1 works', - [1], '1 meter', '1 m' + [1], '1 meter', '1 m', ], [ 'Integer value #2 works', - [453], '453 meters', '453 m' + [453], '453 meters', '453 m', ], [ 'Double value works', - [19913.13], '19.913 kilometers', '19.913 km' + [19913.13], '19.913 kilometers', '19.913 km', ], [ 'It is possible to change number of decimals', - [19913.13, 1], '19.9 kilometers', '19.9 km' + [19913.13, 1], '19.9 kilometers', '19.9 km', ], [ 'It is possible to change number formatting options', [100, null, [ \NumberFormatter::MIN_FRACTION_DIGITS => 4, - ]], '100.0000 meters', '100.0000 m' + ]], '100.0000 meters', '100.0000 m', ], [ 'It is possible to change text options', [-19913.13, null, null, [ - \NumberFormatter::NEGATIVE_PREFIX => 'MINUS' - ]], 'MINUS19.913 kilometers', 'MINUS19.913 km' + \NumberFormatter::NEGATIVE_PREFIX => 'MINUS', + ]], 'MINUS19.913 kilometers', 'MINUS19.913 km', ], ]; } /** * @dataProvider lengthDataProvider + * @param mixed $message + * @param mixed $arguments + * @param mixed $expected + * @param mixed $_shortLength + * @param mixed $expectedException */ public function testIntlAsLength($message, $arguments, $expected, $_shortLength, $expectedException = []) { @@ -306,6 +310,11 @@ class FormatterTest extends TestCase /** * @dataProvider lengthDataProvider + * @param mixed $message + * @param mixed $arguments + * @param mixed $_length + * @param mixed $expected + * @param mixed $expectedException */ public function testIntlAsShortLength($message, $arguments, $_length, $expected, $expectedException = []) { @@ -322,66 +331,71 @@ class FormatterTest extends TestCase return [ [ 'Empty value gets proper output', - [null], '(not set)', '(not set)' + [null], '(not set)', '(not set)', ], [ 'Wrong value is casted properly', ['NaN'], '0 grams', '0 g', - ['yii\base\InvalidParamException', "'NaN' is not a numeric value"] + ['yii\base\InvalidParamException', "'NaN' is not a numeric value"], ], [ 'Negative value works', - [-3], '-3 kilograms', '-3 kg' + [-3], '-3 kilograms', '-3 kg', ], [ 'Zero value works', - [0], '0 grams', '0 g' + [0], '0 grams', '0 g', ], [ 'Decimal value is resolved in base units', - [0.001], '1 gram', '1 g' + [0.001], '1 gram', '1 g', ], [ 'Decimal value smaller than minimum base unit gets rounded (#1)', - [0.0004], '0 grams', '0 g' + [0.0004], '0 grams', '0 g', ], [ 'Decimal value smaller than minimum base unit gets rounded (#2)', - [0.00169], '2 grams', '2 g' + [0.00169], '2 grams', '2 g', ], [ 'Integer value #1 works', - [1], '1 kilogram', '1 kg' + [1], '1 kilogram', '1 kg', ], [ 'Integer value #2 works', - [453], '453 kilograms', '453 kg' + [453], '453 kilograms', '453 kg', ], [ 'Double value works', - [19913.13], '19.913 tons', '19.913 tn' + [19913.13], '19.913 tons', '19.913 tn', ], [ 'It is possible to change number of decimals', - [19913.13, 1], '19.9 tons', '19.9 tn' + [19913.13, 1], '19.9 tons', '19.9 tn', ], [ 'It is possible to change number formatting options', [100, null, [ \NumberFormatter::MIN_FRACTION_DIGITS => 4, - ]], '100.0000 kilograms', '100.0000 kg' + ]], '100.0000 kilograms', '100.0000 kg', ], [ 'It is possible to change text options', [-19913.13, null, null, [ - \NumberFormatter::NEGATIVE_PREFIX => 'MINUS' - ]], 'MINUS19.913 tons', 'MINUS19.913 tn' + \NumberFormatter::NEGATIVE_PREFIX => 'MINUS', + ]], 'MINUS19.913 tons', 'MINUS19.913 tn', ], ]; } /** * @dataProvider weightDataProvider + * @param mixed $message + * @param mixed $arguments + * @param mixed $expected + * @param mixed $_shortWeight + * @param mixed $expectedException */ public function testIntlAsWeight($message, $arguments, $expected, $_shortWeight, $expectedException = []) { @@ -395,6 +409,11 @@ class FormatterTest extends TestCase /** * @dataProvider weightDataProvider + * @param mixed $message + * @param mixed $arguments + * @param mixed $_weight + * @param mixed $expected + * @param mixed $expectedException */ public function testIntlAsShortWeight($message, $arguments, $_weight, $expected, $expectedException = []) { diff --git a/tests/framework/log/ArrayTarget.php b/tests/framework/log/ArrayTarget.php index 763df95..e655573 100644 --- a/tests/framework/log/ArrayTarget.php +++ b/tests/framework/log/ArrayTarget.php @@ -1,4 +1,9 @@ setComponents([ 'db' => static::createConnection(), - 'authManager' => '\yii\rbac\DbManager' + 'authManager' => '\yii\rbac\DbManager', ]); self::assertSame(static::$driverName, Yii::$app->db->getDriverName(), 'Connection represents the same DB driver, as is tested'); ob_start(); diff --git a/tests/framework/test/ArrayFixtureTest.php b/tests/framework/test/ArrayFixtureTest.php index 2ccd51e..e95a07d 100644 --- a/tests/framework/test/ArrayFixtureTest.php +++ b/tests/framework/test/ArrayFixtureTest.php @@ -1,5 +1,4 @@ OrderItem::className(), 'targetAttribute' => ['id' => 'COALESCE(order_id, 0)'], ]); - $m = new Order(['id' => 1]); - $val->validateAttribute($m, 'id'); - $this->assertFalse($m->hasErrors('id')); - } + $m = new Order(['id' => 1]); + $val->validateAttribute($m, 'id'); + $this->assertFalse($m->hasErrors('id')); + } } diff --git a/tests/framework/validators/FileValidatorTest.php b/tests/framework/validators/FileValidatorTest.php index c0be7c2..fb4466b 100644 --- a/tests/framework/validators/FileValidatorTest.php +++ b/tests/framework/validators/FileValidatorTest.php @@ -422,7 +422,7 @@ class FileValidatorTest extends TestCase */ public function testValidateFileByExtensionUsingMimeType($fileName, $_, $allowedExtensions) { - $validator = new FileValidator(['extensions' => (array)$allowedExtensions]); + $validator = new FileValidator(['extensions' => (array) $allowedExtensions]); $file = $this->getRealTestFile($fileName); $this->assertTrue($validator->validate($file)); } @@ -435,7 +435,7 @@ class FileValidatorTest extends TestCase */ public function testValidateFileByExtensionUsingMimeTypeInvalid($fileName, $_, $allowedExtensions) { - $validator = new FileValidator(['extensions' => (array)$allowedExtensions]); + $validator = new FileValidator(['extensions' => (array) $allowedExtensions]); $file = $this->getRealTestFile($fileName); $this->assertFalse($validator->validate($file)); } diff --git a/tests/framework/web/ErrorHandlerTest.php b/tests/framework/web/ErrorHandlerTest.php index 4077efb..91b1940 100644 --- a/tests/framework/web/ErrorHandlerTest.php +++ b/tests/framework/web/ErrorHandlerTest.php @@ -29,9 +29,9 @@ class ErrorHandlerTest extends TestCase public function testCorrectResponseCodeInErrorView() { /** @var ErrorHandler $handler */ - $handler = Yii::$app->getErrorHandler(); + $handler = Yii::$app->getErrorHandler(); ob_start(); // suppress response output - $this->invokeMethod($handler, 'renderException', [new NotFoundHttpException('This message is displayed to end user')]); + $this->invokeMethod($handler, 'renderException', [new NotFoundHttpException('This message is displayed to end user')]); ob_get_clean(); $out = Yii::$app->response->data; $this->assertEquals('Code: 404 diff --git a/tests/framework/web/UrlNormalizerTest.php b/tests/framework/web/UrlNormalizerTest.php index e0a6a83..f31f8b1 100644 --- a/tests/framework/web/UrlNormalizerTest.php +++ b/tests/framework/web/UrlNormalizerTest.php @@ -1,5 +1,4 @@ * diff --git a/tests/framework/web/session/mysql/DbSessionTest.php b/tests/framework/web/session/mysql/DbSessionTest.php index 459f4cb..7282b6b 100644 --- a/tests/framework/web/session/mysql/DbSessionTest.php +++ b/tests/framework/web/session/mysql/DbSessionTest.php @@ -1,9 +1,14 @@ * diff --git a/tests/framework/web/session/pgsql/DbSessionTest.php b/tests/framework/web/session/pgsql/DbSessionTest.php index 58350fc..12a447b 100644 --- a/tests/framework/web/session/pgsql/DbSessionTest.php +++ b/tests/framework/web/session/pgsql/DbSessionTest.php @@ -1,9 +1,14 @@ * diff --git a/tests/framework/web/session/sqlite/DbSessionTest.php b/tests/framework/web/session/sqlite/DbSessionTest.php index bb90faa..d6724cf 100644 --- a/tests/framework/web/session/sqlite/DbSessionTest.php +++ b/tests/framework/web/session/sqlite/DbSessionTest.php @@ -1,9 +1,14 @@ * diff --git a/tests/framework/widgets/ActiveFieldTest.php b/tests/framework/widgets/ActiveFieldTest.php index edd9af6..26c6f01 100644 --- a/tests/framework/widgets/ActiveFieldTest.php +++ b/tests/framework/widgets/ActiveFieldTest.php @@ -535,7 +535,7 @@ EOD; public function testOptionsClass() { $this->activeField->options = ['class' => 'test-wrapper']; - $expectedValue = << @@ -547,7 +547,7 @@ HTML; $this->assertEqualsWithoutLE($expectedValue, trim($actualValue)); $this->activeField->options = ['class' => ['test-wrapper', 'test-add']]; - $expectedValue = <<