Browse Source

Code style fixes

tags/2.0.13
Alexander Makarov 7 years ago
parent
commit
fb23b0d0ea
No known key found for this signature in database
GPG Key ID: 3617B79C6A325E4A
  1. 2
      framework/data/ActiveDataFilter.php
  2. 10
      framework/data/DataFilter.php
  3. 4
      framework/db/Migration.php
  4. 2
      framework/filters/auth/HttpBasicAuth.php
  5. 4
      framework/log/Target.php
  6. 3
      framework/rbac/migrations/m170907_052038_rbac_add_index_on_auth_assignment_user_id.php
  7. 4
      framework/rest/IndexAction.php
  8. 2
      framework/widgets/ActiveField.php
  9. 5
      framework/widgets/InputWidget.php
  10. 2
      tests/compatibility.php
  11. 1
      tests/data/ar/Animal.php
  12. 1
      tests/data/ar/BitValues.php
  13. 1
      tests/data/ar/Cat.php
  14. 7
      tests/data/ar/CustomerWithConstructor.php
  15. 1
      tests/data/ar/Dog.php
  16. 7
      tests/data/ar/OrderItemWithConstructor.php
  17. 7
      tests/data/ar/OrderWithConstructor.php
  18. 7
      tests/data/ar/ProfileWithConstructor.php
  19. 6
      tests/data/modules/magic/Module.php
  20. 5
      tests/data/modules/magic/controllers/ETagController.php
  21. 5
      tests/framework/base/StaticInstanceTraitTest.php
  22. 19
      tests/framework/data/ActiveDataFilterTest.php
  23. 63
      tests/framework/data/DataFilterTest.php
  24. 11
      tests/framework/db/CommandTest.php
  25. 8
      tests/framework/db/QueryBuilderTest.php
  26. 3
      tests/framework/di/stubs/Variadic.php
  27. 2
      tests/framework/di/testContainerWithVariadicCallable.php
  28. 2
      tests/framework/helpers/HtmlTest.php
  29. 77
      tests/framework/i18n/FormatterTest.php
  30. 5
      tests/framework/log/ArrayTarget.php
  31. 3
      tests/framework/rbac/DbManagerTestCase.php
  32. 1
      tests/framework/test/ArrayFixtureTest.php
  33. 4
      tests/framework/validators/FileValidatorTest.php
  34. 1
      tests/framework/web/UrlNormalizerTest.php
  35. 2
      tests/framework/web/ViewTest.php
  36. 1
      tests/framework/web/session/AbstractDbSessionTest.php
  37. 7
      tests/framework/web/session/mssql/DbSessionTest.php
  38. 7
      tests/framework/web/session/mysql/DbSessionTest.php
  39. 7
      tests/framework/web/session/pgsql/DbSessionTest.php
  40. 7
      tests/framework/web/session/sqlite/DbSessionTest.php
  41. 4
      tests/framework/widgets/ActiveFieldTest.php

2
framework/data/ActiveDataFilter.php

@ -145,7 +145,7 @@ class ActiveDataFilter extends DataFilter
}
return [
$operator,
$this->buildCondition($condition)
$this->buildCondition($condition),
];
}

10
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.

4
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

2
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.
*

4
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) : '');
}

3
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);
}
/**

4
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,
],
]);
}

2
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;

5
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);
}
}

2
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
{
}
}
}

1
tests/data/ar/Animal.php

@ -1,5 +1,4 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC

1
tests/data/ar/BitValues.php

@ -1,5 +1,4 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC

1
tests/data/ar/Cat.php

@ -1,5 +1,4 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC

7
tests/data/ar/CustomerWithConstructor.php

@ -1,9 +1,14 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yiiunit\data\ar;
/**
* CustomerWithConstructor
* CustomerWithConstructor.
*
* @property int $id
* @property string $name

1
tests/data/ar/Dog.php

@ -1,5 +1,4 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC

7
tests/data/ar/OrderItemWithConstructor.php

@ -1,9 +1,14 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yiiunit\data\ar;
/**
* OrderItemWithConstructor
* OrderItemWithConstructor.
*
* @property int $order_id
* @property int $item_id

7
tests/data/ar/OrderWithConstructor.php

@ -1,9 +1,14 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yiiunit\data\ar;
/**
* OrderWithConstructor
* OrderWithConstructor.
*
* @property int $id
* @property int $customer_id

7
tests/data/ar/ProfileWithConstructor.php

@ -1,9 +1,14 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yiiunit\data\ar;
/**
* ProfileWithConstructor
* ProfileWithConstructor.
*
* @property int $id
* @property string $description

6
tests/data/modules/magic/Module.php

@ -1,8 +1,12 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yiiunit\data\modules\magic;
class Module extends \yii\base\Module
{
}

5
tests/data/modules/magic/controllers/ETagController.php

@ -1,4 +1,9 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yiiunit\data\modules\magic\controllers;

5
tests/framework/base/StaticInstanceTraitTest.php

@ -1,4 +1,9 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yiiunit\framework\base;

19
tests/framework/data/ActiveDataFilterTest.php

@ -1,4 +1,9 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yiiunit\framework\data;
@ -40,13 +45,13 @@ class ActiveDataFilterTest extends TestCase
'and' => [
['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,7 +195,7 @@ class ActiveDataFilterTest extends TestCase
$builder->filter = [
'name' => [
'like' => 'foo'
'like' => 'foo',
],
];
$expectedResult = ['CALLBACK-LIKE', 'LIKE', 'foo', 'name'];

63
tests/framework/data/DataFilterTest.php

@ -1,4 +1,9 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yiiunit\framework\data;
@ -56,7 +61,7 @@ class DataFilterTest extends TestCase
public function testLoad()
{
$filterValue = [
'name' => '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();

11
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()

8
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,
]
],
],
];
}

3
tests/framework/di/stubs/Variadic.php

@ -15,8 +15,5 @@ class Variadic
{
public function __construct(QuxInterface ...$quxes)
{
}
}

2
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);

2
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');

77
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], '<span class="not-set">(not set)</span>', '<span class="not-set">(not set)</span>'
[null], '<span class="not-set">(not set)</span>', '<span class="not-set">(not set)</span>',
],
[
'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], '<span class="not-set">(not set)</span>', '<span class="not-set">(not set)</span>'
[null], '<span class="not-set">(not set)</span>', '<span class="not-set">(not set)</span>',
],
[
'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 = [])
{

5
tests/framework/log/ArrayTarget.php

@ -1,4 +1,9 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yiiunit\framework\log;

3
tests/framework/rbac/DbManagerTestCase.php

@ -20,7 +20,6 @@ use yii\rbac\Permission;
use yii\rbac\Role;
use yiiunit\data\rbac\UserID;
use yiiunit\framework\console\controllers\EchoMigrateController;
use yiiunit\framework\db\oci\QueryBuilderTest;
use yiiunit\framework\log\ArrayTarget;
/**
@ -56,7 +55,7 @@ abstract class DbManagerTestCase extends ManagerTestCase
Yii::$app->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();

1
tests/framework/test/ArrayFixtureTest.php

@ -1,5 +1,4 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC

4
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));
}

1
tests/framework/web/UrlNormalizerTest.php

@ -1,5 +1,4 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC

2
tests/framework/web/ViewTest.php

@ -99,7 +99,7 @@ class ViewTest extends TestCase
}
/**
* Parses CSRF token from page HTML
* Parses CSRF token from page HTML.
*
* @param string $html
* @return string CSRF token

1
tests/framework/web/session/AbstractDbSessionTest.php

@ -8,7 +8,6 @@
namespace yiiunit\framework\web\session;
use Yii;
use yii\base\Security;
use yii\db\Connection;
use yii\db\Query;
use yii\web\DbSession;

7
tests/framework/web/session/mssql/DbSessionTest.php

@ -1,9 +1,14 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yiiunit\framework\web\session\mssql;
/**
* Class DbSessionTest
* Class DbSessionTest.
*
* @author Dmytro Naumenko <d.naumenko.a@gmail.com>
*

7
tests/framework/web/session/mysql/DbSessionTest.php

@ -1,9 +1,14 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yiiunit\framework\web\session\mysql;
/**
* Class DbSessionTest
* Class DbSessionTest.
*
* @author Dmytro Naumenko <d.naumenko.a@gmail.com>
*

7
tests/framework/web/session/pgsql/DbSessionTest.php

@ -1,9 +1,14 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yiiunit\framework\web\session\pgsql;
/**
* Class DbSessionTest
* Class DbSessionTest.
*
* @author Dmytro Naumenko <d.naumenko.a@gmail.com>
*

7
tests/framework/web/session/sqlite/DbSessionTest.php

@ -1,9 +1,14 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yiiunit\framework\web\session\sqlite;
/**
* Class DbSessionTest
* Class DbSessionTest.
*
* @author Dmytro Naumenko <d.naumenko.a@gmail.com>
*

4
tests/framework/widgets/ActiveFieldTest.php

@ -535,7 +535,7 @@ EOD;
public function testOptionsClass()
{
$this->activeField->options = ['class' => 'test-wrapper'];
$expectedValue = <<<HTML
$expectedValue = <<<'HTML'
<div class="test-wrapper field-activefieldtestmodel-attributename">
<input type="hidden" id="activefieldtestmodel-attributename" class="form-control" name="ActiveFieldTestModel[attributeName]">
@ -547,7 +547,7 @@ HTML;
$this->assertEqualsWithoutLE($expectedValue, trim($actualValue));
$this->activeField->options = ['class' => ['test-wrapper', 'test-add']];
$expectedValue = <<<HTML
$expectedValue = <<<'HTML'
<div class="test-wrapper test-add field-activefieldtestmodel-attributename">
<input type="hidden" id="activefieldtestmodel-attributename" class="form-control" name="ActiveFieldTestModel[attributeName]">

Loading…
Cancel
Save