From 0596fa82fd9893c1074a245546dbb9047afd6ecb Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Tue, 13 Aug 2013 02:43:47 +0400 Subject: [PATCH] code style fixes --- apps/advanced/backend/config/params.php | 3 +- apps/advanced/backend/views/layouts/main.php | 4 +- apps/advanced/console/config/params.php | 3 +- .../dev/backend/config/params-local.php | 2 +- .../dev/common/config/params-local.php | 2 +- .../dev/console/config/params-local.php | 2 +- .../dev/frontend/config/params-local.php | 2 +- .../prod/backend/config/params-local.php | 2 +- .../prod/common/config/params-local.php | 2 +- .../prod/console/config/params-local.php | 2 +- .../prod/frontend/config/params-local.php | 2 +- apps/advanced/frontend/config/params.php | 3 +- apps/advanced/frontend/views/layouts/main.php | 3 +- build/controllers/ClassmapController.php | 2 +- extensions/twig/yii/twig/ViewRenderer.php | 2 +- framework/yii/captcha/Captcha.php | 1 - tests/unit/TestCase.php | 2 +- tests/unit/data/ar/Customer.php | 2 +- tests/unit/data/ar/Order.php | 2 +- tests/unit/data/base/InvalidRulesModel.php | 2 +- tests/unit/data/base/Singer.php | 1 + tests/unit/data/base/Speaker.php | 1 + tests/unit/data/config.php | 5 +- tests/unit/framework/base/BehaviorTest.php | 1 - tests/unit/framework/base/ComponentTest.php | 6 +- tests/unit/framework/base/ModelTest.php | 1 + tests/unit/framework/base/ObjectTest.php | 2 +- .../unit/framework/behaviors/AutoTimestampTest.php | 5 +- tests/unit/framework/caching/ApcCacheTest.php | 3 +- tests/unit/framework/caching/CacheTestCase.php | 3 +- tests/unit/framework/caching/DbCacheTest.php | 4 +- tests/unit/framework/caching/FileCacheTest.php | 1 + tests/unit/framework/caching/MemCacheTest.php | 1 + tests/unit/framework/caching/MemCachedTest.php | 1 + tests/unit/framework/caching/WinCacheTest.php | 1 + tests/unit/framework/caching/XCacheTest.php | 1 + tests/unit/framework/caching/ZendDataCacheTest.php | 1 + .../console/controllers/AssetControllerTest.php | 2 +- tests/unit/framework/data/SortTest.php | 2 +- tests/unit/framework/db/ActiveRecordTest.php | 4 +- tests/unit/framework/db/CommandTest.php | 61 +++--- tests/unit/framework/db/ConnectionTest.php | 12 +- tests/unit/framework/db/QueryBuilderTest.php | 3 +- tests/unit/framework/db/QueryTest.php | 20 +- .../framework/db/mssql/MssqlActiveRecordTest.php | 10 +- tests/unit/framework/db/mssql/MssqlCommandTest.php | 16 +- .../framework/db/mssql/MssqlConnectionTest.php | 16 +- tests/unit/framework/db/mssql/MssqlQueryTest.php | 10 +- .../db/pgsql/PostgreSQLActiveRecordTest.php | 10 +- .../db/pgsql/PostgreSQLConnectionTest.php | 24 +-- .../db/pgsql/PostgreSQLQueryBuilderTest.php | 3 +- .../framework/db/sqlite/SqliteActiveRecordTest.php | 10 +- .../unit/framework/db/sqlite/SqliteCommandTest.php | 24 +-- .../framework/db/sqlite/SqliteConnectionTest.php | 70 +++---- .../framework/db/sqlite/SqliteQueryBuilderTest.php | 3 +- tests/unit/framework/db/sqlite/SqliteQueryTest.php | 10 +- tests/unit/framework/helpers/ConsoleTest.php | 1 - tests/unit/framework/helpers/FileHelperTest.php | 7 +- tests/unit/framework/helpers/HtmlTest.php | 6 +- tests/unit/framework/helpers/InflectorTest.php | 204 ++++++++++----------- tests/unit/framework/helpers/JsonTest.php | 3 +- tests/unit/framework/helpers/StringHelperTest.php | 1 + tests/unit/framework/helpers/VarDumperTest.php | 1 + .../requirements/YiiRequirementCheckerTest.php | 3 +- .../framework/validators/EmailValidatorTest.php | 1 + tests/unit/framework/widgets/SpacelessTest.php | 2 +- .../app/protected/controllers/SiteController.php | 2 +- 67 files changed, 306 insertions(+), 318 deletions(-) diff --git a/apps/advanced/backend/config/params.php b/apps/advanced/backend/config/params.php index 1e197d0..1643a70 100644 --- a/apps/advanced/backend/config/params.php +++ b/apps/advanced/backend/config/params.php @@ -1,5 +1,4 @@ 'admin@example.com', -); \ No newline at end of file +); diff --git a/apps/advanced/backend/views/layouts/main.php b/apps/advanced/backend/views/layouts/main.php index 5915efb..36f4645 100644 --- a/apps/advanced/backend/views/layouts/main.php +++ b/apps/advanced/backend/views/layouts/main.php @@ -34,8 +34,7 @@ AppAsset::register($this); ); if (Yii::$app->user->isGuest) { $menuItems[] = array('label' => 'Login', 'url' => array('/site/login')); - } - else { + } else { $menuItems[] = array('label' => 'Logout (' . Yii::$app->user->identity->username .')' , 'url' => array('/site/logout')); } echo Nav::widget(array( @@ -60,7 +59,6 @@ AppAsset::register($this); endBody(); ?> - endPage(); ?> diff --git a/apps/advanced/console/config/params.php b/apps/advanced/console/config/params.php index 1e197d0..1643a70 100644 --- a/apps/advanced/console/config/params.php +++ b/apps/advanced/console/config/params.php @@ -1,5 +1,4 @@ 'admin@example.com', -); \ No newline at end of file +); diff --git a/apps/advanced/environments/dev/backend/config/params-local.php b/apps/advanced/environments/dev/backend/config/params-local.php index 2670143..5b61b0e 100644 --- a/apps/advanced/environments/dev/backend/config/params-local.php +++ b/apps/advanced/environments/dev/backend/config/params-local.php @@ -1,3 +1,3 @@ 'admin@example.com', -); \ No newline at end of file +); diff --git a/apps/advanced/frontend/views/layouts/main.php b/apps/advanced/frontend/views/layouts/main.php index 9e4c372..f26994f 100644 --- a/apps/advanced/frontend/views/layouts/main.php +++ b/apps/advanced/frontend/views/layouts/main.php @@ -38,8 +38,7 @@ AppAsset::register($this); if (Yii::$app->user->isGuest) { $menuItems[] = array('label' => 'Signup', 'url' => array('/site/signup')); $menuItems[] = array('label' => 'Login', 'url' => array('/site/login')); - } - else { + } else { $menuItems[] = array('label' => 'Logout (' . Yii::$app->user->identity->username .')' , 'url' => array('/site/logout')); } echo Nav::widget(array( diff --git a/build/controllers/ClassmapController.php b/build/controllers/ClassmapController.php index f9b9a85..ca78e9e 100644 --- a/build/controllers/ClassmapController.php +++ b/build/controllers/ClassmapController.php @@ -33,7 +33,7 @@ class ClassmapController extends Controller $mapFile = YII_PATH . '/classes.php'; } $options = array( - 'filter' => function($path) { + 'filter' => function ($path) { if (is_file($path)) { $file = basename($path); if ($file[0] < 'A' || $file[0] > 'Z') { diff --git a/extensions/twig/yii/twig/ViewRenderer.php b/extensions/twig/yii/twig/ViewRenderer.php index 76bee95..06ad2d2 100644 --- a/extensions/twig/yii/twig/ViewRenderer.php +++ b/extensions/twig/yii/twig/ViewRenderer.php @@ -46,7 +46,7 @@ class ViewRenderer extends BaseViewRenderer 'cache' => Yii::getAlias($this->cachePath), ), $this->options)); - $this->twig->addFunction('path', new \Twig_Function_Function(function($path, $args = array()){ + $this->twig->addFunction('path', new \Twig_Function_Function(function ($path, $args = array()) { return Html::url(array_merge(array($path), $args)); })); diff --git a/framework/yii/captcha/Captcha.php b/framework/yii/captcha/Captcha.php index 78a4db3..fc1d881 100644 --- a/framework/yii/captcha/Captcha.php +++ b/framework/yii/captcha/Captcha.php @@ -13,7 +13,6 @@ use yii\helpers\Html; use yii\helpers\Json; use yii\widgets\InputWidget; - /** * Captcha renders a CAPTCHA image and an input field that takes user-entered verification code. * diff --git a/tests/unit/TestCase.php b/tests/unit/TestCase.php index efcedf0..3289be4 100644 --- a/tests/unit/TestCase.php +++ b/tests/unit/TestCase.php @@ -45,7 +45,7 @@ abstract class TestCase extends \yii\test\TestCase 'basePath' => __DIR__, ); - new $appClass(array_merge($defaultConfig,$config)); + new $appClass(array_merge($defaultConfig, $config)); } /** diff --git a/tests/unit/data/ar/Customer.php b/tests/unit/data/ar/Customer.php index b26b51b..561d1ae 100644 --- a/tests/unit/data/ar/Customer.php +++ b/tests/unit/data/ar/Customer.php @@ -1,6 +1,6 @@ hasMany('Item', array('id' => 'item_id')) - ->via('orderItems', function($q) { + ->via('orderItems', function ($q) { // additional query configuration })->orderBy('id'); } diff --git a/tests/unit/data/base/InvalidRulesModel.php b/tests/unit/data/base/InvalidRulesModel.php index f5a8438..13f428d 100644 --- a/tests/unit/data/base/InvalidRulesModel.php +++ b/tests/unit/data/base/InvalidRulesModel.php @@ -1,5 +1,6 @@ array( 'mysql' => array( @@ -23,6 +22,6 @@ return array( 'username' => 'postgres', 'password' => 'postgres', 'fixture' => __DIR__ . '/postgres.sql', - ) - ) + ), + ), ); diff --git a/tests/unit/framework/base/BehaviorTest.php b/tests/unit/framework/base/BehaviorTest.php index 95b7220..edb9a1e 100644 --- a/tests/unit/framework/base/BehaviorTest.php +++ b/tests/unit/framework/base/BehaviorTest.php @@ -8,7 +8,6 @@ use yiiunit\TestCase; class BarClass extends Component { - } class FooClass extends Component diff --git a/tests/unit/framework/base/ComponentTest.php b/tests/unit/framework/base/ComponentTest.php index 712a515..79fb7db 100644 --- a/tests/unit/framework/base/ComponentTest.php +++ b/tests/unit/framework/base/ComponentTest.php @@ -194,7 +194,7 @@ class ComponentTest extends TestCase $this->assertFalse($this->component->event->handled); $eventRaised = false; - $this->component->on('click', function($event) use (&$eventRaised) { + $this->component->on('click', function ($event) use (&$eventRaised) { $eventRaised = true; }); $this->component->raiseEvent(); @@ -202,7 +202,7 @@ class ComponentTest extends TestCase // raise event w/o parameters $eventRaised = false; - $this->component->on('test', function($event) use (&$eventRaised) { + $this->component->on('test', function ($event) use (&$eventRaised) { $eventRaised = true; }); $this->component->trigger('test'); @@ -331,7 +331,7 @@ class NewComponent extends Component public function getExecute() { - return function($param) { + return function ($param) { return $param * 2; }; } diff --git a/tests/unit/framework/base/ModelTest.php b/tests/unit/framework/base/ModelTest.php index ff20d42..e4d8976 100644 --- a/tests/unit/framework/base/ModelTest.php +++ b/tests/unit/framework/base/ModelTest.php @@ -1,6 +1,7 @@ mockApplication( array( 'components' => array( @@ -112,4 +113,4 @@ class ActiveRecordAutoTimestamp extends ActiveRecord { return 'test_auto_timestamp'; } -} \ No newline at end of file +} diff --git a/tests/unit/framework/caching/ApcCacheTest.php b/tests/unit/framework/caching/ApcCacheTest.php index 17bcb6e..1d07498 100644 --- a/tests/unit/framework/caching/ApcCacheTest.php +++ b/tests/unit/framework/caching/ApcCacheTest.php @@ -1,5 +1,6 @@ markTestSkipped("APC cli is not enabled. Skipping."); } - if(!ini_get("apc.enabled") || !ini_get("apc.enable_cli")) { + if (!ini_get("apc.enabled") || !ini_get("apc.enable_cli")) { $this->markTestSkipped("APC is installed but not enabled. Skipping."); } diff --git a/tests/unit/framework/caching/CacheTestCase.php b/tests/unit/framework/caching/CacheTestCase.php index 81ac5cc..491459b 100644 --- a/tests/unit/framework/caching/CacheTestCase.php +++ b/tests/unit/framework/caching/CacheTestCase.php @@ -6,7 +6,8 @@ namespace yii\caching; * Mock for the time() function for caching classes * @return int */ -function time() { +function time() +{ return \yiiunit\framework\caching\CacheTestCase::$time ?: \time(); } diff --git a/tests/unit/framework/caching/DbCacheTest.php b/tests/unit/framework/caching/DbCacheTest.php index 3a26595..969b034 100644 --- a/tests/unit/framework/caching/DbCacheTest.php +++ b/tests/unit/framework/caching/DbCacheTest.php @@ -35,11 +35,11 @@ class DbCacheTest extends CacheTestCase * @param bool $reset whether to clean up the test database * @return \yii\db\Connection */ - function getConnection($reset = true) + public function getConnection($reset = true) { if ($this->_connection === null) { $databases = $this->getParam('databases'); - $params = $databases['mysql']; + $params = $databases['mysql']; $db = new \yii\db\Connection; $db->dsn = $params['dsn']; $db->username = $params['username']; diff --git a/tests/unit/framework/caching/FileCacheTest.php b/tests/unit/framework/caching/FileCacheTest.php index 62f8637..0bdbc86 100644 --- a/tests/unit/framework/caching/FileCacheTest.php +++ b/tests/unit/framework/caching/FileCacheTest.php @@ -1,5 +1,6 @@ testFilePath . DIRECTORY_SEPARATOR . 'bundle.php'; $configFile = $this->testFilePath . DIRECTORY_SEPARATOR . 'config.php'; diff --git a/tests/unit/framework/data/SortTest.php b/tests/unit/framework/data/SortTest.php index 8e623ba..9891ad1 100644 --- a/tests/unit/framework/data/SortTest.php +++ b/tests/unit/framework/data/SortTest.php @@ -6,11 +6,11 @@ */ namespace yiiunit\framework\data; + use yii\web\UrlManager; use yiiunit\TestCase; use yii\data\Sort; - /** * @author Qiang Xue * @since 2.0 diff --git a/tests/unit/framework/db/ActiveRecordTest.php b/tests/unit/framework/db/ActiveRecordTest.php index b089ece..7df4159 100644 --- a/tests/unit/framework/db/ActiveRecordTest.php +++ b/tests/unit/framework/db/ActiveRecordTest.php @@ -13,7 +13,7 @@ class ActiveRecordTest extends DatabaseTestCase { protected function setUp() { - parent::setUp(); + parent::setUp(); ActiveRecord::$db = $this->getConnection(); } @@ -85,7 +85,7 @@ class ActiveRecordTest extends DatabaseTestCase $this->assertTrue($customers['user3'] instanceof Customer); // indexBy callable - $customers = Customer::find()->indexBy(function($customer) { + $customers = Customer::find()->indexBy(function ($customer) { return $customer->id . '-' . $customer->name; })->orderBy('id')->all(); $this->assertEquals(3, count($customers)); diff --git a/tests/unit/framework/db/CommandTest.php b/tests/unit/framework/db/CommandTest.php index dac5f61..52fd046 100644 --- a/tests/unit/framework/db/CommandTest.php +++ b/tests/unit/framework/db/CommandTest.php @@ -15,7 +15,7 @@ class CommandTest extends DatabaseTestCase $this->mockApplication(); } - function testConstruct() + public function testConstruct() { $db = $this->getConnection(false); @@ -29,7 +29,7 @@ class CommandTest extends DatabaseTestCase $this->assertEquals($sql, $command->sql); } - function testGetSetSql() + public function testGetSetSql() { $db = $this->getConnection(false); @@ -42,7 +42,7 @@ class CommandTest extends DatabaseTestCase $this->assertEquals($sql2, $command->sql); } - function testAutoQuoting() + public function testAutoQuoting() { $db = $this->getConnection(false); @@ -51,7 +51,7 @@ class CommandTest extends DatabaseTestCase $this->assertEquals("SELECT `id`, `t`.`name` FROM `tbl_customer` t", $command->sql); } - function testPrepareCancel() + public function testPrepareCancel() { $db = $this->getConnection(false); @@ -63,7 +63,7 @@ class CommandTest extends DatabaseTestCase $this->assertEquals(null, $command->pdoStatement); } - function testExecute() + public function testExecute() { $db = $this->getConnection(); @@ -80,7 +80,7 @@ class CommandTest extends DatabaseTestCase $command->execute(); } - function testQuery() + public function testQuery() { $db = $this->getConnection(); @@ -141,7 +141,7 @@ class CommandTest extends DatabaseTestCase $command->query(); } - function testBindParamValue() + public function testBindParamValue() { $db = $this->getConnection(); @@ -197,7 +197,7 @@ class CommandTest extends DatabaseTestCase $this->assertEquals('user5@example.com', $command->queryScalar()); } - function testFetchMode() + public function testFetchMode() { $db = $this->getConnection(); @@ -221,78 +221,63 @@ class CommandTest extends DatabaseTestCase $this->assertTrue(is_array($result) && isset($result[0])); } - function testInsert() + public function testInsert() { - } - function testUpdate() + public function testUpdate() { - } - function testDelete() + public function testDelete() { - } - function testCreateTable() + public function testCreateTable() { - } - function testRenameTable() + public function testRenameTable() { - } - function testDropTable() + public function testDropTable() { - } - function testTruncateTable() + public function testTruncateTable() { - } - function testAddColumn() + public function testAddColumn() { - } - function testDropColumn() + public function testDropColumn() { - } - function testRenameColumn() + public function testRenameColumn() { - } - function testAlterColumn() + public function testAlterColumn() { - } - function testAddForeignKey() + public function testAddForeignKey() { - } - function testDropForeignKey() + public function testDropForeignKey() { - } - function testCreateIndex() + public function testCreateIndex() { - } - function testDropIndex() + public function testDropIndex() { - } } diff --git a/tests/unit/framework/db/ConnectionTest.php b/tests/unit/framework/db/ConnectionTest.php index d32c9c7..42b470b 100644 --- a/tests/unit/framework/db/ConnectionTest.php +++ b/tests/unit/framework/db/ConnectionTest.php @@ -12,7 +12,7 @@ class ConnectionTest extends DatabaseTestCase $this->mockApplication(); } - function testConstruct() + public function testConstruct() { $connection = $this->getConnection(false); $params = $this->database; @@ -22,7 +22,7 @@ class ConnectionTest extends DatabaseTestCase $this->assertEquals($params['password'], $connection->password); } - function testOpenClose() + public function testOpenClose() { $connection = $this->getConnection(false, false); @@ -43,13 +43,13 @@ class ConnectionTest extends DatabaseTestCase $connection->open(); } - function testGetDriverName() + public function testGetDriverName() { $connection = $this->getConnection(false, false); $this->assertEquals($this->driverName, $connection->driverName); } - function testQuoteValue() + public function testQuoteValue() { $connection = $this->getConnection(false); $this->assertEquals(123, $connection->quoteValue(123)); @@ -57,7 +57,7 @@ class ConnectionTest extends DatabaseTestCase $this->assertEquals("'It\\'s interesting'", $connection->quoteValue("It's interesting")); } - function testQuoteTableName() + public function testQuoteTableName() { $connection = $this->getConnection(false); $this->assertEquals('`table`', $connection->quoteTableName('table')); @@ -68,7 +68,7 @@ class ConnectionTest extends DatabaseTestCase $this->assertEquals('(table)', $connection->quoteTableName('(table)')); } - function testQuoteColumnName() + public function testQuoteColumnName() { $connection = $this->getConnection(false); $this->assertEquals('`column`', $connection->quoteColumnName('column')); diff --git a/tests/unit/framework/db/QueryBuilderTest.php b/tests/unit/framework/db/QueryBuilderTest.php index 56cca00..146cfdb 100644 --- a/tests/unit/framework/db/QueryBuilderTest.php +++ b/tests/unit/framework/db/QueryBuilderTest.php @@ -127,7 +127,6 @@ class QueryBuilderTest extends DatabaseTestCase $qb->db->createCommand()->dropPrimaryKey($pkeyName, $tableName)->execute(); $qb = $this->getQueryBuilder(); // resets the schema $tableSchema = $qb->db->getSchema()->getTableSchema($tableName); - $this->assertEquals(0, count($tableSchema->primaryKey)); + $this->assertEquals(0, count($tableSchema->primaryKey)); } - } diff --git a/tests/unit/framework/db/QueryTest.php b/tests/unit/framework/db/QueryTest.php index 237652f..5d1f1a9 100644 --- a/tests/unit/framework/db/QueryTest.php +++ b/tests/unit/framework/db/QueryTest.php @@ -15,7 +15,7 @@ class QueryTest extends DatabaseTestCase $this->mockApplication(); } - function testSelect() + public function testSelect() { // default $query = new Query; @@ -31,14 +31,14 @@ class QueryTest extends DatabaseTestCase $this->assertEquals('something', $query->selectOption); } - function testFrom() + public function testFrom() { $query = new Query; $query->from('tbl_user'); $this->assertEquals(array('tbl_user'), $query->from); } - function testWhere() + public function testWhere() { $query = new Query; $query->where('id = :id', array(':id' => 1)); @@ -54,12 +54,11 @@ class QueryTest extends DatabaseTestCase $this->assertEquals(array(':id' => 1, ':name' => 'something', ':age' => '30'), $query->params); } - function testJoin() + public function testJoin() { - } - function testGroup() + public function testGroup() { $query = new Query; $query->groupBy('team'); @@ -72,7 +71,7 @@ class QueryTest extends DatabaseTestCase $this->assertEquals(array('team', 'company', 'age'), $query->groupBy); } - function testHaving() + public function testHaving() { $query = new Query; $query->having('id = :id', array(':id' => 1)); @@ -88,7 +87,7 @@ class QueryTest extends DatabaseTestCase $this->assertEquals(array(':id' => 1, ':name' => 'something', ':age' => '30'), $query->params); } - function testOrder() + public function testOrder() { $query = new Query; $query->orderBy('team'); @@ -107,7 +106,7 @@ class QueryTest extends DatabaseTestCase $this->assertEquals(array('team' => false, 'company' => true, 'age' => false), $query->orderBy); } - function testLimitOffset() + public function testLimitOffset() { $query = new Query; $query->limit(10)->offset(5); @@ -115,8 +114,7 @@ class QueryTest extends DatabaseTestCase $this->assertEquals(5, $query->offset); } - function testUnion() + public function testUnion() { - } } diff --git a/tests/unit/framework/db/mssql/MssqlActiveRecordTest.php b/tests/unit/framework/db/mssql/MssqlActiveRecordTest.php index 76c30b9..5647411 100644 --- a/tests/unit/framework/db/mssql/MssqlActiveRecordTest.php +++ b/tests/unit/framework/db/mssql/MssqlActiveRecordTest.php @@ -6,9 +6,9 @@ use yiiunit\framework\db\ActiveRecordTest; class MssqlActiveRecordTest extends ActiveRecordTest { - protected function setUp() - { - $this->driverName = 'sqlsrv'; - parent::setUp(); - } + protected function setUp() + { + $this->driverName = 'sqlsrv'; + parent::setUp(); + } } diff --git a/tests/unit/framework/db/mssql/MssqlCommandTest.php b/tests/unit/framework/db/mssql/MssqlCommandTest.php index 75447bd..e27fcee 100644 --- a/tests/unit/framework/db/mssql/MssqlCommandTest.php +++ b/tests/unit/framework/db/mssql/MssqlCommandTest.php @@ -6,13 +6,13 @@ use yiiunit\framework\db\CommandTest; class MssqlCommandTest extends CommandTest { - public function setUp() - { - $this->driverName = 'sqlsrv'; - parent::setUp(); - } + public function setUp() + { + $this->driverName = 'sqlsrv'; + parent::setUp(); + } - function testAutoQuoting() + public function testAutoQuoting() { $db = $this->getConnection(false); @@ -21,12 +21,12 @@ class MssqlCommandTest extends CommandTest $this->assertEquals("SELECT [id], [t].[name] FROM [tbl_customer] t", $command->sql); } - function testPrepareCancel() + public function testPrepareCancel() { $this->markTestSkipped('MSSQL driver does not support this feature.'); } - function testBindParamValue() + public function testBindParamValue() { $db = $this->getConnection(); diff --git a/tests/unit/framework/db/mssql/MssqlConnectionTest.php b/tests/unit/framework/db/mssql/MssqlConnectionTest.php index 42ac380..7bbaae7 100644 --- a/tests/unit/framework/db/mssql/MssqlConnectionTest.php +++ b/tests/unit/framework/db/mssql/MssqlConnectionTest.php @@ -6,13 +6,13 @@ use yiiunit\framework\db\ConnectionTest; class MssqlConnectionTest extends ConnectionTest { - public function setUp() - { - $this->driverName = 'sqlsrv'; - parent::setUp(); - } + public function setUp() + { + $this->driverName = 'sqlsrv'; + parent::setUp(); + } - function testQuoteValue() + public function testQuoteValue() { $connection = $this->getConnection(false); $this->assertEquals(123, $connection->quoteValue(123)); @@ -20,7 +20,7 @@ class MssqlConnectionTest extends ConnectionTest $this->assertEquals("'It''s interesting'", $connection->quoteValue("It's interesting")); } - function testQuoteTableName() + public function testQuoteTableName() { $connection = $this->getConnection(false); $this->assertEquals('[table]', $connection->quoteTableName('table')); @@ -31,7 +31,7 @@ class MssqlConnectionTest extends ConnectionTest $this->assertEquals('(table)', $connection->quoteTableName('(table)')); } - function testQuoteColumnName() + public function testQuoteColumnName() { $connection = $this->getConnection(false); $this->assertEquals('[column]', $connection->quoteColumnName('column')); diff --git a/tests/unit/framework/db/mssql/MssqlQueryTest.php b/tests/unit/framework/db/mssql/MssqlQueryTest.php index 08af19d..4f37c14 100644 --- a/tests/unit/framework/db/mssql/MssqlQueryTest.php +++ b/tests/unit/framework/db/mssql/MssqlQueryTest.php @@ -6,9 +6,9 @@ use yiiunit\framework\db\QueryTest; class MssqlQueryTest extends QueryTest { - public function setUp() - { - $this->driverName = 'sqlsrv'; - parent::setUp(); - } + public function setUp() + { + $this->driverName = 'sqlsrv'; + parent::setUp(); + } } diff --git a/tests/unit/framework/db/pgsql/PostgreSQLActiveRecordTest.php b/tests/unit/framework/db/pgsql/PostgreSQLActiveRecordTest.php index 18bfbd8..2836223 100644 --- a/tests/unit/framework/db/pgsql/PostgreSQLActiveRecordTest.php +++ b/tests/unit/framework/db/pgsql/PostgreSQLActiveRecordTest.php @@ -6,9 +6,9 @@ use yiiunit\framework\db\ActiveRecordTest; class PostgreSQLActiveRecordTest extends ActiveRecordTest { - protected function setUp() - { - $this->driverName = 'pgsql'; - parent::setUp(); - } + protected function setUp() + { + $this->driverName = 'pgsql'; + parent::setUp(); + } } diff --git a/tests/unit/framework/db/pgsql/PostgreSQLConnectionTest.php b/tests/unit/framework/db/pgsql/PostgreSQLConnectionTest.php index 678b197..7ac65c5 100644 --- a/tests/unit/framework/db/pgsql/PostgreSQLConnectionTest.php +++ b/tests/unit/framework/db/pgsql/PostgreSQLConnectionTest.php @@ -1,28 +1,30 @@ driverName = 'pgsql'; parent::setUp(); } - public function testConnection() { + public function testConnection() + { $connection = $this->getConnection(true); } - function testQuoteValue() { + public function testQuoteValue() + { $connection = $this->getConnection(false); $this->assertEquals(123, $connection->quoteValue(123)); $this->assertEquals("'string'", $connection->quoteValue('string')); $this->assertEquals("'It''s interesting'", $connection->quoteValue("It's interesting")); } - - function testQuoteTableName() + + public function testQuoteTableName() { $connection = $this->getConnection(false); $this->assertEquals('"table"', $connection->quoteTableName('table')); @@ -33,8 +35,8 @@ class PostgreSQLConnectionTest extends ConnectionTest { $this->assertEquals('{{table}}', $connection->quoteTableName('{{table}}')); $this->assertEquals('(table)', $connection->quoteTableName('(table)')); } - - function testQuoteColumnName() + + public function testQuoteColumnName() { $connection = $this->getConnection(false); $this->assertEquals('"column"', $connection->quoteColumnName('column')); @@ -46,6 +48,4 @@ class PostgreSQLConnectionTest extends ConnectionTest { $this->assertEquals('{{column}}', $connection->quoteColumnName('{{column}}')); $this->assertEquals('(column)', $connection->quoteColumnName('(column)')); } - - } diff --git a/tests/unit/framework/db/pgsql/PostgreSQLQueryBuilderTest.php b/tests/unit/framework/db/pgsql/PostgreSQLQueryBuilderTest.php index 9c5d1e1..7c31190 100644 --- a/tests/unit/framework/db/pgsql/PostgreSQLQueryBuilderTest.php +++ b/tests/unit/framework/db/pgsql/PostgreSQLQueryBuilderTest.php @@ -72,5 +72,4 @@ class PostgreSQLQueryBuilderTest extends QueryBuilderTest array(Schema::TYPE_MONEY . ' NOT NULL', 'numeric(19,4) NOT NULL'), ); } - -} \ No newline at end of file +} diff --git a/tests/unit/framework/db/sqlite/SqliteActiveRecordTest.php b/tests/unit/framework/db/sqlite/SqliteActiveRecordTest.php index 573108e..2e76162 100644 --- a/tests/unit/framework/db/sqlite/SqliteActiveRecordTest.php +++ b/tests/unit/framework/db/sqlite/SqliteActiveRecordTest.php @@ -5,9 +5,9 @@ use yiiunit\framework\db\ActiveRecordTest; class SqliteActiveRecordTest extends ActiveRecordTest { - protected function setUp() - { - $this->driverName = 'sqlite'; - parent::setUp(); - } + protected function setUp() + { + $this->driverName = 'sqlite'; + parent::setUp(); + } } diff --git a/tests/unit/framework/db/sqlite/SqliteCommandTest.php b/tests/unit/framework/db/sqlite/SqliteCommandTest.php index 750ea11..e330c7e 100644 --- a/tests/unit/framework/db/sqlite/SqliteCommandTest.php +++ b/tests/unit/framework/db/sqlite/SqliteCommandTest.php @@ -5,18 +5,18 @@ use yiiunit\framework\db\CommandTest; class SqliteCommandTest extends CommandTest { - protected function setUp() - { - $this->driverName = 'sqlite'; - parent::setUp(); - } + protected function setUp() + { + $this->driverName = 'sqlite'; + parent::setUp(); + } - public function testAutoQuoting() - { - $db = $this->getConnection(false); + public function testAutoQuoting() + { + $db = $this->getConnection(false); - $sql = 'SELECT [[id]], [[t.name]] FROM {{tbl_customer}} t'; - $command = $db->createCommand($sql); - $this->assertEquals("SELECT \"id\", 't'.\"name\" FROM 'tbl_customer' t", $command->sql); - } + $sql = 'SELECT [[id]], [[t.name]] FROM {{tbl_customer}} t'; + $command = $db->createCommand($sql); + $this->assertEquals("SELECT \"id\", 't'.\"name\" FROM 'tbl_customer' t", $command->sql); + } } diff --git a/tests/unit/framework/db/sqlite/SqliteConnectionTest.php b/tests/unit/framework/db/sqlite/SqliteConnectionTest.php index e33c5ad..2065200 100644 --- a/tests/unit/framework/db/sqlite/SqliteConnectionTest.php +++ b/tests/unit/framework/db/sqlite/SqliteConnectionTest.php @@ -5,44 +5,44 @@ use yiiunit\framework\db\ConnectionTest; class SqliteConnectionTest extends ConnectionTest { - protected function setUp() - { - $this->driverName = 'sqlite'; - parent::setUp(); - } + protected function setUp() + { + $this->driverName = 'sqlite'; + parent::setUp(); + } - public function testConstruct() - { - $connection = $this->getConnection(false); - $params = $this->database; + public function testConstruct() + { + $connection = $this->getConnection(false); + $params = $this->database; - $this->assertEquals($params['dsn'], $connection->dsn); - } + $this->assertEquals($params['dsn'], $connection->dsn); + } - public function testQuoteValue() - { - $connection = $this->getConnection(false); - $this->assertEquals(123, $connection->quoteValue(123)); - $this->assertEquals("'string'", $connection->quoteValue('string')); - $this->assertEquals("'It''s interesting'", $connection->quoteValue("It's interesting")); - } + public function testQuoteValue() + { + $connection = $this->getConnection(false); + $this->assertEquals(123, $connection->quoteValue(123)); + $this->assertEquals("'string'", $connection->quoteValue('string')); + $this->assertEquals("'It''s interesting'", $connection->quoteValue("It's interesting")); + } - public function testQuoteTableName() - { - $connection = $this->getConnection(false); - $this->assertEquals("'table'", $connection->quoteTableName('table')); - $this->assertEquals("'schema'.'table'", $connection->quoteTableName('schema.table')); - $this->assertEquals('{{table}}', $connection->quoteTableName('{{table}}')); - $this->assertEquals('(table)', $connection->quoteTableName('(table)')); - } + public function testQuoteTableName() + { + $connection = $this->getConnection(false); + $this->assertEquals("'table'", $connection->quoteTableName('table')); + $this->assertEquals("'schema'.'table'", $connection->quoteTableName('schema.table')); + $this->assertEquals('{{table}}', $connection->quoteTableName('{{table}}')); + $this->assertEquals('(table)', $connection->quoteTableName('(table)')); + } - public function testQuoteColumnName() - { - $connection = $this->getConnection(false); - $this->assertEquals('"column"', $connection->quoteColumnName('column')); - $this->assertEquals("'table'.\"column\"", $connection->quoteColumnName('table.column')); - $this->assertEquals('[[column]]', $connection->quoteColumnName('[[column]]')); - $this->assertEquals('{{column}}', $connection->quoteColumnName('{{column}}')); - $this->assertEquals('(column)', $connection->quoteColumnName('(column)')); - } + public function testQuoteColumnName() + { + $connection = $this->getConnection(false); + $this->assertEquals('"column"', $connection->quoteColumnName('column')); + $this->assertEquals("'table'.\"column\"", $connection->quoteColumnName('table.column')); + $this->assertEquals('[[column]]', $connection->quoteColumnName('[[column]]')); + $this->assertEquals('{{column}}', $connection->quoteColumnName('{{column}}')); + $this->assertEquals('(column)', $connection->quoteColumnName('(column)')); + } } diff --git a/tests/unit/framework/db/sqlite/SqliteQueryBuilderTest.php b/tests/unit/framework/db/sqlite/SqliteQueryBuilderTest.php index 8e769af..2f6b164 100644 --- a/tests/unit/framework/db/sqlite/SqliteQueryBuilderTest.php +++ b/tests/unit/framework/db/sqlite/SqliteQueryBuilderTest.php @@ -78,5 +78,4 @@ class SqliteQueryBuilderTest extends QueryBuilderTest $this->setExpectedException('yii\base\NotSupportedException'); parent::testAddDropPrimayKey(); } - -} \ No newline at end of file +} diff --git a/tests/unit/framework/db/sqlite/SqliteQueryTest.php b/tests/unit/framework/db/sqlite/SqliteQueryTest.php index 66068d2..ebbb1bb 100644 --- a/tests/unit/framework/db/sqlite/SqliteQueryTest.php +++ b/tests/unit/framework/db/sqlite/SqliteQueryTest.php @@ -5,9 +5,9 @@ use yiiunit\framework\db\QueryTest; class SqliteQueryTest extends QueryTest { - protected function setUp() - { - $this->driverName = 'sqlite'; - parent::setUp(); - } + protected function setUp() + { + $this->driverName = 'sqlite'; + parent::setUp(); + } } diff --git a/tests/unit/framework/helpers/ConsoleTest.php b/tests/unit/framework/helpers/ConsoleTest.php index 3bfa56d..f1d3b3a 100644 --- a/tests/unit/framework/helpers/ConsoleTest.php +++ b/tests/unit/framework/helpers/ConsoleTest.php @@ -75,5 +75,4 @@ class ConsoleTest extends TestCase sleep(1); } }*/ - } diff --git a/tests/unit/framework/helpers/FileHelperTest.php b/tests/unit/framework/helpers/FileHelperTest.php index 4d874de..df27819 100644 --- a/tests/unit/framework/helpers/FileHelperTest.php +++ b/tests/unit/framework/helpers/FileHelperTest.php @@ -100,7 +100,7 @@ class FileHelperTest extends TestCase * @param string $fileName file name. * @param string $message error message */ - protected function assertFileMode($expectedMode, $fileName, $message='') + protected function assertFileMode($expectedMode, $fileName, $message = '') { $expectedMode = sprintf('%o', $expectedMode); $this->assertEquals($expectedMode, $this->getMode($fileName), $message); @@ -236,7 +236,7 @@ class FileHelperTest extends TestCase $dirName = $basePath . DIRECTORY_SEPARATOR . $dirName; $options = array( - 'filter' => function($path) use ($passedFileName) { + 'filter' => function ($path) use ($passedFileName) { return $passedFileName == basename($path); } ); @@ -268,7 +268,8 @@ class FileHelperTest extends TestCase $this->assertEquals(array($dirName . DIRECTORY_SEPARATOR . $fileName), $foundFiles); } - public function testMkdir() { + public function testMkdir() + { $basePath = $this->testFilePath; $dirName = $basePath . DIRECTORY_SEPARATOR . 'test_dir_level_1' . DIRECTORY_SEPARATOR . 'test_dir_level_2'; FileHelper::mkdir($dirName); diff --git a/tests/unit/framework/helpers/HtmlTest.php b/tests/unit/framework/helpers/HtmlTest.php index 3a35bd2..fafc72f 100644 --- a/tests/unit/framework/helpers/HtmlTest.php +++ b/tests/unit/framework/helpers/HtmlTest.php @@ -370,7 +370,7 @@ EOD;
EOD; - $this->assertEqualsWithoutLE($expected, Html::radioList('test', array('value2'), $this->getDataItems2())); + $this->assertEqualsWithoutLE($expected, Html::radioList('test', array('value2'), $this->getDataItems2())); $expected = <<

@@ -414,7 +414,7 @@ EOD; EOD; $this->assertEqualsWithoutLE($expected, Html::ul($data, array( 'class' => 'test', - 'item' => function($item, $index) { + 'item' => function ($item, $index) { return "
  • $item
  • "; } ))); @@ -444,7 +444,7 @@ EOD; EOD; $this->assertEqualsWithoutLE($expected, Html::ol($data, array( 'class' => 'test', - 'item' => function($item, $index) { + 'item' => function ($item, $index) { return "
  • $item
  • "; } ))); diff --git a/tests/unit/framework/helpers/InflectorTest.php b/tests/unit/framework/helpers/InflectorTest.php index f1a98ba..df5b424 100644 --- a/tests/unit/framework/helpers/InflectorTest.php +++ b/tests/unit/framework/helpers/InflectorTest.php @@ -8,35 +8,35 @@ use yiiunit\TestCase; class InflectorTest extends TestCase { - public function testPluralize() - { - $testData = array( - 'move' => 'moves', - 'foot' => 'feet', - 'child' => 'children', - 'human' => 'humans', - 'man' => 'men', - 'staff' => 'staff', - 'tooth' => 'teeth', - 'person' => 'people', - 'mouse' => 'mice', - 'touch' => 'touches', - 'hash' => 'hashes', - 'shelf' => 'shelves', - 'potato' => 'potatoes', - 'bus' => 'buses', - 'test' => 'tests', - 'car' => 'cars', - ); - - foreach ($testData as $testIn => $testOut) { - $this->assertEquals($testOut, Inflector::pluralize($testIn)); - $this->assertEquals(ucfirst($testOut), ucfirst(Inflector::pluralize($testIn))); - } - } - - public function testSingularize() - { + public function testPluralize() + { + $testData = array( + 'move' => 'moves', + 'foot' => 'feet', + 'child' => 'children', + 'human' => 'humans', + 'man' => 'men', + 'staff' => 'staff', + 'tooth' => 'teeth', + 'person' => 'people', + 'mouse' => 'mice', + 'touch' => 'touches', + 'hash' => 'hashes', + 'shelf' => 'shelves', + 'potato' => 'potatoes', + 'bus' => 'buses', + 'test' => 'tests', + 'car' => 'cars', + ); + + foreach ($testData as $testIn => $testOut) { + $this->assertEquals($testOut, Inflector::pluralize($testIn)); + $this->assertEquals(ucfirst($testOut), ucfirst(Inflector::pluralize($testIn))); + } + } + + public function testSingularize() + { $testData = array( 'moves' => 'move', 'feet' => 'foot', @@ -59,77 +59,77 @@ class InflectorTest extends TestCase $this->assertEquals($testOut, Inflector::singularize($testIn)); $this->assertEquals(ucfirst($testOut), ucfirst(Inflector::singularize($testIn))); } - } - - public function testTitleize() - { - $this->assertEquals("Me my self and i", Inflector::titleize('MeMySelfAndI')); - $this->assertEquals("Me My Self And I", Inflector::titleize('MeMySelfAndI', true)); - } - - public function testCamelize() - { - $this->assertEquals("MeMySelfAndI", Inflector::camelize('me my_self-andI')); - } - - public function testUnderscore() - { - $this->assertEquals("me_my_self_and_i", Inflector::underscore('MeMySelfAndI')); - } - - public function testCamel2words() - { - $this->assertEquals('Camel Case', Inflector::camel2words('camelCase')); - $this->assertEquals('Lower Case', Inflector::camel2words('lower_case')); - $this->assertEquals('Tricky Stuff It Is Testing', Inflector::camel2words(' tricky_stuff.it-is testing... ')); - } - - public function testCamel2id() - { - $this->assertEquals('post-tag', Inflector::camel2id('PostTag')); - $this->assertEquals('post_tag', Inflector::camel2id('PostTag', '_')); - - $this->assertEquals('post-tag', Inflector::camel2id('postTag')); - $this->assertEquals('post_tag', Inflector::camel2id('postTag', '_')); - } - - public function testId2camel() - { - $this->assertEquals('PostTag', Inflector::id2camel('post-tag')); - $this->assertEquals('PostTag', Inflector::id2camel('post_tag', '_')); - - $this->assertEquals('PostTag', Inflector::id2camel('post-tag')); - $this->assertEquals('PostTag', Inflector::id2camel('post_tag', '_')); - } - - public function testHumanize() - { - $this->assertEquals("Me my self and i", Inflector::humanize('me_my_self_and_i')); - $this->assertEquals("Me My Self And I", Inflector::humanize('me_my_self_and_i', true)); - } - - public function testVariablize() - { - $this->assertEquals("customerTable", Inflector::variablize('customer_table')); - } - - public function testTableize() - { - $this->assertEquals("customer_tables", Inflector::tableize('customerTable')); - } - - public function testSlug() - { - $this->assertEquals("this-is-a-title", Inflector::slug('this is a title')); - } - - public function testClassify() - { - $this->assertEquals("CustomerTable", Inflector::classify('customer_tables')); - } - - public function testOrdinalize() - { - $this->assertEquals('21st', Inflector::ordinalize('21')); - } + } + + public function testTitleize() + { + $this->assertEquals("Me my self and i", Inflector::titleize('MeMySelfAndI')); + $this->assertEquals("Me My Self And I", Inflector::titleize('MeMySelfAndI', true)); + } + + public function testCamelize() + { + $this->assertEquals("MeMySelfAndI", Inflector::camelize('me my_self-andI')); + } + + public function testUnderscore() + { + $this->assertEquals("me_my_self_and_i", Inflector::underscore('MeMySelfAndI')); + } + + public function testCamel2words() + { + $this->assertEquals('Camel Case', Inflector::camel2words('camelCase')); + $this->assertEquals('Lower Case', Inflector::camel2words('lower_case')); + $this->assertEquals('Tricky Stuff It Is Testing', Inflector::camel2words(' tricky_stuff.it-is testing... ')); + } + + public function testCamel2id() + { + $this->assertEquals('post-tag', Inflector::camel2id('PostTag')); + $this->assertEquals('post_tag', Inflector::camel2id('PostTag', '_')); + + $this->assertEquals('post-tag', Inflector::camel2id('postTag')); + $this->assertEquals('post_tag', Inflector::camel2id('postTag', '_')); + } + + public function testId2camel() + { + $this->assertEquals('PostTag', Inflector::id2camel('post-tag')); + $this->assertEquals('PostTag', Inflector::id2camel('post_tag', '_')); + + $this->assertEquals('PostTag', Inflector::id2camel('post-tag')); + $this->assertEquals('PostTag', Inflector::id2camel('post_tag', '_')); + } + + public function testHumanize() + { + $this->assertEquals("Me my self and i", Inflector::humanize('me_my_self_and_i')); + $this->assertEquals("Me My Self And I", Inflector::humanize('me_my_self_and_i', true)); + } + + public function testVariablize() + { + $this->assertEquals("customerTable", Inflector::variablize('customer_table')); + } + + public function testTableize() + { + $this->assertEquals("customer_tables", Inflector::tableize('customerTable')); + } + + public function testSlug() + { + $this->assertEquals("this-is-a-title", Inflector::slug('this is a title')); + } + + public function testClassify() + { + $this->assertEquals("CustomerTable", Inflector::classify('customer_tables')); + } + + public function testOrdinalize() + { + $this->assertEquals('21st', Inflector::ordinalize('21')); + } } diff --git a/tests/unit/framework/helpers/JsonTest.php b/tests/unit/framework/helpers/JsonTest.php index 5504985..3734744 100644 --- a/tests/unit/framework/helpers/JsonTest.php +++ b/tests/unit/framework/helpers/JsonTest.php @@ -23,7 +23,8 @@ class JsonTest extends TestCase // simple object encoding $data = new \stdClass(); - $data->a = 1; $data->b = 2; + $data->a = 1; + $data->b = 2; $this->assertSame('{"a":1,"b":2}', Json::encode($data)); // expression encoding diff --git a/tests/unit/framework/helpers/StringHelperTest.php b/tests/unit/framework/helpers/StringHelperTest.php index b7f422a..fe6a96c 100644 --- a/tests/unit/framework/helpers/StringHelperTest.php +++ b/tests/unit/framework/helpers/StringHelperTest.php @@ -1,5 +1,6 @@ \n

    This is a left bar!

    ". "

    This is a right bar!

    \t

    Bye!

    \n\n"; - $this->assertEquals($expected,ob_get_clean()); + $this->assertEquals($expected, ob_get_clean()); } } diff --git a/tests/web/app/protected/controllers/SiteController.php b/tests/web/app/protected/controllers/SiteController.php index 0cc92ae..89a4086 100644 --- a/tests/web/app/protected/controllers/SiteController.php +++ b/tests/web/app/protected/controllers/SiteController.php @@ -16,7 +16,7 @@ class DefaultController extends \yii\web\Controller 'value 1' => 'item 1', 'value 2' => 'item 2', 'value 3' => 'item 3', - ), isset($_POST['test']) ? $_POST['test'] : null, + ), isset($_POST['test']) ? $_POST['test'] : null, function ($index, $label, $name, $value, $checked) { return Html::label( $label . ' ' . Html::checkbox($name, $value, $checked),