Commit 01ebf78ca49d7aae7a6d51922c6636191fddcb16

Authored by Administrator
0 parents

Initial commit

Showing 210 changed files with 6138 additions and 0 deletions   Show diff stats
LICENSE.md 0 → 100644
  1 +++ a/LICENSE.md
  1 +The Yii framework is free software. It is released under the terms of
  2 +the following BSD License.
  3 +
  4 +Copyright © 2008 by Yii Software LLC (http://www.yiisoft.com)
  5 +All rights reserved.
  6 +
  7 +Redistribution and use in source and binary forms, with or without
  8 +modification, are permitted provided that the following conditions
  9 +are met:
  10 +
  11 + * Redistributions of source code must retain the above copyright
  12 + notice, this list of conditions and the following disclaimer.
  13 + * Redistributions in binary form must reproduce the above copyright
  14 + notice, this list of conditions and the following disclaimer in
  15 + the documentation and/or other materials provided with the
  16 + distribution.
  17 + * Neither the name of Yii Software LLC nor the names of its
  18 + contributors may be used to endorse or promote products derived
  19 + from this software without specific prior written permission.
  20 +
  21 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  24 +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  25 +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  26 +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  27 +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  28 +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  29 +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  30 +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  31 +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  32 +POSSIBILITY OF SUCH DAMAGE.
README.md 0 → 100644
  1 +++ a/README.md
  1 +Yii 2 Advanced Project Template
  2 +===============================
  3 +
  4 +Yii 2 Advanced Project Template is a skeleton [Yii 2](http://www.yiiframework.com/) application best for
  5 +developing complex Web applications with multiple tiers.
  6 +
  7 +The template includes three tiers: front end, back end, and console, each of which
  8 +is a separate Yii application.
  9 +
  10 +The template is designed to work in a team development environment. It supports
  11 +deploying the application in different environments.
  12 +
  13 +[![Latest Stable Version](https://poser.pugx.org/yiisoft/yii2-app-advanced/v/stable.png)](https://packagist.org/packages/yiisoft/yii2-app-advanced)
  14 +[![Total Downloads](https://poser.pugx.org/yiisoft/yii2-app-advanced/downloads.png)](https://packagist.org/packages/yiisoft/yii2-app-advanced)
  15 +[![Build Status](https://travis-ci.org/yiisoft/yii2-app-advanced.svg?branch=master)](https://travis-ci.org/yiisoft/yii2-app-advanced)
  16 +
  17 +DIRECTORY STRUCTURE
  18 +-------------------
  19 +
  20 +```
  21 +common
  22 + config/ contains shared configurations
  23 + mail/ contains view files for e-mails
  24 + models/ contains model classes used in both backend and frontend
  25 +console
  26 + config/ contains console configurations
  27 + controllers/ contains console controllers (commands)
  28 + migrations/ contains database migrations
  29 + models/ contains console-specific model classes
  30 + runtime/ contains files generated during runtime
  31 +backend
  32 + assets/ contains application assets such as JavaScript and CSS
  33 + config/ contains backend configurations
  34 + controllers/ contains Web controller classes
  35 + models/ contains backend-specific model classes
  36 + runtime/ contains files generated during runtime
  37 + views/ contains view files for the Web application
  38 + web/ contains the entry script and Web resources
  39 +frontend
  40 + assets/ contains application assets such as JavaScript and CSS
  41 + config/ contains frontend configurations
  42 + controllers/ contains Web controller classes
  43 + models/ contains frontend-specific model classes
  44 + runtime/ contains files generated during runtime
  45 + views/ contains view files for the Web application
  46 + web/ contains the entry script and Web resources
  47 + widgets/ contains frontend widgets
  48 +vendor/ contains dependent 3rd-party packages
  49 +environments/ contains environment-based overrides
  50 +tests contains various tests for the advanced application
  51 + codeception/ contains tests developed with Codeception PHP Testing Framework
  52 +```
backend/assets/AppAsset.php 0 → 100644
  1 +++ a/backend/assets/AppAsset.php
  1 +<?php
  2 +/**
  3 + * @link http://www.yiiframework.com/
  4 + * @copyright Copyright (c) 2008 Yii Software LLC
  5 + * @license http://www.yiiframework.com/license/
  6 + */
  7 +
  8 +namespace backend\assets;
  9 +
  10 +use yii\web\AssetBundle;
  11 +
  12 +/**
  13 + * @author Qiang Xue <qiang.xue@gmail.com>
  14 + * @since 2.0
  15 + */
  16 +class AppAsset extends AssetBundle
  17 +{
  18 + public $basePath = '@webroot';
  19 + public $baseUrl = '@web';
  20 + public $css = [
  21 + 'css/site.css',
  22 + ];
  23 + public $js = [
  24 + 'js/main.js',
  25 + ];
  26 + public $depends = [
  27 + 'yii\web\YiiAsset',
  28 + 'yii\bootstrap\BootstrapAsset',
  29 + 'yii\web\JqueryAsset',
  30 + ];
  31 +}
backend/components/ConstantTrait.php 0 → 100644
  1 +++ a/backend/components/ConstantTrait.php
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: denys
  5 + * Date: 20.10.15
  6 + * Time: 15:48
  7 + */
  8 +
  9 +namespace backend\components;
  10 +
  11 +use ReflectionClass;
  12 +
  13 +trait ConstantTrait
  14 +{
  15 + public function getConstants()
  16 + {
  17 + $oClass = new ReflectionClass(get_class($this));
  18 + return $oClass->getConstants();
  19 + }
  20 +}
0 \ No newline at end of file 21 \ No newline at end of file
backend/components/croppers/AbstractCrop.php 0 → 100644
  1 +++ a/backend/components/croppers/AbstractCrop.php
  1 +<?php
  2 +
  3 +namespace backend\components\croppers;
  4 +
  5 +
  6 +use backend\components\ConstantTrait;
  7 +use Imagine\Image\Box;
  8 +use Imagine\Image\Point;
  9 +
  10 +abstract class AbstractCrop
  11 +{
  12 + use ConstantTrait;
  13 +
  14 + public function crop($image, $path)
  15 + {
  16 + $image->crop(new Point(static::X, static::Y), new Box(static::WIDTH, static::HEIGHT))
  17 + ->save($path);
  18 + }
  19 +}
0 \ No newline at end of file 20 \ No newline at end of file
backend/components/croppers/CropContext.php 0 → 100644
  1 +++ a/backend/components/croppers/CropContext.php
  1 +<?php
  2 +
  3 +namespace backend\components\croppers;
  4 +
  5 +
  6 +class CropContext
  7 +{
  8 + /**
  9 + * @var CropInterface
  10 + */
  11 + private $cropper;
  12 +
  13 + public function __construct(AbstractCrop $abstractCrop) {
  14 + $this->cropper = $abstractCrop;
  15 + }
  16 +
  17 + public function cropImage($image, $path) {
  18 + $this->cropper->crop($image, $path);
  19 + }
  20 +}
0 \ No newline at end of file 21 \ No newline at end of file
backend/components/croppers/CropFactory.php 0 → 100644
  1 +++ a/backend/components/croppers/CropFactory.php
  1 +<?php
  2 +
  3 +namespace backend\components\croppers;
  4 +
  5 +use Yii;
  6 +
  7 +class CropFactory
  8 +{
  9 + private static $instance;
  10 + private $crops = [];
  11 +
  12 + private function __construct() {
  13 + $this->init();
  14 + }
  15 +
  16 + private function init() {
  17 + $this->crops[] = new EconomixCrop();
  18 + $this->crops[] = new GoldenGardenFlowersCrop();
  19 + $this->crops[] = new GoldenGardenVegiesCrop();
  20 + $this->crops[] = new GoldenGardenGiantCrop();
  21 + $this->crops[] = new UkrSeedsNovikGiantCrop();
  22 + $this->crops[] = new UkrSeedsNovikMiniCrop();
  23 + $this->crops[] = new UkrSeedsNovikVegiesCrop();
  24 + $this->crops[] = new UkrSeedsNovikFlowersCrop();
  25 + $this->crops[] = new UkrSeedsTekVegiesCrop();
  26 + $this->crops[] = new UkrSeedsFloraMiniCrop();
  27 + $this->crops[] = new UkrSeedsFloraVegiesCrop();
  28 + }
  29 +
  30 + public function getCrop($crop_id) {
  31 + return $this->crops[$crop_id];
  32 + }
  33 +
  34 + public static function getInstance() {
  35 + if (null === self::$instance) {
  36 + self::$instance = new self();
  37 + }
  38 + return self::$instance;
  39 + }
  40 +}
0 \ No newline at end of file 41 \ No newline at end of file
backend/components/croppers/EconomixCrop.php 0 → 100644
  1 +++ a/backend/components/croppers/EconomixCrop.php
  1 +<?php
  2 +
  3 +namespace backend\components\croppers;
  4 +
  5 +
  6 +/**
  7 + * Class EconomixCrop
  8 + * Economix Flora 70x120
  9 + * @package backend\components\croppers
  10 + */
  11 +class EconomixCrop extends AbstractCrop
  12 +{
  13 + const WIDTH = 296;
  14 + const HEIGHT = 500;
  15 + const X = 302;
  16 + const Y = 599;
  17 + /* previous
  18 + * const WIDTH = 394;
  19 + const HEIGHT = 666;
  20 + const X = 598;
  21 + const Y = 799;*/
  22 +}
0 \ No newline at end of file 23 \ No newline at end of file
backend/components/croppers/GoldenGardenFlowersCrop.php 0 → 100644
  1 +++ a/backend/components/croppers/GoldenGardenFlowersCrop.php
  1 +<?php
  2 +
  3 +namespace backend\components\croppers;
  4 +
  5 +
  6 +class GoldenGardenFlowersCrop extends AbstractCrop
  7 +{
  8 + const WIDTH = 946;
  9 + const HEIGHT = 1773;
  10 + const X = 235;
  11 + const Y = 1746;
  12 +}
0 \ No newline at end of file 13 \ No newline at end of file
backend/components/croppers/GoldenGardenGiantCrop.php 0 → 100644
  1 +++ a/backend/components/croppers/GoldenGardenGiantCrop.php
  1 +<?php
  2 +
  3 +namespace backend\components\croppers;
  4 +
  5 +
  6 +class GoldenGardenGiantCrop extends AbstractCrop
  7 +{
  8 +
  9 +}
0 \ No newline at end of file 10 \ No newline at end of file
backend/components/croppers/GoldenGardenVegiesCrop.php 0 → 100644
  1 +++ a/backend/components/croppers/GoldenGardenVegiesCrop.php
  1 +<?php
  2 +
  3 +namespace backend\components\croppers;
  4 +
  5 +
  6 +class GoldenGardenVegiesCrop extends AbstractCrop
  7 +{
  8 + const WIDTH = 946;
  9 + const HEIGHT = 1773;
  10 + const X = 827;
  11 + const Y = 1746;
  12 +}
0 \ No newline at end of file 13 \ No newline at end of file
backend/components/croppers/UkrSeedsFloraMiniCrop.php 0 → 100644
  1 +++ a/backend/components/croppers/UkrSeedsFloraMiniCrop.php
  1 +<?php
  2 +
  3 +namespace backend\components\croppers;
  4 +
  5 +
  6 +class UkrSeedsFloraMiniCrop extends AbstractCrop
  7 +{
  8 +
  9 +}
0 \ No newline at end of file 10 \ No newline at end of file
backend/components/croppers/UkrSeedsFloraVegiesCrop.php 0 → 100644
  1 +++ a/backend/components/croppers/UkrSeedsFloraVegiesCrop.php
  1 +<?php
  2 +
  3 +namespace backend\components\croppers;
  4 +
  5 +
  6 +class UkrSeedsFloraVegiesCrop extends AbstractCrop
  7 +{
  8 +
  9 +}
0 \ No newline at end of file 10 \ No newline at end of file
backend/components/croppers/UkrSeedsNovikFlowersCrop.php 0 → 100644
  1 +++ a/backend/components/croppers/UkrSeedsNovikFlowersCrop.php
  1 +<?php
  2 +
  3 +namespace backend\components\croppers;
  4 +
  5 +
  6 +class UkrSeedsNovikFlowersCrop extends AbstractCrop
  7 +{
  8 +
  9 +}
0 \ No newline at end of file 10 \ No newline at end of file
backend/components/croppers/UkrSeedsNovikGiantCrop.php 0 → 100644
  1 +++ a/backend/components/croppers/UkrSeedsNovikGiantCrop.php
  1 +<?php
  2 +
  3 +namespace backend\components\croppers;
  4 +
  5 +
  6 +class UkrSeedsNovikGiantCrop extends AbstractCrop
  7 +{
  8 +
  9 +}
0 \ No newline at end of file 10 \ No newline at end of file
backend/components/croppers/UkrSeedsNovikMiniCrop.php 0 → 100644
  1 +++ a/backend/components/croppers/UkrSeedsNovikMiniCrop.php
  1 +<?php
  2 +
  3 +namespace backend\components\croppers;
  4 +
  5 +
  6 +class UkrSeedsNovikMiniCrop extends AbstractCrop
  7 +{
  8 +
  9 +}
0 \ No newline at end of file 10 \ No newline at end of file
backend/components/croppers/UkrSeedsNovikVegiesCrop.php 0 → 100644
  1 +++ a/backend/components/croppers/UkrSeedsNovikVegiesCrop.php
  1 +<?php
  2 +
  3 +namespace backend\components\croppers;
  4 +
  5 +
  6 +class UkrSeedsNovikVegiesCrop extends AbstractCrop
  7 +{
  8 +
  9 +}
0 \ No newline at end of file 10 \ No newline at end of file
backend/components/croppers/UkrSeedsTekVegiesCrop.php 0 → 100644
  1 +++ a/backend/components/croppers/UkrSeedsTekVegiesCrop.php
  1 +<?php
  2 +
  3 +namespace backend\components\croppers;
  4 +
  5 +
  6 +class UkrSeedsTekVegiesCrop extends AbstractCrop
  7 +{
  8 +
  9 +}
0 \ No newline at end of file 10 \ No newline at end of file
backend/config/.gitignore 0 → 100644
  1 +++ a/backend/config/.gitignore
  1 +main-local.php
  2 +params-local.php
0 \ No newline at end of file 3 \ No newline at end of file
backend/config/bootstrap.php 0 → 100644
  1 +++ a/backend/config/bootstrap.php
  1 +<?php
backend/config/main.php 0 → 100644
  1 +++ a/backend/config/main.php
  1 +<?php
  2 +$params = array_merge(
  3 + require(__DIR__ . '/../../common/config/params.php'),
  4 + require(__DIR__ . '/../../common/config/params-local.php'),
  5 + require(__DIR__ . '/params.php'),
  6 + require(__DIR__ . '/params-local.php')
  7 +);
  8 +
  9 +return [
  10 + 'id' => 'app-backend',
  11 + 'basePath' => dirname(__DIR__),
  12 + 'controllerNamespace' => 'backend\controllers',
  13 + 'bootstrap' => ['log'],
  14 + 'modules' => [],
  15 + 'components' => [
  16 + 'imagine' => 'Imagine\Gd\Imagine',
  17 + 'user' => [
  18 + 'identityClass' => 'common\models\User',
  19 + 'enableAutoLogin' => true,
  20 + ],
  21 + 'log' => [
  22 + 'traceLevel' => YII_DEBUG ? 3 : 0,
  23 + 'targets' => [
  24 + [
  25 + 'class' => 'yii\log\FileTarget',
  26 + 'levels' => ['error', 'warning'],
  27 + ],
  28 + ],
  29 + ],
  30 + 'errorHandler' => [
  31 + 'errorAction' => 'site/error',
  32 + ],
  33 + ],
  34 + 'params' => $params,
  35 +];
backend/config/params.php 0 → 100644
  1 +++ a/backend/config/params.php
  1 +<?php
  2 +return [
  3 + 'adminEmail' => 'admin@example.com',
  4 + 'ukrSeeds' => [
  5 + 0 => 'Economix Flora 70x120',
  6 + 1 => 'GoldenGarden Novik Flowers 80x150',
  7 + 2 => 'GoldenGarden Novik Vegetables 80x150',
  8 + 3 => 'GoldenGarden Novik Giant 115x165',
  9 + 4 => 'UkrSeeds Novik Giant 115x165',
  10 + 5 => 'UkrSeeds Novik Mini 70x120',
  11 + 6 => 'UkrSeeds Novik Vegetables 80x150',
  12 + 7 => 'UkrSeeds Novik Flowers 80x150',
  13 + 8 => 'UkrSeeds Tek Vegetables 80x150',
  14 + 9 => 'UkrSeeds Flora Mini 70x120',
  15 + 10 => 'UkrSeeds Flora Vegetables 80x150',
  16 + ]
  17 +];
backend/controllers/ImageController.php 0 → 100644
  1 +++ a/backend/controllers/ImageController.php
  1 +<?php
  2 +
  3 +namespace backend\controllers;
  4 +
  5 +use backend\components\croppers\CropContext;
  6 +use backend\components\croppers\CropFactory;
  7 +
  8 +use Yii;
  9 +use yii\web\Controller;
  10 +use backend\models\UploadForm;
  11 +use yii\web\UploadedFile;
  12 +
  13 +class ImageController extends Controller
  14 +{
  15 + public function actionIndex()
  16 + {
  17 + $request = Yii::$app->request;
  18 + $model = new UploadForm();
  19 + $ukrSeeds = Yii::$app->params['ukrSeeds'];
  20 +
  21 + if ($request->isPost) {
  22 + $model->imageFiles = UploadedFile::getInstances($model, 'imageFiles');
  23 + $model->upload();
  24 +
  25 + $crop_id = $request->post('crop_id');
  26 +
  27 + $cropFactory = CropFactory::getInstance();
  28 + $cropContext = new CropContext($cropFactory->getCrop($crop_id));
  29 +
  30 + foreach($model->imageFiles as $file) {
  31 + $path = dirname(dirname(__DIR__)) . '/uploads/' . $file->baseName . '.' . $file->extension;
  32 + $image = Yii::$app->imagine->open($path);
  33 + $cropContext->cropImage($image, $path);
  34 + }
  35 + }
  36 + return $this->render('index', ['model' => $model, 'ukrSeeds' => $ukrSeeds]);
  37 + }
  38 +
  39 + public function actionGetParams($crop_id)
  40 + {
  41 + if (Yii::$app->request->isAjax) {
  42 +
  43 + $cropFactory = CropFactory::getInstance();
  44 +
  45 + $res = [
  46 + 'body' => $cropFactory->getCrop($crop_id)->getConstants(),
  47 + 'success' => true,
  48 + ];
  49 +
  50 + return json_encode($res);
  51 + }
  52 + }
  53 +}
0 \ No newline at end of file 54 \ No newline at end of file
backend/controllers/SiteController.php 0 → 100644
  1 +++ a/backend/controllers/SiteController.php
  1 +<?php
  2 +namespace backend\controllers;
  3 +
  4 +use Yii;
  5 +use yii\filters\AccessControl;
  6 +use yii\web\Controller;
  7 +use common\models\LoginForm;
  8 +use yii\filters\VerbFilter;
  9 +
  10 +/**
  11 + * Site controller
  12 + */
  13 +class SiteController extends Controller
  14 +{
  15 + /**
  16 + * @inheritdoc
  17 + */
  18 + public function behaviors()
  19 + {
  20 + return [
  21 + 'access' => [
  22 + 'class' => AccessControl::className(),
  23 + 'rules' => [
  24 + [
  25 + 'actions' => ['login', 'error'],
  26 + 'allow' => true,
  27 + ],
  28 + [
  29 + 'actions' => ['logout', 'index'],
  30 + 'allow' => true,
  31 + 'roles' => ['@'],
  32 + ],
  33 + ],
  34 + ],
  35 + 'verbs' => [
  36 + 'class' => VerbFilter::className(),
  37 + 'actions' => [
  38 + 'logout' => ['post'],
  39 + ],
  40 + ],
  41 + ];
  42 + }
  43 +
  44 + /**
  45 + * @inheritdoc
  46 + */
  47 + public function actions()
  48 + {
  49 + return [
  50 + 'error' => [
  51 + 'class' => 'yii\web\ErrorAction',
  52 + ],
  53 + ];
  54 + }
  55 +
  56 + public function actionIndex()
  57 + {
  58 + return $this->render('index');
  59 + }
  60 +
  61 + public function actionLogin()
  62 + {
  63 + if (!\Yii::$app->user->isGuest) {
  64 + return $this->goHome();
  65 + }
  66 +
  67 + $model = new LoginForm();
  68 + if ($model->load(Yii::$app->request->post()) && $model->login()) {
  69 + return $this->goBack();
  70 + } else {
  71 + return $this->render('login', [
  72 + 'model' => $model,
  73 + ]);
  74 + }
  75 + }
  76 +
  77 + public function actionLogout()
  78 + {
  79 + Yii::$app->user->logout();
  80 +
  81 + return $this->goHome();
  82 + }
  83 +}
backend/models/.gitkeep 0 → 100644
  1 +++ a/backend/models/.gitkeep
  1 +*
backend/models/UploadForm.php 0 → 100644
  1 +++ a/backend/models/UploadForm.php
  1 +<?php
  2 +namespace backend\models;
  3 +
  4 +use yii\base\Model;
  5 +use yii\web\UploadedFile;
  6 +
  7 +class UploadForm extends Model
  8 +{
  9 + public $imageFiles;
  10 +
  11 + public function rules()
  12 + {
  13 + return [
  14 + [['imageFiles'], 'file', 'skipOnEmpty' => false, 'extensions' => 'png, jpg', 'maxFiles' => 4],
  15 +
  16 + ];
  17 + }
  18 +
  19 + public function upload()
  20 + {
  21 + if ($this->validate()) {
  22 + foreach($this->imageFiles as $file) {
  23 + $path = dirname(dirname(__DIR__)) . '/uploads/' . $file->baseName . '.' . $file->extension;
  24 + $file->saveAs($path);
  25 + }
  26 + return true;
  27 + } else {
  28 + return false;
  29 + }
  30 + }
  31 +}
0 \ No newline at end of file 32 \ No newline at end of file
backend/runtime/.gitignore 0 → 100644
  1 +++ a/backend/runtime/.gitignore
  1 +*
  2 +!.gitignore
0 \ No newline at end of file 3 \ No newline at end of file
backend/views/image/index.php 0 → 100644
  1 +++ a/backend/views/image/index.php
  1 +<?php
  2 +
  3 +use \kartik\file\FileInput;
  4 +use yii\widgets\ActiveForm;
  5 +use yii\helpers\Html;
  6 +
  7 +/* @var $this yii\web\View */
  8 +$this->title = 'Image cropper';
  9 +?>
  10 +<?php $form = ActiveForm::begin(['options' => ['enctype'=>'multipart/form-data']]); ?>
  11 + <?= $form->field($model, 'imageFiles[]')->widget(FileInput::classname(), [
  12 + 'options' => ['accept' => 'image/*', 'multiple' => true],
  13 + 'language' => 'ru'
  14 + ]); ?>
  15 + <?= Html::dropDownList('crop_id', null, $ukrSeeds, ['id' => 'ukr_seeds']) ?>
  16 +<?php $form->end(); ?>
  17 +<?= Html::buttonInput('Draw', ['onclick' => 'js:draw();', 'style' => 'display : block']) ?>
  18 +<canvas/>
  19 +
  20 +
backend/views/layouts/main.php 0 → 100644
  1 +++ a/backend/views/layouts/main.php
  1 +<?php
  2 +use backend\assets\AppAsset;
  3 +use yii\helpers\Html;
  4 +use yii\bootstrap\Nav;
  5 +use yii\bootstrap\NavBar;
  6 +use yii\widgets\Breadcrumbs;
  7 +
  8 +/* @var $this \yii\web\View */
  9 +/* @var $content string */
  10 +
  11 +AppAsset::register($this);
  12 +?>
  13 +<?php $this->beginPage() ?>
  14 +<!DOCTYPE html>
  15 +<html lang="<?= Yii::$app->language ?>">
  16 +<head>
  17 + <meta charset="<?= Yii::$app->charset ?>">
  18 + <meta name="viewport" content="width=device-width, initial-scale=1">
  19 + <?= Html::csrfMetaTags() ?>
  20 + <title><?= Html::encode($this->title) ?></title>
  21 + <?php $this->head() ?>
  22 +</head>
  23 +<body>
  24 + <?php $this->beginBody() ?>
  25 + <div class="wrap">
  26 + <?php
  27 + NavBar::begin([
  28 + 'brandLabel' => 'My Company',
  29 + 'brandUrl' => Yii::$app->homeUrl,
  30 + 'options' => [
  31 + 'class' => 'navbar-inverse navbar-fixed-top',
  32 + ],
  33 + ]);
  34 + $menuItems = [
  35 + ['label' => 'Home', 'url' => ['/site/index']],
  36 + ];
  37 + if (Yii::$app->user->isGuest) {
  38 + $menuItems[] = ['label' => 'Login', 'url' => ['/site/login']];
  39 + } else {
  40 + $menuItems[] = [
  41 + 'label' => 'Logout (' . Yii::$app->user->identity->username . ')',
  42 + 'url' => ['/site/logout'],
  43 + 'linkOptions' => ['data-method' => 'post']
  44 + ];
  45 + }
  46 + echo Nav::widget([
  47 + 'options' => ['class' => 'navbar-nav navbar-right'],
  48 + 'items' => $menuItems,
  49 + ]);
  50 + NavBar::end();
  51 + ?>
  52 +
  53 + <div class="container">
  54 + <?= Breadcrumbs::widget([
  55 + 'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
  56 + ]) ?>
  57 + <?= $content ?>
  58 + </div>
  59 + </div>
  60 +
  61 + <footer class="footer">
  62 + <div class="container">
  63 + <p class="pull-left">&copy; My Company <?= date('Y') ?></p>
  64 + <p class="pull-right"><?= Yii::powered() ?></p>
  65 + </div>
  66 + </footer>
  67 +
  68 + <?php $this->endBody() ?>
  69 +</body>
  70 +</html>
  71 +<?php $this->endPage() ?>
backend/views/site/error.php 0 → 100644
  1 +++ a/backend/views/site/error.php
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +
  5 +/* @var $this yii\web\View */
  6 +/* @var $name string */
  7 +/* @var $message string */
  8 +/* @var $exception Exception */
  9 +
  10 +$this->title = $name;
  11 +?>
  12 +<div class="site-error">
  13 +
  14 + <h1><?= Html::encode($this->title) ?></h1>
  15 +
  16 + <div class="alert alert-danger">
  17 + <?= nl2br(Html::encode($message)) ?>
  18 + </div>
  19 +
  20 + <p>
  21 + The above error occurred while the Web server was processing your request.
  22 + </p>
  23 + <p>
  24 + Please contact us if you think this is a server error. Thank you.
  25 + </p>
  26 +
  27 +</div>
backend/views/site/index.php 0 → 100644
  1 +++ a/backend/views/site/index.php
  1 +<?php
  2 +/* @var $this yii\web\View */
  3 +
  4 +$this->title = 'My Yii Application';
  5 +?>
  6 +<div class="site-index">
  7 +
  8 + <div class="jumbotron">
  9 + <h1>Congratulations!</h1>
  10 +
  11 + <p class="lead">You have successfully created your Yii-powered application.</p>
  12 +
  13 + <p><a class="btn btn-lg btn-success" href="http://www.yiiframework.com">Get started with Yii</a></p>
  14 + </div>
  15 +
  16 + <div class="body-content">
  17 +
  18 + <div class="row">
  19 + <div class="col-lg-4">
  20 + <h2>Heading</h2>
  21 +
  22 + <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
  23 + dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
  24 + ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
  25 + fugiat nulla pariatur.</p>
  26 +
  27 + <p><a class="btn btn-default" href="http://www.yiiframework.com/doc/">Yii Documentation &raquo;</a></p>
  28 + </div>
  29 + <div class="col-lg-4">
  30 + <h2>Heading</h2>
  31 +
  32 + <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
  33 + dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
  34 + ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
  35 + fugiat nulla pariatur.</p>
  36 +
  37 + <p><a class="btn btn-default" href="http://www.yiiframework.com/forum/">Yii Forum &raquo;</a></p>
  38 + </div>
  39 + <div class="col-lg-4">
  40 + <h2>Heading</h2>
  41 +
  42 + <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
  43 + dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
  44 + ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
  45 + fugiat nulla pariatur.</p>
  46 +
  47 + <p><a class="btn btn-default" href="http://www.yiiframework.com/extensions/">Yii Extensions &raquo;</a></p>
  48 + </div>
  49 + </div>
  50 +
  51 + </div>
  52 +</div>
backend/views/site/login.php 0 → 100644
  1 +++ a/backend/views/site/login.php
  1 +<?php
  2 +use yii\helpers\Html;
  3 +use yii\bootstrap\ActiveForm;
  4 +
  5 +/* @var $this yii\web\View */
  6 +/* @var $form yii\bootstrap\ActiveForm */
  7 +/* @var $model \common\models\LoginForm */
  8 +
  9 +$this->title = 'Login';
  10 +$this->params['breadcrumbs'][] = $this->title;
  11 +?>
  12 +<div class="site-login">
  13 + <h1><?= Html::encode($this->title) ?></h1>
  14 +
  15 + <p>Please fill out the following fields to login:</p>
  16 +
  17 + <div class="row">
  18 + <div class="col-lg-5">
  19 + <?php $form = ActiveForm::begin(['id' => 'login-form']); ?>
  20 + <?= $form->field($model, 'username') ?>
  21 + <?= $form->field($model, 'password')->passwordInput() ?>
  22 + <?= $form->field($model, 'rememberMe')->checkbox() ?>
  23 + <div class="form-group">
  24 + <?= Html::submitButton('Login', ['class' => 'btn btn-primary', 'name' => 'login-button']) ?>
  25 + </div>
  26 + <?php ActiveForm::end(); ?>
  27 + </div>
  28 + </div>
  29 +</div>
backend/web/.gitignore 0 → 100644
  1 +++ a/backend/web/.gitignore
  1 +/index.php
  2 +/index-test.php
backend/web/assets/.gitignore 0 → 100644
  1 +++ a/backend/web/assets/.gitignore
  1 +*
  2 +!.gitignore
backend/web/css/site.css 0 → 100644
  1 +++ a/backend/web/css/site.css
  1 +html,
  2 +body {
  3 + height: 100%;
  4 +}
  5 +
  6 +.wrap {
  7 + min-height: 100%;
  8 + height: auto;
  9 + margin: 0 auto -60px;
  10 + padding: 0 0 60px;
  11 +}
  12 +
  13 +.wrap > .container {
  14 + padding: 70px 15px 20px;
  15 +}
  16 +
  17 +.footer {
  18 + height: 60px;
  19 + background-color: #f5f5f5;
  20 + border-top: 1px solid #ddd;
  21 + padding-top: 20px;
  22 +}
  23 +
  24 +.jumbotron {
  25 + text-align: center;
  26 + background-color: transparent;
  27 +}
  28 +
  29 +.jumbotron .btn {
  30 + font-size: 21px;
  31 + padding: 14px 24px;
  32 +}
  33 +
  34 +.not-set {
  35 + color: #c55;
  36 + font-style: italic;
  37 +}
  38 +
  39 +/* add sorting icons to gridview sort links */
  40 +a.asc:after, a.desc:after {
  41 + position: relative;
  42 + top: 1px;
  43 + display: inline-block;
  44 + font-family: 'Glyphicons Halflings';
  45 + font-style: normal;
  46 + font-weight: normal;
  47 + line-height: 1;
  48 + padding-left: 5px;
  49 +}
  50 +
  51 +a.asc:after {
  52 + content: /*"\e113"*/ "\e151";
  53 +}
  54 +
  55 +a.desc:after {
  56 + content: /*"\e114"*/ "\e152";
  57 +}
  58 +
  59 +.sort-numerical a.asc:after {
  60 + content: "\e153";
  61 +}
  62 +
  63 +.sort-numerical a.desc:after {
  64 + content: "\e154";
  65 +}
  66 +
  67 +.sort-ordinal a.asc:after {
  68 + content: "\e155";
  69 +}
  70 +
  71 +.sort-ordinal a.desc:after {
  72 + content: "\e156";
  73 +}
  74 +
  75 +.grid-view th {
  76 + white-space: nowrap;
  77 +}
  78 +
  79 +.hint-block {
  80 + display: block;
  81 + margin-top: 5px;
  82 + color: #999;
  83 +}
  84 +
  85 +.error-summary {
  86 + color: #a94442;
  87 + background: #fdf7f7;
  88 + border-left: 3px solid #eed3d7;
  89 + padding: 10px 20px;
  90 + margin: 0 0 15px 0;
  91 +}
backend/web/favicon.ico 0 → 100644
No preview for this file type
backend/web/images/tablet_PNG8572.png 0 → 100644

104 KB

backend/web/js/main.js 0 → 100644
  1 +++ a/backend/web/js/main.js
  1 +var canvas = $('canvas').attr({'width' : 1200, 'height' : 500}).css('border', '1px solid black');
  2 +var context = canvas.get(0).getContext('2d');
  3 +
  4 +var model = {
  5 + width : 0,
  6 + height : 0,
  7 + point : {
  8 + x : 0,
  9 + y : 0
  10 + }
  11 +};
  12 +
  13 +var select = $('#ukr_seeds');
  14 +select.change(getParams);
  15 +
  16 +getParams();
  17 +
  18 +function getParams()
  19 +{
  20 + $.ajax({
  21 + url: location.href + '/get-params',
  22 + data: {
  23 + 'crop_id': select.val()
  24 + },
  25 + type: 'GET',
  26 + dataType: 'json',
  27 + success: function(data) {
  28 + model.width = data.body.WIDTH;
  29 + model.height = data.body.HEIGHT;
  30 + model.point.x = data.body.X;
  31 + model.point.y = data.body.Y;
  32 + canvas.attr({'width' : model.width + 20, 'height' : model.height + 20});
  33 + context.clearRect(0, 0, canvas.width, canvas.height);
  34 + console.log(model);
  35 + }
  36 + });
  37 +}
  38 +
  39 +function draw()
  40 +{
  41 + var image = $('img').get(0);
  42 + context.clearRect(0, 0, canvas.width, canvas.height);
  43 + context.drawImage(image, model.point.x, model.point.y, model.width, model.height, 10, 10, model.width, model.height);
  44 + console.log( image.width, image.height );
  45 +}
0 \ No newline at end of file 46 \ No newline at end of file
backend/web/robots.txt 0 → 100644
  1 +++ a/backend/web/robots.txt
  1 +User-Agent: *
  2 +Disallow: /
common/config/.gitignore 0 → 100644
  1 +++ a/common/config/.gitignore
  1 +main-local.php
  2 +params-local.php
common/config/bootstrap.php 0 → 100644
  1 +++ a/common/config/bootstrap.php
  1 +<?php
  2 +Yii::setAlias('common', dirname(__DIR__));
  3 +Yii::setAlias('frontend', dirname(dirname(__DIR__)) . '/frontend');
  4 +Yii::setAlias('backend', dirname(dirname(__DIR__)) . '/backend');
  5 +Yii::setAlias('console', dirname(dirname(__DIR__)) . '/console');
common/config/main.php 0 → 100644
  1 +++ a/common/config/main.php
  1 +<?php
  2 +return [
  3 + 'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',
  4 + 'components' => [
  5 + 'cache' => [
  6 + 'class' => 'yii\caching\FileCache',
  7 + ],
  8 + ],
  9 +];
common/config/params.php 0 → 100644
  1 +++ a/common/config/params.php
  1 +<?php
  2 +return [
  3 +
  4 +];
common/mail/layouts/html.php 0 → 100644
  1 +++ a/common/mail/layouts/html.php
  1 +<?php
  2 +use yii\helpers\Html;
  3 +
  4 +/* @var $this \yii\web\View view component instance */
  5 +/* @var $message \yii\mail\MessageInterface the message being composed */
  6 +/* @var $content string main view render result */
  7 +?>
  8 +<?php $this->beginPage() ?>
  9 +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  10 +<html xmlns="http://www.w3.org/1999/xhtml">
  11 +<head>
  12 + <meta http-equiv="Content-Type" content="text/html; charset=<?= Yii::$app->charset ?>" />
  13 + <title><?= Html::encode($this->title) ?></title>
  14 + <?php $this->head() ?>
  15 +</head>
  16 +<body>
  17 + <?php $this->beginBody() ?>
  18 + <?= $content ?>
  19 + <?php $this->endBody() ?>
  20 +</body>
  21 +</html>
  22 +<?php $this->endPage() ?>
common/mail/layouts/text.php 0 → 100644
  1 +++ a/common/mail/layouts/text.php
  1 +<?php
  2 +use yii\helpers\Html;
  3 +
  4 +/* @var $this \yii\web\View view component instance */
  5 +/* @var $message \yii\mail\MessageInterface the message being composed */
  6 +/* @var $content string main view render result */
  7 +?>
  8 +<?php $this->beginPage() ?>
  9 +<?php $this->beginBody() ?>
  10 +<?= $content ?>
  11 +<?php $this->endBody() ?>
  12 +<?php $this->endPage() ?>
common/mail/passwordResetToken-html.php 0 → 100644
  1 +++ a/common/mail/passwordResetToken-html.php
  1 +<?php
  2 +use yii\helpers\Html;
  3 +
  4 +/* @var $this yii\web\View */
  5 +/* @var $user common\models\User */
  6 +
  7 +$resetLink = Yii::$app->urlManager->createAbsoluteUrl(['site/reset-password', 'token' => $user->password_reset_token]);
  8 +?>
  9 +<div class="password-reset">
  10 + <p>Hello <?= Html::encode($user->username) ?>,</p>
  11 +
  12 + <p>Follow the link below to reset your password:</p>
  13 +
  14 + <p><?= Html::a(Html::encode($resetLink), $resetLink) ?></p>
  15 +</div>
common/mail/passwordResetToken-text.php 0 → 100644
  1 +++ a/common/mail/passwordResetToken-text.php
  1 +<?php
  2 +
  3 +/* @var $this yii\web\View */
  4 +/* @var $user common\models\User */
  5 +
  6 +$resetLink = Yii::$app->urlManager->createAbsoluteUrl(['site/reset-password', 'token' => $user->password_reset_token]);
  7 +?>
  8 +Hello <?= $user->username ?>,
  9 +
  10 +Follow the link below to reset your password:
  11 +
  12 +<?= $resetLink ?>
common/models/LoginForm.php 0 → 100644
  1 +++ a/common/models/LoginForm.php
  1 +<?php
  2 +namespace common\models;
  3 +
  4 +use Yii;
  5 +use yii\base\Model;
  6 +
  7 +/**
  8 + * Login form
  9 + */
  10 +class LoginForm extends Model
  11 +{
  12 + public $username;
  13 + public $password;
  14 + public $rememberMe = true;
  15 +
  16 + private $_user = false;
  17 +
  18 +
  19 + /**
  20 + * @inheritdoc
  21 + */
  22 + public function rules()
  23 + {
  24 + return [
  25 + // username and password are both required
  26 + [['username', 'password'], 'required'],
  27 + // rememberMe must be a boolean value
  28 + ['rememberMe', 'boolean'],
  29 + // password is validated by validatePassword()
  30 + ['password', 'validatePassword'],
  31 + ];
  32 + }
  33 +
  34 + /**
  35 + * Validates the password.
  36 + * This method serves as the inline validation for password.
  37 + *
  38 + * @param string $attribute the attribute currently being validated
  39 + * @param array $params the additional name-value pairs given in the rule
  40 + */
  41 + public function validatePassword($attribute, $params)
  42 + {
  43 + if (!$this->hasErrors()) {
  44 + $user = $this->getUser();
  45 + if (!$user || !$user->validatePassword($this->password)) {
  46 + $this->addError($attribute, 'Incorrect username or password.');
  47 + }
  48 + }
  49 + }
  50 +
  51 + /**
  52 + * Logs in a user using the provided username and password.
  53 + *
  54 + * @return boolean whether the user is logged in successfully
  55 + */
  56 + public function login()
  57 + {
  58 + if ($this->validate()) {
  59 + return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600 * 24 * 30 : 0);
  60 + } else {
  61 + return false;
  62 + }
  63 + }
  64 +
  65 + /**
  66 + * Finds user by [[username]]
  67 + *
  68 + * @return User|null
  69 + */
  70 + public function getUser()
  71 + {
  72 + if ($this->_user === false) {
  73 + $this->_user = User::findByUsername($this->username);
  74 + }
  75 +
  76 + return $this->_user;
  77 + }
  78 +}
common/models/User.php 0 → 100644
  1 +++ a/common/models/User.php
  1 +<?php
  2 +namespace common\models;
  3 +
  4 +use Yii;
  5 +use yii\base\NotSupportedException;
  6 +use yii\behaviors\TimestampBehavior;
  7 +use yii\db\ActiveRecord;
  8 +use yii\web\IdentityInterface;
  9 +
  10 +/**
  11 + * User model
  12 + *
  13 + * @property integer $id
  14 + * @property string $username
  15 + * @property string $password_hash
  16 + * @property string $password_reset_token
  17 + * @property string $email
  18 + * @property string $auth_key
  19 + * @property integer $status
  20 + * @property integer $created_at
  21 + * @property integer $updated_at
  22 + * @property string $password write-only password
  23 + */
  24 +class User extends ActiveRecord implements IdentityInterface
  25 +{
  26 + const STATUS_DELETED = 0;
  27 + const STATUS_ACTIVE = 10;
  28 +
  29 + /**
  30 + * @inheritdoc
  31 + */
  32 + public static function tableName()
  33 + {
  34 + return '{{%user}}';
  35 + }
  36 +
  37 + /**
  38 + * @inheritdoc
  39 + */
  40 + public function behaviors()
  41 + {
  42 + return [
  43 + TimestampBehavior::className(),
  44 + ];
  45 + }
  46 +
  47 + /**
  48 + * @inheritdoc
  49 + */
  50 + public function rules()
  51 + {
  52 + return [
  53 + ['status', 'default', 'value' => self::STATUS_ACTIVE],
  54 + ['status', 'in', 'range' => [self::STATUS_ACTIVE, self::STATUS_DELETED]],
  55 + ];
  56 + }
  57 +
  58 + /**
  59 + * @inheritdoc
  60 + */
  61 + public static function findIdentity($id)
  62 + {
  63 + return static::findOne(['id' => $id, 'status' => self::STATUS_ACTIVE]);
  64 + }
  65 +
  66 + /**
  67 + * @inheritdoc
  68 + */
  69 + public static function findIdentityByAccessToken($token, $type = null)
  70 + {
  71 + throw new NotSupportedException('"findIdentityByAccessToken" is not implemented.');
  72 + }
  73 +
  74 + /**
  75 + * Finds user by username
  76 + *
  77 + * @param string $username
  78 + * @return static|null
  79 + */
  80 + public static function findByUsername($username)
  81 + {
  82 + return static::findOne(['username' => $username, 'status' => self::STATUS_ACTIVE]);
  83 + }
  84 +
  85 + /**
  86 + * Finds user by password reset token
  87 + *
  88 + * @param string $token password reset token
  89 + * @return static|null
  90 + */
  91 + public static function findByPasswordResetToken($token)
  92 + {
  93 + if (!static::isPasswordResetTokenValid($token)) {
  94 + return null;
  95 + }
  96 +
  97 + return static::findOne([
  98 + 'password_reset_token' => $token,
  99 + 'status' => self::STATUS_ACTIVE,
  100 + ]);
  101 + }
  102 +
  103 + /**
  104 + * Finds out if password reset token is valid
  105 + *
  106 + * @param string $token password reset token
  107 + * @return boolean
  108 + */
  109 + public static function isPasswordResetTokenValid($token)
  110 + {
  111 + if (empty($token)) {
  112 + return false;
  113 + }
  114 + $expire = Yii::$app->params['user.passwordResetTokenExpire'];
  115 + $parts = explode('_', $token);
  116 + $timestamp = (int) end($parts);
  117 + return $timestamp + $expire >= time();
  118 + }
  119 +
  120 + /**
  121 + * @inheritdoc
  122 + */
  123 + public function getId()
  124 + {
  125 + return $this->getPrimaryKey();
  126 + }
  127 +
  128 + /**
  129 + * @inheritdoc
  130 + */
  131 + public function getAuthKey()
  132 + {
  133 + return $this->auth_key;
  134 + }
  135 +
  136 + /**
  137 + * @inheritdoc
  138 + */
  139 + public function validateAuthKey($authKey)
  140 + {
  141 + return $this->getAuthKey() === $authKey;
  142 + }
  143 +
  144 + /**
  145 + * Validates password
  146 + *
  147 + * @param string $password password to validate
  148 + * @return boolean if password provided is valid for current user
  149 + */
  150 + public function validatePassword($password)
  151 + {
  152 + return Yii::$app->security->validatePassword($password, $this->password_hash);
  153 + }
  154 +
  155 + /**
  156 + * Generates password hash from password and sets it to the model
  157 + *
  158 + * @param string $password
  159 + */
  160 + public function setPassword($password)
  161 + {
  162 + $this->password_hash = Yii::$app->security->generatePasswordHash($password);
  163 + }
  164 +
  165 + /**
  166 + * Generates "remember me" authentication key
  167 + */
  168 + public function generateAuthKey()
  169 + {
  170 + $this->auth_key = Yii::$app->security->generateRandomString();
  171 + }
  172 +
  173 + /**
  174 + * Generates new password reset token
  175 + */
  176 + public function generatePasswordResetToken()
  177 + {
  178 + $this->password_reset_token = Yii::$app->security->generateRandomString() . '_' . time();
  179 + }
  180 +
  181 + /**
  182 + * Removes password reset token
  183 + */
  184 + public function removePasswordResetToken()
  185 + {
  186 + $this->password_reset_token = null;
  187 + }
  188 +}
composer.json 0 → 100644
  1 +++ a/composer.json
  1 +{
  2 + "name": "yiisoft/yii2-app-advanced",
  3 + "description": "Yii 2 Advanced Project Template",
  4 + "keywords": ["yii2", "framework", "advanced", "project template"],
  5 + "homepage": "http://www.yiiframework.com/",
  6 + "type": "project",
  7 + "license": "BSD-3-Clause",
  8 + "support": {
  9 + "issues": "https://github.com/yiisoft/yii2/issues?state=open",
  10 + "forum": "http://www.yiiframework.com/forum/",
  11 + "wiki": "http://www.yiiframework.com/wiki/",
  12 + "irc": "irc://irc.freenode.net/yii",
  13 + "source": "https://github.com/yiisoft/yii2"
  14 + },
  15 + "minimum-stability": "stable",
  16 + "require": {
  17 + "php": ">=5.4.0",
  18 + "yiisoft/yii2": ">=2.0.4",
  19 + "yiisoft/yii2-bootstrap": "*",
  20 + "yiisoft/yii2-swiftmailer": "*",
  21 + "yiisoft/yii2-imagine": "~2.0.0",
  22 + "kartik-v/yii2-widget-fileinput": "@dev"
  23 + },
  24 + "require-dev": {
  25 + "yiisoft/yii2-codeception": "*",
  26 + "yiisoft/yii2-debug": "*",
  27 + "yiisoft/yii2-gii": "*",
  28 + "yiisoft/yii2-faker": "*",
  29 + "yiisoft/yii2-imagine": "~2.0.0"
  30 + },
  31 + "config": {
  32 + "process-timeout": 1800
  33 + },
  34 + "extra": {
  35 + "asset-installer-paths": {
  36 + "npm-asset-library": "vendor/npm",
  37 + "bower-asset-library": "vendor/bower"
  38 + }
  39 + }
  40 +}
composer.lock 0 → 100644
  1 +++ a/composer.lock
  1 +{
  2 + "_readme": [
  3 + "This file locks the dependencies of your project to a known state",
  4 + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
  5 + "This file is @generated automatically"
  6 + ],
  7 + "hash": "ff5bec9bbd6546ea49291f5e366ffeed",
  8 + "content-hash": "5ff673161b2e2d58895f013dd3ce2851",
  9 + "packages": [
  10 + {
  11 + "name": "bower-asset/bootstrap",
  12 + "version": "v3.3.5",
  13 + "source": {
  14 + "type": "git",
  15 + "url": "https://github.com/twbs/bootstrap.git",
  16 + "reference": "16b48259a62f576e52c903c476bd42b90ab22482"
  17 + },
  18 + "dist": {
  19 + "type": "zip",
  20 + "url": "https://api.github.com/repos/twbs/bootstrap/zipball/16b48259a62f576e52c903c476bd42b90ab22482",
  21 + "reference": "16b48259a62f576e52c903c476bd42b90ab22482",
  22 + "shasum": ""
  23 + },
  24 + "require": {
  25 + "bower-asset/jquery": ">=1.9.1"
  26 + },
  27 + "type": "bower-asset-library",
  28 + "extra": {
  29 + "bower-asset-main": [
  30 + "less/bootstrap.less",
  31 + "dist/js/bootstrap.js"
  32 + ],
  33 + "bower-asset-ignore": [
  34 + "/.*",
  35 + "_config.yml",
  36 + "CNAME",
  37 + "composer.json",
  38 + "CONTRIBUTING.md",
  39 + "docs",
  40 + "js/tests",
  41 + "test-infra"
  42 + ]
  43 + },
  44 + "license": [
  45 + "MIT"
  46 + ],
  47 + "description": "The most popular front-end framework for developing responsive, mobile first projects on the web.",
  48 + "keywords": [
  49 + "css",
  50 + "framework",
  51 + "front-end",
  52 + "js",
  53 + "less",
  54 + "mobile-first",
  55 + "responsive",
  56 + "web"
  57 + ]
  58 + },
  59 + {
  60 + "name": "bower-asset/jquery",
  61 + "version": "2.1.4",
  62 + "source": {
  63 + "type": "git",
  64 + "url": "https://github.com/jquery/jquery.git",
  65 + "reference": "7751e69b615c6eca6f783a81e292a55725af6b85"
  66 + },
  67 + "dist": {
  68 + "type": "zip",
  69 + "url": "https://api.github.com/repos/jquery/jquery/zipball/7751e69b615c6eca6f783a81e292a55725af6b85",
  70 + "reference": "7751e69b615c6eca6f783a81e292a55725af6b85",
  71 + "shasum": ""
  72 + },
  73 + "require-dev": {
  74 + "bower-asset/qunit": "1.14.0",
  75 + "bower-asset/requirejs": "2.1.10",
  76 + "bower-asset/sinon": "1.8.1",
  77 + "bower-asset/sizzle": "2.1.1-patch2"
  78 + },
  79 + "type": "bower-asset-library",
  80 + "extra": {
  81 + "bower-asset-main": "dist/jquery.js",
  82 + "bower-asset-ignore": [
  83 + "**/.*",
  84 + "build",
  85 + "dist/cdn",
  86 + "speed",
  87 + "test",
  88 + "*.md",
  89 + "AUTHORS.txt",
  90 + "Gruntfile.js",
  91 + "package.json"
  92 + ]
  93 + },
  94 + "license": [
  95 + "MIT"
  96 + ],
  97 + "keywords": [
  98 + "javascript",
  99 + "jquery",
  100 + "library"
  101 + ]
  102 + },
  103 + {
  104 + "name": "bower-asset/jquery.inputmask",
  105 + "version": "3.1.63",
  106 + "source": {
  107 + "type": "git",
  108 + "url": "https://github.com/RobinHerbots/jquery.inputmask.git",
  109 + "reference": "c40c7287eadc31e341ebbf0c02352eb55b9cbc48"
  110 + },
  111 + "dist": {
  112 + "type": "zip",
  113 + "url": "https://api.github.com/repos/RobinHerbots/jquery.inputmask/zipball/c40c7287eadc31e341ebbf0c02352eb55b9cbc48",
  114 + "reference": "c40c7287eadc31e341ebbf0c02352eb55b9cbc48",
  115 + "shasum": ""
  116 + },
  117 + "require": {
  118 + "bower-asset/jquery": ">=1.7"
  119 + },
  120 + "type": "bower-asset-library",
  121 + "extra": {
  122 + "bower-asset-main": [
  123 + "./dist/inputmask/jquery.inputmask.js",
  124 + "./dist/inputmask/jquery.inputmask.extensions.js",
  125 + "./dist/inputmask/jquery.inputmask.date.extensions.js",
  126 + "./dist/inputmask/jquery.inputmask.numeric.extensions.js",
  127 + "./dist/inputmask/jquery.inputmask.phone.extensions.js",
  128 + "./dist/inputmask/jquery.inputmask.regex.extensions.js"
  129 + ],
  130 + "bower-asset-ignore": [
  131 + "**/.*",
  132 + "qunit/",
  133 + "nuget/",
  134 + "tools/",
  135 + "js/",
  136 + "*.md",
  137 + "build.properties",
  138 + "build.xml",
  139 + "jquery.inputmask.jquery.json"
  140 + ]
  141 + },
  142 + "license": [
  143 + "http://opensource.org/licenses/mit-license.php"
  144 + ],
  145 + "description": "jquery.inputmask is a jquery plugin which create an input mask.",
  146 + "keywords": [
  147 + "form",
  148 + "input",
  149 + "inputmask",
  150 + "jquery",
  151 + "mask",
  152 + "plugins"
  153 + ]
  154 + },
  155 + {
  156 + "name": "bower-asset/punycode",
  157 + "version": "v1.3.2",
  158 + "source": {
  159 + "type": "git",
  160 + "url": "https://github.com/bestiejs/punycode.js.git",
  161 + "reference": "38c8d3131a82567bfef18da09f7f4db68c84f8a3"
  162 + },
  163 + "dist": {
  164 + "type": "zip",
  165 + "url": "https://api.github.com/repos/bestiejs/punycode.js/zipball/38c8d3131a82567bfef18da09f7f4db68c84f8a3",
  166 + "reference": "38c8d3131a82567bfef18da09f7f4db68c84f8a3",
  167 + "shasum": ""
  168 + },
  169 + "type": "bower-asset-library",
  170 + "extra": {
  171 + "bower-asset-main": "punycode.js",
  172 + "bower-asset-ignore": [
  173 + "coverage",
  174 + "tests",
  175 + ".*",
  176 + "component.json",
  177 + "Gruntfile.js",
  178 + "node_modules",
  179 + "package.json"
  180 + ]
  181 + }
  182 + },
  183 + {
  184 + "name": "bower-asset/yii2-pjax",
  185 + "version": "v2.0.4",
  186 + "source": {
  187 + "type": "git",
  188 + "url": "https://github.com/yiisoft/jquery-pjax.git",
  189 + "reference": "3f20897307cca046fca5323b318475ae9dac0ca0"
  190 + },
  191 + "dist": {
  192 + "type": "zip",
  193 + "url": "https://api.github.com/repos/yiisoft/jquery-pjax/zipball/3f20897307cca046fca5323b318475ae9dac0ca0",
  194 + "reference": "3f20897307cca046fca5323b318475ae9dac0ca0",
  195 + "shasum": ""
  196 + },
  197 + "require": {
  198 + "bower-asset/jquery": ">=1.8"
  199 + },
  200 + "type": "bower-asset-library",
  201 + "extra": {
  202 + "bower-asset-main": "./jquery.pjax.js",
  203 + "bower-asset-ignore": [
  204 + ".travis.yml",
  205 + "Gemfile",
  206 + "Gemfile.lock",
  207 + "vendor/",
  208 + "script/",
  209 + "test/"
  210 + ]
  211 + },
  212 + "license": [
  213 + "MIT"
  214 + ]
  215 + },
  216 + {
  217 + "name": "cebe/markdown",
  218 + "version": "1.1.0",
  219 + "source": {
  220 + "type": "git",
  221 + "url": "https://github.com/cebe/markdown.git",
  222 + "reference": "54a2c49de31cc44e864ebf0500a35ef21d0010b2"
  223 + },
  224 + "dist": {
  225 + "type": "zip",
  226 + "url": "https://api.github.com/repos/cebe/markdown/zipball/54a2c49de31cc44e864ebf0500a35ef21d0010b2",
  227 + "reference": "54a2c49de31cc44e864ebf0500a35ef21d0010b2",
  228 + "shasum": ""
  229 + },
  230 + "require": {
  231 + "lib-pcre": "*",
  232 + "php": ">=5.4.0"
  233 + },
  234 + "require-dev": {
  235 + "cebe/indent": "*",
  236 + "facebook/xhprof": "*@dev",
  237 + "phpunit/phpunit": "4.1.*"
  238 + },
  239 + "bin": [
  240 + "bin/markdown"
  241 + ],
  242 + "type": "library",
  243 + "extra": {
  244 + "branch-alias": {
  245 + "dev-master": "1.1.x-dev"
  246 + }
  247 + },
  248 + "autoload": {
  249 + "psr-4": {
  250 + "cebe\\markdown\\": ""
  251 + }
  252 + },
  253 + "notification-url": "https://packagist.org/downloads/",
  254 + "license": [
  255 + "MIT"
  256 + ],
  257 + "authors": [
  258 + {
  259 + "name": "Carsten Brandt",
  260 + "email": "mail@cebe.cc",
  261 + "homepage": "http://cebe.cc/",
  262 + "role": "Creator"
  263 + }
  264 + ],
  265 + "description": "A super fast, highly extensible markdown parser for PHP",
  266 + "homepage": "https://github.com/cebe/markdown#readme",
  267 + "keywords": [
  268 + "extensible",
  269 + "fast",
  270 + "gfm",
  271 + "markdown",
  272 + "markdown-extra"
  273 + ],
  274 + "time": "2015-03-06 05:28:07"
  275 + },
  276 + {
  277 + "name": "ezyang/htmlpurifier",
  278 + "version": "v4.6.0",
  279 + "source": {
  280 + "type": "git",
  281 + "url": "https://github.com/ezyang/htmlpurifier.git",
  282 + "reference": "6f389f0f25b90d0b495308efcfa073981177f0fd"
  283 + },
  284 + "dist": {
  285 + "type": "zip",
  286 + "url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/6f389f0f25b90d0b495308efcfa073981177f0fd",
  287 + "reference": "6f389f0f25b90d0b495308efcfa073981177f0fd",
  288 + "shasum": ""
  289 + },
  290 + "require": {
  291 + "php": ">=5.2"
  292 + },
  293 + "type": "library",
  294 + "autoload": {
  295 + "psr-0": {
  296 + "HTMLPurifier": "library/"
  297 + },
  298 + "files": [
  299 + "library/HTMLPurifier.composer.php"
  300 + ]
  301 + },
  302 + "notification-url": "https://packagist.org/downloads/",
  303 + "license": [
  304 + "LGPL"
  305 + ],
  306 + "authors": [
  307 + {
  308 + "name": "Edward Z. Yang",
  309 + "email": "admin@htmlpurifier.org",
  310 + "homepage": "http://ezyang.com"
  311 + }
  312 + ],
  313 + "description": "Standards compliant HTML filter written in PHP",
  314 + "homepage": "http://htmlpurifier.org/",
  315 + "keywords": [
  316 + "html"
  317 + ],
  318 + "time": "2013-11-30 08:25:19"
  319 + },
  320 + {
  321 + "name": "imagine/imagine",
  322 + "version": "v0.5.0",
  323 + "source": {
  324 + "type": "git",
  325 + "url": "https://github.com/avalanche123/Imagine.git",
  326 + "reference": "f64ec666baaa800edcbf237db41121a569230709"
  327 + },
  328 + "dist": {
  329 + "type": "zip",
  330 + "url": "https://api.github.com/repos/avalanche123/Imagine/zipball/f64ec666baaa800edcbf237db41121a569230709",
  331 + "reference": "f64ec666baaa800edcbf237db41121a569230709",
  332 + "shasum": ""
  333 + },
  334 + "require": {
  335 + "php": ">=5.3.2"
  336 + },
  337 + "require-dev": {
  338 + "sami/sami": "dev-master"
  339 + },
  340 + "suggest": {
  341 + "ext-gd": "to use the GD implementation",
  342 + "ext-gmagick": "to use the Gmagick implementation",
  343 + "ext-imagick": "to use the Imagick implementation"
  344 + },
  345 + "type": "library",
  346 + "autoload": {
  347 + "psr-0": {
  348 + "Imagine": "lib/"
  349 + }
  350 + },
  351 + "notification-url": "https://packagist.org/downloads/",
  352 + "license": [
  353 + "MIT"
  354 + ],
  355 + "authors": [
  356 + {
  357 + "name": "Bulat Shakirzyanov",
  358 + "email": "mallluhuct@gmail.com",
  359 + "homepage": "http://avalanche123.com"
  360 + }
  361 + ],
  362 + "description": "Image processing for PHP 5.3",
  363 + "homepage": "http://imagine.readthedocs.org/",
  364 + "keywords": [
  365 + "drawing",
  366 + "graphics",
  367 + "image manipulation",
  368 + "image processing"
  369 + ],
  370 + "time": "2013-07-10 17:25:36"
  371 + },
  372 + {
  373 + "name": "kartik-v/bootstrap-fileinput",
  374 + "version": "v4.2.7",
  375 + "source": {
  376 + "type": "git",
  377 + "url": "https://github.com/kartik-v/bootstrap-fileinput.git",
  378 + "reference": "0468bbba9c28c1250aca83eba9b33e32ec135f78"
  379 + },
  380 + "dist": {
  381 + "type": "zip",
  382 + "url": "https://api.github.com/repos/kartik-v/bootstrap-fileinput/zipball/0468bbba9c28c1250aca83eba9b33e32ec135f78",
  383 + "reference": "0468bbba9c28c1250aca83eba9b33e32ec135f78",
  384 + "shasum": ""
  385 + },
  386 + "type": "library",
  387 + "autoload": {
  388 + "psr-4": {
  389 + "kartik\\plugins\\fileinput\\": ""
  390 + }
  391 + },
  392 + "notification-url": "https://packagist.org/downloads/",
  393 + "license": [
  394 + "BSD-3-Clause"
  395 + ],
  396 + "authors": [
  397 + {
  398 + "name": "Kartik Visweswaran",
  399 + "email": "kartikv2@gmail.com",
  400 + "homepage": "http://www.krajee.com/"
  401 + }
  402 + ],
  403 + "description": "An enhanced HTML 5 file input for Bootstrap 3.x with features for file preview for many file types, multiple selection, ajax uploads, and more.",
  404 + "homepage": "https://github.com/kartik-v/bootstrap-fileinput",
  405 + "keywords": [
  406 + "ajax",
  407 + "bootstrap",
  408 + "delete",
  409 + "file",
  410 + "image",
  411 + "input",
  412 + "jquery",
  413 + "multiple",
  414 + "preview",
  415 + "progress",
  416 + "upload"
  417 + ],
  418 + "time": "2015-09-13 17:39:44"
  419 + },
  420 + {
  421 + "name": "kartik-v/yii2-krajee-base",
  422 + "version": "v1.7.7",
  423 + "source": {
  424 + "type": "git",
  425 + "url": "https://github.com/kartik-v/yii2-krajee-base.git",
  426 + "reference": "c0adff9d9762f4fd3bf0e7cd0000fcab0bf00f19"
  427 + },
  428 + "dist": {
  429 + "type": "zip",
  430 + "url": "https://api.github.com/repos/kartik-v/yii2-krajee-base/zipball/c0adff9d9762f4fd3bf0e7cd0000fcab0bf00f19",
  431 + "reference": "c0adff9d9762f4fd3bf0e7cd0000fcab0bf00f19",
  432 + "shasum": ""
  433 + },
  434 + "require": {
  435 + "yiisoft/yii2-bootstrap": "@dev"
  436 + },
  437 + "type": "yii2-extension",
  438 + "autoload": {
  439 + "psr-4": {
  440 + "kartik\\base\\": ""
  441 + }
  442 + },
  443 + "notification-url": "https://packagist.org/downloads/",
  444 + "license": [
  445 + "BSD-3-Clause"
  446 + ],
  447 + "authors": [
  448 + {
  449 + "name": "Kartik Visweswaran",
  450 + "email": "kartikv2@gmail.com",
  451 + "homepage": "http://www.krajee.com/"
  452 + }
  453 + ],
  454 + "description": "Base library and foundation components for all Yii2 Krajee extensions.",
  455 + "homepage": "https://github.com/kartik-v/yii2-krajee-base",
  456 + "keywords": [
  457 + "base",
  458 + "extension",
  459 + "foundation",
  460 + "krajee",
  461 + "widget",
  462 + "yii2"
  463 + ],
  464 + "time": "2015-06-16 05:19:57"
  465 + },
  466 + {
  467 + "name": "kartik-v/yii2-widget-fileinput",
  468 + "version": "dev-master",
  469 + "source": {
  470 + "type": "git",
  471 + "url": "https://github.com/kartik-v/yii2-widget-fileinput.git",
  472 + "reference": "084447f095888ddb09a95a1a363842ca87e01c9d"
  473 + },
  474 + "dist": {
  475 + "type": "zip",
  476 + "url": "https://api.github.com/repos/kartik-v/yii2-widget-fileinput/zipball/084447f095888ddb09a95a1a363842ca87e01c9d",
  477 + "reference": "084447f095888ddb09a95a1a363842ca87e01c9d",
  478 + "shasum": ""
  479 + },
  480 + "require": {
  481 + "kartik-v/bootstrap-fileinput": "~4.2",
  482 + "kartik-v/yii2-krajee-base": "~1.7"
  483 + },
  484 + "type": "yii2-extension",
  485 + "autoload": {
  486 + "psr-4": {
  487 + "kartik\\file\\": ""
  488 + }
  489 + },
  490 + "notification-url": "https://packagist.org/downloads/",
  491 + "license": [
  492 + "BSD-3-Clause"
  493 + ],
  494 + "authors": [
  495 + {
  496 + "name": "Kartik Visweswaran",
  497 + "email": "kartikv2@gmail.com",
  498 + "homepage": "http://www.krajee.com/"
  499 + }
  500 + ],
  501 + "description": "An enhanced FileInput widget for Bootstrap 3.x with file preview, multiple selection, and more features (sub repo split from yii2-widgets)",
  502 + "homepage": "https://github.com/kartik-v/yii2-widget-fileinput",
  503 + "keywords": [
  504 + "extension",
  505 + "file",
  506 + "form",
  507 + "input",
  508 + "jquery",
  509 + "plugin",
  510 + "upload",
  511 + "widget",
  512 + "yii2"
  513 + ],
  514 + "time": "2015-08-17 13:03:50"
  515 + },
  516 + {
  517 + "name": "swiftmailer/swiftmailer",
  518 + "version": "v5.4.1",
  519 + "source": {
  520 + "type": "git",
  521 + "url": "https://github.com/swiftmailer/swiftmailer.git",
  522 + "reference": "0697e6aa65c83edf97bb0f23d8763f94e3f11421"
  523 + },
  524 + "dist": {
  525 + "type": "zip",
  526 + "url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/0697e6aa65c83edf97bb0f23d8763f94e3f11421",
  527 + "reference": "0697e6aa65c83edf97bb0f23d8763f94e3f11421",
  528 + "shasum": ""
  529 + },
  530 + "require": {
  531 + "php": ">=5.3.3"
  532 + },
  533 + "require-dev": {
  534 + "mockery/mockery": "~0.9.1,<0.9.4"
  535 + },
  536 + "type": "library",
  537 + "extra": {
  538 + "branch-alias": {
  539 + "dev-master": "5.4-dev"
  540 + }
  541 + },
  542 + "autoload": {
  543 + "files": [
  544 + "lib/swift_required.php"
  545 + ]
  546 + },
  547 + "notification-url": "https://packagist.org/downloads/",
  548 + "license": [
  549 + "MIT"
  550 + ],
  551 + "authors": [
  552 + {
  553 + "name": "Chris Corbyn"
  554 + },
  555 + {
  556 + "name": "Fabien Potencier",
  557 + "email": "fabien@symfony.com"
  558 + }
  559 + ],
  560 + "description": "Swiftmailer, free feature-rich PHP mailer",
  561 + "homepage": "http://swiftmailer.org",
  562 + "keywords": [
  563 + "email",
  564 + "mail",
  565 + "mailer"
  566 + ],
  567 + "time": "2015-06-06 14:19:39"
  568 + },
  569 + {
  570 + "name": "yiisoft/yii2",
  571 + "version": "2.0.6",
  572 + "source": {
  573 + "type": "git",
  574 + "url": "https://github.com/yiisoft/yii2-framework.git",
  575 + "reference": "f42b2eb80f61992438661b01d0d74c6738e2ff38"
  576 + },
  577 + "dist": {
  578 + "type": "zip",
  579 + "url": "https://api.github.com/repos/yiisoft/yii2-framework/zipball/f42b2eb80f61992438661b01d0d74c6738e2ff38",
  580 + "reference": "f42b2eb80f61992438661b01d0d74c6738e2ff38",
  581 + "shasum": ""
  582 + },
  583 + "require": {
  584 + "bower-asset/jquery": "2.1.*@stable | 1.11.*@stable",
  585 + "bower-asset/jquery.inputmask": "3.1.*",
  586 + "bower-asset/punycode": "1.3.*",
  587 + "bower-asset/yii2-pjax": ">=2.0.1",
  588 + "cebe/markdown": "~1.0.0 | ~1.1.0",
  589 + "ext-mbstring": "*",
  590 + "ezyang/htmlpurifier": "4.6.*",
  591 + "lib-pcre": "*",
  592 + "php": ">=5.4.0",
  593 + "yiisoft/yii2-composer": "*"
  594 + },
  595 + "bin": [
  596 + "yii"
  597 + ],
  598 + "type": "library",
  599 + "extra": {
  600 + "branch-alias": {
  601 + "dev-master": "2.0.x-dev"
  602 + }
  603 + },
  604 + "autoload": {
  605 + "psr-4": {
  606 + "yii\\": ""
  607 + }
  608 + },
  609 + "notification-url": "https://packagist.org/downloads/",
  610 + "license": [
  611 + "BSD-3-Clause"
  612 + ],
  613 + "authors": [
  614 + {
  615 + "name": "Qiang Xue",
  616 + "email": "qiang.xue@gmail.com",
  617 + "homepage": "http://www.yiiframework.com/",
  618 + "role": "Founder and project lead"
  619 + },
  620 + {
  621 + "name": "Alexander Makarov",
  622 + "email": "sam@rmcreative.ru",
  623 + "homepage": "http://rmcreative.ru/",
  624 + "role": "Core framework development"
  625 + },
  626 + {
  627 + "name": "Maurizio Domba",
  628 + "homepage": "http://mdomba.info/",
  629 + "role": "Core framework development"
  630 + },
  631 + {
  632 + "name": "Carsten Brandt",
  633 + "email": "mail@cebe.cc",
  634 + "homepage": "http://cebe.cc/",
  635 + "role": "Core framework development"
  636 + },
  637 + {
  638 + "name": "Timur Ruziev",
  639 + "email": "resurtm@gmail.com",
  640 + "homepage": "http://resurtm.com/",
  641 + "role": "Core framework development"
  642 + },
  643 + {
  644 + "name": "Paul Klimov",
  645 + "email": "klimov.paul@gmail.com",
  646 + "role": "Core framework development"
  647 + }
  648 + ],
  649 + "description": "Yii PHP Framework Version 2",
  650 + "homepage": "http://www.yiiframework.com/",
  651 + "keywords": [
  652 + "framework",
  653 + "yii2"
  654 + ],
  655 + "time": "2015-08-05 22:00:30"
  656 + },
  657 + {
  658 + "name": "yiisoft/yii2-bootstrap",
  659 + "version": "2.0.5",
  660 + "source": {
  661 + "type": "git",
  662 + "url": "https://github.com/yiisoft/yii2-bootstrap.git",
  663 + "reference": "1464f93834b1d5edb1f5625f7ffd6c3723fa4923"
  664 + },
  665 + "dist": {
  666 + "type": "zip",
  667 + "url": "https://api.github.com/repos/yiisoft/yii2-bootstrap/zipball/1464f93834b1d5edb1f5625f7ffd6c3723fa4923",
  668 + "reference": "1464f93834b1d5edb1f5625f7ffd6c3723fa4923",
  669 + "shasum": ""
  670 + },
  671 + "require": {
  672 + "bower-asset/bootstrap": "3.3.* | 3.2.* | 3.1.*",
  673 + "yiisoft/yii2": ">=2.0.6"
  674 + },
  675 + "type": "yii2-extension",
  676 + "extra": {
  677 + "branch-alias": {
  678 + "dev-master": "2.0.x-dev"
  679 + },
  680 + "asset-installer-paths": {
  681 + "npm-asset-library": "vendor/npm",
  682 + "bower-asset-library": "vendor/bower"
  683 + }
  684 + },
  685 + "autoload": {
  686 + "psr-4": {
  687 + "yii\\bootstrap\\": ""
  688 + }
  689 + },
  690 + "notification-url": "https://packagist.org/downloads/",
  691 + "license": [
  692 + "BSD-3-Clause"
  693 + ],
  694 + "authors": [
  695 + {
  696 + "name": "Qiang Xue",
  697 + "email": "qiang.xue@gmail.com"
  698 + }
  699 + ],
  700 + "description": "The Twitter Bootstrap extension for the Yii framework",
  701 + "keywords": [
  702 + "bootstrap",
  703 + "yii2"
  704 + ],
  705 + "time": "2015-09-23 17:48:24"
  706 + },
  707 + {
  708 + "name": "yiisoft/yii2-composer",
  709 + "version": "2.0.3",
  710 + "source": {
  711 + "type": "git",
  712 + "url": "https://github.com/yiisoft/yii2-composer.git",
  713 + "reference": "ca8d23707ae47d20b0454e4b135c156f6da6d7be"
  714 + },
  715 + "dist": {
  716 + "type": "zip",
  717 + "url": "https://api.github.com/repos/yiisoft/yii2-composer/zipball/ca8d23707ae47d20b0454e4b135c156f6da6d7be",
  718 + "reference": "ca8d23707ae47d20b0454e4b135c156f6da6d7be",
  719 + "shasum": ""
  720 + },
  721 + "require": {
  722 + "composer-plugin-api": "1.0.0"
  723 + },
  724 + "type": "composer-plugin",
  725 + "extra": {
  726 + "class": "yii\\composer\\Plugin",
  727 + "branch-alias": {
  728 + "dev-master": "2.0.x-dev"
  729 + }
  730 + },
  731 + "autoload": {
  732 + "psr-4": {
  733 + "yii\\composer\\": ""
  734 + }
  735 + },
  736 + "notification-url": "https://packagist.org/downloads/",
  737 + "license": [
  738 + "BSD-3-Clause"
  739 + ],
  740 + "authors": [
  741 + {
  742 + "name": "Qiang Xue",
  743 + "email": "qiang.xue@gmail.com"
  744 + }
  745 + ],
  746 + "description": "The composer plugin for Yii extension installer",
  747 + "keywords": [
  748 + "composer",
  749 + "extension installer",
  750 + "yii2"
  751 + ],
  752 + "time": "2015-03-01 06:22:44"
  753 + },
  754 + {
  755 + "name": "yiisoft/yii2-imagine",
  756 + "version": "2.0.3",
  757 + "source": {
  758 + "type": "git",
  759 + "url": "https://github.com/yiisoft/yii2-imagine.git",
  760 + "reference": "0961343138b65bba447de84b2b300899617e6acc"
  761 + },
  762 + "dist": {
  763 + "type": "zip",
  764 + "url": "https://api.github.com/repos/yiisoft/yii2-imagine/zipball/0961343138b65bba447de84b2b300899617e6acc",
  765 + "reference": "0961343138b65bba447de84b2b300899617e6acc",
  766 + "shasum": ""
  767 + },
  768 + "require": {
  769 + "imagine/imagine": "0.5.*",
  770 + "yiisoft/yii2": "*"
  771 + },
  772 + "type": "yii2-extension",
  773 + "extra": {
  774 + "branch-alias": {
  775 + "dev-master": "2.0.x-dev"
  776 + }
  777 + },
  778 + "autoload": {
  779 + "psr-4": {
  780 + "yii\\imagine\\": ""
  781 + }
  782 + },
  783 + "notification-url": "https://packagist.org/downloads/",
  784 + "license": [
  785 + "BSD-3-Clause"
  786 + ],
  787 + "authors": [
  788 + {
  789 + "name": "Antonio Ramirez",
  790 + "email": "amigo.cobos@gmail.com"
  791 + }
  792 + ],
  793 + "description": "The Imagine integration for the Yii framework",
  794 + "keywords": [
  795 + "helper",
  796 + "image",
  797 + "imagine",
  798 + "yii2"
  799 + ],
  800 + "time": "2015-03-01 06:22:44"
  801 + },
  802 + {
  803 + "name": "yiisoft/yii2-swiftmailer",
  804 + "version": "2.0.4",
  805 + "source": {
  806 + "type": "git",
  807 + "url": "https://github.com/yiisoft/yii2-swiftmailer.git",
  808 + "reference": "4ec435a89e30b203cea99770910fb5499cb3627a"
  809 + },
  810 + "dist": {
  811 + "type": "zip",
  812 + "url": "https://api.github.com/repos/yiisoft/yii2-swiftmailer/zipball/4ec435a89e30b203cea99770910fb5499cb3627a",
  813 + "reference": "4ec435a89e30b203cea99770910fb5499cb3627a",
  814 + "shasum": ""
  815 + },
  816 + "require": {
  817 + "swiftmailer/swiftmailer": "~5.0",
  818 + "yiisoft/yii2": ">=2.0.4"
  819 + },
  820 + "type": "yii2-extension",
  821 + "extra": {
  822 + "branch-alias": {
  823 + "dev-master": "2.0.x-dev"
  824 + }
  825 + },
  826 + "autoload": {
  827 + "psr-4": {
  828 + "yii\\swiftmailer\\": ""
  829 + }
  830 + },
  831 + "notification-url": "https://packagist.org/downloads/",
  832 + "license": [
  833 + "BSD-3-Clause"
  834 + ],
  835 + "authors": [
  836 + {
  837 + "name": "Paul Klimov",
  838 + "email": "klimov.paul@gmail.com"
  839 + }
  840 + ],
  841 + "description": "The SwiftMailer integration for the Yii framework",
  842 + "keywords": [
  843 + "email",
  844 + "mail",
  845 + "mailer",
  846 + "swift",
  847 + "swiftmailer",
  848 + "yii2"
  849 + ],
  850 + "time": "2015-05-10 22:12:32"
  851 + }
  852 + ],
  853 + "packages-dev": [
  854 + {
  855 + "name": "bower-asset/typeahead.js",
  856 + "version": "v0.10.5",
  857 + "source": {
  858 + "type": "git",
  859 + "url": "https://github.com/twitter/typeahead.js.git",
  860 + "reference": "5f198b87d1af845da502ea9df93a5e84801ce742"
  861 + },
  862 + "dist": {
  863 + "type": "zip",
  864 + "url": "https://api.github.com/repos/twitter/typeahead.js/zipball/5f198b87d1af845da502ea9df93a5e84801ce742",
  865 + "reference": "5f198b87d1af845da502ea9df93a5e84801ce742",
  866 + "shasum": ""
  867 + },
  868 + "require": {
  869 + "bower-asset/jquery": ">=1.7"
  870 + },
  871 + "require-dev": {
  872 + "bower-asset/jasmine-ajax": ">=1.3.1,<1.4",
  873 + "bower-asset/jasmine-jquery": ">=1.5.2,<1.6",
  874 + "bower-asset/jquery": ">=1.7,<1.8"
  875 + },
  876 + "type": "bower-asset-library",
  877 + "extra": {
  878 + "bower-asset-main": "dist/typeahead.bundle.js"
  879 + }
  880 + },
  881 + {
  882 + "name": "fzaninotto/faker",
  883 + "version": "v1.5.0",
  884 + "source": {
  885 + "type": "git",
  886 + "url": "https://github.com/fzaninotto/Faker.git",
  887 + "reference": "d0190b156bcca848d401fb80f31f504f37141c8d"
  888 + },
  889 + "dist": {
  890 + "type": "zip",
  891 + "url": "https://api.github.com/repos/fzaninotto/Faker/zipball/d0190b156bcca848d401fb80f31f504f37141c8d",
  892 + "reference": "d0190b156bcca848d401fb80f31f504f37141c8d",
  893 + "shasum": ""
  894 + },
  895 + "require": {
  896 + "php": ">=5.3.3"
  897 + },
  898 + "require-dev": {
  899 + "phpunit/phpunit": "~4.0",
  900 + "squizlabs/php_codesniffer": "~1.5"
  901 + },
  902 + "suggest": {
  903 + "ext-intl": "*"
  904 + },
  905 + "type": "library",
  906 + "extra": {
  907 + "branch-alias": {
  908 + "dev-master": "1.5.x-dev"
  909 + }
  910 + },
  911 + "autoload": {
  912 + "psr-4": {
  913 + "Faker\\": "src/Faker/"
  914 + }
  915 + },
  916 + "notification-url": "https://packagist.org/downloads/",
  917 + "license": [
  918 + "MIT"
  919 + ],
  920 + "authors": [
  921 + {
  922 + "name": "François Zaninotto"
  923 + }
  924 + ],
  925 + "description": "Faker is a PHP library that generates fake data for you.",
  926 + "keywords": [
  927 + "data",
  928 + "faker",
  929 + "fixtures"
  930 + ],
  931 + "time": "2015-05-29 06:29:14"
  932 + },
  933 + {
  934 + "name": "phpspec/php-diff",
  935 + "version": "v1.0.2",
  936 + "source": {
  937 + "type": "git",
  938 + "url": "https://github.com/phpspec/php-diff.git",
  939 + "reference": "30e103d19519fe678ae64a60d77884ef3d71b28a"
  940 + },
  941 + "dist": {
  942 + "type": "zip",
  943 + "url": "https://api.github.com/repos/phpspec/php-diff/zipball/30e103d19519fe678ae64a60d77884ef3d71b28a",
  944 + "reference": "30e103d19519fe678ae64a60d77884ef3d71b28a",
  945 + "shasum": ""
  946 + },
  947 + "type": "library",
  948 + "autoload": {
  949 + "psr-0": {
  950 + "Diff": "lib/"
  951 + }
  952 + },
  953 + "notification-url": "https://packagist.org/downloads/",
  954 + "license": [
  955 + "BSD-3-Clause"
  956 + ],
  957 + "authors": [
  958 + {
  959 + "name": "Chris Boulton",
  960 + "homepage": "http://github.com/chrisboulton",
  961 + "role": "Original developer"
  962 + }
  963 + ],
  964 + "description": "A comprehensive library for generating differences between two hashable objects (strings or arrays).",
  965 + "time": "2013-11-01 13:02:21"
  966 + },
  967 + {
  968 + "name": "yiisoft/yii2-codeception",
  969 + "version": "2.0.4",
  970 + "source": {
  971 + "type": "git",
  972 + "url": "https://github.com/yiisoft/yii2-codeception.git",
  973 + "reference": "de5007e7a99359597abbfe1c88dca3ce620061c5"
  974 + },
  975 + "dist": {
  976 + "type": "zip",
  977 + "url": "https://api.github.com/repos/yiisoft/yii2-codeception/zipball/de5007e7a99359597abbfe1c88dca3ce620061c5",
  978 + "reference": "de5007e7a99359597abbfe1c88dca3ce620061c5",
  979 + "shasum": ""
  980 + },
  981 + "require": {
  982 + "yiisoft/yii2": ">=2.0.4"
  983 + },
  984 + "type": "yii2-extension",
  985 + "extra": {
  986 + "branch-alias": {
  987 + "dev-master": "2.0.x-dev"
  988 + }
  989 + },
  990 + "autoload": {
  991 + "psr-4": {
  992 + "yii\\codeception\\": ""
  993 + }
  994 + },
  995 + "notification-url": "https://packagist.org/downloads/",
  996 + "license": [
  997 + "BSD-3-Clause"
  998 + ],
  999 + "authors": [
  1000 + {
  1001 + "name": "Mark Jebri",
  1002 + "email": "mark.github@yandex.ru"
  1003 + }
  1004 + ],
  1005 + "description": "The Codeception integration for the Yii framework",
  1006 + "keywords": [
  1007 + "codeception",
  1008 + "yii2"
  1009 + ],
  1010 + "time": "2015-05-10 22:08:30"
  1011 + },
  1012 + {
  1013 + "name": "yiisoft/yii2-debug",
  1014 + "version": "2.0.5",
  1015 + "source": {
  1016 + "type": "git",
  1017 + "url": "https://github.com/yiisoft/yii2-debug.git",
  1018 + "reference": "1b302e67521d46feb2413d9d96ca94ed82b39b0e"
  1019 + },
  1020 + "dist": {
  1021 + "type": "zip",
  1022 + "url": "https://api.github.com/repos/yiisoft/yii2-debug/zipball/1b302e67521d46feb2413d9d96ca94ed82b39b0e",
  1023 + "reference": "1b302e67521d46feb2413d9d96ca94ed82b39b0e",
  1024 + "shasum": ""
  1025 + },
  1026 + "require": {
  1027 + "yiisoft/yii2": ">=2.0.4",
  1028 + "yiisoft/yii2-bootstrap": "*"
  1029 + },
  1030 + "type": "yii2-extension",
  1031 + "extra": {
  1032 + "branch-alias": {
  1033 + "dev-master": "2.0.x-dev"
  1034 + }
  1035 + },
  1036 + "autoload": {
  1037 + "psr-4": {
  1038 + "yii\\debug\\": ""
  1039 + }
  1040 + },
  1041 + "notification-url": "https://packagist.org/downloads/",
  1042 + "license": [
  1043 + "BSD-3-Clause"
  1044 + ],
  1045 + "authors": [
  1046 + {
  1047 + "name": "Qiang Xue",
  1048 + "email": "qiang.xue@gmail.com"
  1049 + }
  1050 + ],
  1051 + "description": "The debugger extension for the Yii framework",
  1052 + "keywords": [
  1053 + "debug",
  1054 + "debugger",
  1055 + "yii2"
  1056 + ],
  1057 + "time": "2015-08-06 16:14:06"
  1058 + },
  1059 + {
  1060 + "name": "yiisoft/yii2-faker",
  1061 + "version": "2.0.3",
  1062 + "source": {
  1063 + "type": "git",
  1064 + "url": "https://github.com/yiisoft/yii2-faker.git",
  1065 + "reference": "b88ca69ee226a3610b2c26c026c3203d7ac50f6c"
  1066 + },
  1067 + "dist": {
  1068 + "type": "zip",
  1069 + "url": "https://api.github.com/repos/yiisoft/yii2-faker/zipball/b88ca69ee226a3610b2c26c026c3203d7ac50f6c",
  1070 + "reference": "b88ca69ee226a3610b2c26c026c3203d7ac50f6c",
  1071 + "shasum": ""
  1072 + },
  1073 + "require": {
  1074 + "fzaninotto/faker": "*",
  1075 + "yiisoft/yii2": "*"
  1076 + },
  1077 + "type": "yii2-extension",
  1078 + "extra": {
  1079 + "branch-alias": {
  1080 + "dev-master": "2.0.x-dev"
  1081 + }
  1082 + },
  1083 + "autoload": {
  1084 + "psr-4": {
  1085 + "yii\\faker\\": ""
  1086 + }
  1087 + },
  1088 + "notification-url": "https://packagist.org/downloads/",
  1089 + "license": [
  1090 + "BSD-3-Clause"
  1091 + ],
  1092 + "authors": [
  1093 + {
  1094 + "name": "Mark Jebri",
  1095 + "email": "mark.github@yandex.ru"
  1096 + }
  1097 + ],
  1098 + "description": "Fixture generator. The Faker integration for the Yii framework.",
  1099 + "keywords": [
  1100 + "Fixture",
  1101 + "faker",
  1102 + "yii2"
  1103 + ],
  1104 + "time": "2015-03-01 06:22:44"
  1105 + },
  1106 + {
  1107 + "name": "yiisoft/yii2-gii",
  1108 + "version": "2.0.4",
  1109 + "source": {
  1110 + "type": "git",
  1111 + "url": "https://github.com/yiisoft/yii2-gii.git",
  1112 + "reference": "e5a023e8779bd774194842ec1b8fb4917cf04007"
  1113 + },
  1114 + "dist": {
  1115 + "type": "zip",
  1116 + "url": "https://api.github.com/repos/yiisoft/yii2-gii/zipball/e5a023e8779bd774194842ec1b8fb4917cf04007",
  1117 + "reference": "e5a023e8779bd774194842ec1b8fb4917cf04007",
  1118 + "shasum": ""
  1119 + },
  1120 + "require": {
  1121 + "bower-asset/typeahead.js": "0.10.*",
  1122 + "phpspec/php-diff": ">=1.0.2",
  1123 + "yiisoft/yii2": ">=2.0.4",
  1124 + "yiisoft/yii2-bootstrap": "~2.0"
  1125 + },
  1126 + "type": "yii2-extension",
  1127 + "extra": {
  1128 + "branch-alias": {
  1129 + "dev-master": "2.0.x-dev"
  1130 + },
  1131 + "asset-installer-paths": {
  1132 + "npm-asset-library": "vendor/npm",
  1133 + "bower-asset-library": "vendor/bower"
  1134 + }
  1135 + },
  1136 + "autoload": {
  1137 + "psr-4": {
  1138 + "yii\\gii\\": ""
  1139 + }
  1140 + },
  1141 + "notification-url": "https://packagist.org/downloads/",
  1142 + "license": [
  1143 + "BSD-3-Clause"
  1144 + ],
  1145 + "authors": [
  1146 + {
  1147 + "name": "Qiang Xue",
  1148 + "email": "qiang.xue@gmail.com"
  1149 + }
  1150 + ],
  1151 + "description": "The Gii extension for the Yii framework",
  1152 + "keywords": [
  1153 + "code generator",
  1154 + "gii",
  1155 + "yii2"
  1156 + ],
  1157 + "time": "2015-05-10 22:09:31"
  1158 + }
  1159 + ],
  1160 + "aliases": [],
  1161 + "minimum-stability": "stable",
  1162 + "stability-flags": {
  1163 + "kartik-v/yii2-widget-fileinput": 20
  1164 + },
  1165 + "prefer-stable": false,
  1166 + "prefer-lowest": false,
  1167 + "platform": {
  1168 + "php": ">=5.4.0"
  1169 + },
  1170 + "platform-dev": []
  1171 +}
console/config/.gitignore 0 → 100644
  1 +++ a/console/config/.gitignore
  1 +main-local.php
  2 +params-local.php
0 \ No newline at end of file 3 \ No newline at end of file
console/config/bootstrap.php 0 → 100644
  1 +++ a/console/config/bootstrap.php
  1 +<?php
console/config/main.php 0 → 100644
  1 +++ a/console/config/main.php
  1 +<?php
  2 +$params = array_merge(
  3 + require(__DIR__ . '/../../common/config/params.php'),
  4 + require(__DIR__ . '/../../common/config/params-local.php'),
  5 + require(__DIR__ . '/params.php'),
  6 + require(__DIR__ . '/params-local.php')
  7 +);
  8 +
  9 +return [
  10 + 'id' => 'app-console',
  11 + 'basePath' => dirname(__DIR__),
  12 + 'bootstrap' => ['log'],
  13 + 'controllerNamespace' => 'console\controllers',
  14 + 'components' => [
  15 + 'log' => [
  16 + 'targets' => [
  17 + [
  18 + 'class' => 'yii\log\FileTarget',
  19 + 'levels' => ['error', 'warning'],
  20 + ],
  21 + ],
  22 + ],
  23 + ],
  24 + 'params' => $params,
  25 +];
console/config/params.php 0 → 100644
  1 +++ a/console/config/params.php
  1 +<?php
  2 +return [
  3 + 'adminEmail' => 'admin@example.com',
  4 +];
console/controllers/.gitkeep 0 → 100644
  1 +++ a/console/controllers/.gitkeep
console/migrations/m130524_201442_init.php 0 → 100644
  1 +++ a/console/migrations/m130524_201442_init.php
  1 +<?php
  2 +
  3 +use yii\db\Schema;
  4 +use yii\db\Migration;
  5 +
  6 +class m130524_201442_init extends Migration
  7 +{
  8 + public function up()
  9 + {
  10 + $tableOptions = null;
  11 + if ($this->db->driverName === 'mysql') {
  12 + // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
  13 + $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
  14 + }
  15 +
  16 + $this->createTable('{{%user}}', [
  17 + 'id' => Schema::TYPE_PK,
  18 + 'username' => Schema::TYPE_STRING . ' NOT NULL',
  19 + 'auth_key' => Schema::TYPE_STRING . '(32) NOT NULL',
  20 + 'password_hash' => Schema::TYPE_STRING . ' NOT NULL',
  21 + 'password_reset_token' => Schema::TYPE_STRING,
  22 + 'email' => Schema::TYPE_STRING . ' NOT NULL',
  23 +
  24 + 'status' => Schema::TYPE_SMALLINT . ' NOT NULL DEFAULT 10',
  25 + 'created_at' => Schema::TYPE_INTEGER . ' NOT NULL',
  26 + 'updated_at' => Schema::TYPE_INTEGER . ' NOT NULL',
  27 + ], $tableOptions);
  28 + }
  29 +
  30 + public function down()
  31 + {
  32 + $this->dropTable('{{%user}}');
  33 + }
  34 +}
console/models/.gitkeep 0 → 100644
  1 +++ a/console/models/.gitkeep
  1 +*
console/runtime/.gitignore 0 → 100644
  1 +++ a/console/runtime/.gitignore
  1 +*
  2 +!.gitignore
0 \ No newline at end of file 3 \ No newline at end of file
environments/dev/backend/config/main-local.php 0 → 100644
  1 +++ a/environments/dev/backend/config/main-local.php
  1 +<?php
  2 +
  3 +$config = [
  4 + 'components' => [
  5 + 'request' => [
  6 + // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
  7 + 'cookieValidationKey' => '',
  8 + ],
  9 + ],
  10 +];
  11 +
  12 +if (!YII_ENV_TEST) {
  13 + // configuration adjustments for 'dev' environment
  14 + $config['bootstrap'][] = 'debug';
  15 + $config['modules']['debug'] = 'yii\debug\Module';
  16 +
  17 + $config['bootstrap'][] = 'gii';
  18 + $config['modules']['gii'] = 'yii\gii\Module';
  19 +}
  20 +
  21 +return $config;
environments/dev/backend/config/params-local.php 0 → 100644
  1 +++ a/environments/dev/backend/config/params-local.php
  1 +<?php
  2 +return [
  3 +];
environments/dev/backend/web/index-test.php 0 → 100644
  1 +++ a/environments/dev/backend/web/index-test.php
  1 +<?php
  2 +
  3 +// NOTE: Make sure this file is not accessible when deployed to production
  4 +if (!in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1'])) {
  5 + die('You are not allowed to access this file.');
  6 +}
  7 +
  8 +defined('YII_DEBUG') or define('YII_DEBUG', true);
  9 +defined('YII_ENV') or define('YII_ENV', 'test');
  10 +
  11 +require(__DIR__ . '/../../vendor/autoload.php');
  12 +require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
  13 +require(__DIR__ . '/../../common/config/bootstrap.php');
  14 +require(__DIR__ . '/../config/bootstrap.php');
  15 +
  16 +
  17 +$config = require(__DIR__ . '/../../tests/codeception/config/backend/acceptance.php');
  18 +
  19 +(new yii\web\Application($config))->run();
environments/dev/backend/web/index.php 0 → 100644
  1 +++ a/environments/dev/backend/web/index.php
  1 +<?php
  2 +defined('YII_DEBUG') or define('YII_DEBUG', true);
  3 +defined('YII_ENV') or define('YII_ENV', 'dev');
  4 +
  5 +require(__DIR__ . '/../../vendor/autoload.php');
  6 +require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
  7 +require(__DIR__ . '/../../common/config/bootstrap.php');
  8 +require(__DIR__ . '/../config/bootstrap.php');
  9 +
  10 +$config = yii\helpers\ArrayHelper::merge(
  11 + require(__DIR__ . '/../../common/config/main.php'),
  12 + require(__DIR__ . '/../../common/config/main-local.php'),
  13 + require(__DIR__ . '/../config/main.php'),
  14 + require(__DIR__ . '/../config/main-local.php')
  15 +);
  16 +
  17 +$application = new yii\web\Application($config);
  18 +$application->run();
environments/dev/common/config/main-local.php 0 → 100644
  1 +++ a/environments/dev/common/config/main-local.php
  1 +<?php
  2 +return [
  3 + 'components' => [
  4 + 'db' => [
  5 + 'class' => 'yii\db\Connection',
  6 + 'dsn' => 'mysql:host=localhost;dbname=yii2advanced',
  7 + 'username' => 'root',
  8 + 'password' => '',
  9 + 'charset' => 'utf8',
  10 + ],
  11 + 'mailer' => [
  12 + 'class' => 'yii\swiftmailer\Mailer',
  13 + 'viewPath' => '@common/mail',
  14 + // send all mails to a file by default. You have to set
  15 + // 'useFileTransport' to false and configure a transport
  16 + // for the mailer to send real emails.
  17 + 'useFileTransport' => true,
  18 + ],
  19 + ],
  20 +];
environments/dev/common/config/params-local.php 0 → 100644
  1 +++ a/environments/dev/common/config/params-local.php
  1 +<?php
  2 +return [
  3 +];
environments/dev/console/config/main-local.php 0 → 100644
  1 +++ a/environments/dev/console/config/main-local.php
  1 +<?php
  2 +return [
  3 + 'bootstrap' => ['gii'],
  4 + 'modules' => [
  5 + 'gii' => 'yii\gii\Module',
  6 + ],
  7 +];
environments/dev/console/config/params-local.php 0 → 100644
  1 +++ a/environments/dev/console/config/params-local.php
  1 +<?php
  2 +return [
  3 +];
environments/dev/frontend/config/main-local.php 0 → 100644
  1 +++ a/environments/dev/frontend/config/main-local.php
  1 +<?php
  2 +
  3 +$config = [
  4 + 'components' => [
  5 + 'request' => [
  6 + // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
  7 + 'cookieValidationKey' => '',
  8 + ],
  9 + ],
  10 +];
  11 +
  12 +if (!YII_ENV_TEST) {
  13 + // configuration adjustments for 'dev' environment
  14 + $config['bootstrap'][] = 'debug';
  15 + $config['modules']['debug'] = 'yii\debug\Module';
  16 +
  17 + $config['bootstrap'][] = 'gii';
  18 + $config['modules']['gii'] = 'yii\gii\Module';
  19 +}
  20 +
  21 +return $config;
environments/dev/frontend/config/params-local.php 0 → 100644
  1 +++ a/environments/dev/frontend/config/params-local.php
  1 +<?php
  2 +return [
  3 +];
environments/dev/frontend/web/index-test.php 0 → 100644
  1 +++ a/environments/dev/frontend/web/index-test.php
  1 +<?php
  2 +
  3 +// NOTE: Make sure this file is not accessible when deployed to production
  4 +if (!in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1'])) {
  5 + die('You are not allowed to access this file.');
  6 +}
  7 +
  8 +defined('YII_DEBUG') or define('YII_DEBUG', true);
  9 +defined('YII_ENV') or define('YII_ENV', 'test');
  10 +
  11 +require(__DIR__ . '/../../vendor/autoload.php');
  12 +require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
  13 +require(__DIR__ . '/../../common/config/bootstrap.php');
  14 +require(__DIR__ . '/../config/bootstrap.php');
  15 +
  16 +$config = require(__DIR__ . '/../../tests/codeception/config/frontend/acceptance.php');
  17 +
  18 +(new yii\web\Application($config))->run();
environments/dev/frontend/web/index.php 0 → 100644
  1 +++ a/environments/dev/frontend/web/index.php
  1 +<?php
  2 +defined('YII_DEBUG') or define('YII_DEBUG', true);
  3 +defined('YII_ENV') or define('YII_ENV', 'dev');
  4 +
  5 +require(__DIR__ . '/../../vendor/autoload.php');
  6 +require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
  7 +require(__DIR__ . '/../../common/config/bootstrap.php');
  8 +require(__DIR__ . '/../config/bootstrap.php');
  9 +
  10 +$config = yii\helpers\ArrayHelper::merge(
  11 + require(__DIR__ . '/../../common/config/main.php'),
  12 + require(__DIR__ . '/../../common/config/main-local.php'),
  13 + require(__DIR__ . '/../config/main.php'),
  14 + require(__DIR__ . '/../config/main-local.php')
  15 +);
  16 +
  17 +$application = new yii\web\Application($config);
  18 +$application->run();
environments/dev/yii 0 → 100644
  1 +++ a/environments/dev/yii
  1 +#!/usr/bin/env php
  2 +<?php
  3 +/**
  4 + * Yii console bootstrap file.
  5 + *
  6 + * @link http://www.yiiframework.com/
  7 + * @copyright Copyright (c) 2008 Yii Software LLC
  8 + * @license http://www.yiiframework.com/license/
  9 + */
  10 +
  11 +defined('YII_DEBUG') or define('YII_DEBUG', true);
  12 +defined('YII_ENV') or define('YII_ENV', 'dev');
  13 +
  14 +// fcgi doesn't have STDIN and STDOUT defined by default
  15 +defined('STDIN') or define('STDIN', fopen('php://stdin', 'r'));
  16 +defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w'));
  17 +
  18 +require(__DIR__ . '/vendor/autoload.php');
  19 +require(__DIR__ . '/vendor/yiisoft/yii2/Yii.php');
  20 +require(__DIR__ . '/common/config/bootstrap.php');
  21 +require(__DIR__ . '/console/config/bootstrap.php');
  22 +
  23 +$config = yii\helpers\ArrayHelper::merge(
  24 + require(__DIR__ . '/common/config/main.php'),
  25 + require(__DIR__ . '/common/config/main-local.php'),
  26 + require(__DIR__ . '/console/config/main.php'),
  27 + require(__DIR__ . '/console/config/main-local.php')
  28 +);
  29 +
  30 +$application = new yii\console\Application($config);
  31 +$exitCode = $application->run();
  32 +exit($exitCode);
environments/index.php 0 → 100644
  1 +++ a/environments/index.php
  1 +<?php
  2 +/**
  3 + * The manifest of files that are local to specific environment.
  4 + * This file returns a list of environments that the application
  5 + * may be installed under. The returned data must be in the following
  6 + * format:
  7 + *
  8 + * ```php
  9 + * return [
  10 + * 'environment name' => [
  11 + * 'path' => 'directory storing the local files',
  12 + * 'skipFiles' => [
  13 + * // list of files that should only copied once and skipped if they already exist
  14 + * ],
  15 + * 'setWritable' => [
  16 + * // list of directories that should be set writable
  17 + * ],
  18 + * 'setExecutable' => [
  19 + * // list of files that should be set executable
  20 + * ],
  21 + * 'setCookieValidationKey' => [
  22 + * // list of config files that need to be inserted with automatically generated cookie validation keys
  23 + * ],
  24 + * 'createSymlink' => [
  25 + * // list of symlinks to be created. Keys are symlinks, and values are the targets.
  26 + * ],
  27 + * ],
  28 + * ];
  29 + * ```
  30 + */
  31 +return [
  32 + 'Development' => [
  33 + 'path' => 'dev',
  34 + 'setWritable' => [
  35 + 'backend/runtime',
  36 + 'backend/web/assets',
  37 + 'frontend/runtime',
  38 + 'frontend/web/assets',
  39 + ],
  40 + 'setExecutable' => [
  41 + 'yii',
  42 + 'tests/codeception/bin/yii',
  43 + ],
  44 + 'setCookieValidationKey' => [
  45 + 'backend/config/main-local.php',
  46 + 'frontend/config/main-local.php',
  47 + ],
  48 + ],
  49 + 'Production' => [
  50 + 'path' => 'prod',
  51 + 'setWritable' => [
  52 + 'backend/runtime',
  53 + 'backend/web/assets',
  54 + 'frontend/runtime',
  55 + 'frontend/web/assets',
  56 + ],
  57 + 'setExecutable' => [
  58 + 'yii',
  59 + ],
  60 + 'setCookieValidationKey' => [
  61 + 'backend/config/main-local.php',
  62 + 'frontend/config/main-local.php',
  63 + ],
  64 + ],
  65 +];
environments/prod/backend/config/main-local.php 0 → 100644
  1 +++ a/environments/prod/backend/config/main-local.php
  1 +<?php
  2 +return [
  3 + 'components' => [
  4 + 'request' => [
  5 + // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
  6 + 'cookieValidationKey' => '',
  7 + ],
  8 + ],
  9 +];
environments/prod/backend/config/params-local.php 0 → 100644
  1 +++ a/environments/prod/backend/config/params-local.php
  1 +<?php
  2 +return [
  3 +];
environments/prod/backend/web/index.php 0 → 100644
  1 +++ a/environments/prod/backend/web/index.php
  1 +<?php
  2 +defined('YII_DEBUG') or define('YII_DEBUG', false);
  3 +defined('YII_ENV') or define('YII_ENV', 'prod');
  4 +
  5 +require(__DIR__ . '/../../vendor/autoload.php');
  6 +require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
  7 +require(__DIR__ . '/../../common/config/bootstrap.php');
  8 +require(__DIR__ . '/../config/bootstrap.php');
  9 +
  10 +$config = yii\helpers\ArrayHelper::merge(
  11 + require(__DIR__ . '/../../common/config/main.php'),
  12 + require(__DIR__ . '/../../common/config/main-local.php'),
  13 + require(__DIR__ . '/../config/main.php'),
  14 + require(__DIR__ . '/../config/main-local.php')
  15 +);
  16 +
  17 +$application = new yii\web\Application($config);
  18 +$application->run();
environments/prod/common/config/main-local.php 0 → 100644
  1 +++ a/environments/prod/common/config/main-local.php
  1 +<?php
  2 +return [
  3 + 'components' => [
  4 + 'db' => [
  5 + 'class' => 'yii\db\Connection',
  6 + 'dsn' => 'mysql:host=localhost;dbname=yii2advanced',
  7 + 'username' => 'root',
  8 + 'password' => '',
  9 + 'charset' => 'utf8',
  10 + ],
  11 + 'mailer' => [
  12 + 'class' => 'yii\swiftmailer\Mailer',
  13 + 'viewPath' => '@common/mail',
  14 + ],
  15 + ],
  16 +];
environments/prod/common/config/params-local.php 0 → 100644
  1 +++ a/environments/prod/common/config/params-local.php
  1 +<?php
  2 +return [
  3 +];
environments/prod/console/config/main-local.php 0 → 100644
  1 +++ a/environments/prod/console/config/main-local.php
  1 +<?php
  2 +return [
  3 +];
environments/prod/console/config/params-local.php 0 → 100644
  1 +++ a/environments/prod/console/config/params-local.php
  1 +<?php
  2 +return [
  3 +];
environments/prod/frontend/config/main-local.php 0 → 100644
  1 +++ a/environments/prod/frontend/config/main-local.php
  1 +<?php
  2 +return [
  3 + 'components' => [
  4 + 'request' => [
  5 + // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
  6 + 'cookieValidationKey' => '',
  7 + ],
  8 + ],
  9 +];
environments/prod/frontend/config/params-local.php 0 → 100644
  1 +++ a/environments/prod/frontend/config/params-local.php
  1 +<?php
  2 +return [
  3 +];
environments/prod/frontend/web/index.php 0 → 100644
  1 +++ a/environments/prod/frontend/web/index.php
  1 +<?php
  2 +defined('YII_DEBUG') or define('YII_DEBUG', false);
  3 +defined('YII_ENV') or define('YII_ENV', 'prod');
  4 +
  5 +require(__DIR__ . '/../../vendor/autoload.php');
  6 +require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
  7 +require(__DIR__ . '/../../common/config/bootstrap.php');
  8 +require(__DIR__ . '/../config/bootstrap.php');
  9 +
  10 +$config = yii\helpers\ArrayHelper::merge(
  11 + require(__DIR__ . '/../../common/config/main.php'),
  12 + require(__DIR__ . '/../../common/config/main-local.php'),
  13 + require(__DIR__ . '/../config/main.php'),
  14 + require(__DIR__ . '/../config/main-local.php')
  15 +);
  16 +
  17 +$application = new yii\web\Application($config);
  18 +$application->run();
environments/prod/yii 0 → 100644
  1 +++ a/environments/prod/yii
  1 +#!/usr/bin/env php
  2 +<?php
  3 +/**
  4 + * Yii console bootstrap file.
  5 + *
  6 + * @link http://www.yiiframework.com/
  7 + * @copyright Copyright (c) 2008 Yii Software LLC
  8 + * @license http://www.yiiframework.com/license/
  9 + */
  10 +
  11 +defined('YII_DEBUG') or define('YII_DEBUG', false);
  12 +defined('YII_ENV') or define('YII_ENV', 'prod');
  13 +
  14 +// fcgi doesn't have STDIN and STDOUT defined by default
  15 +defined('STDIN') or define('STDIN', fopen('php://stdin', 'r'));
  16 +defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w'));
  17 +
  18 +require(__DIR__ . '/vendor/autoload.php');
  19 +require(__DIR__ . '/vendor/yiisoft/yii2/Yii.php');
  20 +require(__DIR__ . '/common/config/bootstrap.php');
  21 +require(__DIR__ . '/console/config/bootstrap.php');
  22 +
  23 +$config = yii\helpers\ArrayHelper::merge(
  24 + require(__DIR__ . '/common/config/main.php'),
  25 + require(__DIR__ . '/common/config/main-local.php'),
  26 + require(__DIR__ . '/console/config/main.php'),
  27 + require(__DIR__ . '/console/config/main-local.php')
  28 +);
  29 +
  30 +$application = new yii\console\Application($config);
  31 +$exitCode = $application->run();
  32 +exit($exitCode);
frontend/assets/AppAsset.php 0 → 100644
  1 +++ a/frontend/assets/AppAsset.php
  1 +<?php
  2 +/**
  3 + * @link http://www.yiiframework.com/
  4 + * @copyright Copyright (c) 2008 Yii Software LLC
  5 + * @license http://www.yiiframework.com/license/
  6 + */
  7 +
  8 +namespace frontend\assets;
  9 +
  10 +use yii\web\AssetBundle;
  11 +
  12 +/**
  13 + * @author Qiang Xue <qiang.xue@gmail.com>
  14 + * @since 2.0
  15 + */
  16 +class AppAsset extends AssetBundle
  17 +{
  18 + public $basePath = '@webroot';
  19 + public $baseUrl = '@web';
  20 + public $css = [
  21 + 'css/site.css',
  22 + ];
  23 + public $js = [
  24 + ];
  25 + public $depends = [
  26 + 'yii\web\YiiAsset',
  27 + 'yii\bootstrap\BootstrapAsset',
  28 + ];
  29 +}
frontend/config/.gitignore 0 → 100644
  1 +++ a/frontend/config/.gitignore
  1 +main-local.php
  2 +params-local.php
0 \ No newline at end of file 3 \ No newline at end of file
frontend/config/bootstrap.php 0 → 100644
  1 +++ a/frontend/config/bootstrap.php
  1 +<?php
frontend/config/main.php 0 → 100644
  1 +++ a/frontend/config/main.php
  1 +<?php
  2 +$params = array_merge(
  3 + require(__DIR__ . '/../../common/config/params.php'),
  4 + require(__DIR__ . '/../../common/config/params-local.php'),
  5 + require(__DIR__ . '/params.php'),
  6 + require(__DIR__ . '/params-local.php')
  7 +);
  8 +
  9 +return [
  10 + 'id' => 'app-frontend',
  11 + 'basePath' => dirname(__DIR__),
  12 + 'bootstrap' => ['log'],
  13 + 'controllerNamespace' => 'frontend\controllers',
  14 + 'components' => [
  15 + 'user' => [
  16 + 'identityClass' => 'common\models\User',
  17 + 'enableAutoLogin' => true,
  18 + ],
  19 + 'log' => [
  20 + 'traceLevel' => YII_DEBUG ? 3 : 0,
  21 + 'targets' => [
  22 + [
  23 + 'class' => 'yii\log\FileTarget',
  24 + 'levels' => ['error', 'warning'],
  25 + ],
  26 + ],
  27 + ],
  28 + 'errorHandler' => [
  29 + 'errorAction' => 'site/error',
  30 + ],
  31 + ],
  32 + 'params' => $params,
  33 +];
frontend/config/params.php 0 → 100644
  1 +++ a/frontend/config/params.php
  1 +<?php
  2 +return [
  3 + 'adminEmail' => 'admin@example.com',
  4 +];
frontend/controllers/SiteController.php 0 → 100644
  1 +++ a/frontend/controllers/SiteController.php
  1 +<?php
  2 +namespace frontend\controllers;
  3 +
  4 +use Yii;
  5 +use common\models\LoginForm;
  6 +use frontend\models\PasswordResetRequestForm;
  7 +use frontend\models\ResetPasswordForm;
  8 +use frontend\models\SignupForm;
  9 +use frontend\models\ContactForm;
  10 +use yii\base\InvalidParamException;
  11 +use yii\web\BadRequestHttpException;
  12 +use yii\web\Controller;
  13 +use yii\filters\VerbFilter;
  14 +use yii\filters\AccessControl;
  15 +
  16 +/**
  17 + * Site controller
  18 + */
  19 +class SiteController extends Controller
  20 +{
  21 + /**
  22 + * @inheritdoc
  23 + */
  24 + public function behaviors()
  25 + {
  26 + return [
  27 + 'access' => [
  28 + 'class' => AccessControl::className(),
  29 + 'only' => ['logout', 'signup'],
  30 + 'rules' => [
  31 + [
  32 + 'actions' => ['signup'],
  33 + 'allow' => true,
  34 + 'roles' => ['?'],
  35 + ],
  36 + [
  37 + 'actions' => ['logout'],
  38 + 'allow' => true,
  39 + 'roles' => ['@'],
  40 + ],
  41 + ],
  42 + ],
  43 + 'verbs' => [
  44 + 'class' => VerbFilter::className(),
  45 + 'actions' => [
  46 + 'logout' => ['post'],
  47 + ],
  48 + ],
  49 + ];
  50 + }
  51 +
  52 + /**
  53 + * @inheritdoc
  54 + */
  55 + public function actions()
  56 + {
  57 + return [
  58 + 'error' => [
  59 + 'class' => 'yii\web\ErrorAction',
  60 + ],
  61 + 'captcha' => [
  62 + 'class' => 'yii\captcha\CaptchaAction',
  63 + 'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
  64 + ],
  65 + ];
  66 + }
  67 +
  68 + public function actionIndex()
  69 + {
  70 + return $this->render('index');
  71 + }
  72 +
  73 + public function actionLogin()
  74 + {
  75 + if (!\Yii::$app->user->isGuest) {
  76 + return $this->goHome();
  77 + }
  78 +
  79 + $model = new LoginForm();
  80 + if ($model->load(Yii::$app->request->post()) && $model->login()) {
  81 + return $this->goBack();
  82 + } else {
  83 + return $this->render('login', [
  84 + 'model' => $model,
  85 + ]);
  86 + }
  87 + }
  88 +
  89 + public function actionLogout()
  90 + {
  91 + Yii::$app->user->logout();
  92 +
  93 + return $this->goHome();
  94 + }
  95 +
  96 + public function actionContact()
  97 + {
  98 + $model = new ContactForm();
  99 + if ($model->load(Yii::$app->request->post()) && $model->validate()) {
  100 + if ($model->sendEmail(Yii::$app->params['adminEmail'])) {
  101 + Yii::$app->session->setFlash('success', 'Thank you for contacting us. We will respond to you as soon as possible.');
  102 + } else {
  103 + Yii::$app->session->setFlash('error', 'There was an error sending email.');
  104 + }
  105 +
  106 + return $this->refresh();
  107 + } else {
  108 + return $this->render('contact', [
  109 + 'model' => $model,
  110 + ]);
  111 + }
  112 + }
  113 +
  114 + public function actionAbout()
  115 + {
  116 + return $this->render('about');
  117 + }
  118 +
  119 + public function actionSignup()
  120 + {
  121 + $model = new SignupForm();
  122 + if ($model->load(Yii::$app->request->post())) {
  123 + if ($user = $model->signup()) {
  124 + if (Yii::$app->getUser()->login($user)) {
  125 + return $this->goHome();
  126 + }
  127 + }
  128 + }
  129 +
  130 + return $this->render('signup', [
  131 + 'model' => $model,
  132 + ]);
  133 + }
  134 +
  135 + public function actionRequestPasswordReset()
  136 + {
  137 + $model = new PasswordResetRequestForm();
  138 + if ($model->load(Yii::$app->request->post()) && $model->validate()) {
  139 + if ($model->sendEmail()) {
  140 + Yii::$app->getSession()->setFlash('success', 'Check your email for further instructions.');
  141 +
  142 + return $this->goHome();
  143 + } else {
  144 + Yii::$app->getSession()->setFlash('error', 'Sorry, we are unable to reset password for email provided.');
  145 + }
  146 + }
  147 +
  148 + return $this->render('requestPasswordResetToken', [
  149 + 'model' => $model,
  150 + ]);
  151 + }
  152 +
  153 + public function actionResetPassword($token)
  154 + {
  155 + try {
  156 + $model = new ResetPasswordForm($token);
  157 + } catch (InvalidParamException $e) {
  158 + throw new BadRequestHttpException($e->getMessage());
  159 + }
  160 +
  161 + if ($model->load(Yii::$app->request->post()) && $model->validate() && $model->resetPassword()) {
  162 + Yii::$app->getSession()->setFlash('success', 'New password was saved.');
  163 +
  164 + return $this->goHome();
  165 + }
  166 +
  167 + return $this->render('resetPassword', [
  168 + 'model' => $model,
  169 + ]);
  170 + }
  171 +}
frontend/models/ContactForm.php 0 → 100644
  1 +++ a/frontend/models/ContactForm.php
  1 +<?php
  2 +
  3 +namespace frontend\models;
  4 +
  5 +use Yii;
  6 +use yii\base\Model;
  7 +
  8 +/**
  9 + * ContactForm is the model behind the contact form.
  10 + */
  11 +class ContactForm extends Model
  12 +{
  13 + public $name;
  14 + public $email;
  15 + public $subject;
  16 + public $body;
  17 + public $verifyCode;
  18 +
  19 + /**
  20 + * @inheritdoc
  21 + */
  22 + public function rules()
  23 + {
  24 + return [
  25 + // name, email, subject and body are required
  26 + [['name', 'email', 'subject', 'body'], 'required'],
  27 + // email has to be a valid email address
  28 + ['email', 'email'],
  29 + // verifyCode needs to be entered correctly
  30 + ['verifyCode', 'captcha'],
  31 + ];
  32 + }
  33 +
  34 + /**
  35 + * @inheritdoc
  36 + */
  37 + public function attributeLabels()
  38 + {
  39 + return [
  40 + 'verifyCode' => 'Verification Code',
  41 + ];
  42 + }
  43 +
  44 + /**
  45 + * Sends an email to the specified email address using the information collected by this model.
  46 + *
  47 + * @param string $email the target email address
  48 + * @return boolean whether the email was sent
  49 + */
  50 + public function sendEmail($email)
  51 + {
  52 + return Yii::$app->mailer->compose()
  53 + ->setTo($email)
  54 + ->setFrom([$this->email => $this->name])
  55 + ->setSubject($this->subject)
  56 + ->setTextBody($this->body)
  57 + ->send();
  58 + }
  59 +}
frontend/models/PasswordResetRequestForm.php 0 → 100644
  1 +++ a/frontend/models/PasswordResetRequestForm.php
  1 +<?php
  2 +namespace frontend\models;
  3 +
  4 +use common\models\User;
  5 +use yii\base\Model;
  6 +
  7 +/**
  8 + * Password reset request form
  9 + */
  10 +class PasswordResetRequestForm extends Model
  11 +{
  12 + public $email;
  13 +
  14 + /**
  15 + * @inheritdoc
  16 + */
  17 + public function rules()
  18 + {
  19 + return [
  20 + ['email', 'filter', 'filter' => 'trim'],
  21 + ['email', 'required'],
  22 + ['email', 'email'],
  23 + ['email', 'exist',
  24 + 'targetClass' => '\common\models\User',
  25 + 'filter' => ['status' => User::STATUS_ACTIVE],
  26 + 'message' => 'There is no user with such email.'
  27 + ],
  28 + ];
  29 + }
  30 +
  31 + /**
  32 + * Sends an email with a link, for resetting the password.
  33 + *
  34 + * @return boolean whether the email was send
  35 + */
  36 + public function sendEmail()
  37 + {
  38 + /* @var $user User */
  39 + $user = User::findOne([
  40 + 'status' => User::STATUS_ACTIVE,
  41 + 'email' => $this->email,
  42 + ]);
  43 +
  44 + if ($user) {
  45 + if (!User::isPasswordResetTokenValid($user->password_reset_token)) {
  46 + $user->generatePasswordResetToken();
  47 + }
  48 +
  49 + if ($user->save()) {
  50 + return \Yii::$app->mailer->compose(['html' => 'passwordResetToken-html', 'text' => 'passwordResetToken-text'], ['user' => $user])
  51 + ->setFrom([\Yii::$app->params['supportEmail'] => \Yii::$app->name . ' robot'])
  52 + ->setTo($this->email)
  53 + ->setSubject('Password reset for ' . \Yii::$app->name)
  54 + ->send();
  55 + }
  56 + }
  57 +
  58 + return false;
  59 + }
  60 +}
frontend/models/ResetPasswordForm.php 0 → 100644
  1 +++ a/frontend/models/ResetPasswordForm.php
  1 +<?php
  2 +namespace frontend\models;
  3 +
  4 +use common\models\User;
  5 +use yii\base\InvalidParamException;
  6 +use yii\base\Model;
  7 +use Yii;
  8 +
  9 +/**
  10 + * Password reset form
  11 + */
  12 +class ResetPasswordForm extends Model
  13 +{
  14 + public $password;
  15 +
  16 + /**
  17 + * @var \common\models\User
  18 + */
  19 + private $_user;
  20 +
  21 +
  22 + /**
  23 + * Creates a form model given a token.
  24 + *
  25 + * @param string $token
  26 + * @param array $config name-value pairs that will be used to initialize the object properties
  27 + * @throws \yii\base\InvalidParamException if token is empty or not valid
  28 + */
  29 + public function __construct($token, $config = [])
  30 + {
  31 + if (empty($token) || !is_string($token)) {
  32 + throw new InvalidParamException('Password reset token cannot be blank.');
  33 + }
  34 + $this->_user = User::findByPasswordResetToken($token);
  35 + if (!$this->_user) {
  36 + throw new InvalidParamException('Wrong password reset token.');
  37 + }
  38 + parent::__construct($config);
  39 + }
  40 +
  41 + /**
  42 + * @inheritdoc
  43 + */
  44 + public function rules()
  45 + {
  46 + return [
  47 + ['password', 'required'],
  48 + ['password', 'string', 'min' => 6],
  49 + ];
  50 + }
  51 +
  52 + /**
  53 + * Resets password.
  54 + *
  55 + * @return boolean if password was reset.
  56 + */
  57 + public function resetPassword()
  58 + {
  59 + $user = $this->_user;
  60 + $user->setPassword($this->password);
  61 + $user->removePasswordResetToken();
  62 +
  63 + return $user->save(false);
  64 + }
  65 +}
frontend/models/SignupForm.php 0 → 100644
  1 +++ a/frontend/models/SignupForm.php
  1 +<?php
  2 +namespace frontend\models;
  3 +
  4 +use common\models\User;
  5 +use yii\base\Model;
  6 +use Yii;
  7 +
  8 +/**
  9 + * Signup form
  10 + */
  11 +class SignupForm extends Model
  12 +{
  13 + public $first_name;
  14 + public $last_name;
  15 + public $username;
  16 + public $email;
  17 + public $password;
  18 +
  19 + /**
  20 + * @inheritdoc
  21 + */
  22 + public function rules()
  23 + {
  24 + return [
  25 + ['username', 'filter', 'filter' => 'trim'],
  26 + ['username', 'required'],
  27 + ['first_name', 'required'],
  28 + ['last_name', 'required'],
  29 + ['username', 'unique', 'targetClass' => '\common\models\User', 'message' => 'This username has already been taken.'],
  30 + ['username', 'string', 'min' => 2, 'max' => 255],
  31 +
  32 + ['email', 'filter', 'filter' => 'trim'],
  33 + ['email', 'required'],
  34 + ['email', 'email'],
  35 + ['email', 'unique', 'targetClass' => '\common\models\User', 'message' => 'This email address has already been taken.'],
  36 +
  37 + ['password', 'required'],
  38 + ['password', 'string', 'min' => 6],
  39 + ];
  40 + }
  41 +
  42 + /**
  43 + * Signs user up.
  44 + *
  45 + * @return User|null the saved model or null if saving fails
  46 + */
  47 + public function signup()
  48 + {
  49 + if ($this->validate()) {
  50 + $user = new User();
  51 + $user->first_name = $this->first_name;
  52 + $user->last_name = $this->last_name;
  53 + $user->username = $this->username;
  54 + $user->email = $this->email;
  55 + $user->setPassword($this->password);
  56 + $user->generateAuthKey();
  57 + if ($user->save()) {
  58 + return $user;
  59 + }
  60 + }
  61 +
  62 + return null;
  63 + }
  64 +}
frontend/runtime/.gitignore 0 → 100644
  1 +++ a/frontend/runtime/.gitignore
  1 +*
  2 +!.gitignore
0 \ No newline at end of file 3 \ No newline at end of file
frontend/views/layouts/main.php 0 → 100644
  1 +++ a/frontend/views/layouts/main.php
  1 +<?php
  2 +use yii\helpers\Html;
  3 +use yii\bootstrap\Nav;
  4 +use yii\bootstrap\NavBar;
  5 +use yii\widgets\Breadcrumbs;
  6 +use frontend\assets\AppAsset;
  7 +use frontend\widgets\Alert;
  8 +
  9 +/* @var $this \yii\web\View */
  10 +/* @var $content string */
  11 +
  12 +AppAsset::register($this);
  13 +?>
  14 +<?php $this->beginPage() ?>
  15 +<!DOCTYPE html>
  16 +<html lang="<?= Yii::$app->language ?>">
  17 +<head>
  18 + <meta charset="<?= Yii::$app->charset ?>">
  19 + <meta name="viewport" content="width=device-width, initial-scale=1">
  20 + <?= Html::csrfMetaTags() ?>
  21 + <title><?= Html::encode($this->title) ?></title>
  22 + <?php $this->head() ?>
  23 +</head>
  24 +<body>
  25 + <?php $this->beginBody() ?>
  26 + <div class="wrap">
  27 + <?php
  28 + NavBar::begin([
  29 + 'brandLabel' => 'My Company',
  30 + 'brandUrl' => Yii::$app->homeUrl,
  31 + 'options' => [
  32 + 'class' => 'navbar-inverse navbar-fixed-top',
  33 + ],
  34 + ]);
  35 + $menuItems = [
  36 + ['label' => 'Home', 'url' => ['/site/index']],
  37 + ['label' => 'About', 'url' => ['/site/about']],
  38 + ['label' => 'Contact', 'url' => ['/site/contact']],
  39 + ];
  40 + if (Yii::$app->user->isGuest) {
  41 + $menuItems[] = ['label' => 'Signup', 'url' => ['/site/signup']];
  42 + $menuItems[] = ['label' => 'Login', 'url' => ['/site/login']];
  43 + } else {
  44 + $menuItems[] = [
  45 + 'label' => 'Logout (' . Yii::$app->user->identity->username . ')',
  46 + 'url' => ['/site/logout'],
  47 + 'linkOptions' => ['data-method' => 'post']
  48 + ];
  49 + }
  50 + echo Nav::widget([
  51 + 'options' => ['class' => 'navbar-nav navbar-right'],
  52 + 'items' => $menuItems,
  53 + ]);
  54 + NavBar::end();
  55 + ?>
  56 +
  57 + <div class="container">
  58 + <?= Breadcrumbs::widget([
  59 + 'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
  60 + ]) ?>
  61 + <?= Alert::widget() ?>
  62 + <?= $content ?>
  63 + </div>
  64 + </div>
  65 +
  66 + <footer class="footer">
  67 + <div class="container">
  68 + <p class="pull-left">&copy; My Company <?= date('Y') ?></p>
  69 + <p class="pull-right"><?= Yii::powered() ?></p>
  70 + </div>
  71 + </footer>
  72 +
  73 + <?php $this->endBody() ?>
  74 +</body>
  75 +</html>
  76 +<?php $this->endPage() ?>
frontend/views/site/about.php 0 → 100644
  1 +++ a/frontend/views/site/about.php
  1 +<?php
  2 +use yii\helpers\Html;
  3 +
  4 +/* @var $this yii\web\View */
  5 +$this->title = 'About';
  6 +$this->params['breadcrumbs'][] = $this->title;
  7 +?>
  8 +<div class="site-about">
  9 + <h1><?= Html::encode($this->title) ?></h1>
  10 +
  11 + <p>This is the About page. You may modify the following file to customize its content:</p>
  12 +
  13 + <code><?= __FILE__ ?></code>
  14 +</div>
frontend/views/site/contact.php 0 → 100644
  1 +++ a/frontend/views/site/contact.php
  1 +<?php
  2 +use yii\helpers\Html;
  3 +use yii\bootstrap\ActiveForm;
  4 +use yii\captcha\Captcha;
  5 +
  6 +/* @var $this yii\web\View */
  7 +/* @var $form yii\bootstrap\ActiveForm */
  8 +/* @var $model \frontend\models\ContactForm */
  9 +
  10 +$this->title = 'Contact';
  11 +$this->params['breadcrumbs'][] = $this->title;
  12 +?>
  13 +<div class="site-contact">
  14 + <h1><?= Html::encode($this->title) ?></h1>
  15 +
  16 + <p>
  17 + If you have business inquiries or other questions, please fill out the following form to contact us. Thank you.
  18 + </p>
  19 +
  20 + <div class="row">
  21 + <div class="col-lg-5">
  22 + <?php $form = ActiveForm::begin(['id' => 'contact-form']); ?>
  23 + <?= $form->field($model, 'name') ?>
  24 + <?= $form->field($model, 'email') ?>
  25 + <?= $form->field($model, 'subject') ?>
  26 + <?= $form->field($model, 'body')->textArea(['rows' => 6]) ?>
  27 + <?= $form->field($model, 'verifyCode')->widget(Captcha::className(), [
  28 + 'template' => '<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>',
  29 + ]) ?>
  30 + <div class="form-group">
  31 + <?= Html::submitButton('Submit', ['class' => 'btn btn-primary', 'name' => 'contact-button']) ?>
  32 + </div>
  33 + <?php ActiveForm::end(); ?>
  34 + </div>
  35 + </div>
  36 +
  37 +</div>
frontend/views/site/error.php 0 → 100644
  1 +++ a/frontend/views/site/error.php
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +
  5 +/* @var $this yii\web\View */
  6 +/* @var $name string */
  7 +/* @var $message string */
  8 +/* @var $exception Exception */
  9 +
  10 +$this->title = $name;
  11 +?>
  12 +<div class="site-error">
  13 +
  14 + <h1><?= Html::encode($this->title) ?></h1>
  15 +
  16 + <div class="alert alert-danger">
  17 + <?= nl2br(Html::encode($message)) ?>
  18 + </div>
  19 +
  20 + <p>
  21 + The above error occurred while the Web server was processing your request.
  22 + </p>
  23 + <p>
  24 + Please contact us if you think this is a server error. Thank you.
  25 + </p>
  26 +
  27 +</div>
frontend/views/site/index.php 0 → 100644
  1 +++ a/frontend/views/site/index.php
  1 +<?php
  2 +/* @var $this yii\web\View */
  3 +$this->title = 'My Yii Application';
  4 +?>
  5 +<div class="site-index">
  6 +
  7 + <div class="jumbotron">
  8 + <h1>Congratulations!</h1>
  9 +
  10 + <p class="lead">You have successfully created your Yii-powered application.</p>
  11 +
  12 + <p><a class="btn btn-lg btn-success" href="http://www.yiiframework.com">Get started with Yii</a></p>
  13 + </div>
  14 +
  15 + <div class="body-content">
  16 +
  17 + <div class="row">
  18 + <div class="col-lg-4">
  19 + <h2>Heading</h2>
  20 +
  21 + <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
  22 + dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
  23 + ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
  24 + fugiat nulla pariatur.</p>
  25 +
  26 + <p><a class="btn btn-default" href="http://www.yiiframework.com/doc/">Yii Documentation &raquo;</a></p>
  27 + </div>
  28 + <div class="col-lg-4">
  29 + <h2>Heading</h2>
  30 +
  31 + <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
  32 + dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
  33 + ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
  34 + fugiat nulla pariatur.</p>
  35 +
  36 + <p><a class="btn btn-default" href="http://www.yiiframework.com/forum/">Yii Forum &raquo;</a></p>
  37 + </div>
  38 + <div class="col-lg-4">
  39 + <h2>Heading</h2>
  40 +
  41 + <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et
  42 + dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
  43 + ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
  44 + fugiat nulla pariatur.</p>
  45 +
  46 + <p><a class="btn btn-default" href="http://www.yiiframework.com/extensions/">Yii Extensions &raquo;</a></p>
  47 + </div>
  48 + </div>
  49 +
  50 + </div>
  51 +</div>
frontend/views/site/login.php 0 → 100644
  1 +++ a/frontend/views/site/login.php
  1 +<?php
  2 +use yii\helpers\Html;
  3 +use yii\bootstrap\ActiveForm;
  4 +
  5 +/* @var $this yii\web\View */
  6 +/* @var $form yii\bootstrap\ActiveForm */
  7 +/* @var $model \common\models\LoginForm */
  8 +
  9 +$this->title = 'Login';
  10 +$this->params['breadcrumbs'][] = $this->title;
  11 +?>
  12 +<div class="site-login">
  13 + <h1><?= Html::encode($this->title) ?></h1>
  14 +
  15 + <p>Please fill out the following fields to login:</p>
  16 +
  17 + <div class="row">
  18 + <div class="col-lg-5">
  19 + <?php $form = ActiveForm::begin(['id' => 'login-form']); ?>
  20 + <?= $form->field($model, 'username') ?>
  21 + <?= $form->field($model, 'password')->passwordInput() ?>
  22 + <?= $form->field($model, 'rememberMe')->checkbox() ?>
  23 + <div style="color:#999;margin:1em 0">
  24 + If you forgot your password you can <?= Html::a('reset it', ['site/request-password-reset']) ?>.
  25 + </div>
  26 + <div class="form-group">
  27 + <?= Html::submitButton('Login', ['class' => 'btn btn-primary', 'name' => 'login-button']) ?>
  28 + </div>
  29 + <?php ActiveForm::end(); ?>
  30 + </div>
  31 + </div>
  32 +</div>
frontend/views/site/requestPasswordResetToken.php 0 → 100644
  1 +++ a/frontend/views/site/requestPasswordResetToken.php
  1 +<?php
  2 +use yii\helpers\Html;
  3 +use yii\bootstrap\ActiveForm;
  4 +
  5 +/* @var $this yii\web\View */
  6 +/* @var $form yii\bootstrap\ActiveForm */
  7 +/* @var $model \frontend\models\PasswordResetRequestForm */
  8 +
  9 +$this->title = 'Request password reset';
  10 +$this->params['breadcrumbs'][] = $this->title;
  11 +?>
  12 +<div class="site-request-password-reset">
  13 + <h1><?= Html::encode($this->title) ?></h1>
  14 +
  15 + <p>Please fill out your email. A link to reset password will be sent there.</p>
  16 +
  17 + <div class="row">
  18 + <div class="col-lg-5">
  19 + <?php $form = ActiveForm::begin(['id' => 'request-password-reset-form']); ?>
  20 + <?= $form->field($model, 'email') ?>
  21 + <div class="form-group">
  22 + <?= Html::submitButton('Send', ['class' => 'btn btn-primary']) ?>
  23 + </div>
  24 + <?php ActiveForm::end(); ?>
  25 + </div>
  26 + </div>
  27 +</div>
frontend/views/site/resetPassword.php 0 → 100644
  1 +++ a/frontend/views/site/resetPassword.php
  1 +<?php
  2 +use yii\helpers\Html;
  3 +use yii\bootstrap\ActiveForm;
  4 +
  5 +/* @var $this yii\web\View */
  6 +/* @var $form yii\bootstrap\ActiveForm */
  7 +/* @var $model \frontend\models\ResetPasswordForm */
  8 +
  9 +$this->title = 'Reset password';
  10 +$this->params['breadcrumbs'][] = $this->title;
  11 +?>
  12 +<div class="site-reset-password">
  13 + <h1><?= Html::encode($this->title) ?></h1>
  14 +
  15 + <p>Please choose your new password:</p>
  16 +
  17 + <div class="row">
  18 + <div class="col-lg-5">
  19 + <?php $form = ActiveForm::begin(['id' => 'reset-password-form']); ?>
  20 + <?= $form->field($model, 'password')->passwordInput() ?>
  21 + <div class="form-group">
  22 + <?= Html::submitButton('Save', ['class' => 'btn btn-primary']) ?>
  23 + </div>
  24 + <?php ActiveForm::end(); ?>
  25 + </div>
  26 + </div>
  27 +</div>
frontend/views/site/signup.php 0 → 100644
  1 +++ a/frontend/views/site/signup.php
  1 +<?php
  2 +use yii\helpers\Html;
  3 +use yii\bootstrap\ActiveForm;
  4 +
  5 +/* @var $this yii\web\View */
  6 +/* @var $form yii\bootstrap\ActiveForm */
  7 +/* @var $model \frontend\models\SignupForm */
  8 +
  9 +$this->title = 'Signup';
  10 +$this->params['breadcrumbs'][] = $this->title;
  11 +?>
  12 +<div class="site-signup">
  13 + <h1><?= Html::encode($this->title) ?></h1>
  14 +
  15 + <p>Please fill out the following fields to signup:</p>
  16 +
  17 + <div class="row">
  18 + <div class="col-lg-5">
  19 + <?php $form = ActiveForm::begin(['id' => 'form-signup']); ?>
  20 + <?= $form->field($model, 'first_name') ?>
  21 + <?= $form->field($model, 'last_name') ?>
  22 + <?= $form->field($model, 'username') ?>
  23 + <?= $form->field($model, 'email') ?>
  24 + <?= $form->field($model, 'password')->passwordInput() ?>
  25 + <div class="form-group">
  26 + <?= Html::submitButton('Signup', ['class' => 'btn btn-primary', 'name' => 'signup-button']) ?>
  27 + </div>
  28 + <?php ActiveForm::end(); ?>
  29 + </div>
  30 + </div>
  31 +</div>
frontend/web/.gitignore 0 → 100644
  1 +++ a/frontend/web/.gitignore
  1 +/index.php
  2 +/index-test.php
frontend/web/assets/.gitignore 0 → 100644
  1 +++ a/frontend/web/assets/.gitignore
  1 +*
  2 +!.gitignore
frontend/web/css/site.css 0 → 100644
  1 +++ a/frontend/web/css/site.css
  1 +html,
  2 +body {
  3 + height: 100%;
  4 +}
  5 +
  6 +.wrap {
  7 + min-height: 100%;
  8 + height: auto;
  9 + margin: 0 auto -60px;
  10 + padding: 0 0 60px;
  11 +}
  12 +
  13 +.wrap > .container {
  14 + padding: 70px 15px 20px;
  15 +}
  16 +
  17 +.footer {
  18 + height: 60px;
  19 + background-color: #f5f5f5;
  20 + border-top: 1px solid #ddd;
  21 + padding-top: 20px;
  22 +}
  23 +
  24 +.jumbotron {
  25 + text-align: center;
  26 + background-color: transparent;
  27 +}
  28 +
  29 +.jumbotron .btn {
  30 + font-size: 21px;
  31 + padding: 14px 24px;
  32 +}
  33 +
  34 +.not-set {
  35 + color: #c55;
  36 + font-style: italic;
  37 +}
  38 +
  39 +/* add sorting icons to gridview sort links */
  40 +a.asc:after, a.desc:after {
  41 + position: relative;
  42 + top: 1px;
  43 + display: inline-block;
  44 + font-family: 'Glyphicons Halflings';
  45 + font-style: normal;
  46 + font-weight: normal;
  47 + line-height: 1;
  48 + padding-left: 5px;
  49 +}
  50 +
  51 +a.asc:after {
  52 + content: /*"\e113"*/ "\e151";
  53 +}
  54 +
  55 +a.desc:after {
  56 + content: /*"\e114"*/ "\e152";
  57 +}
  58 +
  59 +.sort-numerical a.asc:after {
  60 + content: "\e153";
  61 +}
  62 +
  63 +.sort-numerical a.desc:after {
  64 + content: "\e154";
  65 +}
  66 +
  67 +.sort-ordinal a.asc:after {
  68 + content: "\e155";
  69 +}
  70 +
  71 +.sort-ordinal a.desc:after {
  72 + content: "\e156";
  73 +}
  74 +
  75 +.grid-view th {
  76 + white-space: nowrap;
  77 +}
  78 +
  79 +.hint-block {
  80 + display: block;
  81 + margin-top: 5px;
  82 + color: #999;
  83 +}
  84 +
  85 +.error-summary {
  86 + color: #a94442;
  87 + background: #fdf7f7;
  88 + border-left: 3px solid #eed3d7;
  89 + padding: 10px 20px;
  90 + margin: 0 0 15px 0;
  91 +}
frontend/web/favicon.ico 0 → 100644
No preview for this file type
frontend/web/robots.txt 0 → 100644
  1 +++ a/frontend/web/robots.txt
  1 +User-agent: *
  2 +Disallow:
0 \ No newline at end of file 3 \ No newline at end of file
frontend/widgets/Alert.php 0 → 100644
  1 +++ a/frontend/widgets/Alert.php
  1 +<?php
  2 +/**
  3 + * @link http://www.yiiframework.com/
  4 + * @copyright Copyright (c) 2008 Yii Software LLC
  5 + * @license http://www.yiiframework.com/license/
  6 + */
  7 +
  8 +namespace frontend\widgets;
  9 +
  10 +/**
  11 + * Alert widget renders a message from session flash. All flash messages are displayed
  12 + * in the sequence they were assigned using setFlash. You can set message as following:
  13 + *
  14 + * ```php
  15 + * \Yii::$app->getSession()->setFlash('error', 'This is the message');
  16 + * \Yii::$app->getSession()->setFlash('success', 'This is the message');
  17 + * \Yii::$app->getSession()->setFlash('info', 'This is the message');
  18 + * ```
  19 + *
  20 + * Multiple messages could be set as follows:
  21 + *
  22 + * ```php
  23 + * \Yii::$app->getSession()->setFlash('error', ['Error 1', 'Error 2']);
  24 + * ```
  25 + *
  26 + * @author Kartik Visweswaran <kartikv2@gmail.com>
  27 + * @author Alexander Makarov <sam@rmcreative.ru>
  28 + */
  29 +class Alert extends \yii\bootstrap\Widget
  30 +{
  31 + /**
  32 + * @var array the alert types configuration for the flash messages.
  33 + * This array is setup as $key => $value, where:
  34 + * - $key is the name of the session flash variable
  35 + * - $value is the bootstrap alert type (i.e. danger, success, info, warning)
  36 + */
  37 + public $alertTypes = [
  38 + 'error' => 'alert-danger',
  39 + 'danger' => 'alert-danger',
  40 + 'success' => 'alert-success',
  41 + 'info' => 'alert-info',
  42 + 'warning' => 'alert-warning'
  43 + ];
  44 +
  45 + /**
  46 + * @var array the options for rendering the close button tag.
  47 + */
  48 + public $closeButton = [];
  49 +
  50 + public function init()
  51 + {
  52 + parent::init();
  53 +
  54 + $session = \Yii::$app->getSession();
  55 + $flashes = $session->getAllFlashes();
  56 + $appendCss = isset($this->options['class']) ? ' ' . $this->options['class'] : '';
  57 +
  58 + foreach ($flashes as $type => $data) {
  59 + if (isset($this->alertTypes[$type])) {
  60 + $data = (array) $data;
  61 + foreach ($data as $i => $message) {
  62 + /* initialize css class for each alert box */
  63 + $this->options['class'] = $this->alertTypes[$type] . $appendCss;
  64 +
  65 + /* assign unique id to each alert box */
  66 + $this->options['id'] = $this->getId() . '-' . $type . '-' . $i;
  67 +
  68 + echo \yii\bootstrap\Alert::widget([
  69 + 'body' => $message,
  70 + 'closeButton' => $this->closeButton,
  71 + 'options' => $this->options,
  72 + ]);
  73 + }
  74 +
  75 + $session->removeFlash($type);
  76 + }
  77 + }
  78 + }
  79 +}
index.html 0 → 100644
  1 +++ a/index.html
  1 +<!DOCTYPE html>
  2 +<html>
  3 +<head>
  4 + <title>Welcome!</title>
  5 + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  6 + <style>
  7 + * {
  8 + margin: 0;
  9 + padding: 0;
  10 + border: 0 none;
  11 + background: none;
  12 + }
  13 + body {
  14 + font-weight: normal;
  15 + font-size: 11px;
  16 + font-family: Arial;
  17 + }
  18 + #login-wrapper {
  19 + width: 270px;
  20 + left: 50%;
  21 + margin-left: -135px;
  22 + position: absolute;
  23 + margin-top: -135px;
  24 + top: 50%;
  25 + }
  26 + #login-form {
  27 + width: 270px;
  28 + background: #78a5df;
  29 + height: 270px;
  30 + -webkit-border-radius: 135px;
  31 + -moz-border-radius: 135px;
  32 + border-radius: 135px;
  33 + }
  34 + ul li {
  35 + list-style: none;
  36 + }
  37 + .body-login-form .tab-content {
  38 + position: inherit;
  39 + padding: inherit;
  40 + }
  41 + .b-title {
  42 + text-align: center;
  43 + padding-top: 100px;
  44 + color: white;
  45 + margin-bottom: 20px;
  46 + font-size: 27px;
  47 + }
  48 + .b-content {
  49 + font-size: 12px;
  50 + color: #FFF;
  51 + text-align: center;
  52 + }
  53 + .b-copyright {
  54 + margin-top: 40px;
  55 + text-align: center;
  56 + }
  57 + .b-copyright__link {
  58 + color: #587b9d;
  59 + }
  60 + .b-text_lang_ru {
  61 + display: none;
  62 + }
  63 + </style>
  64 +</head>
  65 +<body class="body-login-form">
  66 +<div id="main-wrapper">
  67 + <div id="overlay" class="hide"></div>
  68 + <div id="content" class="tab-content active" data-tabid="tab1"><div id="login-wrapper">
  69 + <div id="login-form">
  70 + <div id="login-form-form">
  71 + <h2 class="b-title b-text b-text_lang_en">Welcome!</h2>
  72 + <h2 class="b-title b-text b-text_lang_ru">Приветствуем!</h2>
  73 + <div class="b-content">
  74 + <span class="b-text b-text_lang_en">Site test-10.artweb.com.ua just created.</span>
  75 + <span class="b-text b-text_lang_ru">Сайт test-10.artweb.com.ua только что создан.</span>
  76 + <br/>
  77 + <span class="b-text b-text_lang_en">Real content coming soon.</span>
  78 + </div>
  79 + </div>
  80 + </div>
  81 + <div class="b-copyright">
  82 + <a class="b-copyright__link" href="http://ispsystem.com/external/ispmanager.html" target="_blank">ISPsystem © 1997-2015</a>
  83 + </div>
  84 + <div id="error-log" style="display: none;"></div>
  85 + </div></div>
  86 +</div>
  87 +<script type="text/javascript">
  88 + var platformLanguage = navigator && (
  89 + navigator.language ||
  90 + navigator.browserLanguage ||
  91 + navigator.systemLanguage ||
  92 + navigator.userLanguage ||
  93 + null ),
  94 + elemsRU, elemsEN;
  95 + if (platformLanguage.match("ru") && document.getElementsByClassName) {
  96 + elemsRU = document.getElementsByClassName("b-text_lang_ru");
  97 + elemsEN = document.getElementsByClassName("b-text_lang_en");
  98 + var l = elemsEN.length;
  99 + while(l--) {
  100 + elemsEN[l].style.display = "none";
  101 + }
  102 + l = elemsRU.length;
  103 + while(l--) {
  104 + elemsRU[l].style.display = "block";
  105 + }
  106 + document.title = "Приветствуем!";
  107 + }
  108 +</script>
  109 +</body>
  110 +</html>
  1 +++ a/init
  1 +#!/usr/bin/env php
  2 +<?php
  3 +/**
  4 + * Yii Application Initialization Tool
  5 + *
  6 + * In order to run in non-interactive mode:
  7 + *
  8 + * init --env=Development --overwrite=n
  9 + *
  10 + * @author Alexander Makarov <sam@rmcreative.ru>
  11 + *
  12 + * @link http://www.yiiframework.com/
  13 + * @copyright Copyright (c) 2008 Yii Software LLC
  14 + * @license http://www.yiiframework.com/license/
  15 + */
  16 +
  17 +if (!extension_loaded('openssl')) {
  18 + die('The OpenSSL PHP extension is required by Yii2.');
  19 +}
  20 +
  21 +$params = getParams();
  22 +$root = str_replace('\\', '/', __DIR__);
  23 +$envs = require("$root/environments/index.php");
  24 +$envNames = array_keys($envs);
  25 +
  26 +echo "Yii Application Initialization Tool v1.0\n\n";
  27 +
  28 +$envName = null;
  29 +if (empty($params['env']) || $params['env'] === '1') {
  30 + echo "Which environment do you want the application to be initialized in?\n\n";
  31 + foreach ($envNames as $i => $name) {
  32 + echo " [$i] $name\n";
  33 + }
  34 + echo "\n Your choice [0-" . (count($envs) - 1) . ', or "q" to quit] ';
  35 + $answer = trim(fgets(STDIN));
  36 +
  37 + if (!ctype_digit($answer) || !in_array($answer, range(0, count($envs) - 1))) {
  38 + echo "\n Quit initialization.\n";
  39 + exit(0);
  40 + }
  41 +
  42 + if (isset($envNames[$answer])) {
  43 + $envName = $envNames[$answer];
  44 + }
  45 +} else {
  46 + $envName = $params['env'];
  47 +}
  48 +
  49 +if (!in_array($envName, $envNames)) {
  50 + $envsList = implode(', ', $envNames);
  51 + echo "\n $envName is not a valid environment. Try one of the following: $envsList. \n";
  52 + exit(2);
  53 +}
  54 +
  55 +$env = $envs[$envName];
  56 +
  57 +if (empty($params['env'])) {
  58 + echo "\n Initialize the application under '{$envNames[$answer]}' environment? [yes|no] ";
  59 + $answer = trim(fgets(STDIN));
  60 + if (strncasecmp($answer, 'y', 1)) {
  61 + echo "\n Quit initialization.\n";
  62 + exit(0);
  63 + }
  64 +}
  65 +
  66 +echo "\n Start initialization ...\n\n";
  67 +$files = getFileList("$root/environments/{$env['path']}");
  68 +if (isset($env['skipFiles'])) {
  69 + $skipFiles = $env['skipFiles'];
  70 + array_walk($skipFiles, function(&$value) use($env, $root) { $value = "$root/$value"; });
  71 + $files = array_diff($files, array_intersect_key($env['skipFiles'], array_filter($skipFiles, 'file_exists')));
  72 +}
  73 +$all = false;
  74 +foreach ($files as $file) {
  75 + if (!copyFile($root, "environments/{$env['path']}/$file", $file, $all, $params)) {
  76 + break;
  77 + }
  78 +}
  79 +
  80 +$callbacks = ['setCookieValidationKey', 'setWritable', 'setExecutable', 'createSymlink'];
  81 +foreach ($callbacks as $callback) {
  82 + if (!empty($env[$callback])) {
  83 + $callback($root, $env[$callback]);
  84 + }
  85 +}
  86 +
  87 +echo "\n ... initialization completed.\n\n";
  88 +
  89 +function getFileList($root, $basePath = '')
  90 +{
  91 + $files = [];
  92 + $handle = opendir($root);
  93 + while (($path = readdir($handle)) !== false) {
  94 + if ($path === '.svn' || $path === '.' || $path === '..') {
  95 + continue;
  96 + }
  97 + $fullPath = "$root/$path";
  98 + $relativePath = $basePath === '' ? $path : "$basePath/$path";
  99 + if (is_dir($fullPath)) {
  100 + $files = array_merge($files, getFileList($fullPath, $relativePath));
  101 + } else {
  102 + $files[] = $relativePath;
  103 + }
  104 + }
  105 + closedir($handle);
  106 + return $files;
  107 +}
  108 +
  109 +function copyFile($root, $source, $target, &$all, $params)
  110 +{
  111 + if (!is_file($root . '/' . $source)) {
  112 + echo " skip $target ($source not exist)\n";
  113 + return true;
  114 + }
  115 + if (is_file($root . '/' . $target)) {
  116 + if (file_get_contents($root . '/' . $source) === file_get_contents($root . '/' . $target)) {
  117 + echo " unchanged $target\n";
  118 + return true;
  119 + }
  120 + if ($all) {
  121 + echo " overwrite $target\n";
  122 + } else {
  123 + echo " exist $target\n";
  124 + echo " ...overwrite? [Yes|No|All|Quit] ";
  125 +
  126 +
  127 + $answer = !empty($params['overwrite']) ? $params['overwrite'] : trim(fgets(STDIN));
  128 + if (!strncasecmp($answer, 'q', 1)) {
  129 + return false;
  130 + } else {
  131 + if (!strncasecmp($answer, 'y', 1)) {
  132 + echo " overwrite $target\n";
  133 + } else {
  134 + if (!strncasecmp($answer, 'a', 1)) {
  135 + echo " overwrite $target\n";
  136 + $all = true;
  137 + } else {
  138 + echo " skip $target\n";
  139 + return true;
  140 + }
  141 + }
  142 + }
  143 + }
  144 + file_put_contents($root . '/' . $target, file_get_contents($root . '/' . $source));
  145 + return true;
  146 + }
  147 + echo " generate $target\n";
  148 + @mkdir(dirname($root . '/' . $target), 0777, true);
  149 + file_put_contents($root . '/' . $target, file_get_contents($root . '/' . $source));
  150 + return true;
  151 +}
  152 +
  153 +function getParams()
  154 +{
  155 + $rawParams = [];
  156 + if (isset($_SERVER['argv'])) {
  157 + $rawParams = $_SERVER['argv'];
  158 + array_shift($rawParams);
  159 + }
  160 +
  161 + $params = [];
  162 + foreach ($rawParams as $param) {
  163 + if (preg_match('/^--(\w+)(=(.*))?$/', $param, $matches)) {
  164 + $name = $matches[1];
  165 + $params[$name] = isset($matches[3]) ? $matches[3] : true;
  166 + } else {
  167 + $params[] = $param;
  168 + }
  169 + }
  170 + return $params;
  171 +}
  172 +
  173 +function setWritable($root, $paths)
  174 +{
  175 + foreach ($paths as $writable) {
  176 + echo " chmod 0777 $writable\n";
  177 + @chmod("$root/$writable", 0777);
  178 + }
  179 +}
  180 +
  181 +function setExecutable($root, $paths)
  182 +{
  183 + foreach ($paths as $executable) {
  184 + echo " chmod 0755 $executable\n";
  185 + @chmod("$root/$executable", 0755);
  186 + }
  187 +}
  188 +
  189 +function setCookieValidationKey($root, $paths)
  190 +{
  191 + foreach ($paths as $file) {
  192 + echo " generate cookie validation key in $file\n";
  193 + $file = $root . '/' . $file;
  194 + $length = 32;
  195 + $bytes = openssl_random_pseudo_bytes($length);
  196 + $key = strtr(substr(base64_encode($bytes), 0, $length), '+/=', '_-.');
  197 + $content = preg_replace('/(("|\')cookieValidationKey("|\')\s*=>\s*)(""|\'\')/', "\\1'$key'", file_get_contents($file));
  198 + file_put_contents($file, $content);
  199 + }
  200 +}
  201 +
  202 +function createSymlink($root, $links) {
  203 + foreach ($links as $link => $target) {
  204 + echo " symlink " . $root . "/" . $target . " " . $root . "/" . $link . "\n";
  205 + //first removing folders to avoid errors if the folder already exists
  206 + @rmdir($root . "/" . $link);
  207 + @symlink($root . "/" . $target, $root . "/" . $link);
  208 + }
  209 +}
init.bat 0 → 100644
  1 +++ a/init.bat
  1 +@echo off
  2 +
  3 +rem -------------------------------------------------------------
  4 +rem Yii command line init script for Windows.
  5 +rem
  6 +rem @author Qiang Xue <qiang.xue@gmail.com>
  7 +rem @link http://www.yiiframework.com/
  8 +rem @copyright Copyright (c) 2008 Yii Software LLC
  9 +rem @license http://www.yiiframework.com/license/
  10 +rem -------------------------------------------------------------
  11 +
  12 +@setlocal
  13 +
  14 +set YII_PATH=%~dp0
  15 +
  16 +if "%PHP_COMMAND%" == "" set PHP_COMMAND=php.exe
  17 +
  18 +"%PHP_COMMAND%" "%YII_PATH%init" %*
  19 +
  20 +@endlocal
requirements.php 0 → 100644
  1 +++ a/requirements.php
  1 +<?php
  2 +/**
  3 + * Application requirement checker script.
  4 + *
  5 + * In order to run this script use the following console command:
  6 + * php requirements.php
  7 + *
  8 + * In order to run this script from the web, you should copy it to the web root.
  9 + * If you are using Linux you can create a hard link instead, using the following command:
  10 + * ln requirements.php ../requirements.php
  11 + */
  12 +
  13 +// you may need to adjust this path to the correct Yii framework path
  14 +$frameworkPath = dirname(__FILE__) . '/vendor/yiisoft/yii2';
  15 +
  16 +if (!is_dir($frameworkPath)) {
  17 + echo '<h1>Error</h1>';
  18 + echo '<p><strong>The path to yii framework seems to be incorrect.</strong></p>';
  19 + echo '<p>You need to install Yii framework via composer or adjust the framework path in file <abbr title="' . __FILE__ . '">' . basename(__FILE__) . '</abbr>.</p>';
  20 + echo '<p>Please refer to the <abbr title="' . dirname(__FILE__) . '/README.md">README</abbr> on how to install Yii.</p>';
  21 +}
  22 +
  23 +require_once($frameworkPath . '/requirements/YiiRequirementChecker.php');
  24 +$requirementsChecker = new YiiRequirementChecker();
  25 +
  26 +$gdMemo = $imagickMemo = 'Either GD PHP extension with FreeType support or ImageMagick PHP extension with PNG support is required for image CAPTCHA.';
  27 +$gdOK = $imagickOK = false;
  28 +
  29 +if (extension_loaded('imagick')) {
  30 + $imagick = new Imagick();
  31 + $imagickFormats = $imagick->queryFormats('PNG');
  32 + if (in_array('PNG', $imagickFormats)) {
  33 + $imagickOK = true;
  34 + } else {
  35 + $imagickMemo = 'Imagick extension should be installed with PNG support in order to be used for image CAPTCHA.';
  36 + }
  37 +}
  38 +
  39 +if (extension_loaded('gd')) {
  40 + $gdInfo = gd_info();
  41 + if (!empty($gdInfo['FreeType Support'])) {
  42 + $gdOK = true;
  43 + } else {
  44 + $gdMemo = 'GD extension should be installed with FreeType support in order to be used for image CAPTCHA.';
  45 + }
  46 +}
  47 +
  48 +/**
  49 + * Adjust requirements according to your application specifics.
  50 + */
  51 +$requirements = array(
  52 + // Database :
  53 + array(
  54 + 'name' => 'PDO extension',
  55 + 'mandatory' => true,
  56 + 'condition' => extension_loaded('pdo'),
  57 + 'by' => 'All DB-related classes',
  58 + ),
  59 + array(
  60 + 'name' => 'PDO SQLite extension',
  61 + 'mandatory' => false,
  62 + 'condition' => extension_loaded('pdo_sqlite'),
  63 + 'by' => 'All DB-related classes',
  64 + 'memo' => 'Required for SQLite database.',
  65 + ),
  66 + array(
  67 + 'name' => 'PDO MySQL extension',
  68 + 'mandatory' => false,
  69 + 'condition' => extension_loaded('pdo_mysql'),
  70 + 'by' => 'All DB-related classes',
  71 + 'memo' => 'Required for MySQL database.',
  72 + ),
  73 + array(
  74 + 'name' => 'PDO PostgreSQL extension',
  75 + 'mandatory' => false,
  76 + 'condition' => extension_loaded('pdo_pgsql'),
  77 + 'by' => 'All DB-related classes',
  78 + 'memo' => 'Required for PostgreSQL database.',
  79 + ),
  80 + // Cache :
  81 + array(
  82 + 'name' => 'Memcache extension',
  83 + 'mandatory' => false,
  84 + 'condition' => extension_loaded('memcache') || extension_loaded('memcached'),
  85 + 'by' => '<a href="http://www.yiiframework.com/doc-2.0/yii-caching-memcache.html">MemCache</a>',
  86 + 'memo' => extension_loaded('memcached') ? 'To use memcached set <a href="http://www.yiiframework.com/doc-2.0/yii-caching-memcache.html#$useMemcached-detail">MemCache::useMemcached</a> to <code>true</code>.' : ''
  87 + ),
  88 + array(
  89 + 'name' => 'APC extension',
  90 + 'mandatory' => false,
  91 + 'condition' => extension_loaded('apc'),
  92 + 'by' => '<a href="http://www.yiiframework.com/doc-2.0/yii-caching-apccache.html">ApcCache</a>',
  93 + ),
  94 + // CAPTCHA:
  95 + array(
  96 + 'name' => 'GD PHP extension with FreeType support',
  97 + 'mandatory' => false,
  98 + 'condition' => $gdOK,
  99 + 'by' => '<a href="http://www.yiiframework.com/doc-2.0/yii-captcha-captcha.html">Captcha</a>',
  100 + 'memo' => $gdMemo,
  101 + ),
  102 + array(
  103 + 'name' => 'ImageMagick PHP extension with PNG support',
  104 + 'mandatory' => false,
  105 + 'condition' => $imagickOK,
  106 + 'by' => '<a href="http://www.yiiframework.com/doc-2.0/yii-captcha-captcha.html">Captcha</a>',
  107 + 'memo' => $imagickMemo,
  108 + ),
  109 + // PHP ini :
  110 + 'phpExposePhp' => array(
  111 + 'name' => 'Expose PHP',
  112 + 'mandatory' => false,
  113 + 'condition' => $requirementsChecker->checkPhpIniOff("expose_php"),
  114 + 'by' => 'Security reasons',
  115 + 'memo' => '"expose_php" should be disabled at php.ini',
  116 + ),
  117 + 'phpAllowUrlInclude' => array(
  118 + 'name' => 'PHP allow url include',
  119 + 'mandatory' => false,
  120 + 'condition' => $requirementsChecker->checkPhpIniOff("allow_url_include"),
  121 + 'by' => 'Security reasons',
  122 + 'memo' => '"allow_url_include" should be disabled at php.ini',
  123 + ),
  124 + 'phpSmtp' => array(
  125 + 'name' => 'PHP mail SMTP',
  126 + 'mandatory' => false,
  127 + 'condition' => strlen(ini_get('SMTP')) > 0,
  128 + 'by' => 'Email sending',
  129 + 'memo' => 'PHP mail SMTP server required',
  130 + ),
  131 +);
  132 +$requirementsChecker->checkYii()->check($requirements)->render();
tests/README.md 0 → 100644
  1 +++ a/tests/README.md
  1 +This directory contains various tests for the advanced applications.
  2 +
  3 +Tests in `codeception` directory are developed with [Codeception PHP Testing Framework](http://codeception.com/).
  4 +
  5 +After creating and setting up the advanced application, follow these steps to prepare for the tests:
  6 +
  7 +1. Install Codeception if it's not yet installed:
  8 +
  9 + ```
  10 + composer global require "codeception/codeception=2.0.*" "codeception/specify=*" "codeception/verify=*"
  11 + ```
  12 +
  13 + If you've never used Composer for global packages run `composer global status`. It should output:
  14 +
  15 + ```
  16 + Changed current directory to <directory>
  17 + ```
  18 +
  19 + Then add `<directory>/vendor/bin` to you `PATH` environment variable. Now you're able to use `codecept` from command
  20 + line globally.
  21 +
  22 +2. Install faker extension by running the following from template root directory where `composer.json` is:
  23 +
  24 + ```
  25 + composer require --dev yiisoft/yii2-faker:*
  26 + ```
  27 +
  28 +3. Create `yii2_advanced_tests` database then update it by applying migrations:
  29 +
  30 + ```
  31 + codeception/bin/yii migrate
  32 + ```
  33 +
  34 +4. In order to be able to run acceptance tests you need to start a webserver. The simplest way is to use PHP built in
  35 + webserver. In the root directory where `common`, `frontend` etc. are execute the following:
  36 +
  37 + ```
  38 + php -S localhost:8080
  39 + ```
  40 +
  41 +5. Now you can run the tests with the following commands, assuming you are in the `tests/codeception` directory:
  42 +
  43 + ```
  44 + # frontend tests
  45 + cd frontend
  46 + codecept build
  47 + codecept run
  48 +
  49 + # backend tests
  50 +
  51 + cd backend
  52 + codecept build
  53 + codecept run
  54 +
  55 + # etc.
  56 + ```
  57 +
  58 + If you already have run `codecept build` for each application, you can skip that step and run all tests by a single `codecept run`.
tests/codeception.yml 0 → 100644
  1 +++ a/tests/codeception.yml
  1 +include:
  2 + - codeception/common
  3 + - codeception/console
  4 + - codeception/backend
  5 + - codeception/frontend
  6 +
  7 +paths:
  8 + log: codeception/_output
  9 +
  10 +settings:
  11 + colors: true
tests/codeception/_output/.gitignore 0 → 100644
  1 +++ a/tests/codeception/_output/.gitignore
  1 +*
  2 +!.gitignore
tests/codeception/backend/.gitignore 0 → 100644
  1 +++ a/tests/codeception/backend/.gitignore
  1 +# these files are auto generated by codeception build
  2 +/unit/UnitTester.php
  3 +/functional/FunctionalTester.php
  4 +/acceptance/AcceptanceTester.php
tests/codeception/backend/_bootstrap.php 0 → 100644
  1 +++ a/tests/codeception/backend/_bootstrap.php
  1 +<?php
  2 +defined('YII_DEBUG') or define('YII_DEBUG', true);
  3 +defined('YII_ENV') or define('YII_ENV', 'test');
  4 +
  5 +defined('YII_APP_BASE_PATH') or define('YII_APP_BASE_PATH', dirname(dirname(dirname(__DIR__))));
  6 +
  7 +defined('YII_BACKEND_TEST_ENTRY_URL') or define('YII_BACKEND_TEST_ENTRY_URL', parse_url(\Codeception\Configuration::config()['config']['test_entry_url'], PHP_URL_PATH));
  8 +defined('YII_TEST_BACKEND_ENTRY_FILE') or define('YII_TEST_BACKEND_ENTRY_FILE', YII_APP_BASE_PATH . '/backend/web/index-test.php');
  9 +
  10 +require_once(YII_APP_BASE_PATH . '/vendor/autoload.php');
  11 +require_once(YII_APP_BASE_PATH . '/vendor/yiisoft/yii2/Yii.php');
  12 +require_once(YII_APP_BASE_PATH . '/common/config/bootstrap.php');
  13 +require_once(YII_APP_BASE_PATH . '/backend/config/bootstrap.php');
  14 +
  15 +// set correct script paths
  16 +
  17 +// the entry script file path for functional and acceptance tests
  18 +$_SERVER['SCRIPT_FILENAME'] = YII_TEST_BACKEND_ENTRY_FILE;
  19 +$_SERVER['SCRIPT_NAME'] = YII_BACKEND_TEST_ENTRY_URL;
  20 +$_SERVER['SERVER_NAME'] = parse_url(\Codeception\Configuration::config()['config']['test_entry_url'], PHP_URL_HOST);
  21 +$_SERVER['SERVER_PORT'] = parse_url(\Codeception\Configuration::config()['config']['test_entry_url'], PHP_URL_PORT) ?: '80';
  22 +
  23 +Yii::setAlias('@tests', dirname(dirname(__DIR__)));
tests/codeception/backend/_output/.gitignore 0 → 100644
  1 +++ a/tests/codeception/backend/_output/.gitignore
  1 +*
  2 +!.gitignore
tests/codeception/backend/acceptance.suite.yml 0 → 100644
  1 +++ a/tests/codeception/backend/acceptance.suite.yml
  1 +# Codeception Test Suite Configuration
  2 +
  3 +# suite for acceptance tests.
  4 +# perform tests in browser using the Selenium-like tools.
  5 +# powered by Mink (http://mink.behat.org).
  6 +# (tip: that's what your customer will see).
  7 +# (tip: test your ajax and javascript by one of Mink drivers).
  8 +
  9 +# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
  10 +
  11 +class_name: AcceptanceTester
  12 +modules:
  13 + enabled:
  14 + - PhpBrowser
  15 + - tests\codeception\common\_support\FixtureHelper
  16 +# you can use WebDriver instead of PhpBrowser to test javascript and ajax.
  17 +# This will require you to install selenium. See http://codeception.com/docs/04-AcceptanceTests#Selenium
  18 +# "restart" option is used by the WebDriver to start each time per test-file new session and cookies,
  19 +# it is useful if you want to login in your app in each test.
  20 +# - WebDriver
  21 + config:
  22 + PhpBrowser:
  23 +# PLEASE ADJUST IT TO THE ACTUAL ENTRY POINT WITHOUT PATH INFO
  24 + url: http://localhost:8080
  25 +# WebDriver:
  26 +# url: http://localhost:8080
  27 +# browser: firefox
  28 +# restart: true
tests/codeception/backend/acceptance/LoginCept.php 0 → 100644
  1 +++ a/tests/codeception/backend/acceptance/LoginCept.php
  1 +<?php
  2 +
  3 +use tests\codeception\backend\AcceptanceTester;
  4 +use tests\codeception\common\_pages\LoginPage;
  5 +
  6 +/* @var $scenario Codeception\Scenario */
  7 +
  8 +$I = new AcceptanceTester($scenario);
  9 +$I->wantTo('ensure login page works');
  10 +
  11 +$loginPage = LoginPage::openBy($I);
  12 +
  13 +$I->amGoingTo('submit login form with no data');
  14 +$loginPage->login('', '');
  15 +if (method_exists($I, 'wait')) {
  16 + $I->wait(3); // only for selenium
  17 +}
  18 +$I->expectTo('see validations errors');
  19 +$I->see('Username cannot be blank.', '.help-block');
  20 +$I->see('Password cannot be blank.', '.help-block');
  21 +
  22 +$I->amGoingTo('try to login with wrong credentials');
  23 +$I->expectTo('see validations errors');
  24 +$loginPage->login('admin', 'wrong');
  25 +if (method_exists($I, 'wait')) {
  26 + $I->wait(3); // only for selenium
  27 +}
  28 +$I->expectTo('see validations errors');
  29 +$I->see('Incorrect username or password.', '.help-block');
  30 +
  31 +$I->amGoingTo('try to login with correct credentials');
  32 +$loginPage->login('erau', 'password_0');
  33 +if (method_exists($I, 'wait')) {
  34 + $I->wait(3); // only for selenium
  35 +}
  36 +$I->expectTo('see that user is logged');
  37 +$I->seeLink('Logout (erau)');
  38 +$I->dontSeeLink('Login');
  39 +$I->dontSeeLink('Signup');
  40 +/** Uncomment if using WebDriver
  41 + * $I->click('Logout (erau)');
  42 + * $I->dontSeeLink('Logout (erau)');
  43 + * $I->seeLink('Login');
  44 + */
tests/codeception/backend/acceptance/_bootstrap.php 0 → 100644
  1 +++ a/tests/codeception/backend/acceptance/_bootstrap.php
  1 +<?php
  2 +new yii\web\Application(require(dirname(dirname(__DIR__)) . '/config/backend/acceptance.php'));
tests/codeception/backend/codeception.yml 0 → 100644
  1 +++ a/tests/codeception/backend/codeception.yml
  1 +namespace: tests\codeception\backend
  2 +actor: Tester
  3 +paths:
  4 + tests: .
  5 + log: _output
  6 + data: _data
  7 + helpers: _support
  8 +settings:
  9 + bootstrap: _bootstrap.php
  10 + suite_class: \PHPUnit_Framework_TestSuite
  11 + colors: true
  12 + memory_limit: 1024M
  13 + log: true
  14 +config:
  15 + # the entry script URL (with host info) for functional and acceptance tests
  16 + # PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL
  17 + test_entry_url: http://localhost:8080/backend/web/index-test.php
tests/codeception/backend/functional.suite.yml 0 → 100644
  1 +++ a/tests/codeception/backend/functional.suite.yml
  1 +# Codeception Test Suite Configuration
  2 +
  3 +# suite for functional (integration) tests.
  4 +# emulate web requests and make application process them.
  5 +# (tip: better to use with frameworks).
  6 +
  7 +# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
  8 +#basic/web/index.php
  9 +class_name: FunctionalTester
  10 +modules:
  11 + enabled:
  12 + - Filesystem
  13 + - Yii2
  14 + - tests\codeception\common\_support\FixtureHelper
  15 + config:
  16 + Yii2:
  17 + configFile: '../config/backend/functional.php'
tests/codeception/backend/functional/LoginCept.php 0 → 100644
  1 +++ a/tests/codeception/backend/functional/LoginCept.php
  1 +<?php
  2 +
  3 +use tests\codeception\backend\FunctionalTester;
  4 +use tests\codeception\common\_pages\LoginPage;
  5 +
  6 +/* @var $scenario Codeception\Scenario */
  7 +
  8 +$I = new FunctionalTester($scenario);
  9 +$I->wantTo('ensure login page works');
  10 +
  11 +$loginPage = LoginPage::openBy($I);
  12 +
  13 +$I->amGoingTo('submit login form with no data');
  14 +$loginPage->login('', '');
  15 +$I->expectTo('see validations errors');
  16 +$I->see('Username cannot be blank.', '.help-block');
  17 +$I->see('Password cannot be blank.', '.help-block');
  18 +
  19 +$I->amGoingTo('try to login with wrong credentials');
  20 +$I->expectTo('see validations errors');
  21 +$loginPage->login('admin', 'wrong');
  22 +$I->expectTo('see validations errors');
  23 +$I->see('Incorrect username or password.', '.help-block');
  24 +
  25 +$I->amGoingTo('try to login with correct credentials');
  26 +$loginPage->login('erau', 'password_0');
  27 +$I->expectTo('see that user is logged');
  28 +$I->seeLink('Logout (erau)');
  29 +$I->dontSeeLink('Login');
  30 +$I->dontSeeLink('Signup');
tests/codeception/backend/functional/_bootstrap.php 0 → 100644
  1 +++ a/tests/codeception/backend/functional/_bootstrap.php
  1 +<?php
  2 +new yii\web\Application(require(dirname(dirname(__DIR__)) . '/config/backend/functional.php'));
tests/codeception/backend/unit.suite.yml 0 → 100644
  1 +++ a/tests/codeception/backend/unit.suite.yml
  1 +# Codeception Test Suite Configuration
  2 +
  3 +# suite for unit (internal) tests.
  4 +# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
  5 +
  6 +class_name: UnitTester
tests/codeception/backend/unit/DbTestCase.php 0 → 100644
  1 +++ a/tests/codeception/backend/unit/DbTestCase.php
  1 +<?php
  2 +
  3 +namespace tests\codeception\backend\unit;
  4 +
  5 +class DbTestCase extends \yii\codeception\DbTestCase
  6 +{
  7 + public $appConfig = '@tests/codeception/config/backend/unit.php';
  8 +}
tests/codeception/backend/unit/TestCase.php 0 → 100644
  1 +++ a/tests/codeception/backend/unit/TestCase.php
  1 +<?php
  2 +
  3 +namespace tests\codeception\backend\unit;
  4 +
  5 +class TestCase extends \yii\codeception\TestCase
  6 +{
  7 + public $appConfig = '@tests/codeception/config/backend/unit.php';
  8 +}
tests/codeception/backend/unit/_bootstrap.php 0 → 100644
  1 +++ a/tests/codeception/backend/unit/_bootstrap.php
  1 +<?php
  2 +// Here you can initialize variables that will for your tests
tests/codeception/backend/unit/fixtures/data/.gitkeep 0 → 100644
  1 +++ a/tests/codeception/backend/unit/fixtures/data/.gitkeep
tests/codeception/bin/_bootstrap.php 0 → 100644
  1 +++ a/tests/codeception/bin/_bootstrap.php
  1 +<?php
  2 +/**
  3 + * Yii console bootstrap file.
  4 + *
  5 + * @link http://www.yiiframework.com/
  6 + * @copyright Copyright (c) 2008 Yii Software LLC
  7 + * @license http://www.yiiframework.com/license/
  8 + */
  9 +
  10 +defined('YII_DEBUG') or define('YII_DEBUG', true);
  11 +defined('YII_ENV') or define('YII_ENV', 'test');
  12 +
  13 +// fcgi doesn't have STDIN and STDOUT defined by default
  14 +defined('STDIN') or define('STDIN', fopen('php://stdin', 'r'));
  15 +defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w'));
  16 +
  17 +defined('YII_APP_BASE_PATH') or define('YII_APP_BASE_PATH', dirname(dirname(dirname(__DIR__))));
  18 +
  19 +require_once(YII_APP_BASE_PATH . '/vendor/autoload.php');
  20 +require_once(YII_APP_BASE_PATH . '/vendor/yiisoft/yii2/Yii.php');
  21 +require_once(YII_APP_BASE_PATH . '/common/config/bootstrap.php');
  22 +
  23 +Yii::setAlias('@tests', dirname(dirname(__DIR__)));
tests/codeception/bin/yii 0 → 100644
  1 +++ a/tests/codeception/bin/yii
  1 +#!/usr/bin/env php
  2 +<?php
  3 +/**
  4 + * Yii console bootstrap file.
  5 + *
  6 + * @link http://www.yiiframework.com/
  7 + * @copyright Copyright (c) 2008 Yii Software LLC
  8 + * @license http://www.yiiframework.com/license/
  9 + */
  10 +
  11 +require_once __DIR__ . '/_bootstrap.php';
  12 +
  13 +$config = yii\helpers\ArrayHelper::merge(
  14 + require(YII_APP_BASE_PATH . '/common/config/main.php'),
  15 + require(YII_APP_BASE_PATH . '/common/config/main-local.php'),
  16 + require(YII_APP_BASE_PATH . '/console/config/main.php'),
  17 + require(YII_APP_BASE_PATH . '/console/config/main-local.php'),
  18 + require(dirname(__DIR__) . '/config/config.php')
  19 +);
  20 +
  21 +$application = new yii\console\Application($config);
  22 +$exitCode = $application->run();
  23 +exit($exitCode);
tests/codeception/bin/yii.bat 0 → 100644
  1 +++ a/tests/codeception/bin/yii.bat
  1 +@echo off
  2 +
  3 +rem -------------------------------------------------------------
  4 +rem Yii command line bootstrap script for Windows.
  5 +rem
  6 +rem @author Qiang Xue <qiang.xue@gmail.com>
  7 +rem @link http://www.yiiframework.com/
  8 +rem @copyright Copyright (c) 2008 Yii Software LLC
  9 +rem @license http://www.yiiframework.com/license/
  10 +rem -------------------------------------------------------------
  11 +
  12 +@setlocal
  13 +
  14 +set YII_PATH=%~dp0
  15 +
  16 +if "%PHP_COMMAND%" == "" set PHP_COMMAND=php.exe
  17 +
  18 +"%PHP_COMMAND%" "%YII_PATH%yii" %*
  19 +
  20 +@endlocal
tests/codeception/common/.gitignore 0 → 100644
  1 +++ a/tests/codeception/common/.gitignore
  1 +# these files are auto generated by codeception build
  2 +/unit/UnitTester.php
  3 +/functional/FunctionalTester.php
  4 +/acceptance/AcceptanceTester.php
tests/codeception/common/_bootstrap.php 0 → 100644
  1 +++ a/tests/codeception/common/_bootstrap.php
  1 +<?php
  2 +defined('YII_DEBUG') or define('YII_DEBUG', true);
  3 +defined('YII_ENV') or define('YII_ENV', 'test');
  4 +
  5 +defined('YII_APP_BASE_PATH') or define('YII_APP_BASE_PATH', dirname(dirname(dirname(__DIR__))));
  6 +
  7 +require_once(YII_APP_BASE_PATH . '/vendor/autoload.php');
  8 +require_once(YII_APP_BASE_PATH . '/vendor/yiisoft/yii2/Yii.php');
  9 +require_once(YII_APP_BASE_PATH . '/common/config/bootstrap.php');
  10 +
  11 +// set correct script paths
  12 +$_SERVER['SERVER_NAME'] = 'localhost';
  13 +$_SERVER['SERVER_PORT'] = '80';
  14 +
  15 +Yii::setAlias('@tests', dirname(dirname(__DIR__)));
tests/codeception/common/_output/.gitignore 0 → 100644
  1 +++ a/tests/codeception/common/_output/.gitignore
  1 +*
  2 +!.gitignore
tests/codeception/common/_pages/LoginPage.php 0 → 100644
  1 +++ a/tests/codeception/common/_pages/LoginPage.php
  1 +<?php
  2 +
  3 +namespace tests\codeception\common\_pages;
  4 +
  5 +use yii\codeception\BasePage;
  6 +
  7 +/**
  8 + * Represents loging page
  9 + * @property \codeception_frontend\AcceptanceTester|\codeception_frontend\FunctionalTester|\codeception_backend\AcceptanceTester|\codeception_backend\FunctionalTester $actor
  10 + */
  11 +class LoginPage extends BasePage
  12 +{
  13 + public $route = 'site/login';
  14 +
  15 + /**
  16 + * @param string $username
  17 + * @param string $password
  18 + */
  19 + public function login($username, $password)
  20 + {
  21 + $this->actor->fillField('input[name="LoginForm[username]"]', $username);
  22 + $this->actor->fillField('input[name="LoginForm[password]"]', $password);
  23 + $this->actor->click('login-button');
  24 + }
  25 +}
tests/codeception/common/_support/FixtureHelper.php 0 → 100644
  1 +++ a/tests/codeception/common/_support/FixtureHelper.php
  1 +<?php
  2 +
  3 +namespace tests\codeception\common\_support;
  4 +
  5 +use tests\codeception\common\fixtures\UserFixture;
  6 +use Codeception\Module;
  7 +use yii\test\FixtureTrait;
  8 +
  9 +/**
  10 + * This helper is used to populate the database with needed fixtures before any tests are run.
  11 + * In this example, the database is populated with the demo login user, which is used in acceptance
  12 + * and functional tests. All fixtures will be loaded before the suite is started and unloaded after it
  13 + * completes.
  14 + */
  15 +class FixtureHelper extends Module
  16 +{
  17 +
  18 + /**
  19 + * Redeclare visibility because codeception includes all public methods that do not start with "_"
  20 + * and are not excluded by module settings, in actor class.
  21 + */
  22 + use FixtureTrait {
  23 + loadFixtures as protected;
  24 + fixtures as protected;
  25 + globalFixtures as protected;
  26 + unloadFixtures as protected;
  27 + getFixtures as protected;
  28 + getFixture as protected;
  29 + }
  30 +
  31 + /**
  32 + * Method called before any suite tests run. Loads User fixture login user
  33 + * to use in acceptance and functional tests.
  34 + * @param array $settings
  35 + */
  36 + public function _beforeSuite($settings = [])
  37 + {
  38 + $this->loadFixtures();
  39 + }
  40 +
  41 + /**
  42 + * Method is called after all suite tests run
  43 + */
  44 + public function _afterSuite()
  45 + {
  46 + $this->unloadFixtures();
  47 + }
  48 +
  49 + /**
  50 + * @inheritdoc
  51 + */
  52 + public function fixtures()
  53 + {
  54 + return [
  55 + 'user' => [
  56 + 'class' => UserFixture::className(),
  57 + 'dataFile' => '@tests/codeception/common/fixtures/data/init_login.php',
  58 + ],
  59 + ];
  60 + }
  61 +}
tests/codeception/common/codeception.yml 0 → 100644
  1 +++ a/tests/codeception/common/codeception.yml
  1 +namespace: tests\codeception\common
  2 +actor: Tester
  3 +paths:
  4 + tests: .
  5 + log: _output
  6 + data: _data
  7 + helpers: _support
  8 +settings:
  9 + bootstrap: _bootstrap.php
  10 + suite_class: \PHPUnit_Framework_TestSuite
  11 + colors: true
  12 + memory_limit: 1024M
  13 + log: true
tests/codeception/common/fixtures/UserFixture.php 0 → 100644
  1 +++ a/tests/codeception/common/fixtures/UserFixture.php
  1 +<?php
  2 +
  3 +namespace tests\codeception\common\fixtures;
  4 +
  5 +use yii\test\ActiveFixture;
  6 +
  7 +/**
  8 + * User fixture
  9 + */
  10 +class UserFixture extends ActiveFixture
  11 +{
  12 + public $modelClass = 'common\models\User';
  13 +}
tests/codeception/common/fixtures/data/init_login.php 0 → 100644
  1 +++ a/tests/codeception/common/fixtures/data/init_login.php
  1 +<?php
  2 +
  3 +return [
  4 + [
  5 + 'username' => 'erau',
  6 + 'auth_key' => 'tUu1qHcde0diwUol3xeI-18MuHkkprQI',
  7 + // password_0
  8 + 'password_hash' => '$2y$13$nJ1WDlBaGcbCdbNC5.5l4.sgy.OMEKCqtDQOdQ2OWpgiKRWYyzzne',
  9 + 'password_reset_token' => 'RkD_Jw0_8HEedzLk7MM-ZKEFfYR7VbMr_1392559490',
  10 + 'created_at' => '1392559490',
  11 + 'updated_at' => '1392559490',
  12 + 'email' => 'sfriesen@jenkins.info',
  13 + ],
  14 +];
tests/codeception/common/templates/fixtures/user.php 0 → 100644
  1 +++ a/tests/codeception/common/templates/fixtures/user.php
  1 +<?php
  2 +/**
  3 + * @var $faker \Faker\Generator
  4 + * @var $index integer
  5 + */
  6 +
  7 +$security = Yii::$app->getSecurity();
  8 +
  9 +return [
  10 + 'username' => $faker->userName,
  11 + 'email' => $faker->email,
  12 + 'auth_key' => $security->generateRandomString(),
  13 + 'password_hash' => $security->generatePasswordHash('password_' . $index),
  14 + 'password_reset_token' => $security->generateRandomString() . '_' . time(),
  15 + 'created_at' => time(),
  16 + 'updated_at' => time(),
  17 +];
tests/codeception/common/unit.suite.yml 0 → 100644
  1 +++ a/tests/codeception/common/unit.suite.yml
  1 +# Codeception Test Suite Configuration
  2 +
  3 +# suite for unit (internal) tests.
  4 +# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
  5 +
  6 +class_name: UnitTester
tests/codeception/common/unit/DbTestCase.php 0 → 100644
  1 +++ a/tests/codeception/common/unit/DbTestCase.php
  1 +<?php
  2 +
  3 +namespace tests\codeception\common\unit;
  4 +
  5 +/**
  6 + * @inheritdoc
  7 + */
  8 +class DbTestCase extends \yii\codeception\DbTestCase
  9 +{
  10 + public $appConfig = '@tests/codeception/config/common/unit.php';
  11 +}
tests/codeception/common/unit/TestCase.php 0 → 100644
  1 +++ a/tests/codeception/common/unit/TestCase.php
  1 +<?php
  2 +
  3 +namespace tests\codeception\common\unit;
  4 +
  5 +/**
  6 + * @inheritdoc
  7 + */
  8 +class TestCase extends \yii\codeception\TestCase
  9 +{
  10 + public $appConfig = '@tests/codeception/config/common/unit.php';
  11 +}
tests/codeception/common/unit/_bootstrap.php 0 → 100644
  1 +++ a/tests/codeception/common/unit/_bootstrap.php
  1 +<?php
  2 +// Here you can initialize variables that will for your tests
tests/codeception/common/unit/fixtures/data/models/user.php 0 → 100644
  1 +++ a/tests/codeception/common/unit/fixtures/data/models/user.php
  1 +<?php
  2 +
  3 +return [
  4 + [
  5 + 'username' => 'bayer.hudson',
  6 + 'auth_key' => 'HP187Mvq7Mmm3CTU80dLkGmni_FUH_lR',
  7 + //password_0
  8 + 'password_hash' => '$2y$13$EjaPFBnZOQsHdGuHI.xvhuDp1fHpo8hKRSk6yshqa9c5EG8s3C3lO',
  9 + 'password_reset_token' => 'ExzkCOaYc1L8IOBs4wdTGGbgNiG3Wz1I_1402312317',
  10 + 'created_at' => '1402312317',
  11 + 'updated_at' => '1402312317',
  12 + 'email' => 'nicole.paucek@schultz.info',
  13 + ],
  14 +];
tests/codeception/common/unit/models/LoginFormTest.php 0 → 100644
  1 +++ a/tests/codeception/common/unit/models/LoginFormTest.php
  1 +<?php
  2 +
  3 +namespace tests\codeception\common\unit\models;
  4 +
  5 +use Yii;
  6 +use tests\codeception\common\unit\DbTestCase;
  7 +use Codeception\Specify;
  8 +use common\models\LoginForm;
  9 +use tests\codeception\common\fixtures\UserFixture;
  10 +
  11 +/**
  12 + * Login form test
  13 + */
  14 +class LoginFormTest extends DbTestCase
  15 +{
  16 +
  17 + use Specify;
  18 +
  19 + public function setUp()
  20 + {
  21 + parent::setUp();
  22 +
  23 + Yii::configure(Yii::$app, [
  24 + 'components' => [
  25 + 'user' => [
  26 + 'class' => 'yii\web\User',
  27 + 'identityClass' => 'common\models\User',
  28 + ],
  29 + ],
  30 + ]);
  31 + }
  32 +
  33 + protected function tearDown()
  34 + {
  35 + Yii::$app->user->logout();
  36 + parent::tearDown();
  37 + }
  38 +
  39 + public function testLoginNoUser()
  40 + {
  41 + $model = new LoginForm([
  42 + 'username' => 'not_existing_username',
  43 + 'password' => 'not_existing_password',
  44 + ]);
  45 +
  46 + $this->specify('user should not be able to login, when there is no identity', function () use ($model) {
  47 + expect('model should not login user', $model->login())->false();
  48 + expect('user should not be logged in', Yii::$app->user->isGuest)->true();
  49 + });
  50 + }
  51 +
  52 + public function testLoginWrongPassword()
  53 + {
  54 + $model = new LoginForm([
  55 + 'username' => 'bayer.hudson',
  56 + 'password' => 'wrong_password',
  57 + ]);
  58 +
  59 + $this->specify('user should not be able to login with wrong password', function () use ($model) {
  60 + expect('model should not login user', $model->login())->false();
  61 + expect('error message should be set', $model->errors)->hasKey('password');
  62 + expect('user should not be logged in', Yii::$app->user->isGuest)->true();
  63 + });
  64 + }
  65 +
  66 + public function testLoginCorrect()
  67 + {
  68 +
  69 + $model = new LoginForm([
  70 + 'username' => 'bayer.hudson',
  71 + 'password' => 'password_0',
  72 + ]);
  73 +
  74 + $this->specify('user should be able to login with correct credentials', function () use ($model) {
  75 + expect('model should login user', $model->login())->true();
  76 + expect('error message should not be set', $model->errors)->hasntKey('password');
  77 + expect('user should be logged in', Yii::$app->user->isGuest)->false();
  78 + });
  79 + }
  80 +
  81 + /**
  82 + * @inheritdoc
  83 + */
  84 + public function fixtures()
  85 + {
  86 + return [
  87 + 'user' => [
  88 + 'class' => UserFixture::className(),
  89 + 'dataFile' => '@tests/codeception/common/unit/fixtures/data/models/user.php'
  90 + ],
  91 + ];
  92 + }
  93 +
  94 +}
tests/codeception/config/acceptance.php 0 → 100644
  1 +++ a/tests/codeception/config/acceptance.php
  1 +<?php
  2 +/**
  3 + * Application configuration shared by all applications acceptance tests
  4 + */
  5 +return [
  6 +
  7 +];
0 \ No newline at end of file 8 \ No newline at end of file
tests/codeception/config/backend/acceptance.php 0 → 100644
  1 +++ a/tests/codeception/config/backend/acceptance.php
  1 +<?php
  2 +defined('YII_APP_BASE_PATH') or define('YII_APP_BASE_PATH', dirname(dirname(dirname(dirname(__DIR__)))));
  3 +
  4 +/**
  5 + * Application configuration for backend acceptance tests
  6 + */
  7 +return yii\helpers\ArrayHelper::merge(
  8 + require(YII_APP_BASE_PATH . '/common/config/main.php'),
  9 + require(YII_APP_BASE_PATH . '/common/config/main-local.php'),
  10 + require(YII_APP_BASE_PATH . '/backend/config/main.php'),
  11 + require(YII_APP_BASE_PATH . '/backend/config/main-local.php'),
  12 + require(dirname(__DIR__) . '/config.php'),
  13 + require(dirname(__DIR__) . '/acceptance.php'),
  14 + require(__DIR__ . '/config.php'),
  15 + [
  16 + ]
  17 +);
tests/codeception/config/backend/config.php 0 → 100644
  1 +++ a/tests/codeception/config/backend/config.php
  1 +<?php
  2 +/**
  3 + * Application configuration for all backend test types
  4 + */
  5 +return [];
0 \ No newline at end of file 6 \ No newline at end of file
tests/codeception/config/backend/functional.php 0 → 100644
  1 +++ a/tests/codeception/config/backend/functional.php
  1 +<?php
  2 +$_SERVER['SCRIPT_FILENAME'] = YII_TEST_BACKEND_ENTRY_FILE;
  3 +$_SERVER['SCRIPT_NAME'] = YII_BACKEND_TEST_ENTRY_URL;
  4 +
  5 +/**
  6 + * Application configuration for backend functional tests
  7 + */
  8 +return yii\helpers\ArrayHelper::merge(
  9 + require(YII_APP_BASE_PATH . '/common/config/main.php'),
  10 + require(YII_APP_BASE_PATH . '/common/config/main-local.php'),
  11 + require(YII_APP_BASE_PATH . '/backend/config/main.php'),
  12 + require(YII_APP_BASE_PATH . '/backend/config/main-local.php'),
  13 + require(dirname(__DIR__) . '/config.php'),
  14 + require(dirname(__DIR__) . '/functional.php'),
  15 + require(__DIR__ . '/config.php'),
  16 + [
  17 + ]
  18 +);
tests/codeception/config/backend/unit.php 0 → 100644
  1 +++ a/tests/codeception/config/backend/unit.php
  1 +<?php
  2 +
  3 +/**
  4 + * Application configuration for backend unit tests
  5 + */
  6 +return yii\helpers\ArrayHelper::merge(
  7 + require(YII_APP_BASE_PATH . '/common/config/main.php'),
  8 + require(YII_APP_BASE_PATH . '/common/config/main-local.php'),
  9 + require(YII_APP_BASE_PATH . '/backend/config/main.php'),
  10 + require(YII_APP_BASE_PATH . '/backend/config/main-local.php'),
  11 + require(dirname(__DIR__) . '/config.php'),
  12 + require(dirname(__DIR__) . '/unit.php'),
  13 + require(__DIR__ . '/config.php'),
  14 + [
  15 + ]
  16 +);
tests/codeception/config/common/unit.php 0 → 100644
  1 +++ a/tests/codeception/config/common/unit.php
  1 +<?php
  2 +/**
  3 + * Application config for common unit tests
  4 + */
  5 +return yii\helpers\ArrayHelper::merge(
  6 + require(YII_APP_BASE_PATH . '/common/config/main.php'),
  7 + require(YII_APP_BASE_PATH . '/common/config/main-local.php'),
  8 + require(dirname(__DIR__) . '/config.php'),
  9 + require(dirname(__DIR__) . '/unit.php'),
  10 + [
  11 + 'id' => 'app-common',
  12 + 'basePath' => dirname(__DIR__),
  13 + ]
  14 +);
tests/codeception/config/config.php 0 → 100644
  1 +++ a/tests/codeception/config/config.php
  1 +<?php
  2 +/**
  3 + * Application configuration shared by all applications and test types
  4 + */
  5 +return [
  6 + 'controllerMap' => [
  7 + 'fixture' => [
  8 + 'class' => 'yii\faker\FixtureController',
  9 + 'fixtureDataPath' => '@tests/codeception/common/fixtures/data',
  10 + 'templatePath' => '@tests/codeception/common/templates/fixtures',
  11 + 'namespace' => 'tests\codeception\common\fixtures',
  12 + ],
  13 + ],
  14 + 'components' => [
  15 + 'db' => [
  16 + 'dsn' => 'mysql:host=localhost;dbname=yii2_advanced_tests',
  17 + ],
  18 + 'mailer' => [
  19 + 'useFileTransport' => true,
  20 + ],
  21 + 'urlManager' => [
  22 + 'showScriptName' => true,
  23 + ],
  24 + ],
  25 +];
tests/codeception/config/console/unit.php 0 → 100644
  1 +++ a/tests/codeception/config/console/unit.php
  1 +<?php
  2 +/**
  3 + * Application configuration for console unit tests
  4 + */
  5 +return yii\helpers\ArrayHelper::merge(
  6 + require(YII_APP_BASE_PATH . '/common/config/main.php'),
  7 + require(YII_APP_BASE_PATH . '/common/config/main-local.php'),
  8 + require(YII_APP_BASE_PATH . '/console/config/main.php'),
  9 + require(YII_APP_BASE_PATH . '/console/config/main-local.php'),
  10 + require(dirname(__DIR__) . '/config.php'),
  11 + require(dirname(__DIR__) . '/unit.php'),
  12 + [
  13 + ]
  14 +);
tests/codeception/config/frontend/acceptance.php 0 → 100644
  1 +++ a/tests/codeception/config/frontend/acceptance.php
  1 +<?php
  2 +defined('YII_APP_BASE_PATH') or define('YII_APP_BASE_PATH', dirname(dirname(dirname(dirname(__DIR__)))));
  3 +
  4 +/**
  5 + * Application configuration for frontend acceptance tests
  6 + */
  7 +return yii\helpers\ArrayHelper::merge(
  8 + require(YII_APP_BASE_PATH . '/common/config/main.php'),
  9 + require(YII_APP_BASE_PATH . '/common/config/main-local.php'),
  10 + require(YII_APP_BASE_PATH . '/frontend/config/main.php'),
  11 + require(YII_APP_BASE_PATH . '/frontend/config/main-local.php'),
  12 + require(dirname(__DIR__) . '/config.php'),
  13 + require(dirname(__DIR__) . '/acceptance.php'),
  14 + require(__DIR__ . '/config.php'),
  15 + [
  16 + ]
  17 +);
tests/codeception/config/frontend/config.php 0 → 100644
  1 +++ a/tests/codeception/config/frontend/config.php
  1 +<?php
  2 +/**
  3 + * Application configuration for all frontend test types
  4 + */
  5 +return [];
0 \ No newline at end of file 6 \ No newline at end of file
tests/codeception/config/frontend/functional.php 0 → 100644
  1 +++ a/tests/codeception/config/frontend/functional.php
  1 +<?php
  2 +$_SERVER['SCRIPT_FILENAME'] = FRONTEND_ENTRY_FILE;
  3 +$_SERVER['SCRIPT_NAME'] = FRONTEND_ENTRY_URL;
  4 +
  5 +/**
  6 + * Application configuration for frontend functional tests
  7 + */
  8 +return yii\helpers\ArrayHelper::merge(
  9 + require(YII_APP_BASE_PATH . '/common/config/main.php'),
  10 + require(YII_APP_BASE_PATH . '/common/config/main-local.php'),
  11 + require(YII_APP_BASE_PATH . '/frontend/config/main.php'),
  12 + require(YII_APP_BASE_PATH . '/frontend/config/main-local.php'),
  13 + require(dirname(__DIR__) . '/config.php'),
  14 + require(dirname(__DIR__) . '/functional.php'),
  15 + require(__DIR__ . '/config.php'),
  16 + [
  17 + ]
  18 +);
tests/codeception/config/frontend/unit.php 0 → 100644
  1 +++ a/tests/codeception/config/frontend/unit.php
  1 +<?php
  2 +
  3 +/**
  4 + * Application configuration for frontend unit tests
  5 + */
  6 +return yii\helpers\ArrayHelper::merge(
  7 + require(YII_APP_BASE_PATH . '/common/config/main.php'),
  8 + require(YII_APP_BASE_PATH . '/common/config/main-local.php'),
  9 + require(YII_APP_BASE_PATH . '/frontend/config/main.php'),
  10 + require(YII_APP_BASE_PATH . '/frontend/config/main-local.php'),
  11 + require(dirname(__DIR__) . '/config.php'),
  12 + require(dirname(__DIR__) . '/unit.php'),
  13 + require(__DIR__ . '/config.php'),
  14 + [
  15 + ]
  16 +);
tests/codeception/config/functional.php 0 → 100644
  1 +++ a/tests/codeception/config/functional.php
  1 +<?php
  2 +/**
  3 + * Application configuration shared by all applications functional tests
  4 + */
  5 +return [
  6 + 'components' => [
  7 + 'request' => [
  8 + // it's not recommended to run functional tests with CSRF validation enabled
  9 + 'enableCsrfValidation' => false,
  10 + // but if you absolutely need it set cookie domain to localhost
  11 + /*
  12 + 'csrfCookie' => [
  13 + 'domain' => 'localhost',
  14 + ],
  15 + */
  16 + ],
  17 + ],
  18 +];
0 \ No newline at end of file 19 \ No newline at end of file
tests/codeception/config/unit.php 0 → 100644
  1 +++ a/tests/codeception/config/unit.php
  1 +<?php
  2 +/**
  3 + * Application configuration shared by all applications unit tests
  4 + */
  5 +return [
  6 +
  7 +];
0 \ No newline at end of file 8 \ No newline at end of file
tests/codeception/console/.gitignore 0 → 100644
  1 +++ a/tests/codeception/console/.gitignore
  1 +# these files are auto generated by codeception build
  2 +/unit/UnitTester.php
tests/codeception/console/_bootstrap.php 0 → 100644
  1 +++ a/tests/codeception/console/_bootstrap.php
  1 +<?php
  2 +defined('YII_DEBUG') or define('YII_DEBUG', true);
  3 +defined('YII_ENV') or define('YII_ENV', 'test');
  4 +
  5 +defined('YII_APP_BASE_PATH') or define('YII_APP_BASE_PATH', dirname(dirname(dirname(__DIR__))));
  6 +
  7 +require_once(YII_APP_BASE_PATH . '/vendor/autoload.php');
  8 +require_once(YII_APP_BASE_PATH . '/vendor/yiisoft/yii2/Yii.php');
  9 +require_once(YII_APP_BASE_PATH . '/common/config/bootstrap.php');
  10 +require_once(YII_APP_BASE_PATH . '/console/config/bootstrap.php');
  11 +
  12 +// set correct script paths
  13 +$_SERVER['SERVER_NAME'] = 'localhost';
  14 +$_SERVER['SERVER_PORT'] = '80';
  15 +
  16 +Yii::setAlias('@tests', dirname(dirname(__DIR__)));
tests/codeception/console/_output/.gitignore 0 → 100644
  1 +++ a/tests/codeception/console/_output/.gitignore
  1 +*
  2 +!.gitignore
tests/codeception/console/codeception.yml 0 → 100644
  1 +++ a/tests/codeception/console/codeception.yml
  1 +namespace: tests\codeception\console
  2 +actor: Tester
  3 +paths:
  4 + tests: .
  5 + log: _output
  6 + data: _data
  7 + helpers: _support
  8 +settings:
  9 + bootstrap: _bootstrap.php
  10 + suite_class: \PHPUnit_Framework_TestSuite
  11 + colors: true
  12 + memory_limit: 1024M
  13 + log: true
tests/codeception/console/unit.suite.yml 0 → 100644
  1 +++ a/tests/codeception/console/unit.suite.yml
  1 +# Codeception Test Suite Configuration
  2 +
  3 +# suite for unit (internal) tests.
  4 +# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
  5 +
  6 +class_name: UnitTester
tests/codeception/console/unit/DbTestCase.php 0 → 100644
  1 +++ a/tests/codeception/console/unit/DbTestCase.php
  1 +<?php
  2 +
  3 +namespace tests\codeception\console\unit;
  4 +
  5 +/**
  6 + * @inheritdoc
  7 + */
  8 +class DbTestCase extends \yii\codeception\DbTestCase
  9 +{
  10 + public $appConfig = '@tests/codeception/config/console/config.php';
  11 +}
tests/codeception/console/unit/TestCase.php 0 → 100644
  1 +++ a/tests/codeception/console/unit/TestCase.php
  1 +<?php
  2 +
  3 +namespace tests\codeception\console\unit;
  4 +
  5 +/**
  6 + * @inheritdoc
  7 + */
  8 +class TestCase extends \yii\codeception\TestCase
  9 +{
  10 + public $appConfig = '@tests/codeception/config/console/config.php';
  11 +}
tests/codeception/console/unit/_bootstrap.php 0 → 100644
  1 +++ a/tests/codeception/console/unit/_bootstrap.php
  1 +<?php
  2 +// Here you can initialize variables that will for your tests
tests/codeception/console/unit/fixtures/data/.gitkeep 0 → 100644
  1 +++ a/tests/codeception/console/unit/fixtures/data/.gitkeep
tests/codeception/frontend/.gitignore 0 → 100644
  1 +++ a/tests/codeception/frontend/.gitignore
  1 +# these files are auto generated by codeception build
  2 +/unit/UnitTester.php
  3 +/functional/FunctionalTester.php
  4 +/acceptance/AcceptanceTester.php
tests/codeception/frontend/_bootstrap.php 0 → 100644
  1 +++ a/tests/codeception/frontend/_bootstrap.php
  1 +<?php
  2 +defined('YII_DEBUG') or define('YII_DEBUG', true);
  3 +defined('YII_ENV') or define('YII_ENV', 'test');
  4 +
  5 +defined('YII_APP_BASE_PATH') or define('YII_APP_BASE_PATH', dirname(dirname(dirname(__DIR__))));
  6 +
  7 +defined('FRONTEND_ENTRY_URL') or define('FRONTEND_ENTRY_URL', parse_url(\Codeception\Configuration::config()['config']['test_entry_url'], PHP_URL_PATH));
  8 +defined('FRONTEND_ENTRY_FILE') or define('FRONTEND_ENTRY_FILE', YII_APP_BASE_PATH . '/frontend/web/index-test.php');
  9 +
  10 +require_once(YII_APP_BASE_PATH . '/vendor/autoload.php');
  11 +require_once(YII_APP_BASE_PATH . '/vendor/yiisoft/yii2/Yii.php');
  12 +require_once(YII_APP_BASE_PATH . '/common/config/bootstrap.php');
  13 +require_once(YII_APP_BASE_PATH . '/frontend/config/bootstrap.php');
  14 +
  15 +// set correct script paths
  16 +
  17 +// the entry script file path for functional and acceptance tests
  18 +$_SERVER['SCRIPT_FILENAME'] = FRONTEND_ENTRY_FILE;
  19 +$_SERVER['SCRIPT_NAME'] = FRONTEND_ENTRY_URL;
  20 +$_SERVER['SERVER_NAME'] = parse_url(\Codeception\Configuration::config()['config']['test_entry_url'], PHP_URL_HOST);
  21 +$_SERVER['SERVER_PORT'] = parse_url(\Codeception\Configuration::config()['config']['test_entry_url'], PHP_URL_PORT) ?: '80';
  22 +
  23 +Yii::setAlias('@tests', dirname(dirname(__DIR__)));
tests/codeception/frontend/_output/.gitignore 0 → 100644
  1 +++ a/tests/codeception/frontend/_output/.gitignore
  1 +*
  2 +!.gitignore
tests/codeception/frontend/_pages/AboutPage.php 0 → 100644
  1 +++ a/tests/codeception/frontend/_pages/AboutPage.php
  1 +<?php
  2 +
  3 +namespace tests\codeception\frontend\_pages;
  4 +
  5 +use yii\codeception\BasePage;
  6 +
  7 +/**
  8 + * Represents about page
  9 + * @property \codeception_frontend\AcceptanceTester|\codeception_frontend\FunctionalTester $actor
  10 + */
  11 +class AboutPage extends BasePage
  12 +{
  13 + public $route = 'site/about';
  14 +}
tests/codeception/frontend/_pages/ContactPage.php 0 → 100644
  1 +++ a/tests/codeception/frontend/_pages/ContactPage.php
  1 +<?php
  2 +
  3 +namespace tests\codeception\frontend\_pages;
  4 +
  5 +use yii\codeception\BasePage;
  6 +
  7 +/**
  8 + * Represents contact page
  9 + * @property \codeception_frontend\AcceptanceTester|\codeception_frontend\FunctionalTester $actor
  10 + */
  11 +class ContactPage extends BasePage
  12 +{
  13 + public $route = 'site/contact';
  14 +
  15 + /**
  16 + * @param array $contactData
  17 + */
  18 + public function submit(array $contactData)
  19 + {
  20 + foreach ($contactData as $field => $value) {
  21 + $inputType = $field === 'body' ? 'textarea' : 'input';
  22 + $this->actor->fillField($inputType . '[name="ContactForm[' . $field . ']"]', $value);
  23 + }
  24 + $this->actor->click('contact-button');
  25 + }
  26 +}
tests/codeception/frontend/_pages/SignupPage.php 0 → 100644
  1 +++ a/tests/codeception/frontend/_pages/SignupPage.php
  1 +<?php
  2 +
  3 +namespace tests\codeception\frontend\_pages;
  4 +
  5 +use \yii\codeception\BasePage;
  6 +
  7 +/**
  8 + * Represents signup page
  9 + * @property \codeception_frontend\AcceptanceTester|\codeception_frontend\FunctionalTester $actor
  10 + */
  11 +class SignupPage extends BasePage
  12 +{
  13 +
  14 + public $route = 'site/signup';
  15 +
  16 + /**
  17 + * @param array $signupData
  18 + */
  19 + public function submit(array $signupData)
  20 + {
  21 + foreach ($signupData as $field => $value) {
  22 + $inputType = $field === 'body' ? 'textarea' : 'input';
  23 + $this->actor->fillField($inputType . '[name="SignupForm[' . $field . ']"]', $value);
  24 + }
  25 + $this->actor->click('signup-button');
  26 + }
  27 +}
tests/codeception/frontend/acceptance.suite.yml 0 → 100644
  1 +++ a/tests/codeception/frontend/acceptance.suite.yml
  1 +# Codeception Test Suite Configuration
  2 +
  3 +# suite for acceptance tests.
  4 +# perform tests in browser using the Selenium-like tools.
  5 +# powered by Mink (http://mink.behat.org).
  6 +# (tip: that's what your customer will see).
  7 +# (tip: test your ajax and javascript by one of Mink drivers).
  8 +
  9 +# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
  10 +
  11 +class_name: AcceptanceTester
  12 +modules:
  13 + enabled:
  14 + - PhpBrowser
  15 + - tests\codeception\common\_support\FixtureHelper
  16 +# you can use WebDriver instead of PhpBrowser to test javascript and ajax.
  17 +# This will require you to install selenium. See http://codeception.com/docs/04-AcceptanceTests#Selenium
  18 +# "restart" option is used by the WebDriver to start each time per test-file new session and cookies,
  19 +# it is useful if you want to login in your app in each test.
  20 +# - WebDriver
  21 + config:
  22 + PhpBrowser:
  23 +# PLEASE ADJUST IT TO THE ACTUAL ENTRY POINT WITHOUT PATH INFO
  24 + url: http://localhost:8080
  25 +# WebDriver:
  26 +# url: http://localhost:8080
  27 +# browser: firefox
  28 +# restart: true
tests/codeception/frontend/acceptance/AboutCept.php 0 → 100644
  1 +++ a/tests/codeception/frontend/acceptance/AboutCept.php
  1 +<?php
  2 +use tests\codeception\frontend\AcceptanceTester;
  3 +use tests\codeception\frontend\_pages\AboutPage;
  4 +
  5 +/* @var $scenario Codeception\Scenario */
  6 +
  7 +$I = new AcceptanceTester($scenario);
  8 +$I->wantTo('ensure that about works');
  9 +AboutPage::openBy($I);
  10 +$I->see('About', 'h1');
tests/codeception/frontend/acceptance/ContactCept.php 0 → 100644
  1 +++ a/tests/codeception/frontend/acceptance/ContactCept.php
  1 +<?php
  2 +use tests\codeception\frontend\AcceptanceTester;
  3 +use tests\codeception\frontend\_pages\ContactPage;
  4 +
  5 +/* @var $scenario Codeception\Scenario */
  6 +
  7 +$I = new AcceptanceTester($scenario);
  8 +$I->wantTo('ensure that contact works');
  9 +
  10 +$contactPage = ContactPage::openBy($I);
  11 +
  12 +$I->see('Contact', 'h1');
  13 +
  14 +$I->amGoingTo('submit contact form with no data');
  15 +$contactPage->submit([]);
  16 +if (method_exists($I, 'wait')) {
  17 + $I->wait(3); // only for selenium
  18 +}
  19 +$I->expectTo('see validations errors');
  20 +$I->see('Contact', 'h1');
  21 +$I->see('Name cannot be blank', '.help-block');
  22 +$I->see('Email cannot be blank', '.help-block');
  23 +$I->see('Subject cannot be blank', '.help-block');
  24 +$I->see('Body cannot be blank', '.help-block');
  25 +$I->see('The verification code is incorrect', '.help-block');
  26 +
  27 +$I->amGoingTo('submit contact form with not correct email');
  28 +$contactPage->submit([
  29 + 'name' => 'tester',
  30 + 'email' => 'tester.email',
  31 + 'subject' => 'test subject',
  32 + 'body' => 'test content',
  33 + 'verifyCode' => 'testme',
  34 +]);
  35 +if (method_exists($I, 'wait')) {
  36 + $I->wait(3); // only for selenium
  37 +}
  38 +$I->expectTo('see that email adress is wrong');
  39 +$I->dontSee('Name cannot be blank', '.help-block');
  40 +$I->see('Email is not a valid email address.', '.help-block');
  41 +$I->dontSee('Subject cannot be blank', '.help-block');
  42 +$I->dontSee('Body cannot be blank', '.help-block');
  43 +$I->dontSee('The verification code is incorrect', '.help-block');
  44 +
  45 +$I->amGoingTo('submit contact form with correct data');
  46 +$contactPage->submit([
  47 + 'name' => 'tester',
  48 + 'email' => 'tester@example.com',
  49 + 'subject' => 'test subject',
  50 + 'body' => 'test content',
  51 + 'verifyCode' => 'testme',
  52 +]);
  53 +if (method_exists($I, 'wait')) {
  54 + $I->wait(3); // only for selenium
  55 +}
  56 +$I->see('Thank you for contacting us. We will respond to you as soon as possible.');
tests/codeception/frontend/acceptance/HomeCept.php 0 → 100644
  1 +++ a/tests/codeception/frontend/acceptance/HomeCept.php
  1 +<?php
  2 +use tests\codeception\frontend\AcceptanceTester;
  3 +
  4 +/* @var $scenario Codeception\Scenario */
  5 +
  6 +$I = new AcceptanceTester($scenario);
  7 +$I->wantTo('ensure that home page works');
  8 +$I->amOnPage(Yii::$app->homeUrl);
  9 +$I->see('My Company');
  10 +$I->seeLink('About');
  11 +$I->click('About');
  12 +$I->see('This is the About page.');
tests/codeception/frontend/acceptance/LoginCept.php 0 → 100644
  1 +++ a/tests/codeception/frontend/acceptance/LoginCept.php
  1 +<?php
  2 +use tests\codeception\frontend\AcceptanceTester;
  3 +use tests\codeception\common\_pages\LoginPage;
  4 +
  5 +/* @var $scenario Codeception\Scenario */
  6 +
  7 +$I = new AcceptanceTester($scenario);
  8 +$I->wantTo('ensure login page works');
  9 +
  10 +$loginPage = LoginPage::openBy($I);
  11 +
  12 +$I->amGoingTo('submit login form with no data');
  13 +$loginPage->login('', '');
  14 +$I->expectTo('see validations errors');
  15 +$I->see('Username cannot be blank.', '.help-block');
  16 +$I->see('Password cannot be blank.', '.help-block');
  17 +
  18 +$I->amGoingTo('try to login with wrong credentials');
  19 +$I->expectTo('see validations errors');
  20 +$loginPage->login('admin', 'wrong');
  21 +$I->expectTo('see validations errors');
  22 +$I->see('Incorrect username or password.', '.help-block');
  23 +
  24 +$I->amGoingTo('try to login with correct credentials');
  25 +$loginPage->login('erau', 'password_0');
  26 +$I->expectTo('see that user is logged');
  27 +$I->seeLink('Logout (erau)');
  28 +$I->dontSeeLink('Login');
  29 +$I->dontSeeLink('Signup');
  30 +/** Uncomment if using WebDriver
  31 + * $I->click('Logout (erau)');
  32 + * $I->dontSeeLink('Logout (erau)');
  33 + * $I->seeLink('Login');
  34 + */
tests/codeception/frontend/acceptance/SignupCest.php 0 → 100644
  1 +++ a/tests/codeception/frontend/acceptance/SignupCest.php
  1 +<?php
  2 +
  3 +namespace tests\codeception\frontend\acceptance;
  4 +
  5 +use tests\codeception\frontend\_pages\SignupPage;
  6 +use common\models\User;
  7 +
  8 +class SignupCest
  9 +{
  10 +
  11 + /**
  12 + * This method is called before each cest class test method
  13 + * @param \Codeception\Event\TestEvent $event
  14 + */
  15 + public function _before($event)
  16 + {
  17 + }
  18 +
  19 + /**
  20 + * This method is called after each cest class test method, even if test failed.
  21 + * @param \Codeception\Event\TestEvent $event
  22 + */
  23 + public function _after($event)
  24 + {
  25 + User::deleteAll([
  26 + 'email' => 'tester.email@example.com',
  27 + 'username' => 'tester',
  28 + ]);
  29 + }
  30 +
  31 + /**
  32 + * This method is called when test fails.
  33 + * @param \Codeception\Event\FailEvent $event
  34 + */
  35 + public function _fail($event)
  36 + {
  37 + }
  38 +
  39 + /**
  40 + * @param \codeception_frontend\AcceptanceTester $I
  41 + * @param \Codeception\Scenario $scenario
  42 + */
  43 + public function testUserSignup($I, $scenario)
  44 + {
  45 + $I->wantTo('ensure that signup works');
  46 +
  47 + $signupPage = SignupPage::openBy($I);
  48 + $I->see('Signup', 'h1');
  49 + $I->see('Please fill out the following fields to signup:');
  50 +
  51 + $I->amGoingTo('submit signup form with no data');
  52 +
  53 + $signupPage->submit([]);
  54 +
  55 + $I->expectTo('see validation errors');
  56 + $I->see('Username cannot be blank.', '.help-block');
  57 + $I->see('Email cannot be blank.', '.help-block');
  58 + $I->see('Password cannot be blank.', '.help-block');
  59 +
  60 + $I->amGoingTo('submit signup form with not correct email');
  61 + $signupPage->submit([
  62 + 'username' => 'tester',
  63 + 'email' => 'tester.email',
  64 + 'password' => 'tester_password',
  65 + ]);
  66 +
  67 + $I->expectTo('see that email address is wrong');
  68 + $I->dontSee('Username cannot be blank.', '.help-block');
  69 + $I->dontSee('Password cannot be blank.', '.help-block');
  70 + $I->see('Email is not a valid email address.', '.help-block');
  71 +
  72 + $I->amGoingTo('submit signup form with correct email');
  73 + $signupPage->submit([
  74 + 'username' => 'tester',
  75 + 'email' => 'tester.email@example.com',
  76 + 'password' => 'tester_password',
  77 + ]);
  78 +
  79 + $I->expectTo('see that user logged in');
  80 + $I->seeLink('Logout (tester)');
  81 + }
  82 +}
tests/codeception/frontend/acceptance/_bootstrap.php 0 → 100644
  1 +++ a/tests/codeception/frontend/acceptance/_bootstrap.php
  1 +<?php
  2 +new yii\web\Application(require(dirname(dirname(__DIR__)) . '/config/frontend/acceptance.php'));
tests/codeception/frontend/codeception.yml 0 → 100644
  1 +++ a/tests/codeception/frontend/codeception.yml
  1 +namespace: tests\codeception\frontend
  2 +actor: Tester
  3 +paths:
  4 + tests: .
  5 + log: _output
  6 + data: _data
  7 + helpers: _support
  8 +settings:
  9 + bootstrap: _bootstrap.php
  10 + suite_class: \PHPUnit_Framework_TestSuite
  11 + colors: true
  12 + memory_limit: 1024M
  13 + log: true
  14 +config:
  15 + # the entry script URL (with host info) for functional and acceptance tests
  16 + # PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL
  17 + test_entry_url: http://localhost:8080/frontend/web/index-test.php
tests/codeception/frontend/functional.suite.yml 0 → 100644
  1 +++ a/tests/codeception/frontend/functional.suite.yml
  1 +# Codeception Test Suite Configuration
  2 +
  3 +# suite for functional (integration) tests.
  4 +# emulate web requests and make application process them.
  5 +# (tip: better to use with frameworks).
  6 +
  7 +# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
  8 +#basic/web/index.php
  9 +class_name: FunctionalTester
  10 +modules:
  11 + enabled:
  12 + - Filesystem
  13 + - Yii2
  14 + - tests\codeception\common\_support\FixtureHelper
  15 + config:
  16 + Yii2:
  17 + configFile: '../config/frontend/functional.php'
tests/codeception/frontend/functional/AboutCept.php 0 → 100644
  1 +++ a/tests/codeception/frontend/functional/AboutCept.php
  1 +<?php
  2 +use tests\codeception\frontend\FunctionalTester;
  3 +use tests\codeception\frontend\_pages\AboutPage;
  4 +
  5 +/* @var $scenario Codeception\Scenario */
  6 +
  7 +$I = new FunctionalTester($scenario);
  8 +$I->wantTo('ensure that about works');
  9 +AboutPage::openBy($I);
  10 +$I->see('About', 'h1');
tests/codeception/frontend/functional/ContactCept.php 0 → 100644
  1 +++ a/tests/codeception/frontend/functional/ContactCept.php
  1 +<?php
  2 +use tests\codeception\frontend\FunctionalTester;
  3 +use tests\codeception\frontend\_pages\ContactPage;
  4 +
  5 +/* @var $scenario Codeception\Scenario */
  6 +
  7 +$I = new FunctionalTester($scenario);
  8 +$I->wantTo('ensure that contact works');
  9 +
  10 +$contactPage = ContactPage::openBy($I);
  11 +
  12 +$I->see('Contact', 'h1');
  13 +
  14 +$I->amGoingTo('submit contact form with no data');
  15 +$contactPage->submit([]);
  16 +$I->expectTo('see validations errors');
  17 +$I->see('Contact', 'h1');
  18 +$I->see('Name cannot be blank', '.help-block');
  19 +$I->see('Email cannot be blank', '.help-block');
  20 +$I->see('Subject cannot be blank', '.help-block');
  21 +$I->see('Body cannot be blank', '.help-block');
  22 +$I->see('The verification code is incorrect', '.help-block');
  23 +
  24 +$I->amGoingTo('submit contact form with not correct email');
  25 +$contactPage->submit([
  26 + 'name' => 'tester',
  27 + 'email' => 'tester.email',
  28 + 'subject' => 'test subject',
  29 + 'body' => 'test content',
  30 + 'verifyCode' => 'testme',
  31 +]);
  32 +$I->expectTo('see that email adress is wrong');
  33 +$I->dontSee('Name cannot be blank', '.help-block');
  34 +$I->see('Email is not a valid email address.', '.help-block');
  35 +$I->dontSee('Subject cannot be blank', '.help-block');
  36 +$I->dontSee('Body cannot be blank', '.help-block');
  37 +$I->dontSee('The verification code is incorrect', '.help-block');
  38 +
  39 +$I->amGoingTo('submit contact form with correct data');
  40 +$contactPage->submit([
  41 + 'name' => 'tester',
  42 + 'email' => 'tester@example.com',
  43 + 'subject' => 'test subject',
  44 + 'body' => 'test content',
  45 + 'verifyCode' => 'testme',
  46 +]);
  47 +$I->see('Thank you for contacting us. We will respond to you as soon as possible.');
tests/codeception/frontend/functional/HomeCept.php 0 → 100644
  1 +++ a/tests/codeception/frontend/functional/HomeCept.php
  1 +<?php
  2 +use tests\codeception\frontend\FunctionalTester;
  3 +
  4 +/* @var $scenario Codeception\Scenario */
  5 +
  6 +$I = new FunctionalTester($scenario);
  7 +$I->wantTo('ensure that home page works');
  8 +$I->amOnPage(Yii::$app->homeUrl);
  9 +$I->see('My Company');
  10 +$I->seeLink('About');
  11 +$I->click('About');
  12 +$I->see('This is the About page.');
tests/codeception/frontend/functional/LoginCept.php 0 → 100644
  1 +++ a/tests/codeception/frontend/functional/LoginCept.php
  1 +<?php
  2 +use tests\codeception\frontend\FunctionalTester;
  3 +use tests\codeception\common\_pages\LoginPage;
  4 +
  5 +/* @var $scenario Codeception\Scenario */
  6 +
  7 +$I = new FunctionalTester($scenario);
  8 +$I->wantTo('ensure login page works');
  9 +
  10 +$loginPage = LoginPage::openBy($I);
  11 +
  12 +$I->amGoingTo('submit login form with no data');
  13 +$loginPage->login('', '');
  14 +$I->expectTo('see validations errors');
  15 +$I->see('Username cannot be blank.', '.help-block');
  16 +$I->see('Password cannot be blank.', '.help-block');
  17 +
  18 +$I->amGoingTo('try to login with wrong credentials');
  19 +$I->expectTo('see validations errors');
  20 +$loginPage->login('admin', 'wrong');
  21 +$I->expectTo('see validations errors');
  22 +$I->see('Incorrect username or password.', '.help-block');
  23 +
  24 +$I->amGoingTo('try to login with correct credentials');
  25 +$loginPage->login('erau', 'password_0');
  26 +$I->expectTo('see that user is logged');
  27 +$I->seeLink('Logout (erau)');
  28 +$I->dontSeeLink('Login');
  29 +$I->dontSeeLink('Signup');
tests/codeception/frontend/functional/SignupCest.php 0 → 100644
  1 +++ a/tests/codeception/frontend/functional/SignupCest.php
  1 +<?php
  2 +
  3 +namespace tests\codeception\frontend\functional;
  4 +
  5 +use tests\codeception\frontend\_pages\SignupPage;
  6 +use common\models\User;
  7 +
  8 +class SignupCest
  9 +{
  10 +
  11 + /**
  12 + * This method is called before each cest class test method
  13 + * @param \Codeception\Event\TestEvent $event
  14 + */
  15 + public function _before($event)
  16 + {
  17 + }
  18 +
  19 + /**
  20 + * This method is called after each cest class test method, even if test failed.
  21 + * @param \Codeception\Event\TestEvent $event
  22 + */
  23 + public function _after($event)
  24 + {
  25 + User::deleteAll([
  26 + 'email' => 'tester.email@example.com',
  27 + 'username' => 'tester',
  28 + ]);
  29 + }
  30 +
  31 + /**
  32 + * This method is called when test fails.
  33 + * @param \Codeception\Event\FailEvent $event
  34 + */
  35 + public function _fail($event)
  36 + {
  37 +
  38 + }
  39 +
  40 + /**
  41 + *
  42 + * @param \codeception_frontend\FunctionalTester $I
  43 + * @param \Codeception\Scenario $scenario
  44 + */
  45 + public function testUserSignup($I, $scenario)
  46 + {
  47 + $I->wantTo('ensure that signup works');
  48 +
  49 + $signupPage = SignupPage::openBy($I);
  50 + $I->see('Signup', 'h1');
  51 + $I->see('Please fill out the following fields to signup:');
  52 +
  53 + $I->amGoingTo('submit signup form with no data');
  54 +
  55 + $signupPage->submit([]);
  56 +
  57 + $I->expectTo('see validation errors');
  58 + $I->see('Username cannot be blank.', '.help-block');
  59 + $I->see('Email cannot be blank.', '.help-block');
  60 + $I->see('Password cannot be blank.', '.help-block');
  61 +
  62 + $I->amGoingTo('submit signup form with not correct email');
  63 + $signupPage->submit([
  64 + 'username' => 'tester',
  65 + 'email' => 'tester.email',
  66 + 'password' => 'tester_password',
  67 + ]);
  68 +
  69 + $I->expectTo('see that email address is wrong');
  70 + $I->dontSee('Username cannot be blank.', '.help-block');
  71 + $I->dontSee('Password cannot be blank.', '.help-block');
  72 + $I->see('Email is not a valid email address.', '.help-block');
  73 +
  74 + $I->amGoingTo('submit signup form with correct email');
  75 + $signupPage->submit([
  76 + 'username' => 'tester',
  77 + 'email' => 'tester.email@example.com',
  78 + 'password' => 'tester_password',
  79 + ]);
  80 +
  81 + $I->expectTo('see that user is created');
  82 + $I->seeRecord('common\models\User', [
  83 + 'username' => 'tester',
  84 + 'email' => 'tester.email@example.com',
  85 + ]);
  86 +
  87 + $I->expectTo('see that user logged in');
  88 + $I->seeLink('Logout (tester)');
  89 + }
  90 +}
tests/codeception/frontend/functional/_bootstrap.php 0 → 100644
  1 +++ a/tests/codeception/frontend/functional/_bootstrap.php
  1 +<?php
  2 +
  3 +new yii\web\Application(require(dirname(dirname(__DIR__)) . '/config/frontend/functional.php'));
tests/codeception/frontend/unit.suite.yml 0 → 100644
  1 +++ a/tests/codeception/frontend/unit.suite.yml
  1 +# Codeception Test Suite Configuration
  2 +
  3 +# suite for unit (internal) tests.
  4 +# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
  5 +
  6 +class_name: UnitTester
tests/codeception/frontend/unit/DbTestCase.php 0 → 100644
  1 +++ a/tests/codeception/frontend/unit/DbTestCase.php
  1 +<?php
  2 +
  3 +namespace tests\codeception\frontend\unit;
  4 +
  5 +/**
  6 + * @inheritdoc
  7 + */
  8 +class DbTestCase extends \yii\codeception\DbTestCase
  9 +{
  10 + public $appConfig = '@tests/codeception/config/frontend/unit.php';
  11 +}
tests/codeception/frontend/unit/TestCase.php 0 → 100644
  1 +++ a/tests/codeception/frontend/unit/TestCase.php
  1 +<?php
  2 +
  3 +namespace tests\codeception\frontend\unit;
  4 +
  5 +/**
  6 + * @inheritdoc
  7 + */
  8 +class TestCase extends \yii\codeception\TestCase
  9 +{
  10 + public $appConfig = '@tests/codeception/config/frontend/unit.php';
  11 +}
tests/codeception/frontend/unit/_bootstrap.php 0 → 100644
  1 +++ a/tests/codeception/frontend/unit/_bootstrap.php
  1 +<?php
  2 +// Here you can initialize variables that will for your tests
tests/codeception/frontend/unit/fixtures/data/models/user.php 0 → 100644
  1 +++ a/tests/codeception/frontend/unit/fixtures/data/models/user.php
  1 +<?php
  2 +
  3 +return [
  4 + [
  5 + 'username' => 'okirlin',
  6 + 'auth_key' => 'iwTNae9t34OmnK6l4vT4IeaTk-YWI2Rv',
  7 + 'password_hash' => '$2y$13$CXT0Rkle1EMJ/c1l5bylL.EylfmQ39O5JlHJVFpNn618OUS1HwaIi',
  8 + 'password_reset_token' => 't5GU9NwpuGYSfb7FEZMAxqtuz2PkEvv_' . time(),
  9 + 'created_at' => '1391885313',
  10 + 'updated_at' => '1391885313',
  11 + 'email' => 'brady.renner@rutherford.com',
  12 + ],
  13 + [
  14 + 'username' => 'troy.becker',
  15 + 'auth_key' => 'EdKfXrx88weFMV0vIxuTMWKgfK2tS3Lp',
  16 + 'password_hash' => '$2y$13$g5nv41Px7VBqhS3hVsVN2.MKfgT3jFdkXEsMC4rQJLfaMa7VaJqL2',
  17 + 'password_reset_token' => '4BSNyiZNAuxjs5Mty990c47sVrgllIi_' . time(),
  18 + 'created_at' => '1391885313',
  19 + 'updated_at' => '1391885313',
  20 + 'email' => 'nicolas.dianna@hotmail.com',
  21 + 'status' => '0',
  22 + ],
  23 +];
tests/codeception/frontend/unit/models/ContactFormTest.php 0 → 100644
  1 +++ a/tests/codeception/frontend/unit/models/ContactFormTest.php
  1 +<?php
  2 +
  3 +namespace tests\codeception\frontend\unit\models;
  4 +
  5 +use Yii;
  6 +use tests\codeception\frontend\unit\TestCase;
  7 +use frontend\models\ContactForm;
  8 +
  9 +class ContactFormTest extends TestCase
  10 +{
  11 +
  12 + use \Codeception\Specify;
  13 +
  14 + protected function setUp()
  15 + {
  16 + parent::setUp();
  17 + Yii::$app->mailer->fileTransportCallback = function ($mailer, $message) {
  18 + return 'testing_message.eml';
  19 + };
  20 + }
  21 +
  22 + protected function tearDown()
  23 + {
  24 + unlink($this->getMessageFile());
  25 + parent::tearDown();
  26 + }
  27 +
  28 + public function testContact()
  29 + {
  30 + $model = new ContactForm();
  31 +
  32 + $model->attributes = [
  33 + 'name' => 'Tester',
  34 + 'email' => 'tester@example.com',
  35 + 'subject' => 'very important letter subject',
  36 + 'body' => 'body of current message',
  37 + ];
  38 +
  39 + $model->sendEmail('admin@example.com');
  40 +
  41 + $this->specify('email should be send', function () {
  42 + expect('email file should exist', file_exists($this->getMessageFile()))->true();
  43 + });
  44 +
  45 + $this->specify('message should contain correct data', function () use ($model) {
  46 + $emailMessage = file_get_contents($this->getMessageFile());
  47 +
  48 + expect('email should contain user name', $emailMessage)->contains($model->name);
  49 + expect('email should contain sender email', $emailMessage)->contains($model->email);
  50 + expect('email should contain subject', $emailMessage)->contains($model->subject);
  51 + expect('email should contain body', $emailMessage)->contains($model->body);
  52 + });
  53 + }
  54 +
  55 + private function getMessageFile()
  56 + {
  57 + return Yii::getAlias(Yii::$app->mailer->fileTransportPath) . '/testing_message.eml';
  58 + }
  59 +}
tests/codeception/frontend/unit/models/PasswordResetRequestFormTest.php 0 → 100644
  1 +++ a/tests/codeception/frontend/unit/models/PasswordResetRequestFormTest.php
  1 +<?php
  2 +
  3 +namespace tests\codeception\frontend\models;
  4 +
  5 +use Yii;
  6 +use tests\codeception\frontend\unit\DbTestCase;
  7 +use frontend\models\PasswordResetRequestForm;
  8 +use tests\codeception\common\fixtures\UserFixture;
  9 +use common\models\User;
  10 +use Codeception\Specify;
  11 +
  12 +class PasswordResetRequestFormTest extends DbTestCase
  13 +{
  14 + use Specify;
  15 +
  16 + protected function setUp()
  17 + {
  18 + parent::setUp();
  19 +
  20 + Yii::$app->mailer->fileTransportCallback = function ($mailer, $message) {
  21 + return 'testing_message.eml';
  22 + };
  23 + }
  24 +
  25 + protected function tearDown()
  26 + {
  27 + @unlink($this->getMessageFile());
  28 +
  29 + parent::tearDown();
  30 + }
  31 +
  32 + public function testSendEmailWrongUser()
  33 + {
  34 + $this->specify('no user with such email, message should not be sent', function () {
  35 +
  36 + $model = new PasswordResetRequestForm();
  37 + $model->email = 'not-existing-email@example.com';
  38 +
  39 + expect('email not sent', $model->sendEmail())->false();
  40 +
  41 + });
  42 +
  43 + $this->specify('user is not active, message should not be sent', function () {
  44 +
  45 + $model = new PasswordResetRequestForm();
  46 + $model->email = $this->user[1]['email'];
  47 +
  48 + expect('email not sent', $model->sendEmail())->false();
  49 +
  50 + });
  51 + }
  52 +
  53 + public function testSendEmailCorrectUser()
  54 + {
  55 + $model = new PasswordResetRequestForm();
  56 + $model->email = $this->user[0]['email'];
  57 + $user = User::findOne(['password_reset_token' => $this->user[0]['password_reset_token']]);
  58 +
  59 + expect('email sent', $model->sendEmail())->true();
  60 + expect('user has valid token', $user->password_reset_token)->notNull();
  61 +
  62 + $this->specify('message has correct format', function () use ($model) {
  63 +
  64 + expect('message file exists', file_exists($this->getMessageFile()))->true();
  65 +
  66 + $message = file_get_contents($this->getMessageFile());
  67 + expect('message "from" is correct', $message)->contains(Yii::$app->params['supportEmail']);
  68 + expect('message "to" is correct', $message)->contains($model->email);
  69 +
  70 + });
  71 + }
  72 +
  73 + public function fixtures()
  74 + {
  75 + return [
  76 + 'user' => [
  77 + 'class' => UserFixture::className(),
  78 + 'dataFile' => '@tests/codeception/frontend/unit/fixtures/data/models/user.php'
  79 + ],
  80 + ];
  81 + }
  82 +
  83 + private function getMessageFile()
  84 + {
  85 + return Yii::getAlias(Yii::$app->mailer->fileTransportPath) . '/testing_message.eml';
  86 + }
  87 +
  88 +}
tests/codeception/frontend/unit/models/ResetPasswordFormTest.php 0 → 100644
  1 +++ a/tests/codeception/frontend/unit/models/ResetPasswordFormTest.php
  1 +<?php
  2 +
  3 +namespace tests\codeception\frontend\unit\models;
  4 +
  5 +use tests\codeception\frontend\unit\DbTestCase;
  6 +use tests\codeception\common\fixtures\UserFixture;
  7 +use frontend\models\ResetPasswordForm;
  8 +
  9 +class ResetPasswordFormTest extends DbTestCase
  10 +{
  11 +
  12 + /**
  13 + * @expectedException \yii\base\InvalidParamException
  14 + */
  15 + public function testResetWrongToken()
  16 + {
  17 + new ResetPasswordForm('notexistingtoken_1391882543');
  18 + }
  19 +
  20 + /**
  21 + * @expectedException \yii\base\InvalidParamException
  22 + */
  23 + public function testResetEmptyToken()
  24 + {
  25 + new ResetPasswordForm('');
  26 + }
  27 +
  28 + public function testResetCorrectToken()
  29 + {
  30 + $form = new ResetPasswordForm($this->user[0]['password_reset_token']);
  31 + expect('password should be resetted', $form->resetPassword())->true();
  32 + }
  33 +
  34 + public function fixtures()
  35 + {
  36 + return [
  37 + 'user' => [
  38 + 'class' => UserFixture::className(),
  39 + 'dataFile' => '@tests/codeception/frontend/unit/fixtures/data/models/user.php'
  40 + ],
  41 + ];
  42 + }
  43 +
  44 +}
tests/codeception/frontend/unit/models/SignupFormTest.php 0 → 100644
  1 +++ a/tests/codeception/frontend/unit/models/SignupFormTest.php
  1 +<?php
  2 +
  3 +namespace tests\codeception\frontend\unit\models;
  4 +
  5 +use tests\codeception\frontend\unit\DbTestCase;
  6 +use tests\codeception\common\fixtures\UserFixture;
  7 +use Codeception\Specify;
  8 +use frontend\models\SignupForm;
  9 +
  10 +class SignupFormTest extends DbTestCase
  11 +{
  12 +
  13 + use Specify;
  14 +
  15 + public function testCorrectSignup()
  16 + {
  17 + $model = new SignupForm([
  18 + 'username' => 'some_username',
  19 + 'email' => 'some_email@example.com',
  20 + 'password' => 'some_password',
  21 + ]);
  22 +
  23 + $user = $model->signup();
  24 +
  25 + $this->assertInstanceOf('common\models\User', $user, 'user should be valid');
  26 +
  27 + expect('username should be correct', $user->username)->equals('some_username');
  28 + expect('email should be correct', $user->email)->equals('some_email@example.com');
  29 + expect('password should be correct', $user->validatePassword('some_password'))->true();
  30 + }
  31 +
  32 + public function testNotCorrectSignup()
  33 + {
  34 + $model = new SignupForm([
  35 + 'username' => 'troy.becker',
  36 + 'email' => 'nicolas.dianna@hotmail.com',
  37 + 'password' => 'some_password',
  38 + ]);
  39 +
  40 + expect('username and email are in use, user should not be created', $model->signup())->null();
  41 + }
  42 +
  43 + public function fixtures()
  44 + {
  45 + return [
  46 + 'user' => [
  47 + 'class' => UserFixture::className(),
  48 + 'dataFile' => '@tests/codeception/frontend/unit/fixtures/data/models/user.php',
  49 + ],
  50 + ];
  51 + }
  52 +
  53 +}
uploads/1900cofe290515_019.jpg 0 → 100644

2.9 KB

uploads/1900cofe290515_044.jpg 0 → 100644

22.1 KB

uploads/1900cofe290515_044new.jpg 0 → 100644

24.3 KB

uploads/Screenshot from 2015-09-23 10:45:34.png 0 → 100644

85.5 KB

uploads/petrushkaUniversalna.jpg 0 → 100644

33.8 KB

  1 +++ a/yii
  1 +#!/usr/bin/env php
  2 +<?php
  3 +/**
  4 + * Yii console bootstrap file.
  5 + *
  6 + * @link http://www.yiiframework.com/
  7 + * @copyright Copyright (c) 2008 Yii Software LLC
  8 + * @license http://www.yiiframework.com/license/
  9 + */
  10 +
  11 +defined('YII_DEBUG') or define('YII_DEBUG', true);
  12 +defined('YII_ENV') or define('YII_ENV', 'dev');
  13 +
  14 +// fcgi doesn't have STDIN and STDOUT defined by default
  15 +defined('STDIN') or define('STDIN', fopen('php://stdin', 'r'));
  16 +defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w'));
  17 +
  18 +require(__DIR__ . '/vendor/autoload.php');
  19 +require(__DIR__ . '/vendor/yiisoft/yii2/Yii.php');
  20 +require(__DIR__ . '/common/config/bootstrap.php');
  21 +require(__DIR__ . '/console/config/bootstrap.php');
  22 +
  23 +$config = yii\helpers\ArrayHelper::merge(
  24 + require(__DIR__ . '/common/config/main.php'),
  25 + require(__DIR__ . '/common/config/main-local.php'),
  26 + require(__DIR__ . '/console/config/main.php'),
  27 + require(__DIR__ . '/console/config/main-local.php')
  28 +);
  29 +
  30 +$application = new yii\console\Application($config);
  31 +$exitCode = $application->run();
  32 +exit($exitCode);
yii.bat 0 → 100644
  1 +++ a/yii.bat
  1 +@echo off
  2 +
  3 +rem -------------------------------------------------------------
  4 +rem Yii command line bootstrap script for Windows.
  5 +rem
  6 +rem @author Qiang Xue <qiang.xue@gmail.com>
  7 +rem @link http://www.yiiframework.com/
  8 +rem @copyright Copyright (c) 2008 Yii Software LLC
  9 +rem @license http://www.yiiframework.com/license/
  10 +rem -------------------------------------------------------------
  11 +
  12 +@setlocal
  13 +
  14 +set YII_PATH=%~dp0
  15 +
  16 +if "%PHP_COMMAND%" == "" set PHP_COMMAND=php.exe
  17 +
  18 +"%PHP_COMMAND%" "%YII_PATH%yii" %*
  19 +
  20 +@endlocal