Browse Source

Merge branch 'master' of github.com:yiisoft/yii2

tags/2.0.0-beta
Qiang Xue 11 years ago
parent
commit
b07ac2810e
  1. 1
      apps/advanced/backend/config/AppAsset.php
  2. 1
      apps/advanced/backend/config/params.php
  3. 63
      apps/advanced/backend/views/layouts/main.php
  4. 68
      apps/advanced/backend/views/site/index.php
  5. 24
      apps/advanced/backend/views/site/login.php
  6. 79
      apps/advanced/backend/web/css/site.css
  7. 1
      apps/advanced/console/config/params.php
  8. 1
      apps/advanced/frontend/config/AppAsset.php
  9. 1
      apps/advanced/frontend/config/params.php
  10. 77
      apps/advanced/frontend/views/layouts/main.php
  11. 12
      apps/advanced/frontend/views/site/about.php
  12. 41
      apps/advanced/frontend/views/site/contact.php
  13. 68
      apps/advanced/frontend/views/site/index.php
  14. 29
      apps/advanced/frontend/views/site/login.php
  15. 22
      apps/advanced/frontend/views/site/requestPasswordResetToken.php
  16. 20
      apps/advanced/frontend/views/site/resetPassword.php
  17. 24
      apps/advanced/frontend/views/site/signup.php
  18. 79
      apps/advanced/frontend/web/css/site.css
  19. 2
      build/controllers/ClassmapController.php
  20. 2
      extensions/twig/yii/twig/ViewRenderer.php
  21. 1
      framework/yii/captcha/Captcha.php
  22. 1
      framework/yii/data/ArrayDataProvider.php
  23. 3
      tests/unit/TestCase.php
  24. 2
      tests/unit/data/ar/Customer.php
  25. 2
      tests/unit/data/ar/Order.php
  26. 2
      tests/unit/data/base/InvalidRulesModel.php
  27. 1
      tests/unit/data/base/Singer.php
  28. 1
      tests/unit/data/base/Speaker.php
  29. 5
      tests/unit/data/config.php
  30. 1
      tests/unit/framework/base/BehaviorTest.php
  31. 6
      tests/unit/framework/base/ComponentTest.php
  32. 1
      tests/unit/framework/base/ModelTest.php
  33. 2
      tests/unit/framework/base/ObjectTest.php
  34. 3
      tests/unit/framework/behaviors/AutoTimestampTest.php
  35. 3
      tests/unit/framework/caching/ApcCacheTest.php
  36. 3
      tests/unit/framework/caching/CacheTestCase.php
  37. 4
      tests/unit/framework/caching/DbCacheTest.php
  38. 1
      tests/unit/framework/caching/FileCacheTest.php
  39. 1
      tests/unit/framework/caching/MemCacheTest.php
  40. 1
      tests/unit/framework/caching/MemCachedTest.php
  41. 1
      tests/unit/framework/caching/WinCacheTest.php
  42. 1
      tests/unit/framework/caching/XCacheTest.php
  43. 1
      tests/unit/framework/caching/ZendDataCacheTest.php
  44. 2
      tests/unit/framework/console/controllers/AssetControllerTest.php
  45. 2
      tests/unit/framework/data/SortTest.php
  46. 4
      tests/unit/framework/db/ActiveRecordTest.php
  47. 61
      tests/unit/framework/db/CommandTest.php
  48. 12
      tests/unit/framework/db/ConnectionTest.php
  49. 1
      tests/unit/framework/db/QueryBuilderTest.php
  50. 20
      tests/unit/framework/db/QueryTest.php
  51. 10
      tests/unit/framework/db/mssql/MssqlActiveRecordTest.php
  52. 16
      tests/unit/framework/db/mssql/MssqlCommandTest.php
  53. 16
      tests/unit/framework/db/mssql/MssqlConnectionTest.php
  54. 10
      tests/unit/framework/db/mssql/MssqlQueryTest.php
  55. 10
      tests/unit/framework/db/pgsql/PostgreSQLActiveRecordTest.php
  56. 20
      tests/unit/framework/db/pgsql/PostgreSQLConnectionTest.php
  57. 1
      tests/unit/framework/db/pgsql/PostgreSQLQueryBuilderTest.php
  58. 10
      tests/unit/framework/db/sqlite/SqliteActiveRecordTest.php
  59. 24
      tests/unit/framework/db/sqlite/SqliteCommandTest.php
  60. 70
      tests/unit/framework/db/sqlite/SqliteConnectionTest.php
  61. 1
      tests/unit/framework/db/sqlite/SqliteQueryBuilderTest.php
  62. 10
      tests/unit/framework/db/sqlite/SqliteQueryTest.php
  63. 1
      tests/unit/framework/helpers/ConsoleTest.php
  64. 7
      tests/unit/framework/helpers/FileHelperTest.php
  65. 6
      tests/unit/framework/helpers/HtmlTest.php
  66. 204
      tests/unit/framework/helpers/InflectorTest.php
  67. 3
      tests/unit/framework/helpers/JsonTest.php
  68. 1
      tests/unit/framework/helpers/StringHelperTest.php
  69. 1
      tests/unit/framework/helpers/VarDumperTest.php
  70. 3
      tests/unit/framework/requirements/YiiRequirementCheckerTest.php
  71. 1
      tests/unit/framework/validators/EmailValidatorTest.php
  72. 2
      tests/unit/framework/widgets/SpacelessTest.php

1
apps/advanced/backend/config/AppAsset.php

@ -6,6 +6,7 @@
*/ */
namespace backend\config; namespace backend\config;
use yii\web\AssetBundle; use yii\web\AssetBundle;
/** /**

1
apps/advanced/backend/config/params.php

@ -1,5 +1,4 @@
<?php <?php
return array( return array(
'adminEmail' => 'admin@example.com', 'adminEmail' => 'admin@example.com',
); );

63
apps/advanced/backend/views/layouts/main.php

@ -1,7 +1,8 @@
<?php <?php
use backend\config\AppAsset; use backend\config\AppAsset;
use yii\helpers\Html; use yii\helpers\Html;
use yii\widgets\Menu; use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs; use yii\widgets\Breadcrumbs;
/** /**
@ -19,45 +20,45 @@ AppAsset::register($this);
<?php $this->head(); ?> <?php $this->head(); ?>
</head> </head>
<body> <body>
<div class="container">
<?php $this->beginBody(); ?> <?php $this->beginBody(); ?>
<div class="masthead"> <?php
<h3 class="muted">My Company</h3> NavBar::begin(array(
'brandLabel' => 'My Company',
<div class="navbar fullwidth"> 'brandUrl' => Yii::$app->homeUrl,
<div class="navbar-inner"> 'options' => array(
<div class="container"> 'class' => 'navbar-inverse navbar-fixed-top',
<?php echo Menu::widget(array( ),
'options' => array('class' => 'nav'), ));
'items' => array( $menuItems = array(
array('label' => 'Home', 'url' => array('/site/index')), array('label' => 'Home', 'url' => array('/site/index')),
Yii::$app->user->isGuest ? );
array('label' => 'Login', 'url' => array('/site/login')) : if (Yii::$app->user->isGuest) {
array('label' => 'Logout (' . Yii::$app->user->identity->username .')' , 'url' => array('/site/logout')), $menuItems[] = array('label' => 'Login', 'url' => array('/site/login'));
), } else {
)); ?> $menuItems[] = array('label' => 'Logout (' . Yii::$app->user->identity->username .')' , 'url' => array('/site/logout'));
</div> }
</div> echo Nav::widget(array(
</div> 'options' => array('class' => 'navbar-nav pull-right'),
<!-- /.navbar --> 'items' => $menuItems,
</div> ));
NavBar::end();
?>
<div class="container">
<?php echo Breadcrumbs::widget(array( <?php echo Breadcrumbs::widget(array(
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : array(), 'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : array(),
)); ?> )); ?>
<?php echo $content; ?> <?php echo $content; ?>
</div>
<hr> <footer class="footer">
<div class="container">
<p class="pull-left">&copy; My Company <?php echo date('Y'); ?></p>
<p class="pull-right"><?php echo Yii::powered(); ?></p>
</div>
</footer>
<div class="footer">
<p>&copy; My Company <?php echo date('Y'); ?></p>
<p>
<?php echo Yii::powered(); ?>
Template by <a href="http://twitter.github.io/bootstrap/">Twitter Bootstrap</a>
</p>
</div>
<?php $this->endBody(); ?> <?php $this->endBody(); ?>
</div>
</body> </body>
</html> </html>
<?php $this->endPage(); ?> <?php $this->endPage(); ?>

68
apps/advanced/backend/views/site/index.php

@ -2,46 +2,52 @@
/** /**
* @var yii\base\View $this * @var yii\base\View $this
*/ */
$this->title = 'Welcome'; $this->title = 'My Yii Application';
?> ?>
<div class="jumbotron"> <div class="site-index">
<h1>Welcome!</h1>
<p class="lead">Cras justo odio, dapibus ac facilisis in, egestas eget quam. Fusce dapibus, tellus ac cursus <div class="jumbotron">
commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p> <h1>Congratulations!</h1>
<a class="btn btn-large btn-success" href="http://www.yiiframework.com">Get started with Yii</a>
</div>
<hr> <p class="lead">You have successfully created your Yii-powered application.</p>
<!-- Example row of columns --> <p><a class="btn btn-large btn-success" href="http://www.yiiframework.com">Get started with Yii</a></p>
<div class="row-fluid"> </div>
<div class="span4">
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris <div class="body-content">
condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod.
Donec sed odio dui. </p>
<p><a class="btn" href="#">View details &raquo;</a></p> <div class="row">
</div> <div class="col-lg-4">
<div class="span4"> <h2>Heading</h2>
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
Donec sed odio dui. </p> ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur.</p>
<p><a class="btn" href="#">View details &raquo;</a></p> <p><a class="btn btn-default" href="http://www.yiiframework.com/doc/">Yii Documentation &raquo;</a></p>
</div> </div>
<div class="span4"> <div class="col-lg-4">
<h2>Heading</h2> <h2>Heading</h2>
<p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
massa.</p> ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur.</p>
<p><a class="btn btn-default" href="http://www.yiiframework.com/forum/">Yii Forum &raquo;</a></p>
</div>
<div class="col-lg-4">
<h2>Heading</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur.</p>
<p><a class="btn btn-default" href="http://www.yiiframework.com/extensions/">Yii Extensions &raquo;</a></p>
</div>
</div>
<p><a class="btn" href="#">View details &raquo;</a></p>
</div> </div>
</div> </div>

24
apps/advanced/backend/views/site/login.php

@ -10,15 +10,21 @@ use yii\widgets\ActiveForm;
$this->title = 'Login'; $this->title = 'Login';
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;
?> ?>
<h1><?php echo Html::encode($this->title); ?></h1> <div class="site-login">
<h1><?php echo Html::encode($this->title); ?></h1>
<p>Please fill out the following fields to login:</p> <p>Please fill out the following fields to login:</p>
<?php $form = ActiveForm::begin(array('options' => array('class' => 'form-horizontal'))); ?> <div class="row">
<?php echo $form->field($model, 'username')->textInput(); ?> <div class="col-lg-5">
<?php echo $form->field($model, 'password')->passwordInput(); ?> <?php $form = ActiveForm::begin(array('id' => 'login-form')); ?>
<?php echo $form->field($model, 'rememberMe')->checkbox(); ?> <?php echo $form->field($model, 'username')->textInput(); ?>
<div class="form-actions"> <?php echo $form->field($model, 'password')->passwordInput(); ?>
<?php echo Html::submitButton('Login', array('class' => 'btn btn-primary')); ?> <?php echo $form->field($model, 'rememberMe')->checkbox(); ?>
<div class="form-actions">
<?php echo Html::submitButton('Login', array('class' => 'btn btn-primary')); ?>
</div>
<?php ActiveForm::end(); ?>
</div>
</div> </div>
<?php ActiveForm::end(); ?> </div>

79
apps/advanced/backend/web/css/site.css

@ -1,78 +1,19 @@
body { body {
padding-top: 20px; padding-top: 70px;
padding-bottom: 60px;
} }
/* Custom container */ .footer {
.container { border-top: 1px solid #ddd;
margin: 0 auto; margin-top: 30px;
max-width: 1000px; padding-top: 15px;
padding-bottom: 30px;
} }
.container > hr {
margin: 60px 0;
}
/* Main marketing message and sign up button */
.jumbotron { .jumbotron {
margin: 80px 0; text-align: center;
text-align: center; background-color: transparent;
}
.jumbotron h1 {
font-size: 100px;
line-height: 1;
}
.jumbotron .lead {
font-size: 24px;
line-height: 1.25;
} }
.jumbotron .btn { .jumbotron .btn {
font-size: 21px; font-size: 21px;
padding: 14px 24px; padding: 14px 24px;
}
/* Supporting marketing content */
.marketing {
margin: 60px 0;
}
.marketing p + h4 {
margin-top: 28px;
}
/* Customize the navbar links to be fill the entire space of the .navbar */
.navbar.fullwidth .navbar-inner {
padding: 0;
}
.navbar.fullwidth .nav {
margin: 0;
display: table;
width: 100%;
}
.navbar.fullwidth .nav li {
display: table-cell;
width: 1%;
float: none;
}
.navbar.fullwidth .nav li a {
font-weight: bold;
text-align: center;
border-left: 1px solid rgba(255, 255, 255, .75);
border-right: 1px solid rgba(0, 0, 0, .1);
}
.navbar.fullwidth .nav li:first-child a {
border-left: 0;
border-radius: 3px 0 0 3px;
}
.navbar.fullwidth .nav li:last-child a {
border-right: 0;
border-radius: 0 3px 3px 0;
} }

1
apps/advanced/console/config/params.php

@ -1,5 +1,4 @@
<?php <?php
return array( return array(
'adminEmail' => 'admin@example.com', 'adminEmail' => 'admin@example.com',
); );

1
apps/advanced/frontend/config/AppAsset.php

@ -6,6 +6,7 @@
*/ */
namespace frontend\config; namespace frontend\config;
use yii\web\AssetBundle; use yii\web\AssetBundle;
/** /**

1
apps/advanced/frontend/config/params.php

@ -1,5 +1,4 @@
<?php <?php
return array( return array(
'adminEmail' => 'admin@example.com', 'adminEmail' => 'admin@example.com',
); );

77
apps/advanced/frontend/views/layouts/main.php

@ -1,7 +1,8 @@
<?php <?php
use frontend\config\AppAsset; use frontend\config\AppAsset;
use yii\helpers\Html; use yii\helpers\Html;
use yii\widgets\Menu; use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs; use yii\widgets\Breadcrumbs;
use frontend\widgets\Alert; use frontend\widgets\Alert;
@ -20,57 +21,49 @@ AppAsset::register($this);
<?php $this->head(); ?> <?php $this->head(); ?>
</head> </head>
<body> <body>
<div class="container">
<?php $this->beginBody(); ?> <?php $this->beginBody(); ?>
<div class="masthead"> <?php
<h3 class="muted">My Company</h3> NavBar::begin(array(
'brandLabel' => 'My Company',
<div class="navbar fullwidth"> 'brandUrl' => Yii::$app->homeUrl,
<div class="navbar-inner"> 'options' => array(
<div class="container"> 'class' => 'navbar-inverse navbar-fixed-top',
<?php ),
$menuItems = array( ));
array('label' => 'Home', 'url' => array('/site/index')), $menuItems = array(
array('label' => 'About', 'url' => array('/site/about')), array('label' => 'Home', 'url' => array('/site/index')),
array('label' => 'Contact', 'url' => array('/site/contact')), array('label' => 'About', 'url' => array('/site/about')),
); array('label' => 'Contact', 'url' => array('/site/contact')),
if (Yii::$app->user->isGuest) { );
$menuItems[] = array('label' => 'Signup', 'url' => array('/site/signup')); if (Yii::$app->user->isGuest) {
$menuItems[] = array('label' => 'Login', 'url' => array('/site/login')); $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')); $menuItems[] = array('label' => 'Logout (' . Yii::$app->user->identity->username .')' , 'url' => array('/site/logout'));
} }
echo Menu::widget(array( echo Nav::widget(array(
'options' => array('class' => 'nav'), 'options' => array('class' => 'navbar-nav pull-right'),
'items' => $menuItems, 'items' => $menuItems,
)); ));
?> NavBar::end();
</div> ?>
</div>
</div>
<!-- /.navbar -->
</div>
<div class="container">
<?php echo Breadcrumbs::widget(array( <?php echo Breadcrumbs::widget(array(
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : array(), 'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : array(),
)); ?> )); ?>
<?php echo Alert::widget()?> <?php echo Alert::widget()?>
<?php echo $content; ?> <?php echo $content; ?>
</div>
<hr> <footer class="footer">
<div class="container">
<p class="pull-left">&copy; My Company <?php echo date('Y'); ?></p>
<p class="pull-right"><?php echo Yii::powered(); ?></p>
</div>
</footer>
<div class="footer">
<p>&copy; My Company <?php echo date('Y'); ?></p>
<p>
<?php echo Yii::powered(); ?>
Template by <a href="http://twitter.github.io/bootstrap/">Twitter Bootstrap</a>
</p>
</div>
<?php $this->endBody(); ?> <?php $this->endBody(); ?>
</div>
</body> </body>
</html> </html>
<?php $this->endPage(); ?> <?php $this->endPage(); ?>

12
apps/advanced/frontend/views/site/about.php

@ -1,16 +1,16 @@
<?php <?php
use yii\helpers\Html; use yii\helpers\Html;
/** /**
* @var yii\base\View $this * @var yii\base\View $this
*/ */
$this->title = 'About'; $this->title = 'About';
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;
?> ?>
<h1><?php echo Html::encode($this->title); ?></h1> <div class="site-about">
<h1><?php echo Html::encode($this->title); ?></h1>
<p>
This is the About page. You may modify the following file to customize its content:
</p>
<code><?php echo __FILE__; ?></code> <p>This is the About page. You may modify the following file to customize its content:</p>
<code><?php echo __FILE__; ?></code>
</div>

41
apps/advanced/frontend/views/site/contact.php

@ -11,24 +11,29 @@ use yii\captcha\Captcha;
$this->title = 'Contact'; $this->title = 'Contact';
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;
?> ?>
<h1><?php echo Html::encode($this->title); ?></h1> <div class="site-contact">
<h1><?php echo Html::encode($this->title); ?></h1>
<p> <p>
If you have business inquiries or other questions, please fill out the following form to contact us. Thank you. If you have business inquiries or other questions, please fill out the following form to contact us. Thank you.
</p> </p>
<?php $form = ActiveForm::begin(array( <div class="row">
'options' => array('class' => 'form-horizontal'), <div class="col-lg-5">
'fieldConfig' => array('inputOptions' => array('class' => 'input-xlarge')), <?php $form = ActiveForm::begin(array('id' => 'contact-form')); ?>
)); ?> <?php echo $form->field($model, 'name')->textInput(); ?>
<?php echo $form->field($model, 'name')->textInput(); ?> <?php echo $form->field($model, 'email')->textInput(); ?>
<?php echo $form->field($model, 'email')->textInput(); ?> <?php echo $form->field($model, 'subject')->textInput(); ?>
<?php echo $form->field($model, 'subject')->textInput(); ?> <?php echo $form->field($model, 'body')->textArea(array('rows' => 6)); ?>
<?php echo $form->field($model, 'body')->textArea(array('rows' => 6)); ?> <?php echo $form->field($model, 'verifyCode')->widget(Captcha::className(), array(
<?php echo $form->field($model, 'verifyCode')->widget(Captcha::className(), array( 'options' => array('class' => 'form-control'),
'options' => array('class' => 'input-medium'), 'template' => '<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>',
)); ?> )); ?>
<div class="form-actions"> <div class="form-actions">
<?php echo Html::submitButton('Submit', array('class' => 'btn btn-primary')); ?> <?php echo Html::submitButton('Submit', array('class' => 'btn btn-primary')); ?>
</div>
<?php ActiveForm::end(); ?>
</div>
</div> </div>
<?php ActiveForm::end(); ?>
</div>

68
apps/advanced/frontend/views/site/index.php

@ -2,46 +2,52 @@
/** /**
* @var yii\base\View $this * @var yii\base\View $this
*/ */
$this->title = 'Welcome'; $this->title = 'My Yii Application';
?> ?>
<div class="jumbotron"> <div class="site-index">
<h1>Welcome!</h1>
<p class="lead">Cras justo odio, dapibus ac facilisis in, egestas eget quam. Fusce dapibus, tellus ac cursus <div class="jumbotron">
commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p> <h1>Congratulations!</h1>
<a class="btn btn-large btn-success" href="http://www.yiiframework.com">Get started with Yii</a>
</div>
<hr> <p class="lead">You have successfully created your Yii-powered application.</p>
<!-- Example row of columns --> <p><a class="btn btn-large btn-success" href="http://www.yiiframework.com">Get started with Yii</a></p>
<div class="row-fluid"> </div>
<div class="span4">
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris <div class="body-content">
condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod.
Donec sed odio dui. </p>
<p><a class="btn" href="#">View details &raquo;</a></p> <div class="row">
</div> <div class="col-lg-4">
<div class="span4"> <h2>Heading</h2>
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
Donec sed odio dui. </p> ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur.</p>
<p><a class="btn" href="#">View details &raquo;</a></p> <p><a class="btn btn-default" href="http://www.yiiframework.com/doc/">Yii Documentation &raquo;</a></p>
</div> </div>
<div class="span4"> <div class="col-lg-4">
<h2>Heading</h2> <h2>Heading</h2>
<p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
massa.</p> ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur.</p>
<p><a class="btn btn-default" href="http://www.yiiframework.com/forum/">Yii Forum &raquo;</a></p>
</div>
<div class="col-lg-4">
<h2>Heading</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur.</p>
<p><a class="btn btn-default" href="http://www.yiiframework.com/extensions/">Yii Extensions &raquo;</a></p>
</div>
</div>
<p><a class="btn" href="#">View details &raquo;</a></p>
</div> </div>
</div> </div>

29
apps/advanced/frontend/views/site/login.php

@ -10,17 +10,24 @@ use yii\widgets\ActiveForm;
$this->title = 'Login'; $this->title = 'Login';
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;
?> ?>
<h1><?php echo Html::encode($this->title); ?></h1> <div class="site-login">
<h1><?php echo Html::encode($this->title); ?></h1>
<p>Please fill out the following fields to login:</p> <p>Please fill out the following fields to login:</p>
<?php $form = ActiveForm::begin(array('options' => array('class' => 'form-horizontal'))); ?> <div class="row">
<?php echo $form->field($model, 'username')->textInput(); ?> <div class="col-lg-5">
<?php echo $form->field($model, 'password')->passwordInput(); ?> <?php $form = ActiveForm::begin(array('id' => 'login-form')); ?>
<?php echo $form->field($model, 'rememberMe')->checkbox(); ?> <?php echo $form->field($model, 'username')->textInput(); ?>
<div class="form-actions"> <?php echo $form->field($model, 'password')->passwordInput(); ?>
<?php echo Html::submitButton('Login', array('class' => 'btn btn-primary')); ?> <?php echo $form->field($model, 'rememberMe')->checkbox(); ?>
<div style="color:#999;margin:1em 0">
If you forgot your password you can <?php echo Html::a('reset it', array('site/request-password-reset'))?>.
</div>
<div class="form-actions">
<?php echo Html::submitButton('Login', array('class' => 'btn btn-primary')); ?>
</div>
<?php ActiveForm::end(); ?>
</div>
</div> </div>
<?php ActiveForm::end(); ?> </div>
<p>If you forgot your password you can <?php echo Html::a('reset it', array('site/request-password-reset'))?>.</p>

22
apps/advanced/frontend/views/site/requestPasswordResetToken.php

@ -5,18 +5,24 @@ use yii\widgets\ActiveForm;
/** /**
* @var yii\base\View $this * @var yii\base\View $this
* @var yii\widgets\ActiveForm $form * @var yii\widgets\ActiveForm $form
* @var frontend\models\User $model * @var common\models\User $model
*/ */
$this->title = 'Request password reset'; $this->title = 'Request password reset';
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;
?> ?>
<h1><?php echo Html::encode($this->title); ?></h1> <div class="site-request-password-reset">
<h1><?php echo Html::encode($this->title); ?></h1>
<p>Please fill out your email. A link to reset password will be sent there.</p> <p>Please fill out your email. A link to reset password will be sent there.</p>
<?php $form = ActiveForm::begin(array('options' => array('class' => 'form-horizontal'))); ?> <div class="row">
<?php echo $form->field($model, 'email')->textInput(); ?> <div class="col-lg-5">
<div class="form-actions"> <?php $form = ActiveForm::begin(array('id' => 'request-password-reset-form')); ?>
<?php echo Html::submitButton('Send', array('class' => 'btn btn-primary')); ?> <?php echo $form->field($model, 'email')->textInput(); ?>
<div class="form-actions">
<?php echo Html::submitButton('Send', array('class' => 'btn btn-primary')); ?>
</div>
<?php ActiveForm::end(); ?>
</div>
</div> </div>
<?php ActiveForm::end(); ?> </div>

20
apps/advanced/frontend/views/site/resetPassword.php

@ -10,13 +10,19 @@ use yii\widgets\ActiveForm;
$this->title = 'Reset password'; $this->title = 'Reset password';
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;
?> ?>
<h1><?php echo Html::encode($this->title); ?></h1> <div class="site-reset-password">
<h1><?php echo Html::encode($this->title); ?></h1>
<p>Please choose your new password:</p> <p>Please choose your new password:</p>
<?php $form = ActiveForm::begin(array('options' => array('class' => 'form-horizontal'))); ?> <div class="row">
<?php echo $form->field($model, 'password')->passwordInput(); ?> <div class="col-lg-5">
<div class="form-actions"> <?php $form = ActiveForm::begin(array('id' => 'reset-password-form')); ?>
<?php echo Html::submitButton('Save', array('class' => 'btn btn-primary')); ?> <?php echo $form->field($model, 'password')->passwordInput(); ?>
<div class="form-actions">
<?php echo Html::submitButton('Save', array('class' => 'btn btn-primary')); ?>
</div>
<?php ActiveForm::end(); ?>
</div>
</div> </div>
<?php ActiveForm::end(); ?> </div>

24
apps/advanced/frontend/views/site/signup.php

@ -10,15 +10,21 @@ use yii\widgets\ActiveForm;
$this->title = 'Signup'; $this->title = 'Signup';
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;
?> ?>
<h1><?php echo Html::encode($this->title); ?></h1> <div class="site-signup">
<h1><?php echo Html::encode($this->title); ?></h1>
<p>Please fill out the following fields to signup:</p> <p>Please fill out the following fields to signup:</p>
<?php $form = ActiveForm::begin(array('options' => array('class' => 'form-horizontal'))); ?> <div class="row">
<?php echo $form->field($model, 'username')->textInput(); ?> <div class="col-lg-5">
<?php echo $form->field($model, 'email')->textInput(); ?> <?php $form = ActiveForm::begin(array('id' => 'form-signup')); ?>
<?php echo $form->field($model, 'password')->passwordInput(); ?> <?php echo $form->field($model, 'username')->textInput(); ?>
<div class="form-actions"> <?php echo $form->field($model, 'email')->textInput(); ?>
<?php echo Html::submitButton('Signup', array('class' => 'btn btn-primary')); ?> <?php echo $form->field($model, 'password')->passwordInput(); ?>
<div class="form-actions">
<?php echo Html::submitButton('Signup', array('class' => 'btn btn-primary')); ?>
</div>
<?php ActiveForm::end(); ?>
</div>
</div> </div>
<?php ActiveForm::end(); ?> </div>

79
apps/advanced/frontend/web/css/site.css

@ -1,78 +1,19 @@
body { body {
padding-top: 20px; padding-top: 70px;
padding-bottom: 60px;
} }
/* Custom container */ .footer {
.container { border-top: 1px solid #ddd;
margin: 0 auto; margin-top: 30px;
max-width: 1000px; padding-top: 15px;
padding-bottom: 30px;
} }
.container > hr {
margin: 60px 0;
}
/* Main marketing message and sign up button */
.jumbotron { .jumbotron {
margin: 80px 0; text-align: center;
text-align: center; background-color: transparent;
}
.jumbotron h1 {
font-size: 100px;
line-height: 1;
}
.jumbotron .lead {
font-size: 24px;
line-height: 1.25;
} }
.jumbotron .btn { .jumbotron .btn {
font-size: 21px; font-size: 21px;
padding: 14px 24px; padding: 14px 24px;
}
/* Supporting marketing content */
.marketing {
margin: 60px 0;
}
.marketing p + h4 {
margin-top: 28px;
}
/* Customize the navbar links to be fill the entire space of the .navbar */
.navbar.fullwidth .navbar-inner {
padding: 0;
}
.navbar.fullwidth .nav {
margin: 0;
display: table;
width: 100%;
}
.navbar.fullwidth .nav li {
display: table-cell;
width: 1%;
float: none;
}
.navbar.fullwidth .nav li a {
font-weight: bold;
text-align: center;
border-left: 1px solid rgba(255, 255, 255, .75);
border-right: 1px solid rgba(0, 0, 0, .1);
}
.navbar.fullwidth .nav li:first-child a {
border-left: 0;
border-radius: 3px 0 0 3px;
}
.navbar.fullwidth .nav li:last-child a {
border-right: 0;
border-radius: 0 3px 3px 0;
} }

2
build/controllers/ClassmapController.php

@ -33,7 +33,7 @@ class ClassmapController extends Controller
$mapFile = YII_PATH . '/classes.php'; $mapFile = YII_PATH . '/classes.php';
} }
$options = array( $options = array(
'filter' => function($path) { 'filter' => function ($path) {
if (is_file($path)) { if (is_file($path)) {
$file = basename($path); $file = basename($path);
if ($file[0] < 'A' || $file[0] > 'Z') { if ($file[0] < 'A' || $file[0] > 'Z') {

2
extensions/twig/yii/twig/ViewRenderer.php

@ -46,7 +46,7 @@ class ViewRenderer extends BaseViewRenderer
'cache' => Yii::getAlias($this->cachePath), 'cache' => Yii::getAlias($this->cachePath),
), $this->options)); ), $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)); return Html::url(array_merge(array($path), $args));
})); }));

1
framework/yii/captcha/Captcha.php

@ -13,7 +13,6 @@ use yii\helpers\Html;
use yii\helpers\Json; use yii\helpers\Json;
use yii\widgets\InputWidget; use yii\widgets\InputWidget;
/** /**
* Captcha renders a CAPTCHA image and an input field that takes user-entered verification code. * Captcha renders a CAPTCHA image and an input field that takes user-entered verification code.
* *

1
framework/yii/data/ArrayDataProvider.php

@ -7,7 +7,6 @@
namespace yii\data; namespace yii\data;
use yii\base\InvalidConfigException;
use yii\helpers\ArrayHelper; use yii\helpers\ArrayHelper;
/** /**

3
tests/unit/TestCase.php

@ -37,6 +37,7 @@ abstract class TestCase extends \yii\test\TestCase
* Populates Yii::$app with a new application * Populates Yii::$app with a new application
* The application will be destroyed on tearDown() automatically. * The application will be destroyed on tearDown() automatically.
* @param array $config The application configuration, if needed * @param array $config The application configuration, if needed
* @param string $appClass name of the application class to create
*/ */
protected function mockApplication($config = array(), $appClass = '\yii\console\Application') protected function mockApplication($config = array(), $appClass = '\yii\console\Application')
{ {
@ -45,7 +46,7 @@ abstract class TestCase extends \yii\test\TestCase
'basePath' => __DIR__, 'basePath' => __DIR__,
); );
new $appClass(array_merge($defaultConfig,$config)); new $appClass(array_merge($defaultConfig, $config));
} }
/** /**

2
tests/unit/data/ar/Customer.php

@ -1,6 +1,6 @@
<?php <?php
namespace yiiunit\data\ar; namespace yiiunit\data\ar;
use yii\db\ActiveQuery; use yii\db\ActiveQuery;
class Customer extends ActiveRecord class Customer extends ActiveRecord

2
tests/unit/data/ar/Order.php

@ -22,7 +22,7 @@ class Order extends ActiveRecord
public function getItems() public function getItems()
{ {
return $this->hasMany('Item', array('id' => 'item_id')) return $this->hasMany('Item', array('id' => 'item_id'))
->via('orderItems', function($q) { ->via('orderItems', function ($q) {
// additional query configuration // additional query configuration
})->orderBy('id'); })->orderBy('id');
} }

2
tests/unit/data/base/InvalidRulesModel.php

@ -1,5 +1,6 @@
<?php <?php
namespace yiiunit\data\base; namespace yiiunit\data\base;
use yii\base\Model; use yii\base\Model;
/** /**
@ -13,5 +14,4 @@ class InvalidRulesModel extends Model
array('test'), array('test'),
); );
} }
} }

1
tests/unit/data/base/Singer.php

@ -1,5 +1,6 @@
<?php <?php
namespace yiiunit\data\base; namespace yiiunit\data\base;
use yii\base\Model; use yii\base\Model;
/** /**

1
tests/unit/data/base/Speaker.php

@ -1,5 +1,6 @@
<?php <?php
namespace yiiunit\data\base; namespace yiiunit\data\base;
use yii\base\Model; use yii\base\Model;
/** /**

5
tests/unit/data/config.php

@ -1,5 +1,4 @@
<?php <?php
return array( return array(
'databases' => array( 'databases' => array(
'mysql' => array( 'mysql' => array(
@ -23,6 +22,6 @@ return array(
'username' => 'postgres', 'username' => 'postgres',
'password' => 'postgres', 'password' => 'postgres',
'fixture' => __DIR__ . '/postgres.sql', 'fixture' => __DIR__ . '/postgres.sql',
) ),
) ),
); );

1
tests/unit/framework/base/BehaviorTest.php

@ -8,7 +8,6 @@ use yiiunit\TestCase;
class BarClass extends Component class BarClass extends Component
{ {
} }
class FooClass extends Component class FooClass extends Component

6
tests/unit/framework/base/ComponentTest.php

@ -194,7 +194,7 @@ class ComponentTest extends TestCase
$this->assertFalse($this->component->event->handled); $this->assertFalse($this->component->event->handled);
$eventRaised = false; $eventRaised = false;
$this->component->on('click', function($event) use (&$eventRaised) { $this->component->on('click', function ($event) use (&$eventRaised) {
$eventRaised = true; $eventRaised = true;
}); });
$this->component->raiseEvent(); $this->component->raiseEvent();
@ -202,7 +202,7 @@ class ComponentTest extends TestCase
// raise event w/o parameters // raise event w/o parameters
$eventRaised = false; $eventRaised = false;
$this->component->on('test', function($event) use (&$eventRaised) { $this->component->on('test', function ($event) use (&$eventRaised) {
$eventRaised = true; $eventRaised = true;
}); });
$this->component->trigger('test'); $this->component->trigger('test');
@ -331,7 +331,7 @@ class NewComponent extends Component
public function getExecute() public function getExecute()
{ {
return function($param) { return function ($param) {
return $param * 2; return $param * 2;
}; };
} }

1
tests/unit/framework/base/ModelTest.php

@ -1,6 +1,7 @@
<?php <?php
namespace yiiunit\framework\base; namespace yiiunit\framework\base;
use yii\base\Model; use yii\base\Model;
use yiiunit\TestCase; use yiiunit\TestCase;
use yiiunit\data\base\Speaker; use yiiunit\data\base\Speaker;

2
tests/unit/framework/base/ObjectTest.php

@ -175,7 +175,7 @@ class NewObject extends Object
public function getExecute() public function getExecute()
{ {
return function($param) { return function ($param) {
return $param * 2; return $param * 2;
}; };
} }

3
tests/unit/framework/behaviors/AutoTimestampTest.php

@ -26,7 +26,8 @@ class AutoTimestampTest extends TestCase
} }
} }
public function setUp() { public function setUp()
{
$this->mockApplication( $this->mockApplication(
array( array(
'components' => array( 'components' => array(

3
tests/unit/framework/caching/ApcCacheTest.php

@ -1,5 +1,6 @@
<?php <?php
namespace yiiunit\framework\caching; namespace yiiunit\framework\caching;
use yii\caching\ApcCache; use yii\caching\ApcCache;
/** /**
@ -20,7 +21,7 @@ class ApcCacheTest extends CacheTestCase
$this->markTestSkipped("APC cli is not enabled. Skipping."); $this->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."); $this->markTestSkipped("APC is installed but not enabled. Skipping.");
} }

3
tests/unit/framework/caching/CacheTestCase.php

@ -6,7 +6,8 @@ namespace yii\caching;
* Mock for the time() function for caching classes * Mock for the time() function for caching classes
* @return int * @return int
*/ */
function time() { function time()
{
return \yiiunit\framework\caching\CacheTestCase::$time ?: \time(); return \yiiunit\framework\caching\CacheTestCase::$time ?: \time();
} }

4
tests/unit/framework/caching/DbCacheTest.php

@ -35,11 +35,11 @@ class DbCacheTest extends CacheTestCase
* @param bool $reset whether to clean up the test database * @param bool $reset whether to clean up the test database
* @return \yii\db\Connection * @return \yii\db\Connection
*/ */
function getConnection($reset = true) public function getConnection($reset = true)
{ {
if ($this->_connection === null) { if ($this->_connection === null) {
$databases = $this->getParam('databases'); $databases = $this->getParam('databases');
$params = $databases['mysql']; $params = $databases['mysql'];
$db = new \yii\db\Connection; $db = new \yii\db\Connection;
$db->dsn = $params['dsn']; $db->dsn = $params['dsn'];
$db->username = $params['username']; $db->username = $params['username'];

1
tests/unit/framework/caching/FileCacheTest.php

@ -1,5 +1,6 @@
<?php <?php
namespace yiiunit\framework\caching; namespace yiiunit\framework\caching;
use yii\caching\FileCache; use yii\caching\FileCache;
/** /**

1
tests/unit/framework/caching/MemCacheTest.php

@ -1,5 +1,6 @@
<?php <?php
namespace yiiunit\framework\caching; namespace yiiunit\framework\caching;
use yii\caching\MemCache; use yii\caching\MemCache;
/** /**

1
tests/unit/framework/caching/MemCachedTest.php

@ -1,5 +1,6 @@
<?php <?php
namespace yiiunit\framework\caching; namespace yiiunit\framework\caching;
use yii\caching\MemCache; use yii\caching\MemCache;
/** /**

1
tests/unit/framework/caching/WinCacheTest.php

@ -1,5 +1,6 @@
<?php <?php
namespace yiiunit\framework\caching; namespace yiiunit\framework\caching;
use yii\caching\WinCache; use yii\caching\WinCache;
/** /**

1
tests/unit/framework/caching/XCacheTest.php

@ -1,5 +1,6 @@
<?php <?php
namespace yiiunit\framework\caching; namespace yiiunit\framework\caching;
use yii\caching\XCache; use yii\caching\XCache;
/** /**

1
tests/unit/framework/caching/ZendDataCacheTest.php

@ -1,5 +1,6 @@
<?php <?php
namespace yiiunit\framework\caching; namespace yiiunit\framework\caching;
use yii\caching\Cache; use yii\caching\Cache;
use yii\caching\ZendDataCache; use yii\caching\ZendDataCache;

2
tests/unit/framework/console/controllers/AssetControllerTest.php

@ -226,7 +226,7 @@ class AssetControllerTest extends TestCase
'yii', 'yii',
), ),
), ),
);; );
$bundleFile = $this->testFilePath . DIRECTORY_SEPARATOR . 'bundle.php'; $bundleFile = $this->testFilePath . DIRECTORY_SEPARATOR . 'bundle.php';
$configFile = $this->testFilePath . DIRECTORY_SEPARATOR . 'config.php'; $configFile = $this->testFilePath . DIRECTORY_SEPARATOR . 'config.php';

2
tests/unit/framework/data/SortTest.php

@ -6,11 +6,11 @@
*/ */
namespace yiiunit\framework\data; namespace yiiunit\framework\data;
use yii\web\UrlManager; use yii\web\UrlManager;
use yiiunit\TestCase; use yiiunit\TestCase;
use yii\data\Sort; use yii\data\Sort;
/** /**
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0

4
tests/unit/framework/db/ActiveRecordTest.php

@ -13,7 +13,7 @@ class ActiveRecordTest extends DatabaseTestCase
{ {
protected function setUp() protected function setUp()
{ {
parent::setUp(); parent::setUp();
ActiveRecord::$db = $this->getConnection(); ActiveRecord::$db = $this->getConnection();
} }
@ -85,7 +85,7 @@ class ActiveRecordTest extends DatabaseTestCase
$this->assertTrue($customers['user3'] instanceof Customer); $this->assertTrue($customers['user3'] instanceof Customer);
// indexBy callable // indexBy callable
$customers = Customer::find()->indexBy(function($customer) { $customers = Customer::find()->indexBy(function ($customer) {
return $customer->id . '-' . $customer->name; return $customer->id . '-' . $customer->name;
})->orderBy('id')->all(); })->orderBy('id')->all();
$this->assertEquals(3, count($customers)); $this->assertEquals(3, count($customers));

61
tests/unit/framework/db/CommandTest.php

@ -15,7 +15,7 @@ class CommandTest extends DatabaseTestCase
$this->mockApplication(); $this->mockApplication();
} }
function testConstruct() public function testConstruct()
{ {
$db = $this->getConnection(false); $db = $this->getConnection(false);
@ -29,7 +29,7 @@ class CommandTest extends DatabaseTestCase
$this->assertEquals($sql, $command->sql); $this->assertEquals($sql, $command->sql);
} }
function testGetSetSql() public function testGetSetSql()
{ {
$db = $this->getConnection(false); $db = $this->getConnection(false);
@ -42,7 +42,7 @@ class CommandTest extends DatabaseTestCase
$this->assertEquals($sql2, $command->sql); $this->assertEquals($sql2, $command->sql);
} }
function testAutoQuoting() public function testAutoQuoting()
{ {
$db = $this->getConnection(false); $db = $this->getConnection(false);
@ -51,7 +51,7 @@ class CommandTest extends DatabaseTestCase
$this->assertEquals("SELECT `id`, `t`.`name` FROM `tbl_customer` t", $command->sql); $this->assertEquals("SELECT `id`, `t`.`name` FROM `tbl_customer` t", $command->sql);
} }
function testPrepareCancel() public function testPrepareCancel()
{ {
$db = $this->getConnection(false); $db = $this->getConnection(false);
@ -63,7 +63,7 @@ class CommandTest extends DatabaseTestCase
$this->assertEquals(null, $command->pdoStatement); $this->assertEquals(null, $command->pdoStatement);
} }
function testExecute() public function testExecute()
{ {
$db = $this->getConnection(); $db = $this->getConnection();
@ -80,7 +80,7 @@ class CommandTest extends DatabaseTestCase
$command->execute(); $command->execute();
} }
function testQuery() public function testQuery()
{ {
$db = $this->getConnection(); $db = $this->getConnection();
@ -141,7 +141,7 @@ class CommandTest extends DatabaseTestCase
$command->query(); $command->query();
} }
function testBindParamValue() public function testBindParamValue()
{ {
$db = $this->getConnection(); $db = $this->getConnection();
@ -197,7 +197,7 @@ class CommandTest extends DatabaseTestCase
$this->assertEquals('user5@example.com', $command->queryScalar()); $this->assertEquals('user5@example.com', $command->queryScalar());
} }
function testFetchMode() public function testFetchMode()
{ {
$db = $this->getConnection(); $db = $this->getConnection();
@ -221,78 +221,63 @@ class CommandTest extends DatabaseTestCase
$this->assertTrue(is_array($result) && isset($result[0])); $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()
{ {
} }
} }

12
tests/unit/framework/db/ConnectionTest.php

@ -12,7 +12,7 @@ class ConnectionTest extends DatabaseTestCase
$this->mockApplication(); $this->mockApplication();
} }
function testConstruct() public function testConstruct()
{ {
$connection = $this->getConnection(false); $connection = $this->getConnection(false);
$params = $this->database; $params = $this->database;
@ -22,7 +22,7 @@ class ConnectionTest extends DatabaseTestCase
$this->assertEquals($params['password'], $connection->password); $this->assertEquals($params['password'], $connection->password);
} }
function testOpenClose() public function testOpenClose()
{ {
$connection = $this->getConnection(false, false); $connection = $this->getConnection(false, false);
@ -43,13 +43,13 @@ class ConnectionTest extends DatabaseTestCase
$connection->open(); $connection->open();
} }
function testGetDriverName() public function testGetDriverName()
{ {
$connection = $this->getConnection(false, false); $connection = $this->getConnection(false, false);
$this->assertEquals($this->driverName, $connection->driverName); $this->assertEquals($this->driverName, $connection->driverName);
} }
function testQuoteValue() public function testQuoteValue()
{ {
$connection = $this->getConnection(false); $connection = $this->getConnection(false);
$this->assertEquals(123, $connection->quoteValue(123)); $this->assertEquals(123, $connection->quoteValue(123));
@ -57,7 +57,7 @@ class ConnectionTest extends DatabaseTestCase
$this->assertEquals("'It\\'s interesting'", $connection->quoteValue("It's interesting")); $this->assertEquals("'It\\'s interesting'", $connection->quoteValue("It's interesting"));
} }
function testQuoteTableName() public function testQuoteTableName()
{ {
$connection = $this->getConnection(false); $connection = $this->getConnection(false);
$this->assertEquals('`table`', $connection->quoteTableName('table')); $this->assertEquals('`table`', $connection->quoteTableName('table'));
@ -68,7 +68,7 @@ class ConnectionTest extends DatabaseTestCase
$this->assertEquals('(table)', $connection->quoteTableName('(table)')); $this->assertEquals('(table)', $connection->quoteTableName('(table)'));
} }
function testQuoteColumnName() public function testQuoteColumnName()
{ {
$connection = $this->getConnection(false); $connection = $this->getConnection(false);
$this->assertEquals('`column`', $connection->quoteColumnName('column')); $this->assertEquals('`column`', $connection->quoteColumnName('column'));

1
tests/unit/framework/db/QueryBuilderTest.php

@ -129,5 +129,4 @@ class QueryBuilderTest extends DatabaseTestCase
$tableSchema = $qb->db->getSchema()->getTableSchema($tableName); $tableSchema = $qb->db->getSchema()->getTableSchema($tableName);
$this->assertEquals(0, count($tableSchema->primaryKey)); $this->assertEquals(0, count($tableSchema->primaryKey));
} }
} }

20
tests/unit/framework/db/QueryTest.php

@ -15,7 +15,7 @@ class QueryTest extends DatabaseTestCase
$this->mockApplication(); $this->mockApplication();
} }
function testSelect() public function testSelect()
{ {
// default // default
$query = new Query; $query = new Query;
@ -31,14 +31,14 @@ class QueryTest extends DatabaseTestCase
$this->assertEquals('something', $query->selectOption); $this->assertEquals('something', $query->selectOption);
} }
function testFrom() public function testFrom()
{ {
$query = new Query; $query = new Query;
$query->from('tbl_user'); $query->from('tbl_user');
$this->assertEquals(array('tbl_user'), $query->from); $this->assertEquals(array('tbl_user'), $query->from);
} }
function testWhere() public function testWhere()
{ {
$query = new Query; $query = new Query;
$query->where('id = :id', array(':id' => 1)); $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); $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 = new Query;
$query->groupBy('team'); $query->groupBy('team');
@ -72,7 +71,7 @@ class QueryTest extends DatabaseTestCase
$this->assertEquals(array('team', 'company', 'age'), $query->groupBy); $this->assertEquals(array('team', 'company', 'age'), $query->groupBy);
} }
function testHaving() public function testHaving()
{ {
$query = new Query; $query = new Query;
$query->having('id = :id', array(':id' => 1)); $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); $this->assertEquals(array(':id' => 1, ':name' => 'something', ':age' => '30'), $query->params);
} }
function testOrder() public function testOrder()
{ {
$query = new Query; $query = new Query;
$query->orderBy('team'); $query->orderBy('team');
@ -107,7 +106,7 @@ class QueryTest extends DatabaseTestCase
$this->assertEquals(array('team' => false, 'company' => true, 'age' => false), $query->orderBy); $this->assertEquals(array('team' => false, 'company' => true, 'age' => false), $query->orderBy);
} }
function testLimitOffset() public function testLimitOffset()
{ {
$query = new Query; $query = new Query;
$query->limit(10)->offset(5); $query->limit(10)->offset(5);
@ -115,8 +114,7 @@ class QueryTest extends DatabaseTestCase
$this->assertEquals(5, $query->offset); $this->assertEquals(5, $query->offset);
} }
function testUnion() public function testUnion()
{ {
} }
} }

10
tests/unit/framework/db/mssql/MssqlActiveRecordTest.php

@ -6,9 +6,9 @@ use yiiunit\framework\db\ActiveRecordTest;
class MssqlActiveRecordTest extends ActiveRecordTest class MssqlActiveRecordTest extends ActiveRecordTest
{ {
protected function setUp() protected function setUp()
{ {
$this->driverName = 'sqlsrv'; $this->driverName = 'sqlsrv';
parent::setUp(); parent::setUp();
} }
} }

16
tests/unit/framework/db/mssql/MssqlCommandTest.php

@ -6,13 +6,13 @@ use yiiunit\framework\db\CommandTest;
class MssqlCommandTest extends CommandTest class MssqlCommandTest extends CommandTest
{ {
public function setUp() public function setUp()
{ {
$this->driverName = 'sqlsrv'; $this->driverName = 'sqlsrv';
parent::setUp(); parent::setUp();
} }
function testAutoQuoting() public function testAutoQuoting()
{ {
$db = $this->getConnection(false); $db = $this->getConnection(false);
@ -21,12 +21,12 @@ class MssqlCommandTest extends CommandTest
$this->assertEquals("SELECT [id], [t].[name] FROM [tbl_customer] t", $command->sql); $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.'); $this->markTestSkipped('MSSQL driver does not support this feature.');
} }
function testBindParamValue() public function testBindParamValue()
{ {
$db = $this->getConnection(); $db = $this->getConnection();

16
tests/unit/framework/db/mssql/MssqlConnectionTest.php

@ -6,13 +6,13 @@ use yiiunit\framework\db\ConnectionTest;
class MssqlConnectionTest extends ConnectionTest class MssqlConnectionTest extends ConnectionTest
{ {
public function setUp() public function setUp()
{ {
$this->driverName = 'sqlsrv'; $this->driverName = 'sqlsrv';
parent::setUp(); parent::setUp();
} }
function testQuoteValue() public function testQuoteValue()
{ {
$connection = $this->getConnection(false); $connection = $this->getConnection(false);
$this->assertEquals(123, $connection->quoteValue(123)); $this->assertEquals(123, $connection->quoteValue(123));
@ -20,7 +20,7 @@ class MssqlConnectionTest extends ConnectionTest
$this->assertEquals("'It''s interesting'", $connection->quoteValue("It's interesting")); $this->assertEquals("'It''s interesting'", $connection->quoteValue("It's interesting"));
} }
function testQuoteTableName() public function testQuoteTableName()
{ {
$connection = $this->getConnection(false); $connection = $this->getConnection(false);
$this->assertEquals('[table]', $connection->quoteTableName('table')); $this->assertEquals('[table]', $connection->quoteTableName('table'));
@ -31,7 +31,7 @@ class MssqlConnectionTest extends ConnectionTest
$this->assertEquals('(table)', $connection->quoteTableName('(table)')); $this->assertEquals('(table)', $connection->quoteTableName('(table)'));
} }
function testQuoteColumnName() public function testQuoteColumnName()
{ {
$connection = $this->getConnection(false); $connection = $this->getConnection(false);
$this->assertEquals('[column]', $connection->quoteColumnName('column')); $this->assertEquals('[column]', $connection->quoteColumnName('column'));

10
tests/unit/framework/db/mssql/MssqlQueryTest.php

@ -6,9 +6,9 @@ use yiiunit\framework\db\QueryTest;
class MssqlQueryTest extends QueryTest class MssqlQueryTest extends QueryTest
{ {
public function setUp() public function setUp()
{ {
$this->driverName = 'sqlsrv'; $this->driverName = 'sqlsrv';
parent::setUp(); parent::setUp();
} }
} }

10
tests/unit/framework/db/pgsql/PostgreSQLActiveRecordTest.php

@ -6,9 +6,9 @@ use yiiunit\framework\db\ActiveRecordTest;
class PostgreSQLActiveRecordTest extends ActiveRecordTest class PostgreSQLActiveRecordTest extends ActiveRecordTest
{ {
protected function setUp() protected function setUp()
{ {
$this->driverName = 'pgsql'; $this->driverName = 'pgsql';
parent::setUp(); parent::setUp();
} }
} }

20
tests/unit/framework/db/pgsql/PostgreSQLConnectionTest.php

@ -1,28 +1,30 @@
<?php <?php
namespace yiiunit\framework\db\pgsql; namespace yiiunit\framework\db\pgsql;
use yiiunit\framework\db\ConnectionTest; use yiiunit\framework\db\ConnectionTest;
class PostgreSQLConnectionTest extends ConnectionTest { class PostgreSQLConnectionTest extends ConnectionTest
{
public function setUp() { public function setUp()
{
$this->driverName = 'pgsql'; $this->driverName = 'pgsql';
parent::setUp(); parent::setUp();
} }
public function testConnection() { public function testConnection()
{
$connection = $this->getConnection(true); $connection = $this->getConnection(true);
} }
function testQuoteValue() { public function testQuoteValue()
{
$connection = $this->getConnection(false); $connection = $this->getConnection(false);
$this->assertEquals(123, $connection->quoteValue(123)); $this->assertEquals(123, $connection->quoteValue(123));
$this->assertEquals("'string'", $connection->quoteValue('string')); $this->assertEquals("'string'", $connection->quoteValue('string'));
$this->assertEquals("'It''s interesting'", $connection->quoteValue("It's interesting")); $this->assertEquals("'It''s interesting'", $connection->quoteValue("It's interesting"));
} }
function testQuoteTableName() public function testQuoteTableName()
{ {
$connection = $this->getConnection(false); $connection = $this->getConnection(false);
$this->assertEquals('"table"', $connection->quoteTableName('table')); $this->assertEquals('"table"', $connection->quoteTableName('table'));
@ -34,7 +36,7 @@ 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); $connection = $this->getConnection(false);
$this->assertEquals('"column"', $connection->quoteColumnName('column')); $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}}'));
$this->assertEquals('(column)', $connection->quoteColumnName('(column)')); $this->assertEquals('(column)', $connection->quoteColumnName('(column)'));
} }
} }

1
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'), array(Schema::TYPE_MONEY . ' NOT NULL', 'numeric(19,4) NOT NULL'),
); );
} }
} }

10
tests/unit/framework/db/sqlite/SqliteActiveRecordTest.php

@ -5,9 +5,9 @@ use yiiunit\framework\db\ActiveRecordTest;
class SqliteActiveRecordTest extends ActiveRecordTest class SqliteActiveRecordTest extends ActiveRecordTest
{ {
protected function setUp() protected function setUp()
{ {
$this->driverName = 'sqlite'; $this->driverName = 'sqlite';
parent::setUp(); parent::setUp();
} }
} }

24
tests/unit/framework/db/sqlite/SqliteCommandTest.php

@ -5,18 +5,18 @@ use yiiunit\framework\db\CommandTest;
class SqliteCommandTest extends CommandTest class SqliteCommandTest extends CommandTest
{ {
protected function setUp() protected function setUp()
{ {
$this->driverName = 'sqlite'; $this->driverName = 'sqlite';
parent::setUp(); parent::setUp();
} }
public function testAutoQuoting() public function testAutoQuoting()
{ {
$db = $this->getConnection(false); $db = $this->getConnection(false);
$sql = 'SELECT [[id]], [[t.name]] FROM {{tbl_customer}} t'; $sql = 'SELECT [[id]], [[t.name]] FROM {{tbl_customer}} t';
$command = $db->createCommand($sql); $command = $db->createCommand($sql);
$this->assertEquals("SELECT \"id\", 't'.\"name\" FROM 'tbl_customer' t", $command->sql); $this->assertEquals("SELECT \"id\", 't'.\"name\" FROM 'tbl_customer' t", $command->sql);
} }
} }

70
tests/unit/framework/db/sqlite/SqliteConnectionTest.php

@ -5,44 +5,44 @@ use yiiunit\framework\db\ConnectionTest;
class SqliteConnectionTest extends ConnectionTest class SqliteConnectionTest extends ConnectionTest
{ {
protected function setUp() protected function setUp()
{ {
$this->driverName = 'sqlite'; $this->driverName = 'sqlite';
parent::setUp(); parent::setUp();
} }
public function testConstruct() public function testConstruct()
{ {
$connection = $this->getConnection(false); $connection = $this->getConnection(false);
$params = $this->database; $params = $this->database;
$this->assertEquals($params['dsn'], $connection->dsn); $this->assertEquals($params['dsn'], $connection->dsn);
} }
public function testQuoteValue() public function testQuoteValue()
{ {
$connection = $this->getConnection(false); $connection = $this->getConnection(false);
$this->assertEquals(123, $connection->quoteValue(123)); $this->assertEquals(123, $connection->quoteValue(123));
$this->assertEquals("'string'", $connection->quoteValue('string')); $this->assertEquals("'string'", $connection->quoteValue('string'));
$this->assertEquals("'It''s interesting'", $connection->quoteValue("It's interesting")); $this->assertEquals("'It''s interesting'", $connection->quoteValue("It's interesting"));
} }
public function testQuoteTableName() public function testQuoteTableName()
{ {
$connection = $this->getConnection(false); $connection = $this->getConnection(false);
$this->assertEquals("'table'", $connection->quoteTableName('table')); $this->assertEquals("'table'", $connection->quoteTableName('table'));
$this->assertEquals("'schema'.'table'", $connection->quoteTableName('schema.table')); $this->assertEquals("'schema'.'table'", $connection->quoteTableName('schema.table'));
$this->assertEquals('{{table}}', $connection->quoteTableName('{{table}}')); $this->assertEquals('{{table}}', $connection->quoteTableName('{{table}}'));
$this->assertEquals('(table)', $connection->quoteTableName('(table)')); $this->assertEquals('(table)', $connection->quoteTableName('(table)'));
} }
public function testQuoteColumnName() public function testQuoteColumnName()
{ {
$connection = $this->getConnection(false); $connection = $this->getConnection(false);
$this->assertEquals('"column"', $connection->quoteColumnName('column')); $this->assertEquals('"column"', $connection->quoteColumnName('column'));
$this->assertEquals("'table'.\"column\"", $connection->quoteColumnName('table.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}}')); $this->assertEquals('{{column}}', $connection->quoteColumnName('{{column}}'));
$this->assertEquals('(column)', $connection->quoteColumnName('(column)')); $this->assertEquals('(column)', $connection->quoteColumnName('(column)'));
} }
} }

1
tests/unit/framework/db/sqlite/SqliteQueryBuilderTest.php

@ -78,5 +78,4 @@ class SqliteQueryBuilderTest extends QueryBuilderTest
$this->setExpectedException('yii\base\NotSupportedException'); $this->setExpectedException('yii\base\NotSupportedException');
parent::testAddDropPrimayKey(); parent::testAddDropPrimayKey();
} }
} }

10
tests/unit/framework/db/sqlite/SqliteQueryTest.php

@ -5,9 +5,9 @@ use yiiunit\framework\db\QueryTest;
class SqliteQueryTest extends QueryTest class SqliteQueryTest extends QueryTest
{ {
protected function setUp() protected function setUp()
{ {
$this->driverName = 'sqlite'; $this->driverName = 'sqlite';
parent::setUp(); parent::setUp();
} }
} }

1
tests/unit/framework/helpers/ConsoleTest.php

@ -75,5 +75,4 @@ class ConsoleTest extends TestCase
sleep(1); sleep(1);
} }
}*/ }*/
} }

7
tests/unit/framework/helpers/FileHelperTest.php

@ -100,7 +100,7 @@ class FileHelperTest extends TestCase
* @param string $fileName file name. * @param string $fileName file name.
* @param string $message error message * @param string $message error message
*/ */
protected function assertFileMode($expectedMode, $fileName, $message='') protected function assertFileMode($expectedMode, $fileName, $message = '')
{ {
$expectedMode = sprintf('%o', $expectedMode); $expectedMode = sprintf('%o', $expectedMode);
$this->assertEquals($expectedMode, $this->getMode($fileName), $message); $this->assertEquals($expectedMode, $this->getMode($fileName), $message);
@ -236,7 +236,7 @@ class FileHelperTest extends TestCase
$dirName = $basePath . DIRECTORY_SEPARATOR . $dirName; $dirName = $basePath . DIRECTORY_SEPARATOR . $dirName;
$options = array( $options = array(
'filter' => function($path) use ($passedFileName) { 'filter' => function ($path) use ($passedFileName) {
return $passedFileName == basename($path); return $passedFileName == basename($path);
} }
); );
@ -268,7 +268,8 @@ class FileHelperTest extends TestCase
$this->assertEquals(array($dirName . DIRECTORY_SEPARATOR . $fileName), $foundFiles); $this->assertEquals(array($dirName . DIRECTORY_SEPARATOR . $fileName), $foundFiles);
} }
public function testMkdir() { public function testMkdir()
{
$basePath = $this->testFilePath; $basePath = $this->testFilePath;
$dirName = $basePath . DIRECTORY_SEPARATOR . 'test_dir_level_1' . DIRECTORY_SEPARATOR . 'test_dir_level_2'; $dirName = $basePath . DIRECTORY_SEPARATOR . 'test_dir_level_1' . DIRECTORY_SEPARATOR . 'test_dir_level_2';
FileHelper::mkdir($dirName); FileHelper::mkdir($dirName);

6
tests/unit/framework/helpers/HtmlTest.php

@ -370,7 +370,7 @@ EOD;
<div class="radio"><label><input type="radio" name="test" value="value1&lt;&gt;"> text1&lt;&gt;</label></div> <div class="radio"><label><input type="radio" name="test" value="value1&lt;&gt;"> text1&lt;&gt;</label></div>
<div class="radio"><label><input type="radio" name="test" value="value 2"> text 2</label></div> <div class="radio"><label><input type="radio" name="test" value="value 2"> text 2</label></div>
EOD; EOD;
$this->assertEqualsWithoutLE($expected, Html::radioList('test', array('value2'), $this->getDataItems2())); $this->assertEqualsWithoutLE($expected, Html::radioList('test', array('value2'), $this->getDataItems2()));
$expected = <<<EOD $expected = <<<EOD
<input type="hidden" name="test" value="0"><div class="radio"><label><input type="radio" name="test" value="value1"> text1</label></div><br> <input type="hidden" name="test" value="0"><div class="radio"><label><input type="radio" name="test" value="value1"> text1</label></div><br>
@ -414,7 +414,7 @@ EOD;
EOD; EOD;
$this->assertEqualsWithoutLE($expected, Html::ul($data, array( $this->assertEqualsWithoutLE($expected, Html::ul($data, array(
'class' => 'test', 'class' => 'test',
'item' => function($item, $index) { 'item' => function ($item, $index) {
return "<li class=\"item-$index\">$item</li>"; return "<li class=\"item-$index\">$item</li>";
} }
))); )));
@ -444,7 +444,7 @@ EOD;
EOD; EOD;
$this->assertEqualsWithoutLE($expected, Html::ol($data, array( $this->assertEqualsWithoutLE($expected, Html::ol($data, array(
'class' => 'test', 'class' => 'test',
'item' => function($item, $index) { 'item' => function ($item, $index) {
return "<li class=\"item-$index\">$item</li>"; return "<li class=\"item-$index\">$item</li>";
} }
))); )));

204
tests/unit/framework/helpers/InflectorTest.php

@ -8,35 +8,35 @@ use yiiunit\TestCase;
class InflectorTest extends TestCase class InflectorTest extends TestCase
{ {
public function testPluralize() public function testPluralize()
{ {
$testData = array( $testData = array(
'move' => 'moves', 'move' => 'moves',
'foot' => 'feet', 'foot' => 'feet',
'child' => 'children', 'child' => 'children',
'human' => 'humans', 'human' => 'humans',
'man' => 'men', 'man' => 'men',
'staff' => 'staff', 'staff' => 'staff',
'tooth' => 'teeth', 'tooth' => 'teeth',
'person' => 'people', 'person' => 'people',
'mouse' => 'mice', 'mouse' => 'mice',
'touch' => 'touches', 'touch' => 'touches',
'hash' => 'hashes', 'hash' => 'hashes',
'shelf' => 'shelves', 'shelf' => 'shelves',
'potato' => 'potatoes', 'potato' => 'potatoes',
'bus' => 'buses', 'bus' => 'buses',
'test' => 'tests', 'test' => 'tests',
'car' => 'cars', 'car' => 'cars',
); );
foreach ($testData as $testIn => $testOut) { foreach ($testData as $testIn => $testOut) {
$this->assertEquals($testOut, Inflector::pluralize($testIn)); $this->assertEquals($testOut, Inflector::pluralize($testIn));
$this->assertEquals(ucfirst($testOut), ucfirst(Inflector::pluralize($testIn))); $this->assertEquals(ucfirst($testOut), ucfirst(Inflector::pluralize($testIn)));
} }
} }
public function testSingularize() public function testSingularize()
{ {
$testData = array( $testData = array(
'moves' => 'move', 'moves' => 'move',
'feet' => 'foot', 'feet' => 'foot',
@ -59,77 +59,77 @@ class InflectorTest extends TestCase
$this->assertEquals($testOut, Inflector::singularize($testIn)); $this->assertEquals($testOut, Inflector::singularize($testIn));
$this->assertEquals(ucfirst($testOut), ucfirst(Inflector::singularize($testIn))); $this->assertEquals(ucfirst($testOut), ucfirst(Inflector::singularize($testIn)));
} }
} }
public function testTitleize() public function testTitleize()
{ {
$this->assertEquals("Me my self and i", Inflector::titleize('MeMySelfAndI')); $this->assertEquals("Me my self and i", Inflector::titleize('MeMySelfAndI'));
$this->assertEquals("Me My Self And I", Inflector::titleize('MeMySelfAndI', true)); $this->assertEquals("Me My Self And I", Inflector::titleize('MeMySelfAndI', true));
} }
public function testCamelize() public function testCamelize()
{ {
$this->assertEquals("MeMySelfAndI", Inflector::camelize('me my_self-andI')); $this->assertEquals("MeMySelfAndI", Inflector::camelize('me my_self-andI'));
} }
public function testUnderscore() public function testUnderscore()
{ {
$this->assertEquals("me_my_self_and_i", Inflector::underscore('MeMySelfAndI')); $this->assertEquals("me_my_self_and_i", Inflector::underscore('MeMySelfAndI'));
} }
public function testCamel2words() public function testCamel2words()
{ {
$this->assertEquals('Camel Case', Inflector::camel2words('camelCase')); $this->assertEquals('Camel Case', Inflector::camel2words('camelCase'));
$this->assertEquals('Lower Case', Inflector::camel2words('lower_case')); $this->assertEquals('Lower Case', Inflector::camel2words('lower_case'));
$this->assertEquals('Tricky Stuff It Is Testing', Inflector::camel2words(' tricky_stuff.it-is testing... ')); $this->assertEquals('Tricky Stuff It Is Testing', Inflector::camel2words(' tricky_stuff.it-is testing... '));
} }
public function testCamel2id() 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', '_'));
$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() 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', '_'));
$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() 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'));
$this->assertEquals("Me My Self And I", Inflector::humanize('me_my_self_and_i', true)); $this->assertEquals("Me My Self And I", Inflector::humanize('me_my_self_and_i', true));
} }
public function testVariablize() public function testVariablize()
{ {
$this->assertEquals("customerTable", Inflector::variablize('customer_table')); $this->assertEquals("customerTable", Inflector::variablize('customer_table'));
} }
public function testTableize() public function testTableize()
{ {
$this->assertEquals("customer_tables", Inflector::tableize('customerTable')); $this->assertEquals("customer_tables", Inflector::tableize('customerTable'));
} }
public function testSlug() public function testSlug()
{ {
$this->assertEquals("this-is-a-title", Inflector::slug('this is a title')); $this->assertEquals("this-is-a-title", Inflector::slug('this is a title'));
} }
public function testClassify() public function testClassify()
{ {
$this->assertEquals("CustomerTable", Inflector::classify('customer_tables')); $this->assertEquals("CustomerTable", Inflector::classify('customer_tables'));
} }
public function testOrdinalize() public function testOrdinalize()
{ {
$this->assertEquals('21st', Inflector::ordinalize('21')); $this->assertEquals('21st', Inflector::ordinalize('21'));
} }
} }

3
tests/unit/framework/helpers/JsonTest.php

@ -23,7 +23,8 @@ class JsonTest extends TestCase
// simple object encoding // simple object encoding
$data = new \stdClass(); $data = new \stdClass();
$data->a = 1; $data->b = 2; $data->a = 1;
$data->b = 2;
$this->assertSame('{"a":1,"b":2}', Json::encode($data)); $this->assertSame('{"a":1,"b":2}', Json::encode($data));
// expression encoding // expression encoding

1
tests/unit/framework/helpers/StringHelperTest.php

@ -1,5 +1,6 @@
<?php <?php
namespace yiiunit\framework\helpers; namespace yiiunit\framework\helpers;
use \yii\helpers\StringHelper as StringHelper; use \yii\helpers\StringHelper as StringHelper;
use yii\test\TestCase; use yii\test\TestCase;

1
tests/unit/framework/helpers/VarDumperTest.php

@ -1,5 +1,6 @@
<?php <?php
namespace yiiunit\framework\helpers; namespace yiiunit\framework\helpers;
use \yii\helpers\VarDumper; use \yii\helpers\VarDumper;
use yii\test\TestCase; use yii\test\TestCase;

3
tests/unit/framework/requirements/YiiRequirementCheckerTest.php

@ -60,7 +60,8 @@ class YiiRequirementCheckerTest extends TestCase
/** /**
* @depends testCheck * @depends testCheck
*/ */
public function testCheckEval() { public function testCheckEval()
{
$requirementsChecker = new YiiRequirementChecker(); $requirementsChecker = new YiiRequirementChecker();
$requirements = array( $requirements = array(

1
tests/unit/framework/validators/EmailValidatorTest.php

@ -1,5 +1,6 @@
<?php <?php
namespace yiiunit\framework\validators; namespace yiiunit\framework\validators;
use yii\validators\EmailValidator; use yii\validators\EmailValidator;
use yiiunit\TestCase; use yiiunit\TestCase;

2
tests/unit/framework/widgets/SpacelessTest.php

@ -33,6 +33,6 @@ class SpacelessTest extends \yiiunit\TestCase
$expected="<body>\n<div class='wrapper'><div class='left-column'><p>This is a left bar!</p>". $expected="<body>\n<div class='wrapper'><div class='left-column'><p>This is a left bar!</p>".
"</div><div class='right-column'><p>This is a right bar!</p></div></div>\t<p>Bye!</p>\n</body>\n"; "</div><div class='right-column'><p>This is a right bar!</p></div></div>\t<p>Bye!</p>\n</body>\n";
$this->assertEquals($expected,ob_get_clean()); $this->assertEquals($expected, ob_get_clean());
} }
} }

Loading…
Cancel
Save