Browse Source

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

tags/2.0.6
faxriddin 10 years ago
parent
commit
9be5e630f4
  1. 11
      .gitignore
  2. 2
      .scrutinizer.yml
  3. 64
      .travis.yml
  4. 30
      README.md
  5. 30
      apps/advanced/.gitignore
  6. 32
      apps/advanced/LICENSE.md
  7. 129
      apps/advanced/README.md
  8. 26
      apps/advanced/backend/assets/AppAsset.php
  9. 24
      apps/advanced/backend/codeception.yml
  10. 2
      apps/advanced/backend/config/.gitignore
  11. 34
      apps/advanced/backend/config/main.php
  12. 4
      apps/advanced/backend/config/params.php
  13. 83
      apps/advanced/backend/controllers/SiteController.php
  14. 1
      apps/advanced/backend/models/.gitkeep
  15. 2
      apps/advanced/backend/runtime/.gitignore
  16. 4
      apps/advanced/backend/tests/.gitignore
  17. 18
      apps/advanced/backend/tests/_bootstrap.php
  18. 14
      apps/advanced/backend/tests/_config.php
  19. 19
      apps/advanced/backend/tests/_console.php
  20. 1
      apps/advanced/backend/tests/_data/dump.sql
  21. 2
      apps/advanced/backend/tests/_log/.gitignore
  22. 27
      apps/advanced/backend/tests/acceptance.suite.yml
  23. 33
      apps/advanced/backend/tests/acceptance/LoginCept.php
  24. 3
      apps/advanced/backend/tests/acceptance/_bootstrap.php
  25. 16
      apps/advanced/backend/tests/acceptance/_config.php
  26. 15
      apps/advanced/backend/tests/acceptance/_console.php
  27. 21
      apps/advanced/backend/tests/acceptance/yii
  28. 20
      apps/advanced/backend/tests/acceptance/yii.bat
  29. 17
      apps/advanced/backend/tests/functional.suite.yml
  30. 28
      apps/advanced/backend/tests/functional/LoginCept.php
  31. 3
      apps/advanced/backend/tests/functional/_bootstrap.php
  32. 20
      apps/advanced/backend/tests/functional/_config.php
  33. 15
      apps/advanced/backend/tests/functional/_console.php
  34. 21
      apps/advanced/backend/tests/functional/yii
  35. 20
      apps/advanced/backend/tests/functional/yii.bat
  36. 6
      apps/advanced/backend/tests/unit.suite.yml
  37. 8
      apps/advanced/backend/tests/unit/DbTestCase.php
  38. 8
      apps/advanced/backend/tests/unit/TestCase.php
  39. 2
      apps/advanced/backend/tests/unit/_bootstrap.php
  40. 16
      apps/advanced/backend/tests/unit/_config.php
  41. 22
      apps/advanced/backend/tests/unit/_console.php
  42. 0
      apps/advanced/backend/tests/unit/fixtures/data/.gitkeep
  43. 21
      apps/advanced/backend/tests/unit/yii
  44. 20
      apps/advanced/backend/tests/unit/yii.bat
  45. 71
      apps/advanced/backend/views/layouts/main.php
  46. 27
      apps/advanced/backend/views/site/error.php
  47. 52
      apps/advanced/backend/views/site/index.php
  48. 29
      apps/advanced/backend/views/site/login.php
  49. 2
      apps/advanced/backend/web/.gitignore
  50. 2
      apps/advanced/backend/web/assets/.gitignore
  51. 91
      apps/advanced/backend/web/css/site.css
  52. BIN
      apps/advanced/backend/web/favicon.ico
  53. 2
      apps/advanced/backend/web/robots.txt
  54. 11
      apps/advanced/codeception.yml
  55. 20
      apps/advanced/common/codeception.yml
  56. 2
      apps/advanced/common/config/.gitignore
  57. 5
      apps/advanced/common/config/aliases.php
  58. 9
      apps/advanced/common/config/main.php
  59. 6
      apps/advanced/common/config/params.php
  60. 22
      apps/advanced/common/mail/layouts/html.php
  61. 14
      apps/advanced/common/mail/passwordResetToken.php
  62. 77
      apps/advanced/common/models/LoginForm.php
  63. 180
      apps/advanced/common/models/User.php
  64. 4
      apps/advanced/common/tests/.gitignore
  65. 14
      apps/advanced/common/tests/_bootstrap.php
  66. 14
      apps/advanced/common/tests/_config.php
  67. 19
      apps/advanced/common/tests/_console.php
  68. 1
      apps/advanced/common/tests/_data/dump.sql
  69. 60
      apps/advanced/common/tests/_helpers/FixtureHelper.php
  70. 2
      apps/advanced/common/tests/_log/.gitignore
  71. 21
      apps/advanced/common/tests/_pages/LoginPage.php
  72. 10
      apps/advanced/common/tests/fixtures/UserFixture.php
  73. 14
      apps/advanced/common/tests/fixtures/data/init_login.php
  74. 17
      apps/advanced/common/tests/templates/fixtures/user.php
  75. 6
      apps/advanced/common/tests/unit.suite.yml
  76. 8
      apps/advanced/common/tests/unit/DbTestCase.php
  77. 8
      apps/advanced/common/tests/unit/TestCase.php
  78. 2
      apps/advanced/common/tests/unit/_bootstrap.php
  79. 16
      apps/advanced/common/tests/unit/_config.php
  80. 22
      apps/advanced/common/tests/unit/_console.php
  81. 14
      apps/advanced/common/tests/unit/fixtures/data/models/user.php
  82. 88
      apps/advanced/common/tests/unit/models/LoginFormTest.php
  83. 21
      apps/advanced/common/tests/unit/yii
  84. 20
      apps/advanced/common/tests/unit/yii.bat
  85. 50
      apps/advanced/composer.json
  86. 20
      apps/advanced/console/codeception.yml
  87. 2
      apps/advanced/console/config/.gitignore
  88. 26
      apps/advanced/console/config/main.php
  89. 4
      apps/advanced/console/config/params.php
  90. 0
      apps/advanced/console/controllers/.gitkeep
  91. 34
      apps/advanced/console/migrations/m130524_201442_init.php
  92. 1
      apps/advanced/console/models/.gitkeep
  93. 2
      apps/advanced/console/runtime/.gitignore
  94. 2
      apps/advanced/console/tests/.gitignore
  95. 14
      apps/advanced/console/tests/_bootstrap.php
  96. 14
      apps/advanced/console/tests/_config.php
  97. 19
      apps/advanced/console/tests/_console.php
  98. 1
      apps/advanced/console/tests/_data/dump.sql
  99. 2
      apps/advanced/console/tests/_log/.gitignore
  100. 6
      apps/advanced/console/tests/unit.suite.yml
  101. Some files were not shown because too many files have changed in this diff Show More

11
.gitignore vendored

@ -14,12 +14,13 @@ Thumbs.db
# composer vendor dir # composer vendor dir
/vendor /vendor
# cubrid install dir
/cubrid
# composer itself is not needed # composer itself is not needed
composer.phar composer.phar
# composer.lock should not be committed as we always want the latest versions
/composer.lock # composer.lock in applications is ignored since it's automatically created by composer when application is installed
# composer.lock in applications is ignored in dev repo, will be committed in checked out app repos
/apps/*/composer.lock /apps/*/composer.lock
# Mac DS_Store Files # Mac DS_Store Files
@ -29,3 +30,7 @@ composer.phar
phpunit.phar phpunit.phar
# local phpunit config # local phpunit config
/phpunit.xml /phpunit.xml
# ignore sub directory for dev installed apps and extensions
/apps
/extensions

2
.scrutinizer.yml

@ -4,7 +4,7 @@ imports:
tools: tools:
external_code_coverage: external_code_coverage:
timeout: 2100 # Timeout in seconds. timeout: 2100 # Timeout in seconds.
# disable copy paste detector and simliarity analyzer as they have no real value # disable copy paste detector and similarity analyzer as they have no real value
# and a huge bunch of false-positives # and a huge bunch of false-positives
php_sim: false php_sim: false
php_cpd: false php_cpd: false

64
.travis.yml

@ -4,60 +4,70 @@ php:
- 5.4 - 5.4
- 5.5 - 5.5
- 5.6 - 5.6
- 7.0
- hhvm - hhvm
- hhvm-nightly - hhvm-nightly
env:
- CUBRID_VERSION=9.3.0/CUBRID-9.3.0.0206 CUBRID_PDO_VERSION=9.3.0.0001
# run build against hhvm but allow them to fail # run build against hhvm but allow them to fail
# http://docs.travis-ci.com/user/build-configuration/#Rows-That-are-Allowed-To-Fail # http://docs.travis-ci.com/user/build-configuration/#Rows-That-are-Allowed-To-Fail
matrix: matrix:
fast_finish: true fast_finish: true
allow_failures: allow_failures:
- php: hhvm
- php: hhvm-nightly - php: hhvm-nightly
- php: 7.0
services: services:
- redis-server
- memcached - memcached
- elasticsearch
- mongodb # faster builds on new travis setup not using sudo
sudo: false
# cache vendor dirs
cache:
directories:
# - cubrid/9.3.0
- vendor
- $HOME/.composer/cache
# try running against postgres 9.3 # try running against postgres 9.3
addons: addons:
postgresql: "9.3" postgresql: "9.3"
install: install:
- composer self-update && composer --version - travis_retry composer self-update && composer --version
- travis_retry composer global require "fxp/composer-asset-plugin:1.0.0"
- export PATH="$HOME/.composer/vendor/bin:$PATH"
# core framework: # core framework:
- composer install --prefer-dist - travis_retry composer install --prefer-dist --no-interaction
- tests/unit/data/travis/mongodb-setup.sh
- tests/unit/data/travis/apc-setup.sh - tests/unit/data/travis/apc-setup.sh
- tests/unit/data/travis/memcache-setup.sh - tests/unit/data/travis/memcache-setup.sh
- tests/unit/data/travis/cubrid-setup.sh # - tests/unit/data/travis/cubrid-setup.sh
# basic and advanced application:
- tests/unit/data/travis/setup-apps.sh
before_script: before_script:
- echo 'elasticsearch version ' && curl http://localhost:9200/ # show some versions and env information
- php -r "echo INTL_ICU_VERSION . \"\n\";"
- mysql --version
- psql --version
# initialize databases
- mysql -e 'CREATE DATABASE yiitest;'; - mysql -e 'CREATE DATABASE yiitest;';
- psql -U postgres -c 'CREATE DATABASE yiitest;'; - psql -U postgres -c 'CREATE DATABASE yiitest;';
- tests/unit/data/travis/sphinx-setup.sh
- mongo yii2test --eval 'db.addUser("travis", "test");'
# basic and advanced application:
- tests/unit/data/travis/init-apps.sh
script:
- vendor/bin/phpunit --verbose --coverage-clover=coverage.clover --exclude-group mssql,oci,wincache,xcache,zenddata
- | - |
if (php --version | grep -i HipHop > /dev/null); then if [ $TRAVIS_PHP_VERSION = '5.6' ]; then
echo "skipping application tests on HHVM" PHPUNIT_FLAGS="--coverage-clover=coverage.clover"
else
cd apps/basic && php vendor/bin/codecept run
cd ../advanced/backend && ../vendor/bin/codecept run
cd ../common && ../vendor/bin/codecept run
cd ../frontend && ../vendor/bin/codecept run
fi fi
script:
- vendor/bin/phpunit --verbose $PHPUNIT_FLAGS --exclude-group mssql,oci,wincache,xcache,zenddata,cubrid
after_script: after_script:
- cd ../../.. - |
- wget https://scrutinizer-ci.com/ocular.phar if [ $TRAVIS_PHP_VERSION = '5.6' ]; then
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover travis_retry wget https://scrutinizer-ci.com/ocular.phar
php ocular.phar code-coverage:upload --format=php-clover coverage.clover
fi

30
README.md

@ -8,37 +8,22 @@ Yii 2 inherits the main spirit behind Yii for being simple, fast and highly exte
Yii 2 requires PHP 5.4 and embraces the best practices and protocols found in modern Web application development. Yii 2 requires PHP 5.4 and embraces the best practices and protocols found in modern Web application development.
**Yii 2 is not ready for production use yet.** We may make significant changes without prior notices.
We expect to make the first stable release of Yii 2 in the middle of 2014.
If you mainly want to learn Yii with no real project development requirement, we highly recommend
you start with Yii 2 as it will be our main focus for the next few years.
If you have a real project with tight schedule, you should stick to [Yii 1.1](https://github.com/yiisoft/yii)
which is the latest stable release of Yii.
[![Latest Stable Version](https://poser.pugx.org/yiisoft/yii2/v/stable.png)](https://packagist.org/packages/yiisoft/yii2) [![Latest Stable Version](https://poser.pugx.org/yiisoft/yii2/v/stable.png)](https://packagist.org/packages/yiisoft/yii2)
[![Total Downloads](https://poser.pugx.org/yiisoft/yii2/downloads.png)](https://packagist.org/packages/yiisoft/yii2) [![Total Downloads](https://poser.pugx.org/yiisoft/yii2/downloads.png)](https://packagist.org/packages/yiisoft/yii2)
[![Dependency Status](https://www.versioneye.com/php/yiisoft:yii2/dev-master/badge.png)](https://www.versioneye.com/php/yiisoft:yii2/dev-master) [![Reference Status](https://www.versioneye.com/php/yiisoft:yii2/reference_badge.svg)](https://www.versioneye.com/php/yiisoft:yii2/references)
[![Build Status](https://secure.travis-ci.org/yiisoft/yii2.png)](http://travis-ci.org/yiisoft/yii2) [![Build Status](https://secure.travis-ci.org/yiisoft/yii2.png)](http://travis-ci.org/yiisoft/yii2)
[![Dependency Status](https://www.versioneye.com/php/yiisoft:yii2/dev-master/badge.png)](https://www.versioneye.com/php/yiisoft:yii2/dev-master)
[![HHVM Status](http://hhvm.h4cc.de/badge/yiisoft/yii2-dev.png)](http://hhvm.h4cc.de/package/yiisoft/yii2-dev) [![HHVM Status](http://hhvm.h4cc.de/badge/yiisoft/yii2-dev.png)](http://hhvm.h4cc.de/package/yiisoft/yii2-dev)
[![Code Coverage](https://scrutinizer-ci.com/g/yiisoft/yii2/badges/coverage.png?s=31d80f1036099e9d6a3e4d7738f6b000b3c3d10e)](https://scrutinizer-ci.com/g/yiisoft/yii2/) [![Code Coverage](https://scrutinizer-ci.com/g/yiisoft/yii2/badges/coverage.png?s=31d80f1036099e9d6a3e4d7738f6b000b3c3d10e)](https://scrutinizer-ci.com/g/yiisoft/yii2/)
[![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/yiisoft/yii2/badges/quality-score.png?s=b1074a1ff6d0b214d54fa5ab7abbb90fc092471d)](https://scrutinizer-ci.com/g/yiisoft/yii2/) [![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/yiisoft/yii2/badges/quality-score.png?s=b1074a1ff6d0b214d54fa5ab7abbb90fc092471d)](https://scrutinizer-ci.com/g/yiisoft/yii2/)
[![Code Climate](https://codeclimate.com/github/yiisoft/yii2.png)](https://codeclimate.com/github/yiisoft/yii2) [![Code Climate](https://codeclimate.com/github/yiisoft/yii2.png)](https://codeclimate.com/github/yiisoft/yii2)
[![Reference Status](https://www.versioneye.com/php/yiisoft:yii2/reference_badge.svg)](https://www.versioneye.com/php/yiisoft:yii2/references)
DIRECTORY STRUCTURE DIRECTORY STRUCTURE
------------------- -------------------
``` ```
apps/ ready-to-use application templates
advanced/ a template suitable for building sophisticated Web applications
basic/ a template suitable for building simple Web applications
benchmark/ an application demonstrating the performance of Yii
build/ internally used build tools build/ internally used build tools
docs/ documentation docs/ documentation
extensions/ extensions
framework/ core framework code framework/ core framework code
tests/ tests of the core framework code tests/ tests of the core framework code
``` ```
@ -53,14 +38,11 @@ The minimum requirement by Yii is that your Web server supports PHP 5.4.
DOCUMENTATION DOCUMENTATION
------------- -------------
A draft of the [Definitive Guide](docs/guide/README.md) is available. Yii 2.0 has a [Definitive Guide](http://www.yiiframework.com/doc-2.0/guide-index.html) and
a [Class Reference](http://www.yiiframework.com/doc-2.0/index.html) which cover every detail of Yii.
API docs and a rendering of the definitive guide are currently
available under the following urls:
- http://stuff.cebe.cc/yii2docs/ API and Definitive Guide (updated every 15 minutes from the github source) There is also a [PDF version](http://stuff.cebe.cc/yii2-guide.pdf) of the Definitive Guide
- http://www.yiiframework.com/doc-2.0/guide-index.html API and Definitive Guide (last updated for the beta release) and a [Definitive Guide Mirror](http://stuff.cebe.cc/yii2docs/) which update every 15 minutes.
- http://stuff.cebe.cc/yii2-guide.pdf The PDF version of the Guide
For 1.1 users, you may refer to [Upgrading from Yii 1.1](docs/guide/intro-upgrade-from-v1.md) For 1.1 users, you may refer to [Upgrading from Yii 1.1](docs/guide/intro-upgrade-from-v1.md)
to have a general idea of what has changed in 2.0. to have a general idea of what has changed in 2.0.

30
apps/advanced/.gitignore vendored

@ -1,30 +0,0 @@
# yii console command
/yii
# phpstorm project files
.idea
# netbeans project files
nbproject
# zend studio for eclipse project files
.buildpath
.project
.settings
# windows thumbnail cache
Thumbs.db
# composer vendor dir
/vendor
# composer itself is not needed
composer.phar
# Mac DS_Store Files
.DS_Store
# phpunit itself is not needed
phpunit.phar
# local phpunit config
/phpunit.xml

32
apps/advanced/LICENSE.md

@ -1,32 +0,0 @@
The Yii framework is free software. It is released under the terms of
the following BSD License.
Copyright © 2008 by Yii Software LLC (http://www.yiisoft.com)
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
* Neither the name of Yii Software LLC nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

129
apps/advanced/README.md

@ -1,129 +0,0 @@
Yii 2 Advanced Application Template
===================================
Yii 2 Advanced Application Template is a skeleton Yii 2 application best for
developing complex Web applications with multiple tiers.
The template includes three tiers: front end, back end, and console, each of which
is a separate Yii application.
The template is designed to work in a team development environment. It supports
deploying the application in different environments.
DIRECTORY STRUCTURE
-------------------
```
common
config/ contains shared configurations
mail/ contains view files for e-mails
models/ contains model classes used in both backend and frontend
tests/ contains various tests for objects that are common among applications
console
config/ contains console configurations
controllers/ contains console controllers (commands)
migrations/ contains database migrations
models/ contains console-specific model classes
runtime/ contains files generated during runtime
tests/ contains various tests for the console application
backend
assets/ contains application assets such as JavaScript and CSS
config/ contains backend configurations
controllers/ contains Web controller classes
models/ contains backend-specific model classes
runtime/ contains files generated during runtime
tests/ contains various tests for the backend application
views/ contains view files for the Web application
web/ contains the entry script and Web resources
frontend
assets/ contains application assets such as JavaScript and CSS
config/ contains frontend configurations
controllers/ contains Web controller classes
models/ contains frontend-specific model classes
runtime/ contains files generated during runtime
tests/ contains various tests for the frontend application
views/ contains view files for the Web application
web/ contains the entry script and Web resources
vendor/ contains dependent 3rd-party packages
environments/ contains environment-based overrides
```
REQUIREMENTS
------------
The minimum requirement by this application template that your Web server supports PHP 5.4.0.
INSTALLATION
------------
### Install from an Archive File
Extract the archive file downloaded from [yiiframework.com](http://www.yiiframework.com/download/) to
a directory named `advanced` that is directly under the Web root.
Then follow the instructions given in "GETTING STARTED".
### Install via Composer
If you do not have [Composer](http://getcomposer.org/), you may install it by following the instructions
at [getcomposer.org](http://getcomposer.org/doc/00-intro.md#installation-nix).
You can then install the application using the following command:
~~~
php composer.phar create-project --prefer-dist --stability=dev yiisoft/yii2-app-advanced advanced
~~~
GETTING STARTED
---------------
After you install the application, you have to conduct the following steps to initialize
the installed application. You only need to do these once for all.
1. Run command `init` to initialize the application with a specific environment.
2. Create a new database and adjust the `components['db']` configuration in `common/config/main-local.php` accordingly.
3. Apply migrations with console command `yii migrate`. This will create tables needed for the application to work.
4. Set document roots of your Web server:
- for frontend `/path/to/yii-application/frontend/web/` and using the URL `http://frontend/`
- for backend `/path/to/yii-application/backend/web/` and using the URL `http://backend/`
To login into the application, you need to first sign up, with any of your email address, username and password.
Then, you can login into the application with same email address and password at any time.
TESTING
-------
Install additional composer packages:
* `php composer.phar require --dev codeception/codeception:2.0.* codeception/specify:* codeception/verify:* yiisoft/yii2-faker:*`
This application boilerplate use database in testing, so you should create three databases that are used in tests:
* `yii2_advanced_unit` - database for unit tests;
* `yii2_advanced_functional` - database for functional tests;
* `yii2_advanced_acceptance` - database for acceptance tests.
To make your database up to date, you can run in needed test folder `yii migrate`, for example
if you are starting from `frontend` tests then you should run `yii migrate` in each suite folder `acceptance`, `functional`, `unit`
it will upgrade your database to the last state according migrations.
To be able to run acceptance tests you need a running webserver. For this you can use the php builtin server and run it in the directory where your main project folder is located. For example if your application is located in `/www/advanced` all you need to is:
`cd /www` and then `php -S 127.0.0.1:8080` because the default configuration of acceptance tests expects the url of the application to be `/advanced/`.
If you already have a server configured or your application is not located in a folder called `advanced`, you may need to adjust the `test_entry_url` in `backend/codeception.yml` and `frontend/codeception.yml`.
After that is done you should be able to run your tests, for example to run `frontend` tests do:
* `cd frontend`
* `../vendor/bin/codecept build`
* `../vendor/bin/codecept run`
In similar way you can run tests for other application tiers - `backend`, `console`, `common`.
If you already have run `../vendor/bin/codecept build` for each application, you can run all tests by one command: `vendor/bin/codecept run`
You also can adjust you application suite configs and `_bootstrap.php` settings to use other urls and files, as it is can be done in `yii2-basic`.
Current template also includes [yii2-faker](https://github.com/yiisoft/yii2/tree/master/extensions/faker) extension, that is correctly setup for each application tier.

26
apps/advanced/backend/assets/AppAsset.php

@ -1,26 +0,0 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace backend\assets;
use yii\web\AssetBundle;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class AppAsset extends AssetBundle
{
public $basePath = '@webroot';
public $baseUrl = '@web';
public $css = ['css/site.css'];
public $js = [];
public $depends = [
'yii\web\YiiAsset',
'yii\bootstrap\BootstrapAsset',
];
}

24
apps/advanced/backend/codeception.yml

@ -1,24 +0,0 @@
namespace: backend
actor: Tester
paths:
tests: tests
log: tests/_log
data: tests/_data
helpers: tests/_helpers
settings:
bootstrap: _bootstrap.php
suite_class: \PHPUnit_Framework_TestSuite
colors: true
memory_limit: 1024M
log: true
modules:
config:
Db:
dsn: ''
user: ''
password: ''
dump: tests/_data/dump.sql
config:
# the entry script URL (without host info) for functional and acceptance tests
# PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL
test_entry_url: /advanced/backend/web/index-test.php

2
apps/advanced/backend/config/.gitignore vendored

@ -1,2 +0,0 @@
main-local.php
params-local.php

34
apps/advanced/backend/config/main.php

@ -1,34 +0,0 @@
<?php
$params = array_merge(
require(__DIR__ . '/../../common/config/params.php'),
require(__DIR__ . '/../../common/config/params-local.php'),
require(__DIR__ . '/params.php'),
require(__DIR__ . '/params-local.php')
);
return [
'id' => 'app-backend',
'basePath' => dirname(__DIR__),
'controllerNamespace' => 'backend\controllers',
'bootstrap' => ['log'],
'modules' => [],
'components' => [
'user' => [
'identityClass' => 'common\models\User',
'enableAutoLogin' => true,
],
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
'errorHandler' => [
'errorAction' => 'site/error',
],
],
'params' => $params,
];

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

@ -1,4 +0,0 @@
<?php
return [
'adminEmail' => 'admin@example.com',
];

83
apps/advanced/backend/controllers/SiteController.php

@ -1,83 +0,0 @@
<?php
namespace backend\controllers;
use Yii;
use yii\filters\AccessControl;
use yii\web\Controller;
use common\models\LoginForm;
use yii\filters\VerbFilter;
/**
* Site controller
*/
class SiteController extends Controller
{
/**
* @inheritdoc
*/
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'actions' => ['login', 'error'],
'allow' => true,
],
[
'actions' => ['logout', 'index'],
'allow' => true,
'roles' => ['@'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'logout' => ['post'],
],
],
];
}
/**
* @inheritdoc
*/
public function actions()
{
return [
'error' => [
'class' => 'yii\web\ErrorAction',
],
];
}
public function actionIndex()
{
return $this->render('index');
}
public function actionLogin()
{
if (!\Yii::$app->user->isGuest) {
return $this->goHome();
}
$model = new LoginForm();
if ($model->load(Yii::$app->request->post()) && $model->login()) {
return $this->goBack();
} else {
return $this->render('login', [
'model' => $model,
]);
}
}
public function actionLogout()
{
Yii::$app->user->logout();
return $this->goHome();
}
}

1
apps/advanced/backend/models/.gitkeep

@ -1 +0,0 @@
*

2
apps/advanced/backend/runtime/.gitignore vendored

@ -1,2 +0,0 @@
*
!.gitignore

4
apps/advanced/backend/tests/.gitignore vendored

@ -1,4 +0,0 @@
# these files are auto generated by codeception build
/unit/CodeGuy.php
/functional/TestGuy.php
/acceptance/WebGuy.php

18
apps/advanced/backend/tests/_bootstrap.php

@ -1,18 +0,0 @@
<?php
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'test');
require_once(__DIR__ . '/../../vendor/autoload.php');
require_once(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
require(__DIR__ . '/../../common/config/aliases.php');
// set correct script paths
// the entry script file path for functional and acceptance tests
$_SERVER['SCRIPT_FILENAME'] = dirname(__DIR__) . '/web/index-test.php';
$_SERVER['SCRIPT_NAME'] = \Codeception\Configuration::config()['config']['test_entry_url'];
$_SERVER['SERVER_NAME'] = 'localhost';

14
apps/advanced/backend/tests/_config.php

@ -1,14 +0,0 @@
<?php
/**
* application configurations shared by all test types
*/
return [
'components' => [
'mailer' => [
'useFileTransport' => true,
],
'urlManager' => [
'showScriptName' => true,
],
],
];

19
apps/advanced/backend/tests/_console.php

@ -1,19 +0,0 @@
<?php
/**
* Yii console bootstrap file.
*
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
// fcgi doesn't have STDIN and STDOUT defined by default
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r'));
defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w'));
require_once(__DIR__ . '/../../vendor/autoload.php');
require_once(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
require_once(__DIR__ . '/../../common/config/aliases.php');
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'test');

1
apps/advanced/backend/tests/_data/dump.sql

@ -1 +0,0 @@
/* Replace this file with actual dump of your database */

2
apps/advanced/backend/tests/_log/.gitignore vendored

@ -1,2 +0,0 @@
*
!.gitignore

27
apps/advanced/backend/tests/acceptance.suite.yml

@ -1,27 +0,0 @@
# Codeception Test Suite Configuration
# suite for acceptance tests.
# perform tests in browser using the Selenium-like tools.
# powered by Mink (http://mink.behat.org).
# (tip: that's what your customer will see).
# (tip: test your ajax and javascript by one of Mink drivers).
# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
class_name: WebGuy
modules:
enabled:
- PhpBrowser
- common\tests\_helpers\FixtureHelper
# you can use WebDriver instead of PhpBrowser to test javascript and ajax.
# This will require you to install selenium. See http://codeception.com/docs/04-AcceptanceTests#Selenium
# "restart" option is used by the WebDriver to start each time per test-file new session and cookies,
# it is useful if you want to login in your app in each test.
# - WebDriver
config:
PhpBrowser:
url: 'http://localhost:8080'
# WebDriver:
# url: 'http://localhost'
# browser: firefox
# restart: true

33
apps/advanced/backend/tests/acceptance/LoginCept.php

@ -1,33 +0,0 @@
<?php
use common\tests\_pages\LoginPage;
use backend\WebGuy;
$I = new WebGuy($scenario);
$I->wantTo('ensure login page works');
$loginPage = LoginPage::openBy($I);
$I->amGoingTo('submit login form with no data');
$loginPage->login('', '');
$I->expectTo('see validations errors');
$I->see('Username cannot be blank.', '.help-block');
$I->see('Password cannot be blank.', '.help-block');
$I->amGoingTo('try to login with wrong credentials');
$I->expectTo('see validations errors');
$loginPage->login('admin', 'wrong');
$I->expectTo('see validations errors');
$I->see('Incorrect username or password.', '.help-block');
$I->amGoingTo('try to login with correct credentials');
$loginPage->login('erau', 'password_0');
$I->expectTo('see that user is logged');
$I->seeLink('Logout (erau)');
$I->dontSeeLink('Login');
$I->dontSeeLink('Signup');
/** Uncomment if using WebDriver
* $I->click('Logout (erau)');
* $I->dontSeeLink('Logout (erau)');
* $I->seeLink('Login');
*/

3
apps/advanced/backend/tests/acceptance/_bootstrap.php

@ -1,3 +0,0 @@
<?php
new yii\web\Application(require(__DIR__ . '/_config.php'));

16
apps/advanced/backend/tests/acceptance/_config.php

@ -1,16 +0,0 @@
<?php
return yii\helpers\ArrayHelper::merge(
require(__DIR__ . '/../../config/main.php'),
require(__DIR__ . '/../../config/main-local.php'),
require(__DIR__ . '/../../../common/config/main.php'),
require(__DIR__ . '/../../../common/config/main-local.php'),
require(__DIR__ . '/../_config.php'),
[
'components' => [
'db' => [
'dsn' => 'mysql:host=localhost;dbname=yii2_advanced_acceptance',
],
],
]
);

15
apps/advanced/backend/tests/acceptance/_console.php

@ -1,15 +0,0 @@
<?php
return yii\helpers\ArrayHelper::merge(
require(__DIR__ . '/../../../common/config/main.php'),
require(__DIR__ . '/../../../common/config/main-local.php'),
require(__DIR__ . '/../../../console/config/main.php'),
require(__DIR__ . '/../../../console/config/main-local.php'),
[
'components' => [
'db' => [
'dsn' => 'mysql:host=localhost;dbname=yii2_advanced_acceptance',
],
],
]
);

21
apps/advanced/backend/tests/acceptance/yii

@ -1,21 +0,0 @@
#!/usr/bin/env php
<?php
/**
* Yii console bootstrap file.
*
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
// fcgi doesn't have STDIN and STDOUT defined by default
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r'));
defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w'));
require_once(__DIR__ . '/../_console.php');
$config = require(__DIR__ . '/_console.php');
$application = new yii\console\Application($config);
$exitCode = $application->run();
exit($exitCode);

20
apps/advanced/backend/tests/acceptance/yii.bat

@ -1,20 +0,0 @@
@echo off
rem -------------------------------------------------------------
rem Yii command line bootstrap script for Windows.
rem
rem @author Qiang Xue <qiang.xue@gmail.com>
rem @link http://www.yiiframework.com/
rem @copyright Copyright &copy; 2012 Yii Software LLC
rem @license http://www.yiiframework.com/license/
rem -------------------------------------------------------------
@setlocal
set YII_PATH=%~dp0
if "%PHP_COMMAND%" == "" set PHP_COMMAND=php.exe
"%PHP_COMMAND%" "%YII_PATH%yii" %*
@endlocal

17
apps/advanced/backend/tests/functional.suite.yml

@ -1,17 +0,0 @@
# Codeception Test Suite Configuration
# suite for functional (integration) tests.
# emulate web requests and make application process them.
# (tip: better to use with frameworks).
# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
#basic/web/index.php
class_name: TestGuy
modules:
enabled:
- Filesystem
- Yii2
- common\tests\_helpers\FixtureHelper
config:
Yii2:
configFile: 'tests/functional/_config.php'

28
apps/advanced/backend/tests/functional/LoginCept.php

@ -1,28 +0,0 @@
<?php
use common\tests\_pages\LoginPage;
use backend\TestGuy;
$I = new TestGuy($scenario);
$I->wantTo('ensure login page works');
$loginPage = LoginPage::openBy($I);
$I->amGoingTo('submit login form with no data');
$loginPage->login('', '');
$I->expectTo('see validations errors');
$I->see('Username cannot be blank.', '.help-block');
$I->see('Password cannot be blank.', '.help-block');
$I->amGoingTo('try to login with wrong credentials');
$I->expectTo('see validations errors');
$loginPage->login('admin', 'wrong');
$I->expectTo('see validations errors');
$I->see('Incorrect username or password.', '.help-block');
$I->amGoingTo('try to login with correct credentials');
$loginPage->login('erau', 'password_0');
$I->expectTo('see that user is logged');
$I->seeLink('Logout (erau)');
$I->dontSeeLink('Login');
$I->dontSeeLink('Signup');

3
apps/advanced/backend/tests/functional/_bootstrap.php

@ -1,3 +0,0 @@
<?php
new yii\web\Application(require(__DIR__ . '/_config.php'));

20
apps/advanced/backend/tests/functional/_config.php

@ -1,20 +0,0 @@
<?php
// set correct script paths
$_SERVER['SCRIPT_FILENAME'] = dirname(dirname(__DIR__)) . '/web/index-test.php';
$_SERVER['SCRIPT_NAME'] = \Codeception\Configuration::config()['config']['test_entry_url'];;
return yii\helpers\ArrayHelper::merge(
require(__DIR__ . '/../../config/main.php'),
require(__DIR__ . '/../../config/main-local.php'),
require(__DIR__ . '/../../../common/config/main.php'),
require(__DIR__ . '/../../../common/config/main-local.php'),
require(__DIR__ . '/../_config.php'),
[
'components' => [
'db' => [
'dsn' => 'mysql:host=localhost;dbname=yii2_advanced_functional',
],
],
]
);

15
apps/advanced/backend/tests/functional/_console.php

@ -1,15 +0,0 @@
<?php
return yii\helpers\ArrayHelper::merge(
require(__DIR__ . '/../../../common/config/main.php'),
require(__DIR__ . '/../../../common/config/main-local.php'),
require(__DIR__ . '/../../../console/config/main.php'),
require(__DIR__ . '/../../../console/config/main-local.php'),
[
'components' => [
'db' => [
'dsn' => 'mysql:host=localhost;dbname=yii2_advanced_functional',
],
],
]
);

21
apps/advanced/backend/tests/functional/yii

@ -1,21 +0,0 @@
#!/usr/bin/env php
<?php
/**
* Yii console bootstrap file.
*
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
// fcgi doesn't have STDIN and STDOUT defined by default
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r'));
defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w'));
require_once(__DIR__ . '/../_console.php');
$config = require(__DIR__ . '/_console.php');
$application = new yii\console\Application($config);
$exitCode = $application->run();
exit($exitCode);

20
apps/advanced/backend/tests/functional/yii.bat

@ -1,20 +0,0 @@
@echo off
rem -------------------------------------------------------------
rem Yii command line bootstrap script for Windows.
rem
rem @author Qiang Xue <qiang.xue@gmail.com>
rem @link http://www.yiiframework.com/
rem @copyright Copyright &copy; 2012 Yii Software LLC
rem @license http://www.yiiframework.com/license/
rem -------------------------------------------------------------
@setlocal
set YII_PATH=%~dp0
if "%PHP_COMMAND%" == "" set PHP_COMMAND=php.exe
"%PHP_COMMAND%" "%YII_PATH%yii" %*
@endlocal

6
apps/advanced/backend/tests/unit.suite.yml

@ -1,6 +0,0 @@
# Codeception Test Suite Configuration
# suite for unit (internal) tests.
# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
class_name: CodeGuy

8
apps/advanced/backend/tests/unit/DbTestCase.php

@ -1,8 +0,0 @@
<?php
namespace backend\tests\unit;
class DbTestCase extends \yii\codeception\DbTestCase
{
public $appConfig = '@backend/tests/unit/_config.php';
}

8
apps/advanced/backend/tests/unit/TestCase.php

@ -1,8 +0,0 @@
<?php
namespace backend\tests\unit;
class TestCase extends \yii\codeception\TestCase
{
public $appConfig = '@backend/tests/unit/_config.php';
}

2
apps/advanced/backend/tests/unit/_bootstrap.php

@ -1,2 +0,0 @@
<?php
// Here you can initialize variables that will for your tests

16
apps/advanced/backend/tests/unit/_config.php

@ -1,16 +0,0 @@
<?php
return yii\helpers\ArrayHelper::merge(
require(__DIR__ . '/../../../common/config/main.php'),
require(__DIR__ . '/../../../common/config/main-local.php'),
require(__DIR__ . '/../../config/main.php'),
require(__DIR__ . '/../../config/main-local.php'),
require(__DIR__ . '/../_config.php'),
[
'components' => [
'db' => [
'dsn' => 'mysql:host=localhost;dbname=yii2_advanced_unit',
],
],
]
);

22
apps/advanced/backend/tests/unit/_console.php

@ -1,22 +0,0 @@
<?php
return yii\helpers\ArrayHelper::merge(
require(__DIR__ . '/../../../common/config/main.php'),
require(__DIR__ . '/../../../common/config/main-local.php'),
require(__DIR__ . '/../../../console/config/main.php'),
require(__DIR__ . '/../../../console/config/main-local.php'),
[
'components' => [
'db' => [
'dsn' => 'mysql:host=localhost;dbname=yii2_advanced_unit',
],
],
'controllerMap' => [
'fixture' => [
'class' => 'yii\faker\FixtureController',
'fixtureDataPath' => '@backend/tests/unit/fixtures/data',
'templatePath' => '@commmon/tests/templates/fixtures'
],
],
]
);

0
apps/advanced/backend/tests/unit/fixtures/data/.gitkeep

21
apps/advanced/backend/tests/unit/yii

@ -1,21 +0,0 @@
#!/usr/bin/env php
<?php
/**
* Yii console bootstrap file.
*
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
// fcgi doesn't have STDIN and STDOUT defined by default
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r'));
defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w'));
require_once(__DIR__ . '/../_console.php');
$config = require(__DIR__ . '/_console.php');
$application = new yii\console\Application($config);
$exitCode = $application->run();
exit($exitCode);

20
apps/advanced/backend/tests/unit/yii.bat

@ -1,20 +0,0 @@
@echo off
rem -------------------------------------------------------------
rem Yii command line bootstrap script for Windows.
rem
rem @author Qiang Xue <qiang.xue@gmail.com>
rem @link http://www.yiiframework.com/
rem @copyright Copyright &copy; 2012 Yii Software LLC
rem @license http://www.yiiframework.com/license/
rem -------------------------------------------------------------
@setlocal
set YII_PATH=%~dp0
if "%PHP_COMMAND%" == "" set PHP_COMMAND=php.exe
"%PHP_COMMAND%" "%YII_PATH%yii" %*
@endlocal

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

@ -1,71 +0,0 @@
<?php
use backend\assets\AppAsset;
use yii\helpers\Html;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs;
/* @var $this \yii\web\View */
/* @var $content string */
AppAsset::register($this);
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
<head>
<meta charset="<?= Yii::$app->charset ?>"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<?= Html::csrfMetaTags() ?>
<title><?= Html::encode($this->title) ?></title>
<?php $this->head() ?>
</head>
<body>
<?php $this->beginBody() ?>
<div class="wrap">
<?php
NavBar::begin([
'brandLabel' => 'My Company',
'brandUrl' => Yii::$app->homeUrl,
'options' => [
'class' => 'navbar-inverse navbar-fixed-top',
],
]);
$menuItems = [
['label' => 'Home', 'url' => ['/site/index']],
];
if (Yii::$app->user->isGuest) {
$menuItems[] = ['label' => 'Login', 'url' => ['/site/login']];
} else {
$menuItems[] = [
'label' => 'Logout (' . Yii::$app->user->identity->username . ')',
'url' => ['/site/logout'],
'linkOptions' => ['data-method' => 'post']
];
}
echo Nav::widget([
'options' => ['class' => 'navbar-nav navbar-right'],
'items' => $menuItems,
]);
NavBar::end();
?>
<div class="container">
<?= Breadcrumbs::widget([
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
]) ?>
<?= $content ?>
</div>
</div>
<footer class="footer">
<div class="container">
<p class="pull-left">&copy; My Company <?= date('Y') ?></p>
<p class="pull-right"><?= Yii::powered() ?></p>
</div>
</footer>
<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>

27
apps/advanced/backend/views/site/error.php

@ -1,27 +0,0 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $name string */
/* @var $message string */
/* @var $exception Exception */
$this->title = $name;
?>
<div class="site-error">
<h1><?= Html::encode($this->title) ?></h1>
<div class="alert alert-danger">
<?= nl2br(Html::encode($message)) ?>
</div>
<p>
The above error occurred while the Web server was processing your request.
</p>
<p>
Please contact us if you think this is a server error. Thank you.
</p>
</div>

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

@ -1,52 +0,0 @@
<?php
/* @var $this yii\web\View */
$this->title = 'My Yii Application';
?>
<div class="site-index">
<div class="jumbotron">
<h1>Congratulations!</h1>
<p class="lead">You have successfully created your Yii-powered application.</p>
<p><a class="btn btn-lg btn-success" href="http://www.yiiframework.com">Get started with Yii</a></p>
</div>
<div class="body-content">
<div class="row">
<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/doc/">Yii Documentation &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/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>
</div>
</div>

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

@ -1,29 +0,0 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $form yii\widgets\ActiveForm */
/* @var $model \common\models\LoginForm */
$this->title = 'Login';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="site-login">
<h1><?= Html::encode($this->title) ?></h1>
<p>Please fill out the following fields to login:</p>
<div class="row">
<div class="col-lg-5">
<?php $form = ActiveForm::begin(['id' => 'login-form']); ?>
<?= $form->field($model, 'username') ?>
<?= $form->field($model, 'password')->passwordInput() ?>
<?= $form->field($model, 'rememberMe')->checkbox() ?>
<div class="form-group">
<?= Html::submitButton('Login', ['class' => 'btn btn-primary', 'name' => 'login-button']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
</div>
</div>

2
apps/advanced/backend/web/.gitignore vendored

@ -1,2 +0,0 @@
/index.php
/index-test.php

2
apps/advanced/backend/web/assets/.gitignore vendored

@ -1,2 +0,0 @@
*
!.gitignore

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

@ -1,91 +0,0 @@
html,
body {
height: 100%;
}
.wrap {
min-height: 100%;
height: auto;
margin: 0 auto -60px;
padding: 0 0 60px;
}
.wrap > .container {
padding: 70px 15px 20px;
}
.footer {
height: 60px;
background-color: #f5f5f5;
border-top: 1px solid #ddd;
padding-top: 20px;
}
.jumbotron {
text-align: center;
background-color: transparent;
}
.jumbotron .btn {
font-size: 21px;
padding: 14px 24px;
}
.not-set {
color: #c55;
font-style: italic;
}
/* add sorting icons to gridview sort links */
a.asc:after, a.desc:after {
position: relative;
top: 1px;
display: inline-block;
font-family: 'Glyphicons Halflings';
font-style: normal;
font-weight: normal;
line-height: 1;
padding-left: 5px;
}
a.asc:after {
content: /*"\e113"*/ "\e151";
}
a.desc:after {
content: /*"\e114"*/ "\e152";
}
.sort-numerical a.asc:after {
content: "\e153";
}
.sort-numerical a.desc:after {
content: "\e154";
}
.sort-ordinal a.asc:after {
content: "\e155";
}
.sort-ordinal a.desc:after {
content: "\e156";
}
.grid-view th {
white-space: nowrap;
}
.hint-block {
display: block;
margin-top: 5px;
color: #999;
}
.error-summary {
color: #a94442;
background: #fdf7f7;
border-left: 3px solid #eed3d7;
padding: 10px 20px;
margin: 0 0 15px 0;
}

BIN
apps/advanced/backend/web/favicon.ico

Binary file not shown.

Before

Width:  |  Height:  |  Size: 318 B

2
apps/advanced/backend/web/robots.txt

@ -1,2 +0,0 @@
User-Agent: *
Disallow: /

11
apps/advanced/codeception.yml

@ -1,11 +0,0 @@
include:
- common
- console
- backend
- frontend
paths:
log: tests/_log
settings:
colors: true

20
apps/advanced/common/codeception.yml

@ -1,20 +0,0 @@
namespace: common
actor: Tester
paths:
tests: tests
log: tests/_log
data: tests/_data
helpers: tests/_helpers
settings:
bootstrap: _bootstrap.php
suite_class: \PHPUnit_Framework_TestSuite
colors: true
memory_limit: 1024M
log: true
modules:
config:
Db:
dsn: ''
user: ''
password: ''
dump: tests/_data/dump.sql

2
apps/advanced/common/config/.gitignore vendored

@ -1,2 +0,0 @@
main-local.php
params-local.php

5
apps/advanced/common/config/aliases.php

@ -1,5 +0,0 @@
<?php
Yii::setAlias('common', dirname(__DIR__));
Yii::setAlias('frontend', dirname(dirname(__DIR__)) . '/frontend');
Yii::setAlias('backend', dirname(dirname(__DIR__)) . '/backend');
Yii::setAlias('console', dirname(dirname(__DIR__)) . '/console');

9
apps/advanced/common/config/main.php

@ -1,9 +0,0 @@
<?php
return [
'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',
'components' => [
'cache' => [
'class' => 'yii\caching\FileCache',
],
],
];

6
apps/advanced/common/config/params.php

@ -1,6 +0,0 @@
<?php
return [
'adminEmail' => 'admin@example.com',
'supportEmail' => 'support@example.com',
'user.passwordResetTokenExpire' => 3600,
];

22
apps/advanced/common/mail/layouts/html.php

@ -1,22 +0,0 @@
<?php
use yii\helpers\Html;
/* @var $this \yii\web\View view component instance */
/* @var $message \yii\mail\MessageInterface the message being composed */
/* @var $content string main view render result */
?>
<?php $this->beginPage() ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?= Yii::$app->charset ?>" />
<title><?= Html::encode($this->title) ?></title>
<?php $this->head() ?>
</head>
<body>
<?php $this->beginBody() ?>
<?= $content ?>
<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>

14
apps/advanced/common/mail/passwordResetToken.php

@ -1,14 +0,0 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $user common\models\User */
$resetLink = Yii::$app->urlManager->createAbsoluteUrl(['site/reset-password', 'token' => $user->password_reset_token]);
?>
Hello <?= Html::encode($user->username) ?>,
Follow the link below to reset your password:
<?= Html::a(Html::encode($resetLink), $resetLink) ?>

77
apps/advanced/common/models/LoginForm.php

@ -1,77 +0,0 @@
<?php
namespace common\models;
use Yii;
use yii\base\Model;
/**
* Login form
*/
class LoginForm extends Model
{
public $username;
public $password;
public $rememberMe = true;
private $_user = false;
/**
* @inheritdoc
*/
public function rules()
{
return [
// username and password are both required
[['username', 'password'], 'required'],
// rememberMe must be a boolean value
['rememberMe', 'boolean'],
// password is validated by validatePassword()
['password', 'validatePassword'],
];
}
/**
* Validates the password.
* This method serves as the inline validation for password.
*
* @param string $attribute the attribute currently being validated
* @param array $params the additional name-value pairs given in the rule
*/
public function validatePassword($attribute, $params)
{
if (!$this->hasErrors()) {
$user = $this->getUser();
if (!$user || !$user->validatePassword($this->password)) {
$this->addError($attribute, 'Incorrect username or password.');
}
}
}
/**
* Logs in a user using the provided username and password.
*
* @return boolean whether the user is logged in successfully
*/
public function login()
{
if ($this->validate()) {
return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600 * 24 * 30 : 0);
} else {
return false;
}
}
/**
* Finds user by [[username]]
*
* @return User|null
*/
public function getUser()
{
if ($this->_user === false) {
$this->_user = User::findByUsername($this->username);
}
return $this->_user;
}
}

180
apps/advanced/common/models/User.php

@ -1,180 +0,0 @@
<?php
namespace common\models;
use Yii;
use yii\base\NotSupportedException;
use yii\behaviors\TimestampBehavior;
use yii\db\ActiveRecord;
use yii\web\IdentityInterface;
/**
* User model
*
* @property integer $id
* @property string $username
* @property string $password_hash
* @property string $password_reset_token
* @property string $email
* @property string $auth_key
* @property integer $role
* @property integer $status
* @property integer $created_at
* @property integer $updated_at
* @property string $password write-only password
*/
class User extends ActiveRecord implements IdentityInterface
{
const STATUS_DELETED = 0;
const STATUS_ACTIVE = 10;
const ROLE_USER = 10;
/**
* @inheritdoc
*/
public static function tableName()
{
return '{{%user}}';
}
/**
* @inheritdoc
*/
public function behaviors()
{
return [
TimestampBehavior::className(),
];
}
/**
* @inheritdoc
*/
public function rules()
{
return [
['status', 'default', 'value' => self::STATUS_ACTIVE],
['status', 'in', 'range' => [self::STATUS_ACTIVE, self::STATUS_DELETED]],
['role', 'default', 'value' => self::ROLE_USER],
['role', 'in', 'range' => [self::ROLE_USER]],
];
}
/**
* @inheritdoc
*/
public static function findIdentity($id)
{
return static::findOne(['id' => $id, 'status' => self::STATUS_ACTIVE]);
}
/**
* @inheritdoc
*/
public static function findIdentityByAccessToken($token, $type = null)
{
throw new NotSupportedException('"findIdentityByAccessToken" is not implemented.');
}
/**
* Finds user by username
*
* @param string $username
* @return static|null
*/
public static function findByUsername($username)
{
return static::findOne(['username' => $username, 'status' => self::STATUS_ACTIVE]);
}
/**
* Finds user by password reset token
*
* @param string $token password reset token
* @return static|null
*/
public static function findByPasswordResetToken($token)
{
$expire = Yii::$app->params['user.passwordResetTokenExpire'];
$parts = explode('_', $token);
$timestamp = (int) end($parts);
if ($timestamp + $expire < time()) {
// token expired
return null;
}
return static::findOne([
'password_reset_token' => $token,
'status' => self::STATUS_ACTIVE,
]);
}
/**
* @inheritdoc
*/
public function getId()
{
return $this->getPrimaryKey();
}
/**
* @inheritdoc
*/
public function getAuthKey()
{
return $this->auth_key;
}
/**
* @inheritdoc
*/
public function validateAuthKey($authKey)
{
return $this->getAuthKey() === $authKey;
}
/**
* Validates password
*
* @param string $password password to validate
* @return boolean if password provided is valid for current user
*/
public function validatePassword($password)
{
return Yii::$app->security->validatePassword($password, $this->password_hash);
}
/**
* Generates password hash from password and sets it to the model
*
* @param string $password
*/
public function setPassword($password)
{
$this->password_hash = Yii::$app->security->generatePasswordHash($password);
}
/**
* Generates "remember me" authentication key
*/
public function generateAuthKey()
{
$this->auth_key = Yii::$app->security->generateRandomString();
}
/**
* Generates new password reset token
*/
public function generatePasswordResetToken()
{
$this->password_reset_token = Yii::$app->security->generateRandomString() . '_' . time();
}
/**
* Removes password reset token
*/
public function removePasswordResetToken()
{
$this->password_reset_token = null;
}
}

4
apps/advanced/common/tests/.gitignore vendored

@ -1,4 +0,0 @@
# these files are auto generated by codeception build
/unit/CodeGuy.php
/functional/TestGuy.php
/acceptance/WebGuy.php

14
apps/advanced/common/tests/_bootstrap.php

@ -1,14 +0,0 @@
<?php
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'test');
require_once(__DIR__ . '/../../vendor/autoload.php');
require_once(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
require(__DIR__ . '/../../common/config/aliases.php');
// set correct script paths
$_SERVER['SERVER_NAME'] = 'localhost';

14
apps/advanced/common/tests/_config.php

@ -1,14 +0,0 @@
<?php
/**
* application configurations shared by all test types
*/
return [
'components' => [
'mailer' => [
'useFileTransport' => true,
],
'urlManager' => [
'showScriptName' => true,
],
],
];

19
apps/advanced/common/tests/_console.php

@ -1,19 +0,0 @@
<?php
/**
* Yii console bootstrap file.
*
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
// fcgi doesn't have STDIN and STDOUT defined by default
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r'));
defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w'));
require_once(__DIR__ . '/../../vendor/autoload.php');
require_once(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
require_once(__DIR__ . '/../../common/config/aliases.php');
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'test');

1
apps/advanced/common/tests/_data/dump.sql

@ -1 +0,0 @@
/* Replace this file with actual dump of your database */

60
apps/advanced/common/tests/_helpers/FixtureHelper.php

@ -1,60 +0,0 @@
<?php
namespace common\tests\_helpers;
use Codeception\Module;
use yii\test\FixtureTrait;
use common\tests\fixtures\UserFixture;
/**
* This helper is used to populate database with needed fixtures before any tests should be run.
* For example - populate database with demo login user that should be used in acceptance and functional tests.
* All fixtures will be loaded before suite will be starded and unloaded after it.
*/
class FixtureHelper extends Module
{
/**
* Redeclare visibility because codeception includes all public methods that not starts from "_"
* and not excluded by module settings, in guy class.
*/
use FixtureTrait {
loadFixtures as protected;
fixtures as protected;
globalFixtures as protected;
unloadFixtures as protected;
getFixtures as protected;
getFixture as protected;
}
/**
* Method called before any suite tests run. Loads User fixture login user
* to use in acceptance and functional tests.
* @param array $settings
*/
public function _beforeSuite($settings = [])
{
$this->loadFixtures();
}
/**
* Method is called after all suite tests run
*/
public function _afterSuite()
{
$this->unloadFixtures();
}
/**
* @inheritdoc
*/
public function fixtures()
{
return [
'user' => [
'class' => UserFixture::className(),
'dataFile' => '@common/tests/fixtures/data/init_login.php',
],
];
}
}

2
apps/advanced/common/tests/_log/.gitignore vendored

@ -1,2 +0,0 @@
*
!.gitignore

21
apps/advanced/common/tests/_pages/LoginPage.php

@ -1,21 +0,0 @@
<?php
namespace common\tests\_pages;
use yii\codeception\BasePage;
class LoginPage extends BasePage
{
public $route = 'site/login';
/**
* @param string $username
* @param string $password
*/
public function login($username, $password)
{
$this->guy->fillField('input[name="LoginForm[username]"]', $username);
$this->guy->fillField('input[name="LoginForm[password]"]', $password);
$this->guy->click('login-button');
}
}

10
apps/advanced/common/tests/fixtures/UserFixture.php vendored

@ -1,10 +0,0 @@
<?php
namespace common\tests\fixtures;
use yii\test\ActiveFixture;
class UserFixture extends ActiveFixture
{
public $modelClass = 'common\models\User';
}

14
apps/advanced/common/tests/fixtures/data/init_login.php vendored

@ -1,14 +0,0 @@
<?php
return [
[
'username' => 'erau',
'auth_key' => 'tUu1qHcde0diwUol3xeI-18MuHkkprQI',
// password_0
'password_hash' => '$2y$13$nJ1WDlBaGcbCdbNC5.5l4.sgy.OMEKCqtDQOdQ2OWpgiKRWYyzzne',
'password_reset_token' => 'RkD_Jw0_8HEedzLk7MM-ZKEFfYR7VbMr_1392559490',
'created_at' => '1392559490',
'updated_at' => '1392559490',
'email' => 'sfriesen@jenkins.info',
],
];

17
apps/advanced/common/tests/templates/fixtures/user.php

@ -1,17 +0,0 @@
<?php
/**
* @var $faker \Faker\Generator
* @var $index integer
*/
$security = Yii::$app->getSecurity();
return [
'username' => $faker->userName,
'email' => $faker->email,
'auth_key' => $security->generateRandomString(),
'password_hash' => $security->generatePasswordHash('password_' . $index),
'password_reset_token' => $security->generateRandomString() . '_' . time(),
'created_at' => time(),
'updated_at' => time(),
];

6
apps/advanced/common/tests/unit.suite.yml

@ -1,6 +0,0 @@
# Codeception Test Suite Configuration
# suite for unit (internal) tests.
# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
class_name: CodeGuy

8
apps/advanced/common/tests/unit/DbTestCase.php

@ -1,8 +0,0 @@
<?php
namespace common\tests\unit;
class DbTestCase extends \yii\codeception\DbTestCase
{
public $appConfig = '@common/tests/unit/_config.php';
}

8
apps/advanced/common/tests/unit/TestCase.php

@ -1,8 +0,0 @@
<?php
namespace common\tests\unit;
class TestCase extends \yii\codeception\TestCase
{
public $appConfig = '@common/tests/unit/_config.php';
}

2
apps/advanced/common/tests/unit/_bootstrap.php

@ -1,2 +0,0 @@
<?php
// Here you can initialize variables that will for your tests

16
apps/advanced/common/tests/unit/_config.php

@ -1,16 +0,0 @@
<?php
return yii\helpers\ArrayHelper::merge(
require(__DIR__ . '/../../config/main.php'),
require(__DIR__ . '/../../config/main-local.php'),
require(__DIR__ . '/../_config.php'),
[
'components' => [
'db' => [
'dsn' => 'mysql:host=localhost;dbname=yii2_advanced_unit',
],
],
'id' => 'app-common',
'basePath' => dirname(__DIR__),
]
);

22
apps/advanced/common/tests/unit/_console.php

@ -1,22 +0,0 @@
<?php
return yii\helpers\ArrayHelper::merge(
require(__DIR__ . '/../../../console/config/main.php'),
require(__DIR__ . '/../../../console/config/main-local.php'),
require(__DIR__ . '/../../config/main.php'),
require(__DIR__ . '/../../config/main-local.php'),
[
'components' => [
'db' => [
'dsn' => 'mysql:host=localhost;dbname=yii2_advanced_unit',
],
],
'controllerMap' => [
'fixture' => [
'class' => 'yii\faker\FixtureController',
'fixtureDataPath' => '@common/tests/unit/fixtures/data',
'templatePath' => '@common/tests/templates/fixtures'
],
],
]
);

14
apps/advanced/common/tests/unit/fixtures/data/models/user.php

@ -1,14 +0,0 @@
<?php
return [
[
'username' => 'bayer.hudson',
'auth_key' => 'HP187Mvq7Mmm3CTU80dLkGmni_FUH_lR',
//password_0
'password_hash' => '$2y$13$EjaPFBnZOQsHdGuHI.xvhuDp1fHpo8hKRSk6yshqa9c5EG8s3C3lO',
'password_reset_token' => 'ExzkCOaYc1L8IOBs4wdTGGbgNiG3Wz1I_1402312317',
'created_at' => '1402312317',
'updated_at' => '1402312317',
'email' => 'nicole.paucek@schultz.info',
],
];

88
apps/advanced/common/tests/unit/models/LoginFormTest.php

@ -1,88 +0,0 @@
<?php
namespace common\tests\unit\models;
use Yii;
use common\tests\unit\DbTestCase;
use Codeception\Specify;
use common\models\LoginForm;
use common\tests\fixtures\UserFixture;
class LoginFormTest extends DbTestCase
{
use Specify;
public function setUp()
{
parent::setUp();
Yii::configure(Yii::$app, [
'components' => [
'user' => [
'class' => 'yii\web\User',
'identityClass' => 'common\models\User',
],
],
]);
}
protected function tearDown()
{
Yii::$app->user->logout();
parent::tearDown();
}
public function testLoginNoUser()
{
$model = new LoginForm([
'username' => 'not_existing_username',
'password' => 'not_existing_password',
]);
$this->specify('user should not be able to login, when there is no identity', function () use ($model) {
expect('model should not login user', $model->login())->false();
expect('user should not be logged in', Yii::$app->user->isGuest)->true();
});
}
public function testLoginWrongPassword()
{
$model = new LoginForm([
'username' => 'bayer.hudson',
'password' => 'wrong_password',
]);
$this->specify('user should not be able to login with wrong password', function () use ($model) {
expect('model should not login user', $model->login())->false();
expect('error message should be set', $model->errors)->hasKey('password');
expect('user should not be logged in', Yii::$app->user->isGuest)->true();
});
}
public function testLoginCorrect()
{
$model = new LoginForm([
'username' => 'bayer.hudson',
'password' => 'password_0',
]);
$this->specify('user should be able to login with correct credentials', function () use ($model) {
expect('model should login user', $model->login())->true();
expect('error message should not be set', $model->errors)->hasntKey('password');
expect('user should be logged in', Yii::$app->user->isGuest)->false();
});
}
public function fixtures()
{
return [
'user' => [
'class' => UserFixture::className(),
'dataFile' => '@common/tests/unit/fixtures/data/models/user.php'
],
];
}
}

21
apps/advanced/common/tests/unit/yii

@ -1,21 +0,0 @@
#!/usr/bin/env php
<?php
/**
* Yii console bootstrap file.
*
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
// fcgi doesn't have STDIN and STDOUT defined by default
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r'));
defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w'));
require_once(__DIR__ . '/../_console.php');
$config = require(__DIR__ . '/_console.php');
$application = new yii\console\Application($config);
$exitCode = $application->run();
exit($exitCode);

20
apps/advanced/common/tests/unit/yii.bat

@ -1,20 +0,0 @@
@echo off
rem -------------------------------------------------------------
rem Yii command line bootstrap script for Windows.
rem
rem @author Qiang Xue <qiang.xue@gmail.com>
rem @link http://www.yiiframework.com/
rem @copyright Copyright &copy; 2012 Yii Software LLC
rem @license http://www.yiiframework.com/license/
rem -------------------------------------------------------------
@setlocal
set YII_PATH=%~dp0
if "%PHP_COMMAND%" == "" set PHP_COMMAND=php.exe
"%PHP_COMMAND%" "%YII_PATH%yii" %*
@endlocal

50
apps/advanced/composer.json

@ -1,50 +0,0 @@
{
"name": "yiisoft/yii2-app-advanced",
"description": "Yii 2 Advanced Application Template",
"keywords": ["yii2", "framework", "advanced", "application template"],
"homepage": "http://www.yiiframework.com/",
"type": "project",
"license": "BSD-3-Clause",
"support": {
"issues": "https://github.com/yiisoft/yii2/issues?state=open",
"forum": "http://www.yiiframework.com/forum/",
"wiki": "http://www.yiiframework.com/wiki/",
"irc": "irc://irc.freenode.net/yii",
"source": "https://github.com/yiisoft/yii2"
},
"minimum-stability": "dev",
"require": {
"php": ">=5.4.0",
"yiisoft/yii2": "*",
"yiisoft/yii2-bootstrap": "*",
"yiisoft/yii2-swiftmailer": "*"
},
"require-dev": {
"yiisoft/yii2-codeception": "*",
"yiisoft/yii2-debug": "*",
"yiisoft/yii2-gii": "*"
},
"suggest": {
"codeception/codeception": "Codeception, 2.0.* is currently works well with Yii.",
"codeception/specify": "BDD style code blocks for PHPUnit and Codeception",
"codeception/verify": "BDD Assertions for PHPUnit and Codeception",
"yiisoft/yii2-faker": "Fixtures generator for Yii2 based on Faker lib"
},
"scripts": {
"post-create-project-cmd": [
"yii\\composer\\Installer::setPermission"
]
},
"config": {
"process-timeout": 1800
},
"extra": {
"writable": [
"backend/runtime",
"backend/web/assets",
"frontend/runtime",
"frontend/web/assets"
]
}
}

20
apps/advanced/console/codeception.yml

@ -1,20 +0,0 @@
namespace: console
actor: Tester
paths:
tests: tests
log: tests/_log
data: tests/_data
helpers: tests/_helpers
settings:
bootstrap: _bootstrap.php
suite_class: \PHPUnit_Framework_TestSuite
colors: true
memory_limit: 1024M
log: true
modules:
config:
Db:
dsn: ''
user: ''
password: ''
dump: tests/_data/dump.sql

2
apps/advanced/console/config/.gitignore vendored

@ -1,2 +0,0 @@
main-local.php
params-local.php

26
apps/advanced/console/config/main.php

@ -1,26 +0,0 @@
<?php
$params = array_merge(
require(__DIR__ . '/../../common/config/params.php'),
require(__DIR__ . '/../../common/config/params-local.php'),
require(__DIR__ . '/params.php'),
require(__DIR__ . '/params-local.php')
);
return [
'id' => 'app-console',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'controllerNamespace' => 'console\controllers',
'modules' => [],
'components' => [
'log' => [
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
],
'params' => $params,
];

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

@ -1,4 +0,0 @@
<?php
return [
'adminEmail' => 'admin@example.com',
];

0
apps/advanced/console/controllers/.gitkeep

34
apps/advanced/console/migrations/m130524_201442_init.php

@ -1,34 +0,0 @@
<?php
use yii\db\Schema;
use yii\db\Migration;
class m130524_201442_init extends Migration
{
public function up()
{
$tableOptions = null;
if ($this->db->driverName === 'mysql') {
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
}
$this->createTable('{{%user}}', [
'id' => Schema::TYPE_PK,
'username' => Schema::TYPE_STRING . ' NOT NULL',
'auth_key' => Schema::TYPE_STRING . '(32) NOT NULL',
'password_hash' => Schema::TYPE_STRING . ' NOT NULL',
'password_reset_token' => Schema::TYPE_STRING,
'email' => Schema::TYPE_STRING . ' NOT NULL',
'role' => Schema::TYPE_SMALLINT . ' NOT NULL DEFAULT 10',
'status' => Schema::TYPE_SMALLINT . ' NOT NULL DEFAULT 10',
'created_at' => Schema::TYPE_INTEGER . ' NOT NULL',
'updated_at' => Schema::TYPE_INTEGER . ' NOT NULL',
], $tableOptions);
}
public function down()
{
$this->dropTable('{{%user}}');
}
}

1
apps/advanced/console/models/.gitkeep

@ -1 +0,0 @@
*

2
apps/advanced/console/runtime/.gitignore vendored

@ -1,2 +0,0 @@
*
!.gitignore

2
apps/advanced/console/tests/.gitignore vendored

@ -1,2 +0,0 @@
# these files are auto generated by codeception build
/unit/CodeGuy.php

14
apps/advanced/console/tests/_bootstrap.php

@ -1,14 +0,0 @@
<?php
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'test');
require_once(__DIR__ . '/../../vendor/autoload.php');
require_once(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
require(__DIR__ . '/../../common/config/aliases.php');
// set correct script paths
$_SERVER['SERVER_NAME'] = 'localhost';

14
apps/advanced/console/tests/_config.php

@ -1,14 +0,0 @@
<?php
/**
* application configurations shared by all test types
*/
return [
'components' => [
'mailer' => [
'useFileTransport' => true,
],
'urlManager' => [
'showScriptName' => true,
],
],
];

19
apps/advanced/console/tests/_console.php

@ -1,19 +0,0 @@
<?php
/**
* Yii console bootstrap file.
*
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
// fcgi doesn't have STDIN and STDOUT defined by default
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r'));
defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w'));
require_once(__DIR__ . '/../../vendor/autoload.php');
require_once(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
require_once(__DIR__ . '/../../common/config/aliases.php');
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'test');

1
apps/advanced/console/tests/_data/dump.sql

@ -1 +0,0 @@
/* Replace this file with actual dump of your database */

2
apps/advanced/console/tests/_log/.gitignore vendored

@ -1,2 +0,0 @@
*
!.gitignore

6
apps/advanced/console/tests/unit.suite.yml

@ -1,6 +0,0 @@
# Codeception Test Suite Configuration
# suite for unit (internal) tests.
# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
class_name: CodeGuy

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save