Browse Source

Fixed whitespaces to match code style [skip ci]

tags/2.0.12
gagatust 8 years ago committed by Alexander Makarov
parent
commit
6397791513
  1. 12
      build/controllers/DevController.php
  2. 4
      build/controllers/MimeTypeController.php
  3. 30
      build/controllers/PhpDocController.php
  4. 46
      build/controllers/ReleaseController.php
  5. 4
      build/controllers/TranslationController.php
  6. 4
      build/controllers/Utf8Controller.php
  7. 4
      build/controllers/views/translation/report_html.php
  8. 4
      framework/db/ActiveRecord.php
  9. 2
      framework/di/Instance.php
  10. 4
      framework/validators/UniqueValidator.php
  11. 2
      tests/framework/base/ModelTest.php
  12. 2
      tests/framework/console/controllers/CacheControllerTest.php
  13. 6
      tests/framework/db/ActiveRecordTest.php
  14. 10
      tests/framework/db/CommandTest.php
  15. 8
      tests/framework/db/QueryBuilderTest.php
  16. 8
      tests/framework/db/SchemaTest.php
  17. 4
      tests/framework/di/ContainerTest.php
  18. 4
      tests/framework/grid/ActionColumnTest.php
  19. 2
      tests/framework/i18n/FormatterDateTest.php
  20. 4
      tests/framework/log/FileTargetTest.php
  21. 2
      tests/framework/rest/UrlRuleTest.php
  22. 2
      tests/framework/validators/DateValidatorTest.php
  23. 2
      tests/framework/validators/EmailValidatorTest.php
  24. 2
      tests/framework/validators/FileValidatorTest.php
  25. 2
      tests/framework/validators/UniqueValidatorTest.php
  26. 2
      tests/framework/web/DbSessionTest.php
  27. 12
      tests/framework/web/RequestTest.php
  28. 4
      tests/framework/web/UserTest.php
  29. 2
      tests/framework/widgets/ActiveFieldTest.php

12
build/controllers/DevController.php

@ -70,14 +70,14 @@ class DevController extends Controller
return 1;
}
foreach($this->extensions as $ext => $repo) {
foreach ($this->extensions as $ext => $repo) {
$ret = $this->actionExt($ext);
if ($ret !== 0) {
return $ret;
}
}
foreach($this->apps as $app => $repo) {
foreach ($this->apps as $app => $repo) {
$ret = $this->actionApp($app);
if ($ret !== 0) {
return $ret;
@ -107,7 +107,7 @@ class DevController extends Controller
asort($dirs);
$oldcwd = getcwd();
foreach($dirs as $dir) {
foreach ($dirs as $dir) {
$displayDir = substr($dir, strlen($base));
$this->stdout("Running '$command' in $displayDir...\n", Console::BOLD);
chdir($dir);
@ -252,7 +252,7 @@ class DevController extends Controller
$this->unlink($link);
}
$extensions = $this->findDirs("$dir/vendor/yiisoft");
foreach($extensions as $ext) {
foreach ($extensions as $ext) {
if (is_link($link = "$dir/vendor/yiisoft/yii2-$ext")) {
$this->stdout("Removing symlink $link.\n");
$this->unlink($link);
@ -276,7 +276,7 @@ class DevController extends Controller
symlink("$base/framework", $link);
}
$extensions = $this->findDirs("$dir/vendor/yiisoft");
foreach($extensions as $ext) {
foreach ($extensions as $ext) {
if (is_dir($link = "$dir/vendor/yiisoft/yii2-$ext")) {
$this->stdout("Removing dir $link.\n");
FileHelper::removeDirectory($link);
@ -359,7 +359,7 @@ class DevController extends Controller
}
closedir($handle);
foreach($list as $i => $e) {
foreach ($list as $i => $e) {
if ($e === 'composer') { // skip composer to not break composer update
unset($list[$i]);
}

4
build/controllers/MimeTypeController.php

@ -39,14 +39,14 @@ class MimeTypeController extends Controller
$this->stdout("done.\n", Console::FG_GREEN);
$this->stdout("generating file $outFile...");
$mimeMap = [];
foreach(explode("\n", $content) as $line) {
foreach (explode("\n", $content) as $line) {
$line = trim($line);
if (empty($line) || $line[0] == '#') { // skip comments and empty lines
continue;
}
$parts = preg_split('/\s+/', $line);
$mime = array_shift($parts);
foreach($parts as $ext) {
foreach ($parts as $ext) {
if (!empty($ext)) {
$mimeMap[$ext] = $mime;
}

30
build/controllers/PhpDocController.php

@ -167,8 +167,8 @@ class PhpDocController extends Controller
'tests/',
'vendor/',
];
foreach($extensionExcept as $ext => $paths) {
foreach($paths as $path) {
foreach ($extensionExcept as $ext => $paths) {
foreach ($paths as $path) {
$except[] = "/extensions/$ext$path";
}
}
@ -184,7 +184,7 @@ class PhpDocController extends Controller
}
if (isset($extensionExcept[$extension])) {
foreach($extensionExcept[$extension] as $path) {
foreach ($extensionExcept[$extension] as $path) {
$except[] = $path;
}
}
@ -255,7 +255,7 @@ class PhpDocController extends Controller
$namespace = false;
$namespaceLine = '';
$contentAfterNamespace = false;
foreach($lines as $i => $line) {
foreach ($lines as $i => $line) {
$line = trim($line);
if (!empty($line)) {
if (strncmp($line, 'namespace', 9) === 0) {
@ -269,7 +269,7 @@ class PhpDocController extends Controller
}
if ($namespace !== false && $contentAfterNamespace !== false) {
while($contentAfterNamespace > 0) {
while ($contentAfterNamespace > 0) {
array_shift($lines);
$contentAfterNamespace--;
}
@ -297,7 +297,7 @@ class PhpDocController extends Controller
$listIndent = '';
$tag = false;
$indent = '';
foreach($lines as $i => $line) {
foreach ($lines as $i => $line) {
if (preg_match('~^(\s*)/\*\*$~', $line, $matches)) {
$docBlock = true;
$indent = $matches[1];
@ -348,8 +348,8 @@ class PhpDocController extends Controller
{
return preg_replace_callback('~@(param|return) ([\w\\|]+)~i', function($matches) {
$types = explode('|', $matches[2]);
foreach($types as $i => $type) {
switch($type){
foreach ($types as $i => $type) {
switch ($type) {
case 'integer': $types[$i] = 'int'; break;
case 'boolean': $types[$i] = 'bool'; break;
}
@ -367,7 +367,7 @@ class PhpDocController extends Controller
// remove blank lines between properties
$skip = true;
$level = 0;
foreach($lines as $i => $line) {
foreach ($lines as $i => $line) {
if (strpos($line, 'class ') !== false) {
$skip = false;
}
@ -402,7 +402,7 @@ class PhpDocController extends Controller
$skip = true;
$level = 0; // track array properties
$property = '';
foreach($lines as $i => $line) {
foreach ($lines as $i => $line) {
if (strpos($line, 'class ') !== false) {
$skip = false;
}
@ -428,10 +428,10 @@ class PhpDocController extends Controller
$endofPrivate = $i;
$property = 'Private';
$level = 0;
} elseif (substr($line,0 , 6) === 'const ') {
} elseif (substr($line, 0, 6) === 'const ') {
$endofConst = $i;
$property = false;
} elseif (substr($line,0 , 4) === 'use ') {
} elseif (substr($line, 0, 4) === 'use ') {
$endofUse = $i;
$property = false;
} elseif (!empty($line) && $line[0] === '*') {
@ -447,7 +447,7 @@ class PhpDocController extends Controller
}
$endofAll = false;
foreach(['Private', 'Protected', 'Public', 'Const', 'Use'] as $var) {
foreach (['Private', 'Protected', 'Public', 'Const', 'Use'] as $var) {
if (${'endof'.$var} !== false) {
$endofAll = ${'endof'.$var};
break;
@ -456,7 +456,7 @@ class PhpDocController extends Controller
// $this->checkPropertyOrder($lineInfo);
$result = [];
foreach($lines as $i => $line) {
foreach ($lines as $i => $line) {
$result[] = $line;
if (!($propertiesOnly && $i === $endofAll)) {
if ($i === $endofUse || $i === $endofConst || $i === $endofPublic ||
@ -753,7 +753,7 @@ class PhpDocController extends Controller
// example: yii\di\ServiceLocator setComponents() is not recognized in the whole but in
// a part of the class.
$parts = $split ? explode("\n\n", $subject) : [$subject];
foreach($parts as $part) {
foreach ($parts as $part) {
preg_match_all($pattern . 'suU', $part, $matches, PREG_SET_ORDER);
foreach ($matches as &$set) {
foreach ($set as $i => $match)

46
build/controllers/ReleaseController.php

@ -105,7 +105,7 @@ class ReleaseController extends Controller
}
if ($this->update) {
foreach($items as $item) {
foreach ($items as $item) {
$this->stdout("fetching tags for $item...");
if ($item === 'framework') {
$this->gitFetchTags("{$this->basePath}");
@ -126,7 +126,7 @@ class ReleaseController extends Controller
// print version table
$w = $this->minWidth(array_keys($versions));
$this->stdout(str_repeat(' ', $w + 2) . "Current Version Next Version\n", Console::BOLD);
foreach($versions as $ext => $version) {
foreach ($versions as $ext => $version) {
$this->stdout($ext . str_repeat(' ', $w + 3 - mb_strlen($ext)) . $version . "");
$this->stdout(str_repeat(' ', 17 - mb_strlen($version)) . $nextVersions[$ext] . "\n");
}
@ -136,7 +136,7 @@ class ReleaseController extends Controller
private function minWidth($a)
{
$w = 1;
foreach($a as $s) {
foreach ($a as $s) {
if (($l = mb_strlen($s)) > $w) {
$w = $l;
}
@ -199,7 +199,7 @@ class ReleaseController extends Controller
if ($this->version !== null) {
// if a version is explicitly given
$newVersions = [];
foreach($versions as $k => $v) {
foreach ($versions as $k => $v) {
$newVersions[$k] = $this->version;
}
} else {
@ -230,7 +230,7 @@ class ReleaseController extends Controller
return 1;
}
foreach($what as $ext) {
foreach ($what as $ext) {
if ($ext === 'framework') {
$this->releaseFramework("{$this->basePath}/framework", $newVersions['framework']);
} elseif (strncmp('app-', $ext, 4) === 0) {
@ -264,7 +264,7 @@ class ReleaseController extends Controller
$versions = $this->getCurrentVersions($what);
$this->stdout("You are about to generate packages for the following things:\n\n");
foreach($what as $ext) {
foreach ($what as $ext) {
if (strncmp('app-', $ext, 4) === 0) {
$this->stdout(" - ");
$this->stdout(substr($ext, 4), Console::FG_RED);
@ -289,7 +289,7 @@ class ReleaseController extends Controller
return 1;
}
foreach($what as $ext) {
foreach ($what as $ext) {
if ($ext === 'framework') {
throw new Exception('Can not package framework.');
} elseif (strncmp('app-', $ext, 4) === 0) {
@ -334,7 +334,7 @@ class ReleaseController extends Controller
protected function printWhat(array $what, $newVersions, $versions)
{
foreach($what as $ext) {
foreach ($what as $ext) {
if (strncmp('app-', $ext, 4) === 0) {
$this->stdout(" - ");
$this->stdout(substr($ext, 4), Console::FG_RED);
@ -353,7 +353,7 @@ class ReleaseController extends Controller
protected function printWhatUrls(array $what, $oldVersions)
{
foreach($what as $ext) {
foreach ($what as $ext) {
if ($ext === 'framework') {
$this->stdout("framework: https://github.com/yiisoft/yii2-framework/compare/{$oldVersions[$ext]}...master\n");
$this->stdout("app-basic: https://github.com/yiisoft/yii2-app-basic/compare/{$oldVersions[$ext]}...master\n");
@ -372,7 +372,7 @@ class ReleaseController extends Controller
*/
protected function validateWhat(array $what, $limit = [], $ensureGitClean = true)
{
foreach($what as $w) {
foreach ($what as $w) {
if (strncmp('app-', $w, 4) === 0) {
if (!empty($limit) && !in_array('app', $limit)) {
throw new Exception("Only the following types are allowed: ".implode(', ', $limit)."\n");
@ -460,7 +460,7 @@ class ReleaseController extends Controller
$this->runGit("git diff --color", $frameworkPath);
$this->stdout("\n\n\nCheck whether the above diff is okay, if not you may change things as needed before continuing.\n");
$this->stdout("You may abort the program with Ctrl + C and reset the changes by running `git checkout -- .` in the repo.\n\n");
} while(!$this->confirm("Type `yes` to continue, `no` to view git diff again. Continue?"));
} while (!$this->confirm("Type `yes` to continue, `no` to view git diff again. Continue?"));
$this->stdout("\n\n");
$this->stdout(" **** RELEASE TIME! ****\n", Console::FG_YELLOW, Console::BOLD);
@ -581,7 +581,7 @@ class ReleaseController extends Controller
$this->runGit("git diff --color", $path);
$this->stdout("\n\n\nCheck whether the above diff is okay, if not you may change things as needed before continuing.\n");
$this->stdout("You may abort the program with Ctrl + C and reset the changes by running `git checkout -- .` in the repo.\n\n");
} while(!$this->confirm("Type `yes` to continue, `no` to view git diff again. Continue?"));
} while (!$this->confirm("Type `yes` to continue, `no` to view git diff again. Continue?"));
$this->stdout("\n\n");
$this->stdout(" **** RELEASE TIME! ****\n", Console::FG_YELLOW, Console::BOLD);
@ -633,7 +633,7 @@ class ReleaseController extends Controller
protected function setAppAliases($app, $path)
{
$this->_oldAlias = Yii::getAlias('@app');
switch($app) {
switch ($app) {
case 'basic':
Yii::setAlias('@app', $path);
break;
@ -699,7 +699,7 @@ class ReleaseController extends Controller
$this->runGit("git diff --color", $path);
$this->stdout("\n\n\nCheck whether the above diff is okay, if not you may change things as needed before continuing.\n");
$this->stdout("You may abort the program with Ctrl + C and reset the changes by running `git checkout -- .` in the repo.\n\n");
} while(!$this->confirm("Type `yes` to continue, `no` to view git diff again. Continue?"));
} while (!$this->confirm("Type `yes` to continue, `no` to view git diff again. Continue?"));
$this->stdout("\n\n");
$this->stdout(" **** RELEASE TIME! ****\n", Console::FG_YELLOW, Console::BOLD);
@ -825,7 +825,7 @@ class ReleaseController extends Controller
{
$headline = "\n$version under development\n";
$headline .= str_repeat('-', strlen($headline) - 2) . "\n\n- no changes in this release.\n";
foreach($this->getChangelogs($what) as $file) {
foreach ($this->getChangelogs($what) as $file) {
$lines = explode("\n", file_get_contents($file));
$hl = [
array_shift($lines),
@ -839,7 +839,7 @@ class ReleaseController extends Controller
protected function resortChangelogs($what, $version)
{
foreach($this->getChangelogs($what) as $file) {
foreach ($this->getChangelogs($what) as $file) {
// split the file into relevant parts
list($start, $changelog, $end) = $this->splitChangelog($file, $version);
$changelog = $this->resortChangelog($changelog);
@ -860,7 +860,7 @@ class ReleaseController extends Controller
$end = [];
$state = 'start';
foreach($lines as $l => $line) {
foreach ($lines as $l => $line) {
// starting from the changelogs headline
if (isset($lines[$l-2]) && strpos($lines[$l-2], $version) !== false &&
isset($lines[$l-1]) && strncmp($lines[$l-1], '---', 3) === 0) {
@ -886,7 +886,7 @@ class ReleaseController extends Controller
protected function resortChangelog($changelog)
{
// cleanup whitespace
foreach($changelog as $i => $line) {
foreach ($changelog as $i => $line) {
$changelog[$i] = rtrim($line);
}
$changelog = array_filter($changelog);
@ -926,7 +926,7 @@ class ReleaseController extends Controller
protected function getExtensionChangelogs($what)
{
return array_filter(glob($this->basePath . '/extensions/*/CHANGELOG.md'), function($elem) use ($what) {
foreach($what as $ext) {
foreach ($what as $ext) {
if (strpos($elem, "extensions/$ext/CHANGELOG.md") !== false) {
return true;
}
@ -979,7 +979,7 @@ class ReleaseController extends Controller
protected function sed($pattern, $replace, $files)
{
foreach((array) $files as $file) {
foreach ((array) $files as $file) {
file_put_contents($file, preg_replace($pattern, $replace, file_get_contents($file)));
}
}
@ -987,7 +987,7 @@ class ReleaseController extends Controller
protected function getCurrentVersions(array $what)
{
$versions = [];
foreach($what as $ext) {
foreach ($what as $ext) {
if ($ext === 'framework') {
chdir("{$this->basePath}/framework");
} elseif (strncmp('app-', $ext, 4) === 0) {
@ -1011,13 +1011,13 @@ class ReleaseController extends Controller
protected function getNextVersions(array $versions, $type)
{
foreach($versions as $k => $v) {
foreach ($versions as $k => $v) {
if (empty($v)) {
$versions[$k] = '2.0.0';
continue;
}
$parts = explode('.', $v);
switch($type) {
switch ($type) {
case self::MINOR:
$parts[1]++;
$parts[2] = 0;

4
build/controllers/TranslationController.php

@ -47,7 +47,7 @@ class TranslationController extends Controller
$errors = $this->checkFiles($translatedFilePath);
$diff = empty($errors) ? $this->getDiff($translatedFilePath, $sourceFilePath) : '';
if(!empty($diff)) {
if (!empty($diff)) {
$errors[] = 'Translation outdated.';
}
@ -68,7 +68,7 @@ class TranslationController extends Controller
$translatedFilePath = $translationPath . '/' . $fileinfo->getFilename();
$errors = $this->checkFiles(null, $translatedFilePath);
if(!empty($errors)) {
if (!empty($errors)) {
$results[$fileinfo->getFilename()]['errors'] = $errors;
}
}

4
build/controllers/Utf8Controller.php

@ -39,14 +39,14 @@ class Utf8Controller extends Controller
]);
}
foreach($files as $file) {
foreach ($files as $file) {
$content = file_get_contents($file);
$chars = preg_split('//u', $content, null, PREG_SPLIT_NO_EMPTY);
$line = 1;
$pos = 0;
foreach($chars as $c) {
foreach ($chars as $c) {
$ord = $this->unicodeOrd($c);

4
build/controllers/views/translation/report_html.php

@ -36,9 +36,9 @@ use yii\helpers\Html;
<li><strong>Translation:</strong> <?= Html::encode($translationPath) ?></li>
</ul>
<?php foreach($results as $name => $result): ?>
<?php foreach ($results as $name => $result): ?>
<h2 class="<?= empty($result['errors']) ? 'ok' : 'errors' ?>"><?= $name ?></h2>
<?php foreach($result['errors'] as $error): ?>
<?php foreach ($result['errors'] as $error): ?>
<p><?= Html::encode($error) ?></p>
<?php endforeach ?>
<?php if (!empty($result['diff'])): ?>

4
framework/db/ActiveRecord.php

@ -205,7 +205,7 @@ class ActiveRecord extends BaseActiveRecord
*
* ```php
* $models = Customer::find()->where('status = 2')->all();
* foreach($models as $model) {
* foreach ($models as $model) {
* $model->status = 1;
* $model->update(false); // skipping validation as no user input is involved
* }
@ -276,7 +276,7 @@ class ActiveRecord extends BaseActiveRecord
*
* ```php
* $models = Customer::find()->where('status = 3')->all();
* foreach($models as $model) {
* foreach ($models as $model) {
* $model->delete();
* }
* ```

2
framework/di/Instance.php

@ -130,7 +130,7 @@ class Instance
if ($reference instanceof self) {
try {
$component = $reference->get($container);
} catch(\ReflectionException $e) {
} catch (\ReflectionException $e) {
throw new InvalidConfigException('Failed to instantiate component or class "' . $reference->id . '".', 0, $e);
}
if ($type === null || $component instanceof $type) {

4
framework/validators/UniqueValidator.php

@ -173,7 +173,7 @@ class UniqueValidator extends Validator
$dbModel = reset($models);
$pks = $targetClass::primaryKey();
$pk = [];
foreach($pks as $pkAttribute) {
foreach ($pks as $pkAttribute) {
$pk[$pkAttribute] = $dbModel[$pkAttribute];
}
$exists = ($pk != $model->getOldPrimaryKey(true));
@ -247,7 +247,7 @@ class UniqueValidator extends Validator
$attributeCombo = [];
$valueCombo = [];
foreach ($this->targetAttribute as $key => $value) {
if(is_int($key)) {
if (is_int($key)) {
$attributeCombo[] = $model->getAttributeLabel($value);
$valueCombo[] = '"' . $model->$value . '"';
} else {

2
tests/framework/base/ModelTest.php

@ -480,7 +480,7 @@ class WriteOnlyModel extends Model
public function rules()
{
return [
[['password'],'safe'],
[['password'], 'safe'],
];
}

2
tests/framework/console/controllers/CacheControllerTest.php

@ -58,7 +58,7 @@ class CacheControllerTest extends TestCase
],
]);
if(isset($config['fixture'])) {
if (isset($config['fixture'])) {
Yii::$app->db->open();
$lines = explode(';', file_get_contents($config['fixture']));
foreach ($lines as $line) {

6
tests/framework/db/ActiveRecordTest.php

@ -1053,7 +1053,7 @@ abstract class ActiveRecordTest extends DatabaseTestCase
$this->assertEquals(2, count($order->booksWithNullFKViaTable));
$orderItemCount = $orderItemsWithNullFKClass::find()->count();
$this->assertEquals(5, $itemClass::find()->count());
$order->unlinkAll('booksWithNullFKViaTable',false);
$order->unlinkAll('booksWithNullFKViaTable', false);
$this->assertEquals(0, count($order->booksWithNullFKViaTable));
$this->assertEquals(2,$orderItemsWithNullFKClass::find()->where(['AND', ['item_id' => [1, 2]], ['order_id' => null]])->count());
$this->assertEquals($orderItemCount, $orderItemsWithNullFKClass::find()->count());
@ -1186,7 +1186,7 @@ abstract class ActiveRecordTest extends DatabaseTestCase
->all();
$this->assertCount(2, $aggregation);
$this->assertContainsOnlyInstancesOf(Customer::className(), $aggregation);
foreach($aggregation as $item) {
foreach ($aggregation as $item) {
if ($item->status == 1) {
$this->assertEquals(183, $item->sumTotal);
} elseif ($item->status == 2) {
@ -1227,7 +1227,7 @@ abstract class ActiveRecordTest extends DatabaseTestCase
->all();
$this->assertCount(3, $aggregation);
$this->assertContainsOnlyInstancesOf(OrderItem::className(), $aggregation);
foreach($aggregation as $item) {
foreach ($aggregation as $item) {
if ($item->order_id == 1) {
$this->assertEquals(70, $item->subtotal);
} elseif ($item->order_id == 2) {

10
tests/framework/db/CommandTest.php

@ -463,7 +463,7 @@ SQL;
$db = $this->getConnection();
$db->createCommand('DELETE FROM {{order_with_null_fk}}')->execute();
switch($this->driverName){
switch ($this->driverName) {
case 'pgsql':
$expression = "EXTRACT(YEAR FROM TIMESTAMP 'now')";
break;
@ -531,7 +531,7 @@ SQL;
{
$db = $this->getConnection();
if($db->getSchema()->getTableSchema('testCreateTable') !== null){
if ($db->getSchema()->getTableSchema('testCreateTable') !== null) {
$db->createCommand()->dropTable('testCreateTable')->execute();
}
@ -545,13 +545,13 @@ SQL;
public function testAlterTable()
{
if ($this->driverName === 'sqlite'){
if ($this->driverName === 'sqlite') {
$this->markTestSkipped('Sqlite does not support alterTable');
}
$db = $this->getConnection();
if($db->getSchema()->getTableSchema('testAlterTable') !== null){
if ($db->getSchema()->getTableSchema('testAlterTable') !== null) {
$db->createCommand()->dropTable('testAlterTable')->execute();
}
@ -596,7 +596,7 @@ SQL;
$fromTableName = 'type';
$toTableName = 'new_type';
if($db->getSchema()->getTableSchema($toTableName) !== null){
if ($db->getSchema()->getTableSchema($toTableName) !== null) {
$db->createCommand()->dropTable($toTableName)->execute();
}

8
tests/framework/db/QueryBuilderTest.php

@ -1145,7 +1145,7 @@ abstract class QueryBuilderTest extends DatabaseTestCase
}
// adjust dbms specific escaping
foreach($conditions as $i => $condition) {
foreach ($conditions as $i => $condition) {
$conditions[$i][1] = $this->replaceQuotes($condition[1]);
}
return $conditions;
@ -1193,7 +1193,7 @@ abstract class QueryBuilderTest extends DatabaseTestCase
];
// adjust dbms specific escaping
foreach($conditions as $i => $condition) {
foreach ($conditions as $i => $condition) {
$conditions[$i][1] = $this->replaceQuotes($condition[1]);
}
return $conditions;
@ -1464,7 +1464,7 @@ abstract class QueryBuilderTest extends DatabaseTestCase
$this->assertEquals([
'id' => 1,
'abc' => 'abc',
],$params);
], $params);
// simple subquery
$subquery = "(SELECT * FROM user WHERE account_id = accounts.id)";
@ -1697,7 +1697,7 @@ abstract class QueryBuilderTest extends DatabaseTestCase
];
// adjust dbms specific escaping
foreach($conditions as $i => $condition) {
foreach ($conditions as $i => $condition) {
$conditions[$i][1] = $this->replaceQuotes($condition[1]);
if (!empty($this->likeEscapeCharSql)) {
preg_match_all('/(?P<condition>LIKE.+?)( AND| OR|$)/', $conditions[$i][1], $matches, PREG_SET_ORDER);

8
tests/framework/db/SchemaTest.php

@ -24,7 +24,7 @@ abstract class SchemaTest extends DatabaseTestCase
public function testGetTableNames($pdoAttributes)
{
$connection = $this->getConnection();
foreach($pdoAttributes as $name => $value) {
foreach ($pdoAttributes as $name => $value) {
$connection->pdo->setAttribute($name, $value);
}
/* @var $schema Schema */
@ -47,7 +47,7 @@ abstract class SchemaTest extends DatabaseTestCase
public function testGetTableSchemas($pdoAttributes)
{
$connection = $this->getConnection();
foreach($pdoAttributes as $name => $value) {
foreach ($pdoAttributes as $name => $value) {
$connection->pdo->setAttribute($name, $value);
}
/* @var $schema Schema */
@ -364,7 +364,7 @@ abstract class SchemaTest extends DatabaseTestCase
sort($colNames);
$this->assertEquals($expectedColNames, $colNames);
foreach($table->columns as $name => $column) {
foreach ($table->columns as $name => $column) {
$expected = $columns[$name];
$this->assertSame($expected['dbType'], $column->dbType, "dbType of column $name does not match. type is $column->type, dbType is $column->dbType.");
$this->assertSame($expected['phpType'], $column->phpType, "phpType of column $name does not match. type is $column->type, dbType is $column->dbType.");
@ -396,7 +396,7 @@ abstract class SchemaTest extends DatabaseTestCase
try {
$db->createCommand()->dropTable('uniqueIndex')->execute();
} catch(\Exception $e) {
} catch (\Exception $e) {
}
$db->createCommand()->createTable('uniqueIndex', [
'somecol' => 'string',

4
tests/framework/di/ContainerTest.php

@ -159,11 +159,11 @@ class ContainerTest extends TestCase
$this->assertEquals(['ok', 'yii\validators\NumberValidator', 'value_of_c'], $result);
// use native php function
$this->assertEquals(Yii::$container->invoke('trim',[' M2792684 ']), 'M2792684');
$this->assertEquals(Yii::$container->invoke('trim', [' M2792684 ']), 'M2792684');
// use helper function
$array = ['M36', 'D426', 'Y2684'];
$this->assertFalse(Yii::$container->invoke(['yii\helpers\ArrayHelper', 'isAssociative'],[$array]));
$this->assertFalse(Yii::$container->invoke(['yii\helpers\ArrayHelper', 'isAssociative'], [$array]));
$myFunc = function (\yii\console\Request $request, \yii\console\Response $response) {

4
tests/framework/grid/ActionColumnTest.php

@ -69,7 +69,7 @@ class ActionColumnTest extends \yiiunit\TestCase
//test visible button (condition is callback)
$column->visibleButtons = [
'update' => function($model, $key, $index){return $model['id'] == 1;}
'update' => function($model, $key, $index) {return $model['id'] == 1;}
];
$columnContents = $column->renderDataCell(['id' => 1], 1, 0);
$this->assertContains('update_button', $columnContents);
@ -83,7 +83,7 @@ class ActionColumnTest extends \yiiunit\TestCase
//test invisible button (condition is callback)
$column->visibleButtons = [
'update' => function($model, $key, $index){return $model['id'] != 1;}
'update' => function($model, $key, $index) {return $model['id'] != 1;}
];
$columnContents = $column->renderDataCell(['id' => 1], 1, 0);
$this->assertNotContains('update_button', $columnContents);

2
tests/framework/i18n/FormatterDateTest.php

@ -548,7 +548,7 @@ class FormatterDateTest extends TestCase
$utc = new \DateTimeZone('UTC');
$berlin = new \DateTimeZone('Europe/Berlin');
$result = [];
foreach($this->provideTimezones() as $tz) {
foreach ($this->provideTimezones() as $tz) {
$result[] = [$tz[0], 1407674460, 1388580060];
$result[] = [$tz[0], '2014-08-10 12:41:00', '2014-01-01 12:41:00'];
$result[] = [$tz[0], '2014-08-10 12:41:00 UTC', '2014-01-01 12:41:00 UTC'];

4
tests/framework/log/FileTargetTest.php

@ -69,7 +69,7 @@ class FileTargetTest extends TestCase
$this->assertFalse(file_exists($logFile . '.4'));
// exceed max size
for($i = 0; $i < 1024; $i++) {
for ($i = 0; $i < 1024; $i++) {
$logger->log(str_repeat('x', 1024), Logger::LEVEL_WARNING);
}
$logger->flush(true);
@ -89,7 +89,7 @@ class FileTargetTest extends TestCase
// second rotate
for($i = 0; $i < 1024; $i++) {
for ($i = 0; $i < 1024; $i++) {
$logger->log(str_repeat('x', 1024), Logger::LEVEL_WARNING);
}
$logger->flush(true);

2
tests/framework/rest/UrlRuleTest.php

@ -340,7 +340,7 @@ class UrlRuleTest extends TestCase
*/
public function testCreateUrl($rule, $tests)
{
foreach($tests as $test) {
foreach ($tests as $test) {
list($params, $expected) = $test;
$this->mockWebApplication();

2
tests/framework/validators/DateValidatorTest.php

@ -235,7 +235,7 @@ class DateValidatorTest extends TestCase
public function timestampFormatProvider()
{
$return = [];
foreach($this->provideTimezones() as $appTz) {
foreach ($this->provideTimezones() as $appTz) {
foreach ($this->provideTimezones() as $tz) {
$return[] = ['yyyy-MM-dd', '2013-09-13', '2013-09-13', $tz[0], $appTz[0]];
// regardless of timezone, a simple date input should always result in 00:00:00 time

2
tests/framework/validators/EmailValidatorTest.php

@ -114,7 +114,7 @@ class EmailValidatorTest extends TestCase
'ipetrov@gmail.com',
'Ivan Petrov <ipetrov@gmail.com>',
];
foreach($emails as $email) {
foreach ($emails as $email) {
$this->assertTrue($validator->validate($email),"Email: '$email' failed to validate(checkDNS=true, allowName=true)");
}
}

2
tests/framework/validators/FileValidatorTest.php

@ -71,7 +71,7 @@ class FileValidatorTest extends TestCase
public function testGetSizeLimit()
{
$size = min($this->sizeToBytes(ini_get('upload_max_filesize')),$this->sizeToBytes(ini_get('post_max_size')));
$size = min($this->sizeToBytes(ini_get('upload_max_filesize')), $this->sizeToBytes(ini_get('post_max_size')));
$val = new FileValidator();
$this->assertEquals($size, $val->getSizeLimit());
$val->maxSize = $size + 1; // set and test if value is overridden

2
tests/framework/validators/UniqueValidatorTest.php

@ -338,7 +338,7 @@ abstract class UniqueValidatorTest extends DatabaseTestCase
$schema = $this->getConnection()->schema;
$model = new ValidatorTestMainModel();
$query = $this->invokeMethod(new UniqueValidator(), 'prepareQuery', [$model,['val_attr_b' => 'test value a']]);
$query = $this->invokeMethod(new UniqueValidator(), 'prepareQuery', [$model, ['val_attr_b' => 'test value a']]);
$expected = "SELECT * FROM {$schema->quoteTableName('validator_main')} WHERE {$schema->quoteColumnName('val_attr_b')}=:qp0";
$this->assertEquals($expected, $query->createCommand()->getSql());

2
tests/framework/web/DbSessionTest.php

@ -113,7 +113,7 @@ class DbSessionTest extends TestCase
$migrate->run($action, $params);
ob_get_clean();
return array_map(function($version){
return array_map(function($version) {
return substr($version, 15);
}, (new Query())->select(['version'])->from('migration')->column());
}

12
tests/framework/web/RequestTest.php

@ -101,7 +101,7 @@ class RequestTest extends TestCase
$request->enableCsrfValidation = true;
// accept any value on GET request
foreach(['GET', 'HEAD', 'OPTIONS'] as $method) {
foreach (['GET', 'HEAD', 'OPTIONS'] as $method) {
$_POST[$request->methodParam] = $method;
$this->assertTrue($request->validateCsrfToken($token));
$this->assertTrue($request->validateCsrfToken($token . 'a'));
@ -112,7 +112,7 @@ class RequestTest extends TestCase
}
// only accept valid token on POST
foreach(['POST', 'PUT', 'DELETE'] as $method) {
foreach (['POST', 'PUT', 'DELETE'] as $method) {
$_POST[$request->methodParam] = $method;
$this->assertTrue($request->validateCsrfToken($token));
$this->assertFalse($request->validateCsrfToken($token . 'a'));
@ -136,13 +136,13 @@ class RequestTest extends TestCase
$token = $request->getCsrfToken();
// accept no value on GET request
foreach(['GET', 'HEAD', 'OPTIONS'] as $method) {
foreach (['GET', 'HEAD', 'OPTIONS'] as $method) {
$_POST[$request->methodParam] = $method;
$this->assertTrue($request->validateCsrfToken());
}
// only accept valid token on POST
foreach(['POST', 'PUT', 'DELETE'] as $method) {
foreach (['POST', 'PUT', 'DELETE'] as $method) {
$_POST[$request->methodParam] = $method;
$request->setBodyParams([]);
$this->assertFalse($request->validateCsrfToken());
@ -165,13 +165,13 @@ class RequestTest extends TestCase
$token = $request->getCsrfToken();
// accept no value on GET request
foreach(['GET', 'HEAD', 'OPTIONS'] as $method) {
foreach (['GET', 'HEAD', 'OPTIONS'] as $method) {
$_POST[$request->methodParam] = $method;
$this->assertTrue($request->validateCsrfToken());
}
// only accept valid token on POST
foreach(['POST', 'PUT', 'DELETE'] as $method) {
foreach (['POST', 'PUT', 'DELETE'] as $method) {
$_POST[$request->methodParam] = $method;
$request->setBodyParams([]);
//$request->headers->remove(Request::CSRF_HEADER);

4
tests/framework/web/UserTest.php

@ -151,8 +151,8 @@ class UserTest extends TestCase
}
$_SERVER = $server;
Yii::$app->set('response',['class' => 'yii\web\Response']);
Yii::$app->set('request',[
Yii::$app->set('response', ['class' => 'yii\web\Response']);
Yii::$app->set('request', [
'class' => 'yii\web\Request',
'scriptFile' => __DIR__ .'/index.php',
'scriptUrl' => '/index.php',

2
tests/framework/widgets/ActiveFieldTest.php

@ -395,7 +395,7 @@ EOD;
$this->activeField->enableAjaxValidation = true;
$this->activeField->model->addRule($this->attributeName, 'yiiunit\framework\widgets\TestValidator');
foreach($this->activeField->model->validators as $validator) {
foreach ($this->activeField->model->validators as $validator) {
$validator->whenClient = "function (attribute, value) { return 'yii2' == 'yii2'; }"; // js
}

Loading…
Cancel
Save