diff --git a/assets/AppAsset.php b/assets/AppAsset.php index c964d36..0e495a8 100644 --- a/assets/AppAsset.php +++ b/assets/AppAsset.php @@ -15,15 +15,15 @@ use yii\web\AssetBundle; */ class AppAsset extends AssetBundle { - public $basePath = '@webroot'; - public $baseUrl = '@web'; - public $css = [ - 'css/site.css', - ]; - public $js = [ - ]; - public $depends = [ - 'yii\web\YiiAsset', - 'yii\bootstrap\BootstrapAsset', - ]; + public $basePath = '@webroot'; + public $baseUrl = '@web'; + public $css = [ + 'css/site.css', + ]; + public $js = [ + ]; + public $depends = [ + 'yii\web\YiiAsset', + 'yii\bootstrap\BootstrapAsset', + ]; } diff --git a/commands/HelloController.php b/commands/HelloController.php index ce567dd..86ab8b8 100644 --- a/commands/HelloController.php +++ b/commands/HelloController.php @@ -19,12 +19,12 @@ use yii\console\Controller; */ class HelloController extends Controller { - /** - * This command echoes what you have entered as the message. - * @param string $message the message to be echoed. - */ - public function actionIndex($message = 'hello world') - { - echo $message . "\n"; - } + /** + * This command echoes what you have entered as the message. + * @param string $message the message to be echoed. + */ + public function actionIndex($message = 'hello world') + { + echo $message . "\n"; + } } diff --git a/config/console.php b/config/console.php index 1f58e42..f254858 100644 --- a/config/console.php +++ b/config/console.php @@ -6,24 +6,24 @@ $params = require(__DIR__ . '/params.php'); $db = require(__DIR__ . '/db.php'); return [ - 'id' => 'basic-console', - 'basePath' => dirname(__DIR__), - 'preload' => ['log'], - 'controllerNamespace' => 'app\commands', - 'extensions' => require(__DIR__ . '/../vendor/yiisoft/extensions.php'), - 'components' => [ - 'cache' => [ - 'class' => 'yii\caching\FileCache', - ], - 'log' => [ - 'targets' => [ - [ - 'class' => 'yii\log\FileTarget', - 'levels' => ['error', 'warning'], - ], - ], - ], - 'db' => $db, - ], - 'params' => $params, + 'id' => 'basic-console', + 'basePath' => dirname(__DIR__), + 'preload' => ['log'], + 'controllerNamespace' => 'app\commands', + 'extensions' => require(__DIR__ . '/../vendor/yiisoft/extensions.php'), + 'components' => [ + 'cache' => [ + 'class' => 'yii\caching\FileCache', + ], + 'log' => [ + 'targets' => [ + [ + 'class' => 'yii\log\FileTarget', + 'levels' => ['error', 'warning'], + ], + ], + ], + 'db' => $db, + ], + 'params' => $params, ]; diff --git a/config/db.php b/config/db.php index b14e77e..c4c1252 100644 --- a/config/db.php +++ b/config/db.php @@ -1,9 +1,9 @@ 'yii\db\Connection', - 'dsn' => 'mysql:host=localhost;dbname=yii2basic', - 'username' => 'root', - 'password' => '', - 'charset' => 'utf8', + 'class' => 'yii\db\Connection', + 'dsn' => 'mysql:host=localhost;dbname=yii2basic', + 'username' => 'root', + 'password' => '', + 'charset' => 'utf8', ]; diff --git a/config/params.php b/config/params.php index 93cb368..6ebf279 100644 --- a/config/params.php +++ b/config/params.php @@ -1,5 +1,5 @@ 'admin@example.com', + 'adminEmail' => 'admin@example.com', ]; diff --git a/config/web.php b/config/web.php index 6f02f52..462c135 100644 --- a/config/web.php +++ b/config/web.php @@ -4,43 +4,43 @@ $params = require(__DIR__ . '/params.php'); $db = require(__DIR__ . '/db.php'); $config = [ - 'id' => 'basic', - 'basePath' => dirname(__DIR__), - 'extensions' => require(__DIR__ . '/../vendor/yiisoft/extensions.php'), - 'components' => [ - 'cache' => [ - 'class' => 'yii\caching\FileCache', - ], - 'user' => [ - 'identityClass' => 'app\models\User', - 'enableAutoLogin' => true, - ], - 'errorHandler' => [ - 'errorAction' => 'site/error', - ], - 'mail' => [ - 'class' => 'yii\swiftmailer\Mailer', - 'useFileTransport' => true, - ], - 'log' => [ - 'traceLevel' => YII_DEBUG ? 3 : 0, - 'targets' => [ - [ - 'class' => 'yii\log\FileTarget', - 'levels' => ['error', 'warning'], - ], - ], - ], - 'db' => $db, - ], - 'params' => $params, + 'id' => 'basic', + 'basePath' => dirname(__DIR__), + 'extensions' => require(__DIR__ . '/../vendor/yiisoft/extensions.php'), + 'components' => [ + 'cache' => [ + 'class' => 'yii\caching\FileCache', + ], + 'user' => [ + 'identityClass' => 'app\models\User', + 'enableAutoLogin' => true, + ], + 'errorHandler' => [ + 'errorAction' => 'site/error', + ], + 'mail' => [ + 'class' => 'yii\swiftmailer\Mailer', + 'useFileTransport' => true, + ], + 'log' => [ + 'traceLevel' => YII_DEBUG ? 3 : 0, + 'targets' => [ + [ + 'class' => 'yii\log\FileTarget', + 'levels' => ['error', 'warning'], + ], + ], + ], + 'db' => $db, + ], + 'params' => $params, ]; if (YII_ENV_DEV) { - // configuration adjustments for 'dev' environment - $config['preload'][] = 'debug'; - $config['modules']['debug'] = 'yii\debug\Module'; - $config['modules']['gii'] = 'yii\gii\Module'; + // configuration adjustments for 'dev' environment + $config['preload'][] = 'debug'; + $config['modules']['debug'] = 'yii\debug\Module'; + $config['modules']['gii'] = 'yii\gii\Module'; } return $config; diff --git a/controllers/SiteController.php b/controllers/SiteController.php index 0d4d2f9..ebecd28 100644 --- a/controllers/SiteController.php +++ b/controllers/SiteController.php @@ -11,84 +11,86 @@ use app\models\ContactForm; class SiteController extends Controller { - public function behaviors() - { - return [ - 'access' => [ - 'class' => AccessControl::className(), - 'only' => ['logout'], - 'rules' => [ - [ - 'actions' => ['logout'], - 'allow' => true, - 'roles' => ['@'], - ], - ], - ], - 'verbs' => [ - 'class' => VerbFilter::className(), - 'actions' => [ - 'logout' => ['post'], - ], - ], - ]; - } + public function behaviors() + { + return [ + 'access' => [ + 'class' => AccessControl::className(), + 'only' => ['logout'], + 'rules' => [ + [ + 'actions' => ['logout'], + 'allow' => true, + 'roles' => ['@'], + ], + ], + ], + 'verbs' => [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'logout' => ['post'], + ], + ], + ]; + } - public function actions() - { - return [ - 'error' => [ - 'class' => 'yii\web\ErrorAction', - ], - 'captcha' => [ - 'class' => 'yii\captcha\CaptchaAction', - 'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null, - ], - ]; - } + public function actions() + { + return [ + 'error' => [ + 'class' => 'yii\web\ErrorAction', + ], + 'captcha' => [ + 'class' => 'yii\captcha\CaptchaAction', + 'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null, + ], + ]; + } - public function actionIndex() - { - return $this->render('index'); - } + public function actionIndex() + { + return $this->render('index'); + } - public function actionLogin() - { - if (!\Yii::$app->user->isGuest) { - return $this->goHome(); - } + public function actionLogin() + { + if (!\Yii::$app->user->isGuest) { + return $this->goHome(); + } - $model = new LoginForm(); - if ($model->load(Yii::$app->request->post()) && $model->login()) { - return $this->goBack(); - } else { - return $this->render('login', [ - 'model' => $model, - ]); - } - } + $model = new LoginForm(); + if ($model->load(Yii::$app->request->post()) && $model->login()) { + return $this->goBack(); + } else { + return $this->render('login', [ + 'model' => $model, + ]); + } + } - public function actionLogout() - { - Yii::$app->user->logout(); - return $this->goHome(); - } + public function actionLogout() + { + Yii::$app->user->logout(); - public function actionContact() - { - $model = new ContactForm(); - if ($model->load(Yii::$app->request->post()) && $model->contact(Yii::$app->params['adminEmail'])) { - Yii::$app->session->setFlash('contactFormSubmitted'); - return $this->refresh(); - } else { - return $this->render('contact', [ - 'model' => $model, - ]); - } - } + return $this->goHome(); + } - public function actionAbout() - { - return $this->render('about'); - } + public function actionContact() + { + $model = new ContactForm(); + if ($model->load(Yii::$app->request->post()) && $model->contact(Yii::$app->params['adminEmail'])) { + Yii::$app->session->setFlash('contactFormSubmitted'); + + return $this->refresh(); + } else { + return $this->render('contact', [ + 'model' => $model, + ]); + } + } + + public function actionAbout() + { + return $this->render('about'); + } } diff --git a/mail/layouts/html.php b/mail/layouts/html.php index 8e2707d..a9689cc 100644 --- a/mail/layouts/html.php +++ b/mail/layouts/html.php @@ -10,14 +10,14 @@ use yii\helpers\Html;
- -The path to yii framework seems to be incorrect.
'; - echo 'You need to install Yii framework via composer or adjust the framework path in file ' . basename(__FILE__) . '.
'; - echo 'Please refer to the README on how to install Yii.
'; + echo 'The path to yii framework seems to be incorrect.
'; + echo 'You need to install Yii framework via composer or adjust the framework path in file ' . basename(__FILE__) . '.
'; + echo 'Please refer to the README on how to install Yii.
'; } require_once($frameworkPath . '/requirements/YiiRequirementChecker.php'); @@ -27,84 +27,84 @@ $requirementsChecker = new YiiRequirementChecker(); * Adjust requirements according to your application specifics. */ $requirements = array( - // Database : - array( - 'name' => 'PDO extension', - 'mandatory' => true, - 'condition' => extension_loaded('pdo'), - 'by' => 'All DB-related classes', - ), - array( - 'name' => 'PDO SQLite extension', - 'mandatory' => false, - 'condition' => extension_loaded('pdo_sqlite'), - 'by' => 'All DB-related classes', - 'memo' => 'Required for SQLite database.', - ), - array( - 'name' => 'PDO MySQL extension', - 'mandatory' => false, - 'condition' => extension_loaded('pdo_mysql'), - 'by' => 'All DB-related classes', - 'memo' => 'Required for MySQL database.', - ), - array( - 'name' => 'PDO PostgreSQL extension', - 'mandatory' => false, - 'condition' => extension_loaded('pdo_pgsql'), - 'by' => 'All DB-related classes', - 'memo' => 'Required for PostgreSQL database.', - ), - // Cache : - array( - 'name' => 'Memcache extension', - 'mandatory' => false, - 'condition' => extension_loaded('memcache') || extension_loaded('memcached'), - 'by' => 'CMemCache', - 'memo' => extension_loaded('memcached') ? 'To use memcached set CMemCache::useMemcached totrue
.' : ''
- ),
- array(
- 'name' => 'APC extension',
- 'mandatory' => false,
- 'condition' => extension_loaded('apc'),
- 'by' => 'CApcCache',
- ),
- // Additional PHP extensions :
- array(
- 'name' => 'Mcrypt extension',
- 'mandatory' => false,
- 'condition' => extension_loaded('mcrypt'),
- 'by' => 'CSecurityManager',
- 'memo' => 'Required by encrypt and decrypt methods.'
- ),
- // PHP ini :
- 'phpSafeMode' => array(
- 'name' => 'PHP safe mode',
- 'mandatory' => false,
- 'condition' => $requirementsChecker->checkPhpIniOff("safe_mode"),
- 'by' => 'File uploading and console command execution',
- 'memo' => '"safe_mode" should be disabled at php.ini',
- ),
- 'phpExposePhp' => array(
- 'name' => 'Expose PHP',
- 'mandatory' => false,
- 'condition' => $requirementsChecker->checkPhpIniOff("expose_php"),
- 'by' => 'Security reasons',
- 'memo' => '"expose_php" should be disabled at php.ini',
- ),
- 'phpAllowUrlInclude' => array(
- 'name' => 'PHP allow url include',
- 'mandatory' => false,
- 'condition' => $requirementsChecker->checkPhpIniOff("allow_url_include"),
- 'by' => 'Security reasons',
- 'memo' => '"allow_url_include" should be disabled at php.ini',
- ),
- 'phpSmtp' => array(
- 'name' => 'PHP mail SMTP',
- 'mandatory' => false,
- 'condition' => strlen(ini_get('SMTP'))>0,
- 'by' => 'Email sending',
- 'memo' => 'PHP mail SMTP server required',
- ),
+ // Database :
+ array(
+ 'name' => 'PDO extension',
+ 'mandatory' => true,
+ 'condition' => extension_loaded('pdo'),
+ 'by' => 'All DB-related classes',
+ ),
+ array(
+ 'name' => 'PDO SQLite extension',
+ 'mandatory' => false,
+ 'condition' => extension_loaded('pdo_sqlite'),
+ 'by' => 'All DB-related classes',
+ 'memo' => 'Required for SQLite database.',
+ ),
+ array(
+ 'name' => 'PDO MySQL extension',
+ 'mandatory' => false,
+ 'condition' => extension_loaded('pdo_mysql'),
+ 'by' => 'All DB-related classes',
+ 'memo' => 'Required for MySQL database.',
+ ),
+ array(
+ 'name' => 'PDO PostgreSQL extension',
+ 'mandatory' => false,
+ 'condition' => extension_loaded('pdo_pgsql'),
+ 'by' => 'All DB-related classes',
+ 'memo' => 'Required for PostgreSQL database.',
+ ),
+ // Cache :
+ array(
+ 'name' => 'Memcache extension',
+ 'mandatory' => false,
+ 'condition' => extension_loaded('memcache') || extension_loaded('memcached'),
+ 'by' => 'CMemCache',
+ 'memo' => extension_loaded('memcached') ? 'To use memcached set CMemCache::useMemcached to true
.' : ''
+ ),
+ array(
+ 'name' => 'APC extension',
+ 'mandatory' => false,
+ 'condition' => extension_loaded('apc'),
+ 'by' => 'CApcCache',
+ ),
+ // Additional PHP extensions :
+ array(
+ 'name' => 'Mcrypt extension',
+ 'mandatory' => false,
+ 'condition' => extension_loaded('mcrypt'),
+ 'by' => 'CSecurityManager',
+ 'memo' => 'Required by encrypt and decrypt methods.'
+ ),
+ // PHP ini :
+ 'phpSafeMode' => array(
+ 'name' => 'PHP safe mode',
+ 'mandatory' => false,
+ 'condition' => $requirementsChecker->checkPhpIniOff("safe_mode"),
+ 'by' => 'File uploading and console command execution',
+ 'memo' => '"safe_mode" should be disabled at php.ini',
+ ),
+ 'phpExposePhp' => array(
+ 'name' => 'Expose PHP',
+ 'mandatory' => false,
+ 'condition' => $requirementsChecker->checkPhpIniOff("expose_php"),
+ 'by' => 'Security reasons',
+ 'memo' => '"expose_php" should be disabled at php.ini',
+ ),
+ 'phpAllowUrlInclude' => array(
+ 'name' => 'PHP allow url include',
+ 'mandatory' => false,
+ 'condition' => $requirementsChecker->checkPhpIniOff("allow_url_include"),
+ 'by' => 'Security reasons',
+ 'memo' => '"allow_url_include" should be disabled at php.ini',
+ ),
+ 'phpSmtp' => array(
+ 'name' => 'PHP mail SMTP',
+ 'mandatory' => false,
+ 'condition' => strlen(ini_get('SMTP'))>0,
+ 'by' => 'Email sending',
+ 'memo' => 'PHP mail SMTP server required',
+ ),
);
$requirementsChecker->checkYii()->check($requirements)->render();
diff --git a/tests/_config.php b/tests/_config.php
index d9cc356..24ec1b5 100644
--- a/tests/_config.php
+++ b/tests/_config.php
@@ -3,12 +3,12 @@
* application configurations shared by all test types
*/
return [
- 'components' => [
- 'mail' => [
- 'useFileTransport' => true,
- ],
- 'urlManager' => [
- 'showScriptName' => true,
- ],
- ],
+ 'components' => [
+ 'mail' => [
+ 'useFileTransport' => true,
+ ],
+ 'urlManager' => [
+ 'showScriptName' => true,
+ ],
+ ],
];
diff --git a/tests/_helpers/CodeHelper.php b/tests/_helpers/CodeHelper.php
index 6448486..201503d 100644
--- a/tests/_helpers/CodeHelper.php
+++ b/tests/_helpers/CodeHelper.php
@@ -3,5 +3,5 @@ namespace Codeception\Module;
class CodeHelper extends \Codeception\Module
{
- // here you can define custom methods for CodeGuy
+ // here you can define custom methods for CodeGuy
}
diff --git a/tests/_helpers/TestHelper.php b/tests/_helpers/TestHelper.php
index 9558ff1..ae94187 100644
--- a/tests/_helpers/TestHelper.php
+++ b/tests/_helpers/TestHelper.php
@@ -3,5 +3,5 @@ namespace Codeception\Module;
class TestHelper extends \Codeception\Module
{
- // here you can define custom methods for TestGuy
+ // here you can define custom methods for TestGuy
}
diff --git a/tests/_helpers/WebHelper.php b/tests/_helpers/WebHelper.php
index b2953af..a8c7250 100644
--- a/tests/_helpers/WebHelper.php
+++ b/tests/_helpers/WebHelper.php
@@ -3,5 +3,5 @@ namespace Codeception\Module;
class WebHelper extends \Codeception\Module
{
- // here you can define custom methods for WebGuy
+ // here you can define custom methods for WebGuy
}
diff --git a/tests/_pages/AboutPage.php b/tests/_pages/AboutPage.php
index 5f9021f..77acdb8 100644
--- a/tests/_pages/AboutPage.php
+++ b/tests/_pages/AboutPage.php
@@ -6,5 +6,5 @@ use yii\codeception\BasePage;
class AboutPage extends BasePage
{
- public $route = 'site/about';
+ public $route = 'site/about';
}
diff --git a/tests/_pages/ContactPage.php b/tests/_pages/ContactPage.php
index 18015b5..24c8dfa 100644
--- a/tests/_pages/ContactPage.php
+++ b/tests/_pages/ContactPage.php
@@ -6,17 +6,17 @@ use yii\codeception\BasePage;
class ContactPage extends BasePage
{
- public $route = 'site/contact';
+ public $route = 'site/contact';
- /**
- * @param array $contactData
- */
- public function submit(array $contactData)
- {
- foreach ($contactData as $field => $value) {
- $inputType = $field === 'body' ? 'textarea' : 'input';
- $this->guy->fillField($inputType . '[name="ContactForm[' . $field . ']"]', $value);
- }
- $this->guy->click('contact-button');
- }
+ /**
+ * @param array $contactData
+ */
+ public function submit(array $contactData)
+ {
+ foreach ($contactData as $field => $value) {
+ $inputType = $field === 'body' ? 'textarea' : 'input';
+ $this->guy->fillField($inputType . '[name="ContactForm[' . $field . ']"]', $value);
+ }
+ $this->guy->click('contact-button');
+ }
}
diff --git a/tests/_pages/LoginPage.php b/tests/_pages/LoginPage.php
index 503a420..c73d729 100644
--- a/tests/_pages/LoginPage.php
+++ b/tests/_pages/LoginPage.php
@@ -6,16 +6,16 @@ use yii\codeception\BasePage;
class LoginPage extends BasePage
{
- public $route = 'site/login';
+ public $route = 'site/login';
- /**
- * @param string $username
- * @param string $password
- */
- public function login($username, $password)
- {
- $this->guy->fillField('input[name="LoginForm[username]"]', $username);
- $this->guy->fillField('input[name="LoginForm[password]"]', $password);
- $this->guy->click('login-button');
- }
+ /**
+ * @param string $username
+ * @param string $password
+ */
+ public function login($username, $password)
+ {
+ $this->guy->fillField('input[name="LoginForm[username]"]', $username);
+ $this->guy->fillField('input[name="LoginForm[password]"]', $password);
+ $this->guy->click('login-button');
+ }
}
diff --git a/tests/acceptance.suite.yml b/tests/acceptance.suite.yml
index b385284..2e35aa5 100644
--- a/tests/acceptance.suite.yml
+++ b/tests/acceptance.suite.yml
@@ -15,7 +15,7 @@ modules:
- PhpBrowser
# you can use WebDriver instead of PhpBrowser to test javascript and ajax.
# This will require you to install selenium. See http://codeception.com/docs/04-AcceptanceTests#Selenium
-# "restart" option is used by the WebDriver to start each time per test-file new session and cookies,
+# "restart" option is used by the WebDriver to start each time per test-file new session and cookies,
# it is useful if you want to login in your app in each test.
# - WebDriver
config:
diff --git a/tests/acceptance/ContactCept.php b/tests/acceptance/ContactCept.php
index 25f5735..e76ac9b 100644
--- a/tests/acceptance/ContactCept.php
+++ b/tests/acceptance/ContactCept.php
@@ -21,11 +21,11 @@ $I->see('The verification code is incorrect');
$I->amGoingTo('submit contact form with not correct email');
$contactPage->submit([
- 'name' => 'tester',
- 'email' => 'tester.email',
- 'subject' => 'test subject',
- 'body' => 'test content',
- 'verifyCode' => 'testme',
+ 'name' => 'tester',
+ 'email' => 'tester.email',
+ 'subject' => 'test subject',
+ 'body' => 'test content',
+ 'verifyCode' => 'testme',
]);
$I->expectTo('see that email adress is wrong');
$I->dontSee('Name cannot be blank', '.help-inline');
@@ -36,14 +36,14 @@ $I->dontSee('The verification code is incorrect', '.help-inline');
$I->amGoingTo('submit contact form with correct data');
$contactPage->submit([
- 'name' => 'tester',
- 'email' => 'tester@example.com',
- 'subject' => 'test subject',
- 'body' => 'test content',
- 'verifyCode' => 'testme',
+ 'name' => 'tester',
+ 'email' => 'tester@example.com',
+ 'subject' => 'test subject',
+ 'body' => 'test content',
+ 'verifyCode' => 'testme',
]);
if (method_exists($I, 'wait')) {
- $I->wait(3); // only for selenium
+ $I->wait(3); // only for selenium
}
$I->dontSeeElement('#contact-form');
$I->see('Thank you for contacting us. We will respond to you as soon as possible.');
diff --git a/tests/acceptance/LoginCept.php b/tests/acceptance/LoginCept.php
index 5d6a387..07d1c45 100644
--- a/tests/acceptance/LoginCept.php
+++ b/tests/acceptance/LoginCept.php
@@ -23,7 +23,7 @@ $I->see('Incorrect username or password.');
$I->amGoingTo('try to login with correct credentials');
$loginPage->login('admin', 'admin');
if (method_exists($I, 'wait')) {
- $I->wait(3); // only for selenium
+ $I->wait(3); // only for selenium
}
$I->expectTo('see user info');
$I->see('Logout (admin)');
diff --git a/tests/acceptance/_config.php b/tests/acceptance/_config.php
index 4c306b3..857a804 100644
--- a/tests/acceptance/_config.php
+++ b/tests/acceptance/_config.php
@@ -1,13 +1,13 @@
[
- 'db' => [
- 'dsn' => 'mysql:host=localhost;dbname=yii2_basic_acceptance',
- ],
- ],
- ]
+ require(__DIR__ . '/../../config/web.php'),
+ require(__DIR__ . '/../_config.php'),
+ [
+ 'components' => [
+ 'db' => [
+ 'dsn' => 'mysql:host=localhost;dbname=yii2_basic_acceptance',
+ ],
+ ],
+ ]
);
diff --git a/tests/acceptance/_console.php b/tests/acceptance/_console.php
index f89eecf..03cdd1f 100644
--- a/tests/acceptance/_console.php
+++ b/tests/acceptance/_console.php
@@ -1,13 +1,13 @@
[
- 'db' => [
- 'dsn' => 'mysql:host=localhost;dbname=yii2_basic_acceptance',
- ],
- ],
- ]
+ require(__DIR__ . '/../../config/console.php'),
+ require(__DIR__ . '/../_config.php'),
+ [
+ 'components' => [
+ 'db' => [
+ 'dsn' => 'mysql:host=localhost;dbname=yii2_basic_acceptance',
+ ],
+ ],
+ ]
);
diff --git a/tests/functional/ContactCept.php b/tests/functional/ContactCept.php
index 14e6197..49d7735 100644
--- a/tests/functional/ContactCept.php
+++ b/tests/functional/ContactCept.php
@@ -21,11 +21,11 @@ $I->see('The verification code is incorrect');
$I->amGoingTo('submit contact form with not correct email');
$contactPage->submit([
- 'name' => 'tester',
- 'email' => 'tester.email',
- 'subject' => 'test subject',
- 'body' => 'test content',
- 'verifyCode' => 'testme',
+ 'name' => 'tester',
+ 'email' => 'tester.email',
+ 'subject' => 'test subject',
+ 'body' => 'test content',
+ 'verifyCode' => 'testme',
]);
$I->expectTo('see that email adress is wrong');
$I->dontSee('Name cannot be blank', '.help-inline');
@@ -36,11 +36,11 @@ $I->dontSee('The verification code is incorrect', '.help-inline');
$I->amGoingTo('submit contact form with correct data');
$contactPage->submit([
- 'name' => 'tester',
- 'email' => 'tester@example.com',
- 'subject' => 'test subject',
- 'body' => 'test content',
- 'verifyCode' => 'testme',
+ 'name' => 'tester',
+ 'email' => 'tester@example.com',
+ 'subject' => 'test subject',
+ 'body' => 'test content',
+ 'verifyCode' => 'testme',
]);
$I->dontSeeElement('#contact-form');
$I->see('Thank you for contacting us. We will respond to you as soon as possible.');
diff --git a/tests/functional/_config.php b/tests/functional/_config.php
index c2ecae0..512e802 100644
--- a/tests/functional/_config.php
+++ b/tests/functional/_config.php
@@ -5,13 +5,13 @@ $_SERVER['SCRIPT_FILENAME'] = TEST_ENTRY_FILE;
$_SERVER['SCRIPT_NAME'] = TEST_ENTRY_URL;
return yii\helpers\ArrayHelper::merge(
- require(__DIR__ . '/../../config/web.php'),
- require(__DIR__ . '/../_config.php'),
- [
- 'components' => [
- 'db' => [
- 'dsn' => 'mysql:host=localhost;dbname=yii2_basic_functional',
- ],
- ],
- ]
+ require(__DIR__ . '/../../config/web.php'),
+ require(__DIR__ . '/../_config.php'),
+ [
+ 'components' => [
+ 'db' => [
+ 'dsn' => 'mysql:host=localhost;dbname=yii2_basic_functional',
+ ],
+ ],
+ ]
);
diff --git a/tests/functional/_console.php b/tests/functional/_console.php
index 2e674c4..abeee69 100644
--- a/tests/functional/_console.php
+++ b/tests/functional/_console.php
@@ -1,13 +1,13 @@
[
- 'db' => [
- 'dsn' => 'mysql:host=localhost;dbname=yii2_basic_functional',
- ],
- ],
- ]
+ require(__DIR__ . '/../../config/console.php'),
+ require(__DIR__ . '/../_config.php'),
+ [
+ 'components' => [
+ 'db' => [
+ 'dsn' => 'mysql:host=localhost;dbname=yii2_basic_functional',
+ ],
+ ],
+ ]
);
diff --git a/tests/unit/_config.php b/tests/unit/_config.php
index 45f1ef4..2559ef3 100644
--- a/tests/unit/_config.php
+++ b/tests/unit/_config.php
@@ -1,13 +1,13 @@
[
- 'db' => [
- 'dsn' => 'mysql:host=localhost;dbname=yii2_basic_unit',
- ],
- ],
- ]
+ require(__DIR__ . '/../../config/web.php'),
+ require(__DIR__ . '/../_config.php'),
+ [
+ 'components' => [
+ 'db' => [
+ 'dsn' => 'mysql:host=localhost;dbname=yii2_basic_unit',
+ ],
+ ],
+ ]
);
diff --git a/tests/unit/_console.php b/tests/unit/_console.php
index d2a233a..04272a3 100644
--- a/tests/unit/_console.php
+++ b/tests/unit/_console.php
@@ -1,13 +1,13 @@
[
- 'db' => [
- 'dsn' => 'mysql:host=localhost;dbname=yii2_basic_unit',
- ],
- ],
- ]
+ require(__DIR__ . '/../../config/console.php'),
+ require(__DIR__ . '/../_config.php'),
+ [
+ 'components' => [
+ 'db' => [
+ 'dsn' => 'mysql:host=localhost;dbname=yii2_basic_unit',
+ ],
+ ],
+ ]
);
diff --git a/tests/unit/models/ContactFormTest.php b/tests/unit/models/ContactFormTest.php
index c679717..d8a55ee 100644
--- a/tests/unit/models/ContactFormTest.php
+++ b/tests/unit/models/ContactFormTest.php
@@ -7,52 +7,52 @@ use yii\codeception\TestCase;
class ContactFormTest extends TestCase
{
- use \Codeception\Specify;
+ use \Codeception\Specify;
- protected function setUp()
- {
- parent::setUp();
- Yii::$app->mail->fileTransportCallback = function ($mailer, $message) {
- return 'testing_message.eml';
- };
- }
+ protected function setUp()
+ {
+ parent::setUp();
+ Yii::$app->mail->fileTransportCallback = function ($mailer, $message) {
+ return 'testing_message.eml';
+ };
+ }
- protected function tearDown()
- {
- unlink($this->getMessageFile());
- parent::tearDown();
- }
+ protected function tearDown()
+ {
+ unlink($this->getMessageFile());
+ parent::tearDown();
+ }
- public function testContact()
- {
- $model = $this->getMock('app\models\ContactForm', ['validate']);
- $model->expects($this->once())->method('validate')->will($this->returnValue(true));
+ public function testContact()
+ {
+ $model = $this->getMock('app\models\ContactForm', ['validate']);
+ $model->expects($this->once())->method('validate')->will($this->returnValue(true));
- $model->attributes = [
- 'name' => 'Tester',
- 'email' => 'tester@example.com',
- 'subject' => 'very important letter subject',
- 'body' => 'body of current message',
- ];
+ $model->attributes = [
+ 'name' => 'Tester',
+ 'email' => 'tester@example.com',
+ 'subject' => 'very important letter subject',
+ 'body' => 'body of current message',
+ ];
- $model->contact('admin@example.com');
+ $model->contact('admin@example.com');
- $this->specify('email should be send', function () {
- expect('email file should exist', file_exists($this->getMessageFile()))->true();
- });
+ $this->specify('email should be send', function () {
+ expect('email file should exist', file_exists($this->getMessageFile()))->true();
+ });
- $this->specify('message should contain correct data', function () use ($model) {
- $emailMessage = file_get_contents($this->getMessageFile());
+ $this->specify('message should contain correct data', function () use ($model) {
+ $emailMessage = file_get_contents($this->getMessageFile());
- expect('email should contain user name', $emailMessage)->contains($model->name);
- expect('email should contain sender email', $emailMessage)->contains($model->email);
- expect('email should contain subject', $emailMessage)->contains($model->subject);
- expect('email should contain body', $emailMessage)->contains($model->body);
- });
- }
+ expect('email should contain user name', $emailMessage)->contains($model->name);
+ expect('email should contain sender email', $emailMessage)->contains($model->email);
+ expect('email should contain subject', $emailMessage)->contains($model->subject);
+ expect('email should contain body', $emailMessage)->contains($model->body);
+ });
+ }
- private function getMessageFile()
- {
- return Yii::getAlias(Yii::$app->mail->fileTransportPath) . '/testing_message.eml';
- }
+ private function getMessageFile()
+ {
+ return Yii::getAlias(Yii::$app->mail->fileTransportPath) . '/testing_message.eml';
+ }
}
diff --git a/tests/unit/models/LoginFormTest.php b/tests/unit/models/LoginFormTest.php
index d1f6043..c2c28cc 100644
--- a/tests/unit/models/LoginFormTest.php
+++ b/tests/unit/models/LoginFormTest.php
@@ -8,59 +8,60 @@ use app\models\User;
class LoginFormTest extends TestCase
{
- use \Codeception\Specify;
+ use \Codeception\Specify;
- protected function tearDown()
- {
- Yii::$app->user->logout();
- parent::tearDown();
- }
+ protected function tearDown()
+ {
+ Yii::$app->user->logout();
+ parent::tearDown();
+ }
- public function testLoginNoUser()
- {
- $model = $this->mockUser(null);
+ public function testLoginNoUser()
+ {
+ $model = $this->mockUser(null);
- $model->username = 'some_username';
- $model->password = 'some_password';
+ $model->username = 'some_username';
+ $model->password = 'some_password';
- $this->specify('user should not be able to login, when there is no identity', function () use ($model) {
- expect('model should not login user', $model->login())->false();
- expect('user should not be logged in', Yii::$app->user->isGuest)->true();
- });
- }
+ $this->specify('user should not be able to login, when there is no identity', function () use ($model) {
+ expect('model should not login user', $model->login())->false();
+ expect('user should not be logged in', Yii::$app->user->isGuest)->true();
+ });
+ }
- public function testLoginWrongPassword()
- {
- $model = $this->mockUser(new User);
+ public function testLoginWrongPassword()
+ {
+ $model = $this->mockUser(new User);
- $model->username = 'demo';
- $model->password = 'wrong-password';
+ $model->username = 'demo';
+ $model->password = 'wrong-password';
- $this->specify('user should not be able to login with wrong password', function () use ($model) {
- expect('model should not login user', $model->login())->false();
- expect('error message should be set', $model->errors)->hasKey('password');
- expect('user should not be logged in', Yii::$app->user->isGuest)->true();
- });
- }
+ $this->specify('user should not be able to login with wrong password', function () use ($model) {
+ expect('model should not login user', $model->login())->false();
+ expect('error message should be set', $model->errors)->hasKey('password');
+ expect('user should not be logged in', Yii::$app->user->isGuest)->true();
+ });
+ }
- public function testLoginCorrect()
- {
- $model = $this->mockUser(new User(['password' => 'demo']));
+ public function testLoginCorrect()
+ {
+ $model = $this->mockUser(new User(['password' => 'demo']));
- $model->username = 'demo';
- $model->password = 'demo';
+ $model->username = 'demo';
+ $model->password = 'demo';
- $this->specify('user should be able to login with correct credentials', function () use ($model) {
- expect('model should login user', $model->login())->true();
- expect('error message should not be set', $model->errors)->hasntKey('password');
- expect('user should be logged in', Yii::$app->user->isGuest)->false();
- });
- }
+ $this->specify('user should be able to login with correct credentials', function () use ($model) {
+ expect('model should login user', $model->login())->true();
+ expect('error message should not be set', $model->errors)->hasntKey('password');
+ expect('user should be logged in', Yii::$app->user->isGuest)->false();
+ });
+ }
- private function mockUser($user)
- {
- $loginForm = $this->getMock('app\models\LoginForm', ['getUser']);
- $loginForm->expects($this->any())->method('getUser')->will($this->returnValue($user));
- return $loginForm;
- }
+ private function mockUser($user)
+ {
+ $loginForm = $this->getMock('app\models\LoginForm', ['getUser']);
+ $loginForm->expects($this->any())->method('getUser')->will($this->returnValue($user));
+
+ return $loginForm;
+ }
}
diff --git a/tests/unit/models/UserTest.php b/tests/unit/models/UserTest.php
index 109da73..8cd9215 100644
--- a/tests/unit/models/UserTest.php
+++ b/tests/unit/models/UserTest.php
@@ -6,12 +6,12 @@ use yii\codeception\TestCase;
class UserTest extends TestCase
{
- protected function setUp()
- {
- parent::setUp();
- // uncomment the following to load fixtures for table tbl_user
- //$this->loadFixtures(['tbl_user']);
- }
+ protected function setUp()
+ {
+ parent::setUp();
+ // uncomment the following to load fixtures for table tbl_user
+ //$this->loadFixtures(['tbl_user']);
+ }
- // TODO add test methods here
+ // TODO add test methods here
}
diff --git a/views/layouts/main.php b/views/layouts/main.php
index f32b53f..6af9564 100644
--- a/views/layouts/main.php
+++ b/views/layouts/main.php
@@ -15,53 +15,53 @@ AppAsset::register($this);
-
-
- - This is the About page. You may modify the following file to customize its content: -
++ This is the About page. You may modify the following file to customize its content: +
-= __FILE__ ?>
+ = __FILE__ ?>
- Note that if you turn on the Yii debugger, you should be able
- to view the mail message on the mail panel of the debugger.
- mail->useFileTransport): ?>
- Because the application is in development mode, the email is not sent but saved as
- a file under = Yii::getAlias(Yii::$app->mail->fileTransportPath) ?>
.
- Please configure the useFileTransport
property of the mail
- application component to be false to enable email sending.
-
-
+ Note that if you turn on the Yii debugger, you should be able
+ to view the mail message on the mail panel of the debugger.
+ mail->useFileTransport): ?>
+ Because the application is in development mode, the email is not sent but saved as
+ a file under = Yii::getAlias(Yii::$app->mail->fileTransportPath) ?>
.
+ Please configure the useFileTransport
property of the mail
+ application component to be false to enable email sending.
+
+
- If you have business inquiries or other questions, please fill out the following form to contact us. Thank you. -
++ If you have business inquiries or other questions, please fill out the following form to contact us. Thank you. +
-- The above error occurred while the Web server was processing your request. -
-- Please contact us if you think this is a server error. Thank you. -
++ The above error occurred while the Web server was processing your request. +
++ Please contact us if you think this is a server error. Thank you. +
You have successfully created your Yii-powered application.
+You have successfully created your Yii-powered application.
- -Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et - dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip - ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu - fugiat nulla pariatur.
+Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et + dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip + ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu + fugiat nulla pariatur.
- -Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et - dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip - ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu - fugiat nulla pariatur.
+Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et + dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip + ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu + fugiat nulla pariatur.
- -Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et - dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip - ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu - fugiat nulla pariatur.
+Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et + dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip + ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu + fugiat nulla pariatur.
- -Please fill out the following fields to login:
+Please fill out the following fields to login:
- 'login-form', - 'options' => ['class' => 'form-horizontal'], - 'fieldConfig' => [ - 'template' => "{label}\napp\models\User::$users
.
- app\models\User::$users
.
+