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. 8
      framework/data/DataFilter.php
  3. 4
      framework/db/Migration.php
  4. 2
      framework/filters/auth/HttpBasicAuth.php
  5. 2
      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. 5
      framework/widgets/InputWidget.php
  9. 2
      tests/compatibility.php
  10. 1
      tests/data/ar/Animal.php
  11. 1
      tests/data/ar/BitValues.php
  12. 1
      tests/data/ar/Cat.php
  13. 7
      tests/data/ar/CustomerWithConstructor.php
  14. 1
      tests/data/ar/Dog.php
  15. 7
      tests/data/ar/OrderItemWithConstructor.php
  16. 7
      tests/data/ar/OrderWithConstructor.php
  17. 7
      tests/data/ar/ProfileWithConstructor.php
  18. 6
      tests/data/modules/magic/Module.php
  19. 5
      tests/data/modules/magic/controllers/ETagController.php
  20. 5
      tests/framework/base/StaticInstanceTraitTest.php
  21. 19
      tests/framework/data/ActiveDataFilterTest.php
  22. 63
      tests/framework/data/DataFilterTest.php
  23. 11
      tests/framework/db/CommandTest.php
  24. 8
      tests/framework/db/QueryBuilderTest.php
  25. 3
      tests/framework/di/stubs/Variadic.php
  26. 2
      tests/framework/helpers/HtmlTest.php
  27. 77
      tests/framework/i18n/FormatterTest.php
  28. 5
      tests/framework/log/ArrayTarget.php
  29. 3
      tests/framework/rbac/DbManagerTestCase.php
  30. 1
      tests/framework/test/ArrayFixtureTest.php
  31. 1
      tests/framework/web/UrlNormalizerTest.php
  32. 2
      tests/framework/web/ViewTest.php
  33. 1
      tests/framework/web/session/AbstractDbSessionTest.php
  34. 7
      tests/framework/web/session/mssql/DbSessionTest.php
  35. 7
      tests/framework/web/session/mysql/DbSessionTest.php
  36. 7
      tests/framework/web/session/pgsql/DbSessionTest.php
  37. 7
      tests/framework/web/session/sqlite/DbSessionTest.php
  38. 4
      tests/framework/widgets/ActiveFieldTest.php

2
framework/data/ActiveDataFilter.php

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

8
framework/data/DataFilter.php

@ -414,7 +414,7 @@ class DataFilter extends Model
$params = array_merge( $params = array_merge(
[ [
'filter' => $this->getAttributeLabel($this->filterAttributeName) 'filter' => $this->getAttributeLabel($this->filterAttributeName),
], ],
$params $params
); );
@ -430,7 +430,7 @@ class DataFilter extends Model
public function attributes() public function attributes()
{ {
return [ return [
$this->filterAttributeName $this->filterAttributeName,
]; ];
} }
@ -448,7 +448,7 @@ class DataFilter extends Model
public function rules() public function rules()
{ {
return [ 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. * 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 * before building the filter. Defaults to `true`. If the validation fails, no filter will
* be built and this method will return `false`. * be built and this method will return `false`.
* @return mixed|false built actual filter value, or `false` if validation fails. * @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. * @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. * @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. * @param float $time the time before the command was executed.
* @since 2.0.13 * @since 2.0.13

2
framework/filters/auth/HttpBasicAuth.php

@ -7,8 +7,6 @@
namespace yii\filters\auth; namespace yii\filters\auth;
use yii\web\Request;
/** /**
* HttpBasicAuth is an action filter that supports the HTTP Basic authentication method. * HttpBasicAuth is an action filter that supports the HTTP Basic authentication method.
* *

2
framework/log/Target.php

@ -353,7 +353,7 @@ abstract class Target extends Component
/** /**
* Returns formatted ('Y-m-d H:i:s') timestamp for message. * 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 * @param float $timestamp
* @return string * @return string
* @since 2.0.13 * @since 2.0.13

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/ * @license http://www.yiiframework.com/license/
*/ */
use yii\base\InvalidConfigException;
use yii\db\Migration; use yii\db\Migration;
use yii\rbac\DbManager; use yii\rbac\DbManager;
use yii\base\InvalidConfigException;
/** /**
* Adds index on `user_id` column in `auth_assignment` table for performance reasons. * 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(); $authManager = $this->getAuthManager();
$this->createIndex($this->index, $authManager->assignmentTable, $this->column); $this->createIndex($this->index, $authManager->assignmentTable, $this->column);
} }
/** /**

4
framework/rest/IndexAction.php

@ -120,10 +120,10 @@ class IndexAction extends Action
'class' => ActiveDataProvider::className(), 'class' => ActiveDataProvider::className(),
'query' => $query, 'query' => $query,
'pagination' => [ 'pagination' => [
'params' => $requestParams 'params' => $requestParams,
], ],
'sort' => [ 'sort' => [
'params' => $requestParams 'params' => $requestParams,
], ],
]); ]);
} }

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]], * This will call [[Html::activeInput()]] if the input widget is [[hasModel()|tied to a model]],
* or [[Html::input()]] if not. * or [[Html::input()]] if not.
@ -104,8 +104,7 @@ class InputWidget extends Widget
{ {
if ($this->hasModel()) { if ($this->hasModel()) {
return Html::activeInput($type, $this->model, $this->attribute, $this->options); 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')) { if (!class_exists('\PHPUnit\TextUI\ResultPrinter') && class_exists('PHPUnit_TextUI_ResultPrinter')) {
class ResultPrinter extends \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')) { if (!class_exists('PHPUnit\Framework\Error\Notice') && class_exists('PHPUnit_Framework_Error_Notice')) {
class Notice extends \PHPUnit_Framework_Error_Notice class Notice extends \PHPUnit_Framework_Error_Notice
{ {
} }
} }
} }

1
tests/data/ar/Animal.php

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

1
tests/data/ar/BitValues.php

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

1
tests/data/ar/Cat.php

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

7
tests/data/ar/CustomerWithConstructor.php

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

1
tests/data/ar/Dog.php

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

7
tests/data/ar/OrderItemWithConstructor.php

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

7
tests/data/ar/OrderWithConstructor.php

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

7
tests/data/ar/ProfileWithConstructor.php

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

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

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

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

@ -1,4 +1,9 @@
<?php <?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; namespace yiiunit\data\modules\magic\controllers;

5
tests/framework/base/StaticInstanceTraitTest.php

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

19
tests/framework/data/ActiveDataFilterTest.php

@ -1,4 +1,9 @@
<?php <?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yiiunit\framework\data; namespace yiiunit\framework\data;
@ -40,13 +45,13 @@ class ActiveDataFilterTest extends TestCase
'and' => [ 'and' => [
['name' => 'some'], ['name' => 'some'],
['number' => '2'], ['number' => '2'],
] ],
], ],
[ [
'AND', 'AND',
['name' => 'some'], ['name' => 'some'],
['number' => '2'], ['number' => '2'],
] ],
], ],
[ [
[ [
@ -59,7 +64,7 @@ class ActiveDataFilterTest extends TestCase
[ [
[ [
'number' => [ 'number' => [
'in' => [1, 5, 8] 'in' => [1, 5, 8],
], ],
], ],
['IN', 'number', [1, 5, 8]], ['IN', 'number', [1, 5, 8]],
@ -67,7 +72,7 @@ class ActiveDataFilterTest extends TestCase
[ [
[ [
'not' => [ 'not' => [
'number' => 10 'number' => 10,
], ],
], ],
['NOT', ['number' => 10]], ['NOT', ['number' => 10]],
@ -94,7 +99,7 @@ class ActiveDataFilterTest extends TestCase
], ],
], ],
], ],
] ],
], ],
[ [
'OR', 'OR',
@ -177,7 +182,7 @@ class ActiveDataFilterTest extends TestCase
'or' => [ 'or' => [
['name' => 'some'], ['name' => 'some'],
['name' => 'another'], ['name' => 'another'],
] ],
]; ];
$expectedResult = [ $expectedResult = [
'CALLBACK-OR', 'CALLBACK-OR',
@ -190,7 +195,7 @@ class ActiveDataFilterTest extends TestCase
$builder->filter = [ $builder->filter = [
'name' => [ 'name' => [
'like' => 'foo' 'like' => 'foo',
], ],
]; ];
$expectedResult = ['CALLBACK-LIKE', 'LIKE', 'foo', 'name']; $expectedResult = ['CALLBACK-LIKE', 'LIKE', 'foo', 'name'];

63
tests/framework/data/DataFilterTest.php

@ -1,4 +1,9 @@
<?php <?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yiiunit\framework\data; namespace yiiunit\framework\data;
@ -56,7 +61,7 @@ class DataFilterTest extends TestCase
public function testLoad() public function testLoad()
{ {
$filterValue = [ $filterValue = [
'name' => 'value' 'name' => 'value',
]; ];
$builder = new DataFilter(); $builder = new DataFilter();
@ -86,19 +91,19 @@ class DataFilterTest extends TestCase
[ [
[], [],
true, true,
[] [],
], ],
[ [
null, null,
true, true,
[] [],
], ],
[ [
'', '',
false, false,
[ [
'The format of Filter is invalid.' 'The format of Filter is invalid.',
] ],
], ],
[ [
[ [
@ -106,7 +111,7 @@ class DataFilterTest extends TestCase
'number' => '10', 'number' => '10',
], ],
true, true,
[] [],
], ],
[ [
[ [
@ -115,14 +120,14 @@ class DataFilterTest extends TestCase
], ],
false, false,
[ [
"Unknown filter attribute 'fake'" "Unknown filter attribute 'fake'",
] ],
], ],
[ [
[ [
'and' => [ 'and' => [
[ [
'name' => ['eq' => 'foo'] 'name' => ['eq' => 'foo'],
], ],
[ [
'number' => ['in' => [1, 5, 8]], 'number' => ['in' => [1, 5, 8]],
@ -130,7 +135,7 @@ class DataFilterTest extends TestCase
], ],
], ],
true, true,
[] [],
], ],
[ [
[ [
@ -141,21 +146,21 @@ class DataFilterTest extends TestCase
], ],
false, false,
[ [
"Operator 'and' requires multiple operands." "Operator 'and' requires multiple operands.",
] ],
], ],
[ [
[ [
'not' => ['name' => 'foo'] 'not' => ['name' => 'foo'],
], ],
true, true,
[] [],
], ],
[ [
[ [
'and' => [ 'and' => [
[ [
'not' => ['name' => 'foo'] 'not' => ['name' => 'foo'],
], ],
[ [
'number' => ['in' => [1, 5, 8]], 'number' => ['in' => [1, 5, 8]],
@ -163,7 +168,7 @@ class DataFilterTest extends TestCase
], ],
], ],
true, true,
[] [],
], ],
[ [
[ [
@ -171,8 +176,8 @@ class DataFilterTest extends TestCase
], ],
false, false,
[ [
"Name must be a string." 'Name must be a string.',
] ],
], ],
[ [
[ [
@ -182,7 +187,7 @@ class DataFilterTest extends TestCase
], ],
], ],
true, true,
[] [],
], ],
[ [
[ [
@ -190,8 +195,8 @@ class DataFilterTest extends TestCase
], ],
false, 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 * @dataProvider dataProviderValidate
* *
* @param array $filter * @param array $filter
* @param boolean $expectedResult * @param bool $expectedResult
* @param array $expectedErrors * @param array $expectedErrors
*/ */
public function testValidate($filter, $expectedResult, $expectedErrors) public function testValidate($filter, $expectedResult, $expectedErrors)
@ -268,20 +273,20 @@ class DataFilterTest extends TestCase
[ [
'and' => [ 'and' => [
[ [
'name' => ['eq' => 'foo'] 'name' => ['eq' => 'foo'],
], ],
[ [
'number' => ['gte' => 15] 'number' => ['gte' => 15],
], ],
], ],
], ],
[ [
'AND' => [ 'AND' => [
[ [
'name' => ['=' => 'foo'] 'name' => ['=' => 'foo'],
], ],
[ [
'number' => ['>=' => 15] 'number' => ['>=' => 15],
], ],
], ],
], ],
@ -318,7 +323,7 @@ class DataFilterTest extends TestCase
$builder->setSearchModel($searchModel); $builder->setSearchModel($searchModel);
$builder->attributeMap = [ $builder->attributeMap = [
'authorName' => '{{author}}.[[name]]' 'authorName' => '{{author}}.[[name]]',
]; ];
$builder->filter = $filter; $builder->filter = $filter;
@ -329,7 +334,7 @@ class DataFilterTest extends TestCase
{ {
$builder = new DataFilter(); $builder = new DataFilter();
$builder->setErrorMessages([ $builder->setErrorMessages([
'unsupportedOperatorType' => 'Test message' 'unsupportedOperatorType' => 'Test message',
]); ]);
$errorMessages = $builder->getErrorMessages(); $errorMessages = $builder->getErrorMessages();
@ -338,7 +343,7 @@ class DataFilterTest extends TestCase
$builder->setErrorMessages(function () { $builder->setErrorMessages(function () {
return [ return [
'unsupportedOperatorType' => 'Test message callback' 'unsupportedOperatorType' => 'Test message callback',
]; ];
}); });
$errorMessages = $builder->getErrorMessages(); $errorMessages = $builder->getErrorMessages();

11
tests/framework/db/CommandTest.php

@ -376,7 +376,7 @@ SQL;
['int_col', 'float_col', 'char_col'], ['int_col', 'float_col', 'char_col'],
[['', '', 'Kyiv {{city}}, Ukraine']], [['', '', '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 // See https://github.com/yiisoft/yii2/issues/11242
// Make sure curly bracelets (`{{..}}`) in values will not be escaped // Make sure curly bracelets (`{{..}}`) in values will not be escaped
], ],
@ -385,7 +385,7 @@ SQL;
['{{%type}}.[[int_col]]', '[[float_col]]', 'char_col'], ['{{%type}}.[[int_col]]', '[[float_col]]', 'char_col'],
[['', '', 'Kyiv {{city}}, Ukraine']], [['', '', '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! /* Test covers potentially wrong behavior and marks it as expected!
* In case table name or table column is passed with curly or square bracelets, * 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. * 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 * 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 * @dataProvider batchInsertSqlProvider
* @param mixed $table
* @param mixed $columns
* @param mixed $values
* @param mixed $expected
*/ */
public function testBatchInsertSQL($table, $columns, $values, $expected) public function testBatchInsertSQL($table, $columns, $values, $expected)
{ {
$command = $this->getConnection()->createCommand(); $command = $this->getConnection()->createCommand();
$command->batchInsert($table, $columns, $values); $command->batchInsert($table, $columns, $values);
$this->assertEquals($expected, $command->getSql()); $this->assertEquals($expected, $command->getSql());
} }
public function testInsert() public function testInsert()

8
tests/framework/db/QueryBuilderTest.php

@ -1777,7 +1777,7 @@ abstract class QueryBuilderTest extends DatabaseTestCase
'is_active' => false, 'is_active' => false,
'related_id' => null, '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', ':qp0' => 'test@example.com',
':qp1' => 'silverfire', ':qp1' => 'silverfire',
@ -1795,7 +1795,7 @@ abstract class QueryBuilderTest extends DatabaseTestCase
'INSERT INTO {{%type}} ({{%type}}.[[related_id]], [[time]]) VALUES (:qp0, now())', 'INSERT INTO {{%type}} ({{%type}}.[[related_id]], [[time]]) VALUES (:qp0, now())',
[ [
':qp0' => null, ':qp0' => null,
] ],
], ],
]; ];
} }
@ -1922,12 +1922,12 @@ abstract class QueryBuilderTest extends DatabaseTestCase
'user', 'user',
[ [
'is_enabled' => false, '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())'), $this->replaceQuotes('DELETE FROM [[user]] WHERE ([[is_enabled]]=:qp0) AND ([[power]]=WRONG_POWER())'),
[ [
':qp0' => false, ':qp0' => false,
] ],
], ],
]; ];
} }

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

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

2
tests/framework/helpers/HtmlTest.php

@ -145,7 +145,7 @@ class HtmlTest extends TestCase
'request' => [ 'request' => [
'class' => 'yii\web\Request', 'class' => 'yii\web\Request',
'enableCsrfValidation' => true, 'enableCsrfValidation' => true,
] ],
], ],
]); ]);
$this->expectException('yii\base\InvalidConfigException'); $this->expectException('yii\base\InvalidConfigException');

77
tests/framework/i18n/FormatterTest.php

@ -8,7 +8,6 @@
namespace yiiunit\framework\i18n; namespace yiiunit\framework\i18n;
use Yii; use Yii;
use yii\base\InvalidConfigException;
use yii\i18n\Formatter; use yii\i18n\Formatter;
use yiiunit\TestCase; use yiiunit\TestCase;
@ -233,66 +232,71 @@ class FormatterTest extends TestCase
return [ return [
[ [
'Empty value gets proper output', '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', 'Wrong value is casted properly',
['NaN'], '0 millimeters', '0 mm', ['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', 'Negative value works',
[-3], '-3 meters', '-3 m' [-3], '-3 meters', '-3 m',
], ],
[ [
'Zero value works', 'Zero value works',
[0], '0 millimeters', '0 mm' [0], '0 millimeters', '0 mm',
], ],
[ [
'Decimal value is resolved in base units', '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)', '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)', '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', 'Integer value #1 works',
[1], '1 meter', '1 m' [1], '1 meter', '1 m',
], ],
[ [
'Integer value #2 works', 'Integer value #2 works',
[453], '453 meters', '453 m' [453], '453 meters', '453 m',
], ],
[ [
'Double value works', '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', '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', 'It is possible to change number formatting options',
[100, null, [ [100, null, [
\NumberFormatter::MIN_FRACTION_DIGITS => 4, \NumberFormatter::MIN_FRACTION_DIGITS => 4,
]], '100.0000 meters', '100.0000 m' ]], '100.0000 meters', '100.0000 m',
], ],
[ [
'It is possible to change text options', 'It is possible to change text options',
[-19913.13, null, null, [ [-19913.13, null, null, [
\NumberFormatter::NEGATIVE_PREFIX => 'MINUS' \NumberFormatter::NEGATIVE_PREFIX => 'MINUS',
]], 'MINUS19.913 kilometers', 'MINUS19.913 km' ]], 'MINUS19.913 kilometers', 'MINUS19.913 km',
], ],
]; ];
} }
/** /**
* @dataProvider lengthDataProvider * @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 = []) public function testIntlAsLength($message, $arguments, $expected, $_shortLength, $expectedException = [])
{ {
@ -306,6 +310,11 @@ class FormatterTest extends TestCase
/** /**
* @dataProvider lengthDataProvider * @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 = []) public function testIntlAsShortLength($message, $arguments, $_length, $expected, $expectedException = [])
{ {
@ -322,66 +331,71 @@ class FormatterTest extends TestCase
return [ return [
[ [
'Empty value gets proper output', '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', 'Wrong value is casted properly',
['NaN'], '0 grams', '0 g', ['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', 'Negative value works',
[-3], '-3 kilograms', '-3 kg' [-3], '-3 kilograms', '-3 kg',
], ],
[ [
'Zero value works', 'Zero value works',
[0], '0 grams', '0 g' [0], '0 grams', '0 g',
], ],
[ [
'Decimal value is resolved in base units', '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)', '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)', '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', 'Integer value #1 works',
[1], '1 kilogram', '1 kg' [1], '1 kilogram', '1 kg',
], ],
[ [
'Integer value #2 works', 'Integer value #2 works',
[453], '453 kilograms', '453 kg' [453], '453 kilograms', '453 kg',
], ],
[ [
'Double value works', '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', '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', 'It is possible to change number formatting options',
[100, null, [ [100, null, [
\NumberFormatter::MIN_FRACTION_DIGITS => 4, \NumberFormatter::MIN_FRACTION_DIGITS => 4,
]], '100.0000 kilograms', '100.0000 kg' ]], '100.0000 kilograms', '100.0000 kg',
], ],
[ [
'It is possible to change text options', 'It is possible to change text options',
[-19913.13, null, null, [ [-19913.13, null, null, [
\NumberFormatter::NEGATIVE_PREFIX => 'MINUS' \NumberFormatter::NEGATIVE_PREFIX => 'MINUS',
]], 'MINUS19.913 tons', 'MINUS19.913 tn' ]], 'MINUS19.913 tons', 'MINUS19.913 tn',
], ],
]; ];
} }
/** /**
* @dataProvider weightDataProvider * @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 = []) public function testIntlAsWeight($message, $arguments, $expected, $_shortWeight, $expectedException = [])
{ {
@ -395,6 +409,11 @@ class FormatterTest extends TestCase
/** /**
* @dataProvider weightDataProvider * @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 = []) public function testIntlAsShortWeight($message, $arguments, $_weight, $expected, $expectedException = [])
{ {

5
tests/framework/log/ArrayTarget.php

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

3
tests/framework/rbac/DbManagerTestCase.php

@ -20,7 +20,6 @@ use yii\rbac\Permission;
use yii\rbac\Role; use yii\rbac\Role;
use yiiunit\data\rbac\UserID; use yiiunit\data\rbac\UserID;
use yiiunit\framework\console\controllers\EchoMigrateController; use yiiunit\framework\console\controllers\EchoMigrateController;
use yiiunit\framework\db\oci\QueryBuilderTest;
use yiiunit\framework\log\ArrayTarget; use yiiunit\framework\log\ArrayTarget;
/** /**
@ -56,7 +55,7 @@ abstract class DbManagerTestCase extends ManagerTestCase
Yii::$app->setComponents([ Yii::$app->setComponents([
'db' => static::createConnection(), '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'); self::assertSame(static::$driverName, Yii::$app->db->getDriverName(), 'Connection represents the same DB driver, as is tested');
ob_start(); ob_start();

1
tests/framework/test/ArrayFixtureTest.php

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

1
tests/framework/web/UrlNormalizerTest.php

@ -1,5 +1,4 @@
<?php <?php
/** /**
* @link http://www.yiiframework.com/ * @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC * @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 * @param string $html
* @return string CSRF token * @return string CSRF token

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

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

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

@ -1,9 +1,14 @@
<?php <?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; namespace yiiunit\framework\web\session\mssql;
/** /**
* Class DbSessionTest * Class DbSessionTest.
* *
* @author Dmytro Naumenko <d.naumenko.a@gmail.com> * @author Dmytro Naumenko <d.naumenko.a@gmail.com>
* *

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

@ -1,9 +1,14 @@
<?php <?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; namespace yiiunit\framework\web\session\mysql;
/** /**
* Class DbSessionTest * Class DbSessionTest.
* *
* @author Dmytro Naumenko <d.naumenko.a@gmail.com> * @author Dmytro Naumenko <d.naumenko.a@gmail.com>
* *

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

@ -1,9 +1,14 @@
<?php <?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; namespace yiiunit\framework\web\session\pgsql;
/** /**
* Class DbSessionTest * Class DbSessionTest.
* *
* @author Dmytro Naumenko <d.naumenko.a@gmail.com> * @author Dmytro Naumenko <d.naumenko.a@gmail.com>
* *

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

@ -1,9 +1,14 @@
<?php <?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; namespace yiiunit\framework\web\session\sqlite;
/** /**
* Class DbSessionTest * Class DbSessionTest.
* *
* @author Dmytro Naumenko <d.naumenko.a@gmail.com> * @author Dmytro Naumenko <d.naumenko.a@gmail.com>
* *

4
tests/framework/widgets/ActiveFieldTest.php

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

Loading…
Cancel
Save