From e9148837ee0676a8daeec77690db153b6569f914 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Sat, 1 Mar 2014 23:14:16 -0500 Subject: [PATCH 001/390] rest api WIP --- models/User.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/models/User.php b/models/User.php index b890e6934..8d008a88f 100644 --- a/models/User.php +++ b/models/User.php @@ -8,6 +8,7 @@ class User extends \yii\base\Object implements \yii\web\IdentityInterface public $username; public $password; public $authKey; + public $apiKey; private static $users = [ '100' => [ @@ -15,12 +16,14 @@ class User extends \yii\base\Object implements \yii\web\IdentityInterface 'username' => 'admin', 'password' => 'admin', 'authKey' => 'test100key', + 'apiKey' => '100-apikey', ], '101' => [ 'id' => '101', 'username' => 'demo', 'password' => 'demo', 'authKey' => 'test101key', + 'apiKey' => '101-apikey', ], ]; @@ -32,6 +35,19 @@ public static function findIdentity($id) return isset(self::$users[$id]) ? new static(self::$users[$id]) : null; } + /** + * @inheritdoc + */ + public static function findIdentityByToken($token) + { + foreach (self::$users as $user) { + if ($user['apiKey'] === $token) { + return new static($user); + } + } + return null; + } + /** * Finds user by username * From b61e6d214a6699f6ab982cb56967a884e2cd0422 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Mon, 3 Mar 2014 10:18:39 -0500 Subject: [PATCH 002/390] Support for other auth types. --- models/User.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/models/User.php b/models/User.php index 8d008a88f..7a6fcc004 100644 --- a/models/User.php +++ b/models/User.php @@ -8,7 +8,7 @@ class User extends \yii\base\Object implements \yii\web\IdentityInterface public $username; public $password; public $authKey; - public $apiKey; + public $accessToken; private static $users = [ '100' => [ @@ -16,14 +16,14 @@ class User extends \yii\base\Object implements \yii\web\IdentityInterface 'username' => 'admin', 'password' => 'admin', 'authKey' => 'test100key', - 'apiKey' => '100-apikey', + 'accessToken' => '100-token', ], '101' => [ 'id' => '101', 'username' => 'demo', 'password' => 'demo', 'authKey' => 'test101key', - 'apiKey' => '101-apikey', + 'accessToken' => '101-token', ], ]; @@ -38,10 +38,10 @@ public static function findIdentity($id) /** * @inheritdoc */ - public static function findIdentityByToken($token) + public static function findIdentityByAccessToken($token) { foreach (self::$users as $user) { - if ($user['apiKey'] === $token) { + if ($user['accessToken'] === $token) { return new static($user); } } From d78c7a7d21e159e2c251ebea1a63c0566328215b Mon Sep 17 00:00:00 2001 From: Alexander Mohorev Date: Mon, 3 Mar 2014 20:50:44 +0300 Subject: [PATCH 003/390] @param, @var, @property and @return must declare types as boolean, integer, string, array or null --- models/User.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/User.php b/models/User.php index b890e6934..1ecbc6814 100644 --- a/models/User.php +++ b/models/User.php @@ -76,7 +76,7 @@ public function validateAuthKey($authKey) * Validates password * * @param string $password password to validate - * @return bool if password provided is valid for current user + * @return boolean if password provided is valid for current user */ public function validatePassword($password) { From 3ffc02730248d6e12e9d9fdd11b4b4d19a403c90 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Tue, 4 Mar 2014 22:17:11 +0400 Subject: [PATCH 004/390] Used ternary operator instead of "or" for constant definition --- tests/_bootstrap.php | 8 ++++---- tests/_console_bootstrap.php | 8 ++++---- web/index-test.php | 4 ++-- web/index.php | 4 ++-- yii | 6 +++--- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/_bootstrap.php b/tests/_bootstrap.php index 4890b3ed7..7db3cfdb9 100644 --- a/tests/_bootstrap.php +++ b/tests/_bootstrap.php @@ -2,14 +2,14 @@ // the entry script URL (without host info) for functional and acceptance tests // PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL -defined('TEST_ENTRY_URL') or define('TEST_ENTRY_URL', '/basic/web/index-test.php'); +defined('TEST_ENTRY_URL') ?: define('TEST_ENTRY_URL', '/basic/web/index-test.php'); // the entry script file path for functional and acceptance tests -defined('TEST_ENTRY_FILE') or define('TEST_ENTRY_FILE', dirname(__DIR__) . '/web/index-test.php'); +defined('TEST_ENTRY_FILE') ?: define('TEST_ENTRY_FILE', dirname(__DIR__) . '/web/index-test.php'); -defined('YII_DEBUG') or define('YII_DEBUG', true); +defined('YII_DEBUG') ?: define('YII_DEBUG', true); -defined('YII_ENV') or define('YII_ENV', 'test'); +defined('YII_ENV') ?: define('YII_ENV', 'test'); require_once(__DIR__ . '/../vendor/autoload.php'); diff --git a/tests/_console_bootstrap.php b/tests/_console_bootstrap.php index 81287f3d8..1eb06446b 100644 --- a/tests/_console_bootstrap.php +++ b/tests/_console_bootstrap.php @@ -1,12 +1,12 @@ Date: Tue, 4 Mar 2014 22:40:04 +0400 Subject: [PATCH 005/390] Removed unused "use" statements --- mail/layouts/html.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mail/layouts/html.php b/mail/layouts/html.php index 2e6b615f5..8e2707dc5 100644 --- a/mail/layouts/html.php +++ b/mail/layouts/html.php @@ -1,10 +1,9 @@ beginPage() ?> From d8763496cc9ae67e8a4e74393f539d65bba3a9d0 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Thu, 6 Mar 2014 01:56:51 +0400 Subject: [PATCH 006/390] Revert "Used ternary operator instead of "or" for constant definition" This reverts commit 2bb6f13505e212d68841a7e6609806fb30d04002. --- tests/_bootstrap.php | 8 ++++---- tests/_console_bootstrap.php | 8 ++++---- web/index-test.php | 4 ++-- web/index.php | 4 ++-- yii | 6 +++--- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/_bootstrap.php b/tests/_bootstrap.php index 7db3cfdb9..4890b3ed7 100644 --- a/tests/_bootstrap.php +++ b/tests/_bootstrap.php @@ -2,14 +2,14 @@ // the entry script URL (without host info) for functional and acceptance tests // PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL -defined('TEST_ENTRY_URL') ?: define('TEST_ENTRY_URL', '/basic/web/index-test.php'); +defined('TEST_ENTRY_URL') or define('TEST_ENTRY_URL', '/basic/web/index-test.php'); // the entry script file path for functional and acceptance tests -defined('TEST_ENTRY_FILE') ?: define('TEST_ENTRY_FILE', dirname(__DIR__) . '/web/index-test.php'); +defined('TEST_ENTRY_FILE') or define('TEST_ENTRY_FILE', dirname(__DIR__) . '/web/index-test.php'); -defined('YII_DEBUG') ?: define('YII_DEBUG', true); +defined('YII_DEBUG') or define('YII_DEBUG', true); -defined('YII_ENV') ?: define('YII_ENV', 'test'); +defined('YII_ENV') or define('YII_ENV', 'test'); require_once(__DIR__ . '/../vendor/autoload.php'); diff --git a/tests/_console_bootstrap.php b/tests/_console_bootstrap.php index 1eb06446b..81287f3d8 100644 --- a/tests/_console_bootstrap.php +++ b/tests/_console_bootstrap.php @@ -1,12 +1,12 @@ Date: Fri, 7 Mar 2014 10:35:15 -0500 Subject: [PATCH 007/390] Fixes #2629: `Module::controllerPath` is now read only, and all controller classes must be namespaced under `Module::controllerNamespace` --- config/console.php | 1 - 1 file changed, 1 deletion(-) diff --git a/config/console.php b/config/console.php index 3dd5d42fc..1f58e421e 100644 --- a/config/console.php +++ b/config/console.php @@ -9,7 +9,6 @@ 'id' => 'basic-console', 'basePath' => dirname(__DIR__), 'preload' => ['log'], - 'controllerPath' => dirname(__DIR__) . '/commands', 'controllerNamespace' => 'app\commands', 'extensions' => require(__DIR__ . '/../vendor/yiisoft/extensions.php'), 'components' => [ From a85ef65abaafb8ffa3d0942228e0396681ebeb25 Mon Sep 17 00:00:00 2001 From: Luciano Baraglia Date: Sat, 8 Mar 2014 20:47:04 -0300 Subject: [PATCH 008/390] Code style fixes --- views/site/contact.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/site/contact.php b/views/site/contact.php index c375161fe..bcaf542a7 100644 --- a/views/site/contact.php +++ b/views/site/contact.php @@ -25,7 +25,7 @@ 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 mail->fileTransportPath); ?>. + a file under mail->fileTransportPath) ?>. Please configure the useFileTransport property of the mail application component to be false to enable email sending. From 93cc82c4bf42cea403e1acaab201338bea304b6e Mon Sep 17 00:00:00 2001 From: SonicGD Date: Sun, 16 Mar 2014 10:46:16 +0600 Subject: [PATCH 009/390] Reformat code te be PSR-2 compatible --- assets/AppAsset.php | 22 ++-- commands/HelloController.php | 16 +-- config/console.php | 40 +++--- config/db.php | 10 +- config/params.php | 2 +- config/web.php | 68 +++++----- controllers/SiteController.php | 148 +++++++++++----------- mail/layouts/html.php | 14 +-- models/ContactForm.php | 95 +++++++------- models/LoginForm.php | 111 ++++++++-------- models/User.php | 174 +++++++++++++------------- requirements.php | 166 ++++++++++++------------ tests/_config.php | 16 +-- tests/_helpers/CodeHelper.php | 2 +- tests/_helpers/TestHelper.php | 2 +- tests/_helpers/WebHelper.php | 2 +- tests/_pages/AboutPage.php | 2 +- tests/_pages/ContactPage.php | 24 ++-- tests/_pages/LoginPage.php | 22 ++-- tests/acceptance.suite.yml | 2 +- tests/acceptance/ContactCept.php | 22 ++-- tests/acceptance/LoginCept.php | 2 +- tests/acceptance/_config.php | 18 +-- tests/acceptance/_console.php | 18 +-- tests/functional/ContactCept.php | 20 +-- tests/functional/_config.php | 18 +-- tests/functional/_console.php | 18 +-- tests/unit/_config.php | 18 +-- tests/unit/_console.php | 18 +-- tests/unit/models/ContactFormTest.php | 96 +++++++------- tests/unit/models/LoginFormTest.php | 89 ++++++------- tests/unit/models/UserTest.php | 14 +-- views/layouts/main.php | 82 ++++++------ views/site/about.php | 10 +- views/site/contact.php | 86 ++++++------- views/site/error.php | 20 +-- views/site/index.php | 66 +++++----- views/site/login.php | 50 ++++---- web/index-test.php | 2 +- 39 files changed, 806 insertions(+), 799 deletions(-) diff --git a/assets/AppAsset.php b/assets/AppAsset.php index c964d36a6..0e495a8f8 100644 --- a/assets/AppAsset.php +++ b/assets/AppAsset.php @@ -15,15 +15,15 @@ */ 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 ce567ddaf..86ab8b853 100644 --- a/commands/HelloController.php +++ b/commands/HelloController.php @@ -19,12 +19,12 @@ */ 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 1f58e421e..f25485856 100644 --- a/config/console.php +++ b/config/console.php @@ -6,24 +6,24 @@ $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 b14e77ea3..c4c12529c 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 93cb368d9..6ebf2792b 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 6f02f52c7..462c135a8 100644 --- a/config/web.php +++ b/config/web.php @@ -4,43 +4,43 @@ $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 0d4d2f985..ebecd28e6 100644 --- a/controllers/SiteController.php +++ b/controllers/SiteController.php @@ -11,84 +11,86 @@ 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 8e2707dc5..a9689cc2e 100644 --- a/mail/layouts/html.php +++ b/mail/layouts/html.php @@ -10,14 +10,14 @@ - - <?= Html::encode($this->title) ?> - head() ?> + + <?= Html::encode($this->title) ?> + head() ?> - beginBody() ?> - - endBody() ?> + beginBody() ?> + + endBody() ?> -endPage() ?> \ No newline at end of file +endPage() ?> diff --git a/models/ContactForm.php b/models/ContactForm.php index 13445627e..29a5dd996 100644 --- a/models/ContactForm.php +++ b/models/ContactForm.php @@ -10,54 +10,55 @@ */ class ContactForm extends Model { - public $name; - public $email; - public $subject; - public $body; - public $verifyCode; + public $name; + public $email; + public $subject; + public $body; + public $verifyCode; - /** - * @return array the validation rules. - */ - public function rules() - { - return [ - // name, email, subject and body are required - [['name', 'email', 'subject', 'body'], 'required'], - // email has to be a valid email address - ['email', 'email'], - // verifyCode needs to be entered correctly - ['verifyCode', 'captcha'], - ]; - } + /** + * @return array the validation rules. + */ + public function rules() + { + return [ + // name, email, subject and body are required + [['name', 'email', 'subject', 'body'], 'required'], + // email has to be a valid email address + ['email', 'email'], + // verifyCode needs to be entered correctly + ['verifyCode', 'captcha'], + ]; + } - /** - * @return array customized attribute labels - */ - public function attributeLabels() - { - return [ - 'verifyCode' => 'Verification Code', - ]; - } + /** + * @return array customized attribute labels + */ + public function attributeLabels() + { + return [ + 'verifyCode' => 'Verification Code', + ]; + } - /** - * Sends an email to the specified email address using the information collected by this model. - * @param string $email the target email address - * @return boolean whether the model passes validation - */ - public function contact($email) - { - if ($this->validate()) { - Yii::$app->mail->compose() - ->setTo($email) - ->setFrom([$this->email => $this->name]) - ->setSubject($this->subject) - ->setTextBody($this->body) - ->send(); - return true; - } else { - return false; - } - } + /** + * Sends an email to the specified email address using the information collected by this model. + * @param string $email the target email address + * @return boolean whether the model passes validation + */ + public function contact($email) + { + if ($this->validate()) { + Yii::$app->mail->compose() + ->setTo($email) + ->setFrom([$this->email => $this->name]) + ->setSubject($this->subject) + ->setTextBody($this->body) + ->send(); + + return true; + } else { + return false; + } + } } diff --git a/models/LoginForm.php b/models/LoginForm.php index 76cf1de52..31b814e24 100644 --- a/models/LoginForm.php +++ b/models/LoginForm.php @@ -10,65 +10,66 @@ */ class LoginForm extends Model { - public $username; - public $password; - public $rememberMe = true; + public $username; + public $password; + public $rememberMe = true; - private $_user = false; + private $_user = false; - /** - * @return array the validation rules. - */ - public function rules() - { - return [ - // username and password are both required - [['username', 'password'], 'required'], - // rememberMe must be a boolean value - ['rememberMe', 'boolean'], - // password is validated by validatePassword() - ['password', 'validatePassword'], - ]; - } + /** + * @return array the validation rules. + */ + public function rules() + { + return [ + // username and password are both required + [['username', 'password'], 'required'], + // rememberMe must be a boolean value + ['rememberMe', 'boolean'], + // password is validated by validatePassword() + ['password', 'validatePassword'], + ]; + } - /** - * Validates the password. - * This method serves as the inline validation for password. - */ - public function validatePassword() - { - if (!$this->hasErrors()) { - $user = $this->getUser(); + /** + * Validates the password. + * This method serves as the inline validation for password. + */ + public function validatePassword() + { + if (!$this->hasErrors()) { + $user = $this->getUser(); - if (!$user || !$user->validatePassword($this->password)) { - $this->addError('password', 'Incorrect username or password.'); - } - } - } + if (!$user || !$user->validatePassword($this->password)) { + $this->addError('password', 'Incorrect username or password.'); + } + } + } - /** - * Logs in a user using the provided username and password. - * @return boolean whether the user is logged in successfully - */ - public function login() - { - if ($this->validate()) { - return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600*24*30 : 0); - } else { - return false; - } - } + /** + * Logs in a user using the provided username and password. + * @return boolean whether the user is logged in successfully + */ + public function login() + { + if ($this->validate()) { + return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600*24*30 : 0); + } else { + return false; + } + } - /** - * Finds user by [[username]] - * - * @return User|null - */ - public function getUser() - { - if ($this->_user === false) { - $this->_user = User::findByUsername($this->username); - } - return $this->_user; - } + /** + * Finds user by [[username]] + * + * @return User|null + */ + public function getUser() + { + if ($this->_user === false) { + $this->_user = User::findByUsername($this->username); + } + + return $this->_user; + } } diff --git a/models/User.php b/models/User.php index fd0d0d434..5de7e20c2 100644 --- a/models/User.php +++ b/models/User.php @@ -4,98 +4,100 @@ class User extends \yii\base\Object implements \yii\web\IdentityInterface { - public $id; - public $username; - public $password; - public $authKey; - public $accessToken; + public $id; + public $username; + public $password; + public $authKey; + public $accessToken; - private static $users = [ - '100' => [ - 'id' => '100', - 'username' => 'admin', - 'password' => 'admin', - 'authKey' => 'test100key', - 'accessToken' => '100-token', - ], - '101' => [ - 'id' => '101', - 'username' => 'demo', - 'password' => 'demo', - 'authKey' => 'test101key', - 'accessToken' => '101-token', - ], - ]; + private static $users = [ + '100' => [ + 'id' => '100', + 'username' => 'admin', + 'password' => 'admin', + 'authKey' => 'test100key', + 'accessToken' => '100-token', + ], + '101' => [ + 'id' => '101', + 'username' => 'demo', + 'password' => 'demo', + 'authKey' => 'test101key', + 'accessToken' => '101-token', + ], + ]; - /** - * @inheritdoc - */ - public static function findIdentity($id) - { - return isset(self::$users[$id]) ? new static(self::$users[$id]) : null; - } + /** + * @inheritdoc + */ + public static function findIdentity($id) + { + return isset(self::$users[$id]) ? new static(self::$users[$id]) : null; + } - /** - * @inheritdoc - */ - public static function findIdentityByAccessToken($token) - { - foreach (self::$users as $user) { - if ($user['accessToken'] === $token) { - return new static($user); - } - } - return null; - } + /** + * @inheritdoc + */ + public static function findIdentityByAccessToken($token) + { + foreach (self::$users as $user) { + if ($user['accessToken'] === $token) { + return new static($user); + } + } - /** - * Finds user by username - * - * @param string $username - * @return static|null - */ - public static function findByUsername($username) - { - foreach (self::$users as $user) { - if (strcasecmp($user['username'], $username) === 0) { - return new static($user); - } - } - return null; - } + return null; + } - /** - * @inheritdoc - */ - public function getId() - { - return $this->id; - } + /** + * Finds user by username + * + * @param string $username + * @return static|null + */ + public static function findByUsername($username) + { + foreach (self::$users as $user) { + if (strcasecmp($user['username'], $username) === 0) { + return new static($user); + } + } - /** - * @inheritdoc - */ - public function getAuthKey() - { - return $this->authKey; - } + return null; + } - /** - * @inheritdoc - */ - public function validateAuthKey($authKey) - { - return $this->authKey === $authKey; - } + /** + * @inheritdoc + */ + public function getId() + { + return $this->id; + } - /** - * Validates password - * - * @param string $password password to validate - * @return boolean if password provided is valid for current user - */ - public function validatePassword($password) - { - return $this->password === $password; - } + /** + * @inheritdoc + */ + public function getAuthKey() + { + return $this->authKey; + } + + /** + * @inheritdoc + */ + public function validateAuthKey($authKey) + { + return $this->authKey === $authKey; + } + + /** + * Validates password + * + * @param string $password password to validate + * @return boolean if password provided is valid for current user + */ + public function validatePassword($password) + { + return $this->password === $password; + } } diff --git a/requirements.php b/requirements.php index d470f99d7..b96e4d69d 100644 --- a/requirements.php +++ b/requirements.php @@ -14,10 +14,10 @@ $frameworkPath = dirname(__FILE__) . '/vendor/yiisoft/yii2'; if (!is_dir($frameworkPath)) { - echo '

Error

'; - 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.

'; + echo '

Error

'; + 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 @@ * 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 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', - ), + // 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 d9cc356dd..24ec1b56a 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 64484868d..201503ddf 100644 --- a/tests/_helpers/CodeHelper.php +++ b/tests/_helpers/CodeHelper.php @@ -3,5 +3,5 @@ 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 9558ff151..ae9418775 100644 --- a/tests/_helpers/TestHelper.php +++ b/tests/_helpers/TestHelper.php @@ -3,5 +3,5 @@ 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 b2953af3a..a8c72502a 100644 --- a/tests/_helpers/WebHelper.php +++ b/tests/_helpers/WebHelper.php @@ -3,5 +3,5 @@ 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 5f9021f4e..77acdb815 100644 --- a/tests/_pages/AboutPage.php +++ b/tests/_pages/AboutPage.php @@ -6,5 +6,5 @@ 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 18015b57c..24c8dfa56 100644 --- a/tests/_pages/ContactPage.php +++ b/tests/_pages/ContactPage.php @@ -6,17 +6,17 @@ 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 503a4205f..c73d729af 100644 --- a/tests/_pages/LoginPage.php +++ b/tests/_pages/LoginPage.php @@ -6,16 +6,16 @@ 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 b3852841d..2e35aa558 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 25f5735e4..e76ac9beb 100644 --- a/tests/acceptance/ContactCept.php +++ b/tests/acceptance/ContactCept.php @@ -21,11 +21,11 @@ $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->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 5d6a3878e..07d1c452e 100644 --- a/tests/acceptance/LoginCept.php +++ b/tests/acceptance/LoginCept.php @@ -23,7 +23,7 @@ $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 4c306b3bb..857a804f4 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 f89eecfc2..03cdd1ff6 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 14e61973e..49d7735fd 100644 --- a/tests/functional/ContactCept.php +++ b/tests/functional/ContactCept.php @@ -21,11 +21,11 @@ $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->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 c2ecae0ea..512e802bb 100644 --- a/tests/functional/_config.php +++ b/tests/functional/_config.php @@ -5,13 +5,13 @@ $_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 2e674c4f9..abeee696c 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 45f1ef42f..2559ef31e 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 d2a233ab3..04272a321 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 c6797178e..d8a55ee83 100644 --- a/tests/unit/models/ContactFormTest.php +++ b/tests/unit/models/ContactFormTest.php @@ -7,52 +7,52 @@ class ContactFormTest extends TestCase { - use \Codeception\Specify; - - protected function setUp() - { - parent::setUp(); - Yii::$app->mail->fileTransportCallback = function ($mailer, $message) { - return 'testing_message.eml'; - }; - } - - 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)); - - $model->attributes = [ - 'name' => 'Tester', - 'email' => 'tester@example.com', - 'subject' => 'very important letter subject', - 'body' => 'body of current message', - ]; - - $model->contact('admin@example.com'); - - $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()); - - 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'; - } + use \Codeception\Specify; + + protected function setUp() + { + parent::setUp(); + Yii::$app->mail->fileTransportCallback = function ($mailer, $message) { + return 'testing_message.eml'; + }; + } + + 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)); + + $model->attributes = [ + 'name' => 'Tester', + 'email' => 'tester@example.com', + 'subject' => 'very important letter subject', + 'body' => 'body of current message', + ]; + + $model->contact('admin@example.com'); + + $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()); + + 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'; + } } diff --git a/tests/unit/models/LoginFormTest.php b/tests/unit/models/LoginFormTest.php index d1f6043fa..c2c28cc51 100644 --- a/tests/unit/models/LoginFormTest.php +++ b/tests/unit/models/LoginFormTest.php @@ -8,59 +8,60 @@ 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 109da730d..8cd921533 100644 --- a/tests/unit/models/UserTest.php +++ b/tests/unit/models/UserTest.php @@ -6,12 +6,12 @@ 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 f32b53fe8..6af9564ab 100644 --- a/views/layouts/main.php +++ b/views/layouts/main.php @@ -15,53 +15,53 @@ - - - <?= Html::encode($this->title) ?> - head() ?> + + + <?= Html::encode($this->title) ?> + head() ?> beginBody() ?> -
- 'My Company', - 'brandUrl' => Yii::$app->homeUrl, - 'options' => [ - 'class' => 'navbar-inverse navbar-fixed-top', - ], - ]); - echo Nav::widget([ - 'options' => ['class' => 'navbar-nav navbar-right'], - 'items' => [ - ['label' => 'Home', 'url' => ['/site/index']], - ['label' => 'About', 'url' => ['/site/about']], - ['label' => 'Contact', 'url' => ['/site/contact']], - Yii::$app->user->isGuest ? - ['label' => 'Login', 'url' => ['/site/login']] : - ['label' => 'Logout (' . Yii::$app->user->identity->username . ')', - 'url' => ['/site/logout'], - 'linkOptions' => ['data-method' => 'post']], - ], - ]); - NavBar::end(); - ?> +
+ 'My Company', + 'brandUrl' => Yii::$app->homeUrl, + 'options' => [ + 'class' => 'navbar-inverse navbar-fixed-top', + ], + ]); + echo Nav::widget([ + 'options' => ['class' => 'navbar-nav navbar-right'], + 'items' => [ + ['label' => 'Home', 'url' => ['/site/index']], + ['label' => 'About', 'url' => ['/site/about']], + ['label' => 'Contact', 'url' => ['/site/contact']], + Yii::$app->user->isGuest ? + ['label' => 'Login', 'url' => ['/site/login']] : + ['label' => 'Logout (' . Yii::$app->user->identity->username . ')', + 'url' => ['/site/logout'], + 'linkOptions' => ['data-method' => 'post']], + ], + ]); + NavBar::end(); + ?> -
- isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [], - ]) ?> - -
-
+
+ isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [], + ]) ?> + +
+
-
-
-

© My Company

-

-
-
+
+
+

© My Company

+

+
+
endBody() ?> diff --git a/views/site/about.php b/views/site/about.php index 0608dd2ec..58969ab7a 100644 --- a/views/site/about.php +++ b/views/site/about.php @@ -8,11 +8,11 @@ $this->params['breadcrumbs'][] = $this->title; ?>
-

title) ?>

+

title) ?>

-

- 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: +

- +
diff --git a/views/site/contact.php b/views/site/contact.php index bcaf542a7..6d70462eb 100644 --- a/views/site/contact.php +++ b/views/site/contact.php @@ -12,47 +12,47 @@ $this->params['breadcrumbs'][] = $this->title; ?>
-

title) ?>

- - session->hasFlash('contactFormSubmitted')): ?> - -
- Thank you for contacting us. We will respond to you as soon as possible. -
- -

- 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 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. -

- -
-
- 'contact-form']); ?> - field($model, 'name') ?> - field($model, 'email') ?> - field($model, 'subject') ?> - field($model, 'body')->textArea(['rows' => 6]) ?> - field($model, 'verifyCode')->widget(Captcha::className(), [ - 'template' => '
{image}
{input}
', - ]) ?> -
- 'btn btn-primary', 'name' => 'contact-button']) ?> -
- -
-
- - +

title) ?>

+ + session->hasFlash('contactFormSubmitted')): ?> + +
+ Thank you for contacting us. We will respond to you as soon as possible. +
+ +

+ 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 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. +

+ +
+
+ 'contact-form']); ?> + field($model, 'name') ?> + field($model, 'email') ?> + field($model, 'subject') ?> + field($model, 'body')->textArea(['rows' => 6]) ?> + field($model, 'verifyCode')->widget(Captcha::className(), [ + 'template' => '
{image}
{input}
', + ]) ?> +
+ 'btn btn-primary', 'name' => 'contact-button']) ?> +
+ +
+
+ +
diff --git a/views/site/error.php b/views/site/error.php index 1b7ce0422..c172fd621 100644 --- a/views/site/error.php +++ b/views/site/error.php @@ -13,17 +13,17 @@ ?>
-

title) ?>

+

title) ?>

-
- -
+
+ +
-

- 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. +

diff --git a/views/site/index.php b/views/site/index.php index bcb22781a..6b6394e56 100644 --- a/views/site/index.php +++ b/views/site/index.php @@ -6,48 +6,48 @@ ?>
-
-

Congratulations!

+
+

Congratulations!

-

You have successfully created your Yii-powered application.

+

You have successfully created your Yii-powered application.

-

Get started with Yii

-
+

Get started with Yii

+
-
+
-
-
-

Heading

+
+
+

Heading

-

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.

-

Yii Documentation »

-
-
-

Heading

+

Yii Documentation »

+
+
+

Heading

-

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.

-

Yii Forum »

-
-
-

Heading

+

Yii Forum »

+
+
+

Heading

-

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.

-

Yii Extensions »

-
-
+

Yii Extensions »

+
+
-
+
diff --git a/views/site/login.php b/views/site/login.php index 7d14c54dd..80cc5485e 100644 --- a/views/site/login.php +++ b/views/site/login.php @@ -11,37 +11,37 @@ $this->params['breadcrumbs'][] = $this->title; ?> diff --git a/web/index-test.php b/web/index-test.php index b5ed6956f..326608d21 100644 --- a/web/index-test.php +++ b/web/index-test.php @@ -2,7 +2,7 @@ // NOTE: Make sure this file is not accessible when deployed to production if (!in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1'])) { - die('You are not allowed to access this file.'); + die('You are not allowed to access this file.'); } defined('YII_DEBUG') or define('YII_DEBUG', true); From d4b6fc017135819e14607d0ed896a51d941c1613 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Tue, 25 Mar 2014 08:37:48 -0400 Subject: [PATCH 010/390] more gitignores. --- .gitignore | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..45bf7bf41 --- /dev/null +++ b/.gitignore @@ -0,0 +1,27 @@ +# phpstorm project files +.idea + +# netbeans project files +nbproject + +# zend studio for eclipse project files +.buildpath +.project +.settings + +# windows thumbnail cache +Thumbs.db + +# composer vendor dir +/vendor + +# composer itself is not needed +composer.phar + +# Mac DS_Store Files +.DS_Store + +# phpunit itself is not needed +phpunit.phar +# local phpunit config +/phpunit.xml From 1b8ef667f7260c6eefac2c5849554b4ab9a06ed9 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Sun, 30 Mar 2014 19:33:46 +0400 Subject: [PATCH 011/390] Fixes #2911: Removed `tbl_` default for table prefix --- tests/unit/models/UserTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/models/UserTest.php b/tests/unit/models/UserTest.php index 8cd921533..19ab30da0 100644 --- a/tests/unit/models/UserTest.php +++ b/tests/unit/models/UserTest.php @@ -9,8 +9,8 @@ class UserTest extends TestCase protected function setUp() { parent::setUp(); - // uncomment the following to load fixtures for table tbl_user - //$this->loadFixtures(['tbl_user']); + // uncomment the following to load fixtures for user table + //$this->loadFixtures(['user']); } // TODO add test methods here From 923744d33358f5e125a1c21eb111093b97218496 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Wed, 2 Apr 2014 00:43:23 +0400 Subject: [PATCH 012/390] #2936: New favicon for applications --- web/favicon.ico | Bin 1150 -> 318 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/web/favicon.ico b/web/favicon.ico index 49e61e33ca94362545346cb218c62dc7807e9c66..580ed732e86556ec57f3f3395a210246d679c076 100644 GIT binary patch literal 318 zcmZQzU<5(|0RbS%!l1#(z#zuJz@P!d0zj+)#2|4HXaJKC0wf0lAEr2iX{M9K3=BR0 y!E90pK{x=K$Oz&POT#sS8N$ZKhC)h8ip0_|-T#43{vnSYgXBQCu@O54$pHYIza?e> literal 1150 zcma)6XH1hp7(Rmu{|GtU+!^sFa8rsCv}Jk%uOI+4N{Oj%&Pr>HDfEM$SlXWB1Hz(U z=q`_hetCNkh4Fv)y`0bdjM_j#e<+ev-v&l=4iw2c-UG{xrn23ZP6ZdY2&U;sgmB!MCG& zPViGpf_QK&ieQ-2k5Nuv5z%G|~6pzA1+W5r4)V$G60fX<= z_5nON#o*SQ2hNQdkSS&*ggllP?sgTy0Y3?thD*ULrXP+a5|6ZDaLgIev<}Qz&tpo@ zi(NG3){+k{P1)eYN(Vc}b4V4|ys-2Xb?vn8f;|^RU>vyM5#0~onF@Z_(5$icj Date: Fri, 4 Apr 2014 12:16:17 +0200 Subject: [PATCH 013/390] Add wait() to login test with wrong credentials to fix WebDriver test --- tests/acceptance/LoginCept.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/acceptance/LoginCept.php b/tests/acceptance/LoginCept.php index 07d1c452e..c7c9ae306 100644 --- a/tests/acceptance/LoginCept.php +++ b/tests/acceptance/LoginCept.php @@ -17,6 +17,9 @@ $I->amGoingTo('try to login with wrong credentials'); $loginPage->login('admin', 'wrong'); +if (method_exists($I, 'wait')) { + $I->wait(3); // only for selenium +} $I->expectTo('see validations errors'); $I->see('Incorrect username or password.'); From 4f00e23565f3b5b33afa84ebb890cd5f615df81b Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Sat, 5 Apr 2014 01:00:14 -0400 Subject: [PATCH 014/390] Moved all filter classes to namespace `yii\filters` --- controllers/SiteController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/controllers/SiteController.php b/controllers/SiteController.php index ebecd28e6..f95994160 100644 --- a/controllers/SiteController.php +++ b/controllers/SiteController.php @@ -3,9 +3,9 @@ namespace app\controllers; use Yii; -use yii\web\AccessControl; +use yii\filters\AccessControl; use yii\web\Controller; -use yii\web\VerbFilter; +use yii\filters\VerbFilter; use app\models\LoginForm; use app\models\ContactForm; From 52eea89f09e2a7d770c32588d8ee13620af04b5e Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Wed, 9 Apr 2014 10:47:10 -0400 Subject: [PATCH 015/390] Removed `Application::preload` in favor of `Application::bootstrap` --- config/console.php | 1 - config/web.php | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/config/console.php b/config/console.php index f25485856..88c43c526 100644 --- a/config/console.php +++ b/config/console.php @@ -8,7 +8,6 @@ return [ 'id' => 'basic-console', 'basePath' => dirname(__DIR__), - 'preload' => ['log'], 'controllerNamespace' => 'app\commands', 'extensions' => require(__DIR__ . '/../vendor/yiisoft/extensions.php'), 'components' => [ diff --git a/config/web.php b/config/web.php index 462c135a8..845a521c4 100644 --- a/config/web.php +++ b/config/web.php @@ -38,7 +38,7 @@ if (YII_ENV_DEV) { // configuration adjustments for 'dev' environment - $config['preload'][] = 'debug'; + $config['bootstrap'][] = 'debug'; $config['modules']['debug'] = 'yii\debug\Module'; $config['modules']['gii'] = 'yii\gii\Module'; } From 7c55b9a8cca1b685338c5bafc840b0630a5001cb Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Thu, 10 Apr 2014 00:05:05 -0400 Subject: [PATCH 016/390] updated error handler and requirement checker links. --- requirements.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/requirements.php b/requirements.php index b96e4d69d..db53ef4e4 100644 --- a/requirements.php +++ b/requirements.php @@ -32,27 +32,27 @@ 'name' => 'PDO extension', 'mandatory' => true, 'condition' => extension_loaded('pdo'), - 'by' => 'All DB-related classes', + 'by' => 'All DB-related classes', ), array( 'name' => 'PDO SQLite extension', 'mandatory' => false, 'condition' => extension_loaded('pdo_sqlite'), - 'by' => 'All DB-related classes', + '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', + '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', + 'by' => 'All DB-related classes', 'memo' => 'Required for PostgreSQL database.', ), // Cache : @@ -60,21 +60,21 @@ '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.' : '' + 'by' => 'MemCache', + 'memo' => extension_loaded('memcached') ? 'To use memcached set MemCache::useMemcached to true.' : '' ), array( 'name' => 'APC extension', 'mandatory' => false, 'condition' => extension_loaded('apc'), - 'by' => 'CApcCache', + 'by' => 'ApcCache', ), // Additional PHP extensions : array( 'name' => 'Mcrypt extension', 'mandatory' => false, 'condition' => extension_loaded('mcrypt'), - 'by' => 'CSecurityManager', + 'by' => 'Security Helper', 'memo' => 'Required by encrypt and decrypt methods.' ), // PHP ini : From abcc78cd8f8b4f8fd5b84c1a78b94242c57be415 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Thu, 10 Apr 2014 15:05:01 -0400 Subject: [PATCH 017/390] Refactored app bootstrap logic. --- config/console.php | 1 + config/web.php | 1 + 2 files changed, 2 insertions(+) diff --git a/config/console.php b/config/console.php index 88c43c526..462f35bd6 100644 --- a/config/console.php +++ b/config/console.php @@ -8,6 +8,7 @@ return [ 'id' => 'basic-console', 'basePath' => dirname(__DIR__), + 'bootstrap' => ['log'], 'controllerNamespace' => 'app\commands', 'extensions' => require(__DIR__ . '/../vendor/yiisoft/extensions.php'), 'components' => [ diff --git a/config/web.php b/config/web.php index 845a521c4..fb9c6791c 100644 --- a/config/web.php +++ b/config/web.php @@ -6,6 +6,7 @@ $config = [ 'id' => 'basic', 'basePath' => dirname(__DIR__), + 'bootstrap' => ['log'], 'extensions' => require(__DIR__ . '/../vendor/yiisoft/extensions.php'), 'components' => [ 'cache' => [ From c1472697e2422e8d123d3831e4a2fa8dafe370e9 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Sun, 13 Apr 2014 17:58:59 -0400 Subject: [PATCH 018/390] prepare for 2.0.0-beta release. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 726a7ea93..e879e6b3e 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "irc": "irc://irc.freenode.net/yii", "source": "https://github.com/yiisoft/yii2" }, - "minimum-stability": "dev", + "minimum-stability": "beta", "require": { "php": ">=5.4.0", "yiisoft/yii2": "*", From fedb41fcc340dacbbd98a6c7976f1c08293cf0cf Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Sun, 13 Apr 2014 21:22:29 -0400 Subject: [PATCH 019/390] prepare for next release. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e879e6b3e..726a7ea93 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "irc": "irc://irc.freenode.net/yii", "source": "https://github.com/yiisoft/yii2" }, - "minimum-stability": "beta", + "minimum-stability": "dev", "require": { "php": ">=5.4.0", "yiisoft/yii2": "*", From cbedf7ad960a9a17c40219f821ec857231692f46 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Thu, 17 Apr 2014 20:42:50 -0400 Subject: [PATCH 020/390] Fixes #3088: The debug and gii modules will manage their own URL rules now --- config/web.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/web.php b/config/web.php index fb9c6791c..524fd31b9 100644 --- a/config/web.php +++ b/config/web.php @@ -41,6 +41,8 @@ // configuration adjustments for 'dev' environment $config['bootstrap'][] = 'debug'; $config['modules']['debug'] = 'yii\debug\Module'; + + $config['bootstrap'][] = 'gii'; $config['modules']['gii'] = 'yii\gii\Module'; } From c964a753d8aee813d617ec06f1990dd55e20cfd3 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Tue, 6 May 2014 18:45:18 -0400 Subject: [PATCH 021/390] Fixes #3383: Added `$type` parameter to `IdentityInterface::findIdentityByAccessToken()` --- models/User.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/User.php b/models/User.php index 5de7e20c2..cbfb9fefc 100644 --- a/models/User.php +++ b/models/User.php @@ -38,7 +38,7 @@ public static function findIdentity($id) /** * @inheritdoc */ - public static function findIdentityByAccessToken($token) + public static function findIdentityByAccessToken($token, $type = null) { foreach (self::$users as $user) { if ($user['accessToken'] === $token) { From 914a6f76fea9233f25c1951b350fe844cd1bd177 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Sat, 10 May 2014 14:07:34 -0400 Subject: [PATCH 022/390] finished quick start about database [skip ci] --- config/web.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/config/web.php b/config/web.php index 524fd31b9..fbb7934e8 100644 --- a/config/web.php +++ b/config/web.php @@ -1,7 +1,6 @@ 'basic', @@ -32,7 +31,7 @@ ], ], ], - 'db' => $db, + 'db' => require(__DIR__ . '/db.php'), ], 'params' => $params, ]; From fff7565b0569301fd37418e649c8cb8a877677b5 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Fri, 23 May 2014 16:51:38 +0200 Subject: [PATCH 023/390] Tabs to spaces to be consistent ``` vendor/bin/indent --spaces -r framework/ vendor/bin/indent --tabs -r . --pattern=*.json vendor/bin/indent --spaces -r . --pattern=*.md vendor/bin/indent --spaces -r . --pattern=yii.*.js vendor/bin/indent --spaces -r . --pattern=*.css ``` --- README.md | 10 +++---- web/css/site.css | 74 ++++++++++++++++++++++++------------------------ 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index d025b5e07..452d030c2 100644 --- a/README.md +++ b/README.md @@ -75,11 +75,11 @@ Edit the file `config/db.php` with real data, for example: ```php return [ - 'class' => 'yii\db\Connection', - 'dsn' => 'mysql:host=localhost;dbname=yii2basic', - 'username' => 'root', - 'password' => '1234', - 'charset' => 'utf8', + 'class' => 'yii\db\Connection', + 'dsn' => 'mysql:host=localhost;dbname=yii2basic', + 'username' => 'root', + 'password' => '1234', + 'charset' => 'utf8', ]; ``` diff --git a/web/css/site.css b/web/css/site.css index 068d5fd40..698be709c 100644 --- a/web/css/site.css +++ b/web/css/site.css @@ -1,13 +1,13 @@ html, body { - height: 100%; + height: 100%; } .wrap { - min-height: 100%; - height: auto; - margin: 0 auto -60px; - padding: 0 0 60px; + min-height: 100%; + height: auto; + margin: 0 auto -60px; + padding: 0 0 60px; } .wrap > .container { @@ -15,61 +15,61 @@ body { } .footer { - height: 60px; - background-color: #f5f5f5; - border-top: 1px solid #ddd; - padding-top: 20px; + height: 60px; + background-color: #f5f5f5; + border-top: 1px solid #ddd; + padding-top: 20px; } .jumbotron { - text-align: center; - background-color: transparent; + text-align: center; + background-color: transparent; } .jumbotron .btn { - font-size: 21px; - padding: 14px 24px; + font-size: 21px; + padding: 14px 24px; } .not-set { - color: #c55; - font-style: italic; + color: #c55; + font-style: italic; } /* add sorting icons to gridview sort links */ a.asc:after, a.desc:after { - position: relative; - top: 1px; - display: inline-block; - font-family: 'Glyphicons Halflings'; - font-style: normal; - font-weight: normal; - line-height: 1; - padding-left: 5px; + position: relative; + top: 1px; + display: inline-block; + font-family: 'Glyphicons Halflings'; + font-style: normal; + font-weight: normal; + line-height: 1; + padding-left: 5px; } a.asc:after { - content: /*"\e113"*/ "\e151"; + content: /*"\e113"*/ "\e151"; } a.desc:after { - content: /*"\e114"*/ "\e152"; + content: /*"\e114"*/ "\e152"; } .sort-numerical a.asc:after { - content: "\e153"; + content: "\e153"; } .sort-numerical a.desc:after { - content: "\e154"; + content: "\e154"; } .sort-ordinal a.asc:after { - content: "\e155"; + content: "\e155"; } .sort-ordinal a.desc:after { - content: "\e156"; + content: "\e156"; } .grid-view th { @@ -77,15 +77,15 @@ a.desc:after { } .hint-block { - display: block; - margin-top: 5px; - color: #999; + display: block; + margin-top: 5px; + color: #999; } .error-summary { - color: #a94442; - background: #fdf7f7; - border-left: 3px solid #eed3d7; - padding: 10px 20px; - margin: 0 0 15px 0; + color: #a94442; + background: #fdf7f7; + border-left: 3px solid #eed3d7; + padding: 10px 20px; + margin: 0 0 15px 0; } From b946b9906dc0bb56c8939bcc1ebe651cfbdae00c Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Sat, 24 May 2014 18:11:59 +0400 Subject: [PATCH 024/390] Fixes #3542: Removed requirement to specify `extensions` in application config --- config/console.php | 1 - config/web.php | 1 - 2 files changed, 2 deletions(-) diff --git a/config/console.php b/config/console.php index 462f35bd6..85297b3cb 100644 --- a/config/console.php +++ b/config/console.php @@ -10,7 +10,6 @@ 'basePath' => dirname(__DIR__), 'bootstrap' => ['log'], 'controllerNamespace' => 'app\commands', - 'extensions' => require(__DIR__ . '/../vendor/yiisoft/extensions.php'), 'components' => [ 'cache' => [ 'class' => 'yii\caching\FileCache', diff --git a/config/web.php b/config/web.php index fbb7934e8..f9013d8fb 100644 --- a/config/web.php +++ b/config/web.php @@ -6,7 +6,6 @@ 'id' => 'basic', 'basePath' => dirname(__DIR__), 'bootstrap' => ['log'], - 'extensions' => require(__DIR__ . '/../vendor/yiisoft/extensions.php'), 'components' => [ 'cache' => [ 'class' => 'yii\caching\FileCache', From e6888d16d0513e5ef8ebb6ed1b55234a4b699fcd Mon Sep 17 00:00:00 2001 From: Klimov Paul Date: Thu, 29 May 2014 17:11:45 +0300 Subject: [PATCH 025/390] Mail layout charset specification fixed --- mail/layouts/html.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mail/layouts/html.php b/mail/layouts/html.php index a9689cc2e..b7235d1e8 100644 --- a/mail/layouts/html.php +++ b/mail/layouts/html.php @@ -3,14 +3,15 @@ /** * @var \yii\web\View $this - * @var \yii\mail\BaseMessage $content + * @var \yii\mail\MessageInterface $message + * @var string $content */ ?> beginPage() ?> - + <?= Html::encode($this->title) ?> head() ?> From 91454779c27b969c6bea48abc9f2abd4e57682ea Mon Sep 17 00:00:00 2001 From: Klimov Paul Date: Thu, 29 May 2014 17:41:10 +0300 Subject: [PATCH 026/390] Missing $message var reference removed from mail layouts --- mail/layouts/html.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mail/layouts/html.php b/mail/layouts/html.php index b7235d1e8..8c217132d 100644 --- a/mail/layouts/html.php +++ b/mail/layouts/html.php @@ -3,7 +3,6 @@ /** * @var \yii\web\View $this - * @var \yii\mail\MessageInterface $message * @var string $content */ ?> @@ -11,7 +10,7 @@ - + <?= Html::encode($this->title) ?> head() ?> From 2dedb6aa2c913dfb4f1b9aacf9600699c1b087ad Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Wed, 4 Jun 2014 17:43:09 +0200 Subject: [PATCH 027/390] added explicit comment about file transport to mail config fixes #3694 --- config/web.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/web.php b/config/web.php index f9013d8fb..7fee63a65 100644 --- a/config/web.php +++ b/config/web.php @@ -19,6 +19,9 @@ ], 'mail' => [ 'class' => 'yii\swiftmailer\Mailer', + // send all mails to a file by default. You have to set + // 'useFileTransport' to false and configure a transport + // for the mailer to send real emails. 'useFileTransport' => true, ], 'log' => [ From 7a467ed501812dd6a07d6af3b8279809dd94d8d6 Mon Sep 17 00:00:00 2001 From: Mark Date: Mon, 9 Jun 2014 16:10:16 +0400 Subject: [PATCH 028/390] basic application template tests adjusted --- tests/unit/models/ContactFormTest.php | 4 ++- tests/unit/models/LoginFormTest.php | 36 +++++++++++---------------- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/tests/unit/models/ContactFormTest.php b/tests/unit/models/ContactFormTest.php index d8a55ee83..fe214fab4 100644 --- a/tests/unit/models/ContactFormTest.php +++ b/tests/unit/models/ContactFormTest.php @@ -4,10 +4,11 @@ use Yii; use yii\codeception\TestCase; +use Codeception\Specify; class ContactFormTest extends TestCase { - use \Codeception\Specify; + use Specify; protected function setUp() { @@ -55,4 +56,5 @@ 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 c2c28cc51..f2c60f584 100644 --- a/tests/unit/models/LoginFormTest.php +++ b/tests/unit/models/LoginFormTest.php @@ -4,11 +4,12 @@ use Yii; use yii\codeception\TestCase; -use app\models\User; +use app\models\LoginForm; +use Codeception\Specify; class LoginFormTest extends TestCase { - use \Codeception\Specify; + use Specify; protected function tearDown() { @@ -18,10 +19,10 @@ protected function tearDown() public function testLoginNoUser() { - $model = $this->mockUser(null); - - $model->username = 'some_username'; - $model->password = 'some_password'; + $model = new LoginForm([ + 'username' => 'not_existing_username', + 'password' => 'not_existing_password', + ]); $this->specify('user should not be able to login, when there is no identity', function () use ($model) { expect('model should not login user', $model->login())->false(); @@ -31,10 +32,10 @@ public function testLoginNoUser() public function testLoginWrongPassword() { - $model = $this->mockUser(new User); - - $model->username = 'demo'; - $model->password = 'wrong-password'; + $model = new LoginForm([ + 'username' => 'demo', + '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(); @@ -45,10 +46,10 @@ public function testLoginWrongPassword() public function testLoginCorrect() { - $model = $this->mockUser(new User(['password' => 'demo'])); - - $model->username = 'demo'; - $model->password = 'demo'; + $model = new LoginForm([ + 'username' => 'demo', + 'password' => 'demo', + ]); $this->specify('user should be able to login with correct credentials', function () use ($model) { expect('model should login user', $model->login())->true(); @@ -57,11 +58,4 @@ public function testLoginCorrect() }); } - private function mockUser($user) - { - $loginForm = $this->getMock('app\models\LoginForm', ['getUser']); - $loginForm->expects($this->any())->method('getUser')->will($this->returnValue($user)); - - return $loginForm; - } } From 66a9e874ca55a2a503ba19a29583820392d948c4 Mon Sep 17 00:00:00 2001 From: Mark Date: Mon, 9 Jun 2014 16:33:36 +0400 Subject: [PATCH 029/390] basic application template fixtures added --- tests/unit/fixtures/data/.gitkeep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/unit/fixtures/data/.gitkeep diff --git a/tests/unit/fixtures/data/.gitkeep b/tests/unit/fixtures/data/.gitkeep new file mode 100644 index 000000000..e69de29bb From 27998d9e1b9119ba04bf2a932626f8e9ce4957da Mon Sep 17 00:00:00 2001 From: Alexander Kochetov Date: Tue, 10 Jun 2014 02:19:11 +0400 Subject: [PATCH 030/390] Fix .gitignore for `basic` and `advanced` application templates --- .gitignore | 3 --- 1 file changed, 3 deletions(-) diff --git a/.gitignore b/.gitignore index 45bf7bf41..9b1fe01ac 100644 --- a/.gitignore +++ b/.gitignore @@ -12,9 +12,6 @@ nbproject # windows thumbnail cache Thumbs.db -# composer vendor dir -/vendor - # composer itself is not needed composer.phar From 01429aba178b2d9c8c4f59a2869a67da631ba452 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Fri, 13 Jun 2014 10:04:48 -0400 Subject: [PATCH 031/390] Fixes #3358: Removed automatic CSRF meta tag generation by `View`. Added `Html::csrfMetaTags()` and its call to main layout files --- views/layouts/main.php | 1 + 1 file changed, 1 insertion(+) diff --git a/views/layouts/main.php b/views/layouts/main.php index 6af9564ab..53a9354ff 100644 --- a/views/layouts/main.php +++ b/views/layouts/main.php @@ -17,6 +17,7 @@ + <?= Html::encode($this->title) ?> head() ?> From be792fd146b7c4440aeb176a1c921e67205f0b1f Mon Sep 17 00:00:00 2001 From: Alexander Kochetov Date: Mon, 16 Jun 2014 18:57:09 +0400 Subject: [PATCH 032/390] Application templates refactoring --- .gitignore | 3 +++ vendor/.gitignore | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) delete mode 100644 vendor/.gitignore diff --git a/.gitignore b/.gitignore index 9b1fe01ac..45bf7bf41 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,9 @@ nbproject # windows thumbnail cache Thumbs.db +# composer vendor dir +/vendor + # composer itself is not needed composer.phar diff --git a/vendor/.gitignore b/vendor/.gitignore deleted file mode 100644 index c96a04f00..000000000 --- a/vendor/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore \ No newline at end of file From 2193366f3f21ed7f1af115ba08e4cc574863638c Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Fri, 20 Jun 2014 16:11:45 +0400 Subject: [PATCH 033/390] Fixes #3793: Changed inline autocomplete hints style to get more IDEs support --- mail/layouts/html.php | 7 +++---- views/layouts/main.php | 7 +++---- views/site/about.php | 4 +--- views/site/contact.php | 9 ++++----- views/site/error.php | 10 ++++------ views/site/index.php | 4 +--- views/site/login.php | 9 ++++----- 7 files changed, 20 insertions(+), 30 deletions(-) diff --git a/mail/layouts/html.php b/mail/layouts/html.php index 8c217132d..6c083957d 100644 --- a/mail/layouts/html.php +++ b/mail/layouts/html.php @@ -1,10 +1,9 @@ beginPage() ?> diff --git a/views/layouts/main.php b/views/layouts/main.php index 53a9354ff..b9dcfb97a 100644 --- a/views/layouts/main.php +++ b/views/layouts/main.php @@ -5,10 +5,9 @@ use yii\widgets\Breadcrumbs; use app\assets\AppAsset; -/** - * @var \yii\web\View $this - * @var string $content - */ +/* @var $this \yii\web\View */ +/* @var $content string */ + AppAsset::register($this); ?> beginPage() ?> diff --git a/views/site/about.php b/views/site/about.php index 58969ab7a..13d85a618 100644 --- a/views/site/about.php +++ b/views/site/about.php @@ -1,9 +1,7 @@ title = 'About'; $this->params['breadcrumbs'][] = $this->title; ?> diff --git a/views/site/contact.php b/views/site/contact.php index 6d70462eb..eeb6f5138 100644 --- a/views/site/contact.php +++ b/views/site/contact.php @@ -3,11 +3,10 @@ use yii\widgets\ActiveForm; use yii\captcha\Captcha; -/** - * @var yii\web\View $this - * @var yii\widgets\ActiveForm $form - * @var app\models\ContactForm $model - */ +/* @var $this yii\web\View */ +/* @var $form yii\widgets\ActiveForm */ +/* @var $model app\models\ContactForm */ + $this->title = 'Contact'; $this->params['breadcrumbs'][] = $this->title; ?> diff --git a/views/site/error.php b/views/site/error.php index c172fd621..b9812c488 100644 --- a/views/site/error.php +++ b/views/site/error.php @@ -2,12 +2,10 @@ use yii\helpers\Html; -/** - * @var yii\web\View $this - * @var string $name - * @var string $message - * @var Exception $exception - */ +/* @var $this yii\web\View */ +/* @var $name string */ +/* @var $message string */ +/* @var $exception Exception */ $this->title = $name; ?> diff --git a/views/site/index.php b/views/site/index.php index 6b6394e56..a00ee4da6 100644 --- a/views/site/index.php +++ b/views/site/index.php @@ -1,7 +1,5 @@ title = 'My Yii Application'; ?>
diff --git a/views/site/login.php b/views/site/login.php index 80cc5485e..df0c812aa 100644 --- a/views/site/login.php +++ b/views/site/login.php @@ -2,11 +2,10 @@ use yii\helpers\Html; use yii\widgets\ActiveForm; -/** - * @var yii\web\View $this - * @var yii\widgets\ActiveForm $form - * @var app\models\LoginForm $model - */ +/* @var $this yii\web\View */ +/* @var $form yii\widgets\ActiveForm */ +/* @var $model app\models\LoginForm */ + $this->title = 'Login'; $this->params['breadcrumbs'][] = $this->title; ?> From 91f05a2891982b82ef10859b667232cb1fd34b4d Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Thu, 26 Jun 2014 18:28:28 +0400 Subject: [PATCH 034/390] Fixes #4071: `mail` component renamed to `mailer`, `yii\log\EmailTarget::$mail` renamed to `yii\log\EmailTarget::$mailer` --- config/web.php | 2 +- models/ContactForm.php | 2 +- tests/unit/models/ContactFormTest.php | 4 ++-- views/site/contact.php | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/config/web.php b/config/web.php index 7fee63a65..7939bb322 100644 --- a/config/web.php +++ b/config/web.php @@ -17,7 +17,7 @@ 'errorHandler' => [ 'errorAction' => 'site/error', ], - 'mail' => [ + 'mailer' => [ 'class' => 'yii\swiftmailer\Mailer', // send all mails to a file by default. You have to set // 'useFileTransport' to false and configure a transport diff --git a/models/ContactForm.php b/models/ContactForm.php index 29a5dd996..d4052ee93 100644 --- a/models/ContactForm.php +++ b/models/ContactForm.php @@ -49,7 +49,7 @@ public function attributeLabels() public function contact($email) { if ($this->validate()) { - Yii::$app->mail->compose() + Yii::$app->mailer->compose() ->setTo($email) ->setFrom([$this->email => $this->name]) ->setSubject($this->subject) diff --git a/tests/unit/models/ContactFormTest.php b/tests/unit/models/ContactFormTest.php index fe214fab4..6e69cecd3 100644 --- a/tests/unit/models/ContactFormTest.php +++ b/tests/unit/models/ContactFormTest.php @@ -13,7 +13,7 @@ class ContactFormTest extends TestCase protected function setUp() { parent::setUp(); - Yii::$app->mail->fileTransportCallback = function ($mailer, $message) { + Yii::$app->mailer->fileTransportCallback = function ($mailer, $message) { return 'testing_message.eml'; }; } @@ -54,7 +54,7 @@ public function testContact() private function getMessageFile() { - return Yii::getAlias(Yii::$app->mail->fileTransportPath) . '/testing_message.eml'; + return Yii::getAlias(Yii::$app->mailer->fileTransportPath) . '/testing_message.eml'; } } diff --git a/views/site/contact.php b/views/site/contact.php index eeb6f5138..fad2d7ced 100644 --- a/views/site/contact.php +++ b/views/site/contact.php @@ -22,9 +22,9 @@

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): ?> + mailer->useFileTransport): ?> Because the application is in development mode, the email is not sent but saved as - a file under mail->fileTransportPath) ?>. + a file under mailer->fileTransportPath) ?>. Please configure the useFileTransport property of the mail application component to be false to enable email sending. From aa6c41046e8f71a7551bed0b64f657561819080b Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Thu, 26 Jun 2014 18:28:57 +0400 Subject: [PATCH 035/390] Missing files for #4071 --- tests/_config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/_config.php b/tests/_config.php index 24ec1b56a..8629dd0d9 100644 --- a/tests/_config.php +++ b/tests/_config.php @@ -4,7 +4,7 @@ */ return [ 'components' => [ - 'mail' => [ + 'mailer' => [ 'useFileTransport' => true, ], 'urlManager' => [ From 1c14872c4a123ccb9dc376e6feb03cee7b5215ef Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Sun, 29 Jun 2014 15:26:09 +0200 Subject: [PATCH 036/390] made mcrypt a framework requirement --- requirements.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/requirements.php b/requirements.php index db53ef4e4..a38b9363f 100644 --- a/requirements.php +++ b/requirements.php @@ -69,14 +69,6 @@ 'condition' => extension_loaded('apc'), 'by' => 'ApcCache', ), - // Additional PHP extensions : - array( - 'name' => 'Mcrypt extension', - 'mandatory' => false, - 'condition' => extension_loaded('mcrypt'), - 'by' => 'Security Helper', - 'memo' => 'Required by encrypt and decrypt methods.' - ), // PHP ini : 'phpSafeMode' => array( 'name' => 'PHP safe mode', From d9385653f5214b3d010160a4cf02d61c60ef34cb Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Tue, 1 Jul 2014 14:45:44 -0400 Subject: [PATCH 037/390] Fixes #3992 Fixes #4147 --- mail/layouts/html.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mail/layouts/html.php b/mail/layouts/html.php index 6c083957d..c2fb7a640 100644 --- a/mail/layouts/html.php +++ b/mail/layouts/html.php @@ -1,9 +1,9 @@ beginPage() ?> From 0c8c520cbb19b2e97537705bed8aab64533497e2 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Wed, 2 Jul 2014 14:44:31 +0300 Subject: [PATCH 038/390] Switched to Codeception 2.0.* for application template tests --- composer.json | 2 +- tests/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 726a7ea93..d9d0b11d3 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "yiisoft/yii2-gii": "*" }, "suggest": { - "codeception/codeception": "Codeception, 1.8.*@dev is currently works well with Yii.", + "codeception/codeception": "Codeception, 2.0.* is currently works well with Yii.", "codeception/specify": "BDD style code blocks for PHPUnit and Codeception", "codeception/verify": "BDD Assertions for PHPUnit and Codeception" }, diff --git a/tests/README.md b/tests/README.md index a745bf6bc..e1aed9a6e 100644 --- a/tests/README.md +++ b/tests/README.md @@ -6,7 +6,7 @@ After creating the basic application, follow these steps to prepare for the test 1. Install additional composer packages: ``` - php composer.phar require --dev "codeception/codeception: 1.8.*@dev" "codeception/specify: *" "codeception/verify: *" + php composer.phar require --dev "codeception/codeception: 2.0.*" "codeception/specify: *" "codeception/verify: *" ``` 2. In the file `_bootstrap.php`, modify the definition of the constant `TEST_ENTRY_URL` so that it points to the correct entry script URL. From d24f93b717ca0a977904e8d270b713e62758d5fd Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Wed, 2 Jul 2014 17:08:18 +0200 Subject: [PATCH 039/390] typo --- mail/layouts/html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mail/layouts/html.php b/mail/layouts/html.php index c2fb7a640..bddbc6129 100644 --- a/mail/layouts/html.php +++ b/mail/layouts/html.php @@ -2,7 +2,7 @@ use yii\helpers\Html; /* @var $this \yii\web\View view component instance */ -/* @var $message \yii\mail\MessageInterface the message bing composed */ +/* @var $message \yii\mail\MessageInterface the message being composed */ /* @var $content string main view render result */ ?> beginPage() ?> From 8e1d70c4d4a9f93d214ceb3411615f267765661e Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Fri, 11 Jul 2014 01:11:50 +0400 Subject: [PATCH 040/390] Fixes #4252, Fixes #3171 Fixed Codeception --- tests/_helpers/CodeHelper.php | 5 ++++- tests/_helpers/TestHelper.php | 5 ++++- tests/_helpers/WebHelper.php | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/_helpers/CodeHelper.php b/tests/_helpers/CodeHelper.php index 201503ddf..8ed57692d 100644 --- a/tests/_helpers/CodeHelper.php +++ b/tests/_helpers/CodeHelper.php @@ -3,5 +3,8 @@ class CodeHelper extends \Codeception\Module { - // here you can define custom methods for CodeGuy + public function _beforeSuite($settings = []) + { + include __DIR__.'/../unit/_bootstrap.php'; + } } diff --git a/tests/_helpers/TestHelper.php b/tests/_helpers/TestHelper.php index ae9418775..65f807666 100644 --- a/tests/_helpers/TestHelper.php +++ b/tests/_helpers/TestHelper.php @@ -3,5 +3,8 @@ class TestHelper extends \Codeception\Module { - // here you can define custom methods for TestGuy + public function _beforeSuite($settings = []) + { + include __DIR__.'/../functional/_bootstrap.php'; + } } diff --git a/tests/_helpers/WebHelper.php b/tests/_helpers/WebHelper.php index a8c72502a..c332c4ac4 100644 --- a/tests/_helpers/WebHelper.php +++ b/tests/_helpers/WebHelper.php @@ -3,5 +3,8 @@ class WebHelper extends \Codeception\Module { - // here you can define custom methods for WebGuy + public function _beforeSuite($settings = []) + { + include __DIR__.'/../acceptance/_bootstrap.php'; + } } From 539a6f0c5965bc92bcf8af23c33d0e86e85f4857 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Fri, 11 Jul 2014 19:24:33 +0400 Subject: [PATCH 041/390] Codeceoption adjustments - Removed hacks since these are no longer required: https://github.com/Codeception/Codeception/commit/71db233985531f298264dc4ca0160d2aa1c83b7f - Removed unused helper classes - Added 2.0 style "actor" to config Thanks to @Ragazzo and @DavertMik for helping with it. --- codeception.yml | 1 + tests/_helpers/CodeHelper.php | 10 ---------- tests/_helpers/TestHelper.php | 10 ---------- tests/_helpers/WebHelper.php | 10 ---------- tests/acceptance.suite.yml | 1 - tests/functional.suite.yml | 1 - tests/unit.suite.yml | 3 --- 7 files changed, 1 insertion(+), 35 deletions(-) delete mode 100644 tests/_helpers/CodeHelper.php delete mode 100644 tests/_helpers/TestHelper.php delete mode 100644 tests/_helpers/WebHelper.php diff --git a/codeception.yml b/codeception.yml index 864fba0bf..496ebd9c3 100644 --- a/codeception.yml +++ b/codeception.yml @@ -1,3 +1,4 @@ +actor: Tester paths: tests: tests log: tests/_log diff --git a/tests/_helpers/CodeHelper.php b/tests/_helpers/CodeHelper.php deleted file mode 100644 index 8ed57692d..000000000 --- a/tests/_helpers/CodeHelper.php +++ /dev/null @@ -1,10 +0,0 @@ - Date: Sat, 19 Jul 2014 14:56:31 -0400 Subject: [PATCH 042/390] `yii\web\Request::cookieValidationKey` is now automatically generated by the installation script for the basic and advanced application templates --- composer.json | 98 ++++++++++++++++++++++++++------------------------ config/web.php | 4 +++ 2 files changed, 55 insertions(+), 47 deletions(-) diff --git a/composer.json b/composer.json index d9d0b11d3..a21128bf3 100644 --- a/composer.json +++ b/composer.json @@ -1,49 +1,53 @@ { - "name": "yiisoft/yii2-app-basic", - "description": "Yii 2 Basic Application Template", - "keywords": ["yii2", "framework", "basic", "application template"], - "homepage": "http://www.yiiframework.com/", - "type": "project", - "license": "BSD-3-Clause", - "support": { - "issues": "https://github.com/yiisoft/yii2/issues?state=open", - "forum": "http://www.yiiframework.com/forum/", - "wiki": "http://www.yiiframework.com/wiki/", - "irc": "irc://irc.freenode.net/yii", - "source": "https://github.com/yiisoft/yii2" - }, - "minimum-stability": "dev", - "require": { - "php": ">=5.4.0", - "yiisoft/yii2": "*", - "yiisoft/yii2-bootstrap": "*", - "yiisoft/yii2-swiftmailer": "*" - }, - "require-dev": { - "yiisoft/yii2-codeception": "*", - "yiisoft/yii2-debug": "*", - "yiisoft/yii2-gii": "*" - }, - "suggest": { - "codeception/codeception": "Codeception, 2.0.* is currently works well with Yii.", - "codeception/specify": "BDD style code blocks for PHPUnit and Codeception", - "codeception/verify": "BDD Assertions for PHPUnit and Codeception" - }, - "scripts": { - "post-create-project-cmd": [ - "yii\\composer\\Installer::setPermission" - ] - }, - "config": { - "process-timeout": 1800 - }, - "extra": { - "writable": [ - "runtime", - "web/assets" - ], - "executable": [ - "yii" - ] - } + "name": "yiisoft/yii2-app-basic", + "description": "Yii 2 Basic Application Template", + "keywords": ["yii2", "framework", "basic", "application template"], + "homepage": "http://www.yiiframework.com/", + "type": "project", + "license": "BSD-3-Clause", + "support": { + "issues": "https://github.com/yiisoft/yii2/issues?state=open", + "forum": "http://www.yiiframework.com/forum/", + "wiki": "http://www.yiiframework.com/wiki/", + "irc": "irc://irc.freenode.net/yii", + "source": "https://github.com/yiisoft/yii2" + }, + "minimum-stability": "dev", + "require": { + "php": ">=5.4.0", + "yiisoft/yii2": "*", + "yiisoft/yii2-bootstrap": "*", + "yiisoft/yii2-swiftmailer": "*" + }, + "require-dev": { + "yiisoft/yii2-codeception": "*", + "yiisoft/yii2-debug": "*", + "yiisoft/yii2-gii": "*" + }, + "suggest": { + "codeception/codeception": "Codeception, 2.0.* is currently works well with Yii.", + "codeception/specify": "BDD style code blocks for PHPUnit and Codeception", + "codeception/verify": "BDD Assertions for PHPUnit and Codeception" + }, + "scripts": { + "post-create-project-cmd": [ + "yii\\composer\\Installer::setPermission", + "yii\\composer\\Installer::generateCookieValidationKey" + ] + }, + "config": { + "process-timeout": 1800 + }, + "extra": { + "writable": [ + "runtime", + "web/assets" + ], + "executable": [ + "yii" + ], + "config": [ + "config/web.php" + ] + } } diff --git a/config/web.php b/config/web.php index 7939bb322..793943716 100644 --- a/config/web.php +++ b/config/web.php @@ -7,6 +7,10 @@ 'basePath' => dirname(__DIR__), 'bootstrap' => ['log'], 'components' => [ + 'request' => [ + // a secret key used to validate cookies. You may modify this key with your own one. + 'cookieValidationKey' => '', + ], 'cache' => [ 'class' => 'yii\caching\FileCache', ], From 48d2ced997f25aa7e3e9654c41c3bd4b53c81991 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Sat, 19 Jul 2014 15:39:03 -0400 Subject: [PATCH 043/390] Request::cookieValidationKey must be explicitly specified now. --- config/web.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/web.php b/config/web.php index 793943716..1632a5aab 100644 --- a/config/web.php +++ b/config/web.php @@ -8,7 +8,7 @@ 'bootstrap' => ['log'], 'components' => [ 'request' => [ - // a secret key used to validate cookies. You may modify this key with your own one. + // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation 'cookieValidationKey' => '', ], 'cache' => [ From f77cd8b411257fedbe590bbdcb7f9e06b1a7bbb6 Mon Sep 17 00:00:00 2001 From: mickgeek Date: Thu, 31 Jul 2014 10:11:55 +0400 Subject: [PATCH 044/390] Fix signature validation --- models/LoginForm.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/models/LoginForm.php b/models/LoginForm.php index 31b814e24..687d29ded 100644 --- a/models/LoginForm.php +++ b/models/LoginForm.php @@ -34,14 +34,17 @@ public function rules() /** * Validates the password. * This method serves as the inline validation for password. + * + * @param string $attribute the attribute currently being validated + * @param array $params the additional name-value pairs given in the rule */ - public function validatePassword() + public function validatePassword($attribute, $params) { if (!$this->hasErrors()) { $user = $this->getUser(); if (!$user || !$user->validatePassword($this->password)) { - $this->addError('password', 'Incorrect username or password.'); + $this->addError($attribute, 'Incorrect username or password.'); } } } From c55a791237b5e90dce917851f60777380a925de4 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Fri, 15 Aug 2014 03:30:47 +0400 Subject: [PATCH 045/390] Codeception test adjustments for basic and advanced applications - Moved everything test-related into `tests` directory. Codeception tests are in `codeception`. - Removed database module since we're using fixtures and migrations. - Moved console entry points and bootstrap into `tests/codeception/bin`. - Adjusted travis build scripts. - Adjusted documentation to be consistent and reflect changes made. --- composer.json | 5 -- tests/README.md | 52 +++++++++++++------ tests/acceptance/_console.php | 13 ----- tests/acceptance/yii | 17 ------ codeception.yml => tests/codeception.yml | 10 ++-- tests/{ => codeception}/.gitignore | 0 tests/{ => codeception}/_bootstrap.php | 10 ++-- tests/{ => codeception}/_config.php | 0 tests/{ => codeception}/_data/dump.sql | 0 tests/{ => codeception}/_log/.gitignore | 0 tests/{ => codeception}/_pages/AboutPage.php | 2 +- .../{ => codeception}/_pages/ContactPage.php | 2 +- tests/{ => codeception}/_pages/LoginPage.php | 2 +- tests/{ => codeception}/acceptance.suite.yml | 0 .../acceptance/AboutCept.php | 2 +- .../acceptance/ContactCept.php | 2 +- .../{ => codeception}/acceptance/HomeCept.php | 0 .../acceptance/LoginCept.php | 2 +- .../acceptance/_bootstrap.php | 0 .../{ => codeception}/acceptance/_config.php | 2 +- .../bin}/_console_bootstrap.php | 6 ++- tests/codeception/bin/yii_acceptance | 27 ++++++++++ .../bin/yii_acceptance.bat} | 2 +- tests/codeception/bin/yii_functional | 27 ++++++++++ .../bin/yii_functional.bat} | 2 +- tests/codeception/bin/yii_unit | 27 ++++++++++ .../yii.bat => codeception/bin/yii_unit.bat} | 2 +- tests/{ => codeception}/functional.suite.yml | 2 +- .../functional/AboutCept.php | 2 +- .../functional/ContactCept.php | 2 +- .../{ => codeception}/functional/HomeCept.php | 0 .../functional/LoginCept.php | 2 +- .../functional/_bootstrap.php | 0 .../{ => codeception}/functional/_config.php | 2 +- tests/{ => codeception}/unit.suite.yml | 0 tests/{ => codeception}/unit/_bootstrap.php | 0 tests/{ => codeception}/unit/_config.php | 2 +- .../{ => codeception}/unit/fixtures/.gitkeep | 0 .../unit/fixtures/data/.gitkeep | 0 .../unit/models/ContactFormTest.php | 2 +- .../unit/models/LoginFormTest.php | 2 +- .../unit/models/UserTest.php | 2 +- .../unit/templates/fixtures/.gitkeep | 0 tests/functional/_console.php | 13 ----- tests/functional/yii | 17 ------ tests/unit/_console.php | 13 ----- tests/unit/yii | 17 ------ web/index-test.php | 2 +- 48 files changed, 150 insertions(+), 144 deletions(-) delete mode 100644 tests/acceptance/_console.php delete mode 100644 tests/acceptance/yii rename codeception.yml => tests/codeception.yml (62%) rename tests/{ => codeception}/.gitignore (100%) rename tests/{ => codeception}/_bootstrap.php (65%) rename tests/{ => codeception}/_config.php (100%) rename tests/{ => codeception}/_data/dump.sql (100%) rename tests/{ => codeception}/_log/.gitignore (100%) rename tests/{ => codeception}/_pages/AboutPage.php (78%) rename tests/{ => codeception}/_pages/ContactPage.php (94%) rename tests/{ => codeception}/_pages/LoginPage.php (93%) rename tests/{ => codeception}/acceptance.suite.yml (100%) rename tests/{ => codeception}/acceptance/AboutCept.php (78%) rename tests/{ => codeception}/acceptance/ContactCept.php (97%) rename tests/{ => codeception}/acceptance/HomeCept.php (100%) rename tests/{ => codeception}/acceptance/LoginCept.php (95%) rename tests/{ => codeception}/acceptance/_bootstrap.php (100%) rename tests/{ => codeception}/acceptance/_config.php (83%) rename tests/{ => codeception/bin}/_console_bootstrap.php (62%) create mode 100644 tests/codeception/bin/yii_acceptance rename tests/{unit/yii.bat => codeception/bin/yii_acceptance.bat} (91%) create mode 100644 tests/codeception/bin/yii_functional rename tests/{acceptance/yii.bat => codeception/bin/yii_functional.bat} (91%) create mode 100644 tests/codeception/bin/yii_unit rename tests/{functional/yii.bat => codeception/bin/yii_unit.bat} (92%) rename tests/{ => codeception}/functional.suite.yml (85%) rename tests/{ => codeception}/functional/AboutCept.php (78%) rename tests/{ => codeception}/functional/ContactCept.php (97%) rename tests/{ => codeception}/functional/HomeCept.php (100%) rename tests/{ => codeception}/functional/LoginCept.php (95%) rename tests/{ => codeception}/functional/_bootstrap.php (100%) rename tests/{ => codeception}/functional/_config.php (87%) rename tests/{ => codeception}/unit.suite.yml (100%) rename tests/{ => codeception}/unit/_bootstrap.php (100%) rename tests/{ => codeception}/unit/_config.php (83%) rename tests/{ => codeception}/unit/fixtures/.gitkeep (100%) rename tests/{ => codeception}/unit/fixtures/data/.gitkeep (100%) rename tests/{ => codeception}/unit/models/ContactFormTest.php (98%) rename tests/{ => codeception}/unit/models/LoginFormTest.php (98%) rename tests/{ => codeception}/unit/models/UserTest.php (89%) rename tests/{ => codeception}/unit/templates/fixtures/.gitkeep (100%) delete mode 100644 tests/functional/_console.php delete mode 100644 tests/functional/yii delete mode 100644 tests/unit/_console.php delete mode 100644 tests/unit/yii diff --git a/composer.json b/composer.json index a21128bf3..607accb1b 100644 --- a/composer.json +++ b/composer.json @@ -24,11 +24,6 @@ "yiisoft/yii2-debug": "*", "yiisoft/yii2-gii": "*" }, - "suggest": { - "codeception/codeception": "Codeception, 2.0.* is currently works well with Yii.", - "codeception/specify": "BDD style code blocks for PHPUnit and Codeception", - "codeception/verify": "BDD Assertions for PHPUnit and Codeception" - }, "scripts": { "post-create-project-cmd": [ "yii\\composer\\Installer::setPermission", diff --git a/tests/README.md b/tests/README.md index e1aed9a6e..1c4b50bca 100644 --- a/tests/README.md +++ b/tests/README.md @@ -1,32 +1,50 @@ -This folder contains various tests for the basic application. -These tests are developed with [Codeception PHP Testing Framework](http://codeception.com/). +This directory contains various tests for the basic application. + +Tests in `codeception` directory are developed with [Codeception PHP Testing Framework](http://codeception.com/). After creating the basic application, follow these steps to prepare for the tests: -1. Install additional composer packages: +1. Install Codeception if it's not yet installed: + +``` +composer global require "codeception/codeception=2.0.*" +composer global require "codeception/specify=*" +composer global require "codeception/verify=*" +``` + +If you've never used Composer for global packages run `composer global status`. It should output: + +``` +Changed current directory to +``` - ``` - php composer.phar require --dev "codeception/codeception: 2.0.*" "codeception/specify: *" "codeception/verify: *" - ``` -2. In the file `_bootstrap.php`, modify the definition of the constant `TEST_ENTRY_URL` so - that it points to the correct entry script URL. -3. Go to the application base directory and build the test suites: +Then add `/vendor/bin` to you `PATH` environment variable. Now we're able to use `codecept` from command +line globally. - ``` - vendor/bin/codecept build - ``` +2. Build the test suites: + +``` +codecept build +``` + +3. In order to be able to run acceptance tests you need to start a webserver. The simplest way is to use PHP built in +webserver. In the `web` directory execute the following: + +``` +php -S localhost:8080 +``` -Now you can run the tests with the following commands: +4. Now you can run the tests with the following commands: ``` # run all available tests -vendor/bin/codecept run +codecept run # run acceptance tests -vendor/bin/codecept run acceptance +codecept run acceptance # run functional tests -vendor/bin/codecept run functional +codecept run functional # run unit tests -vendor/bin/codecept run unit +codecept run unit ``` Please refer to [Codeception tutorial](http://codeception.com/docs/01-Introduction) for diff --git a/tests/acceptance/_console.php b/tests/acceptance/_console.php deleted file mode 100644 index 03cdd1ff6..000000000 --- a/tests/acceptance/_console.php +++ /dev/null @@ -1,13 +0,0 @@ - [ - 'db' => [ - 'dsn' => 'mysql:host=localhost;dbname=yii2_basic_acceptance', - ], - ], - ] -); diff --git a/tests/acceptance/yii b/tests/acceptance/yii deleted file mode 100644 index e587ba400..000000000 --- a/tests/acceptance/yii +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env php -run(); -exit($exitCode); diff --git a/codeception.yml b/tests/codeception.yml similarity index 62% rename from codeception.yml rename to tests/codeception.yml index 496ebd9c3..64952529e 100644 --- a/codeception.yml +++ b/tests/codeception.yml @@ -1,9 +1,9 @@ actor: Tester paths: - tests: tests - log: tests/_log - data: tests/_data - helpers: tests/_helpers + tests: codeception + log: codeception/_log + data: codeception/_data + helpers: codeception/_helpers settings: bootstrap: _bootstrap.php suite_class: \PHPUnit_Framework_TestSuite @@ -16,4 +16,4 @@ modules: dsn: '' user: '' password: '' - dump: tests/_data/dump.sql + dump: codeception/_data/dump.sql diff --git a/tests/.gitignore b/tests/codeception/.gitignore similarity index 100% rename from tests/.gitignore rename to tests/codeception/.gitignore diff --git a/tests/_bootstrap.php b/tests/codeception/_bootstrap.php similarity index 65% rename from tests/_bootstrap.php rename to tests/codeception/_bootstrap.php index 4890b3ed7..ecd76de93 100644 --- a/tests/_bootstrap.php +++ b/tests/codeception/_bootstrap.php @@ -2,22 +2,22 @@ // the entry script URL (without host info) for functional and acceptance tests // PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL -defined('TEST_ENTRY_URL') or define('TEST_ENTRY_URL', '/basic/web/index-test.php'); +defined('TEST_ENTRY_URL') or define('TEST_ENTRY_URL', '/index-test.php'); // the entry script file path for functional and acceptance tests -defined('TEST_ENTRY_FILE') or define('TEST_ENTRY_FILE', dirname(__DIR__) . '/web/index-test.php'); +defined('TEST_ENTRY_FILE') or define('TEST_ENTRY_FILE', dirname(dirname(__DIR__)) . '/web/index-test.php'); defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_ENV') or define('YII_ENV', 'test'); -require_once(__DIR__ . '/../vendor/autoload.php'); +require_once(__DIR__ . '/../../vendor/autoload.php'); -require_once(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php'); +require_once(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php'); // set correct script paths $_SERVER['SCRIPT_FILENAME'] = TEST_ENTRY_FILE; $_SERVER['SCRIPT_NAME'] = TEST_ENTRY_URL; $_SERVER['SERVER_NAME'] = 'localhost'; -Yii::setAlias('@tests', __DIR__); +Yii::setAlias('@codeception', __DIR__); diff --git a/tests/_config.php b/tests/codeception/_config.php similarity index 100% rename from tests/_config.php rename to tests/codeception/_config.php diff --git a/tests/_data/dump.sql b/tests/codeception/_data/dump.sql similarity index 100% rename from tests/_data/dump.sql rename to tests/codeception/_data/dump.sql diff --git a/tests/_log/.gitignore b/tests/codeception/_log/.gitignore similarity index 100% rename from tests/_log/.gitignore rename to tests/codeception/_log/.gitignore diff --git a/tests/_pages/AboutPage.php b/tests/codeception/_pages/AboutPage.php similarity index 78% rename from tests/_pages/AboutPage.php rename to tests/codeception/_pages/AboutPage.php index 77acdb815..727cd3859 100644 --- a/tests/_pages/AboutPage.php +++ b/tests/codeception/_pages/AboutPage.php @@ -1,6 +1,6 @@ wantTo('ensure that about works'); diff --git a/tests/acceptance/ContactCept.php b/tests/codeception/acceptance/ContactCept.php similarity index 97% rename from tests/acceptance/ContactCept.php rename to tests/codeception/acceptance/ContactCept.php index e76ac9beb..50aa69acb 100644 --- a/tests/acceptance/ContactCept.php +++ b/tests/codeception/acceptance/ContactCept.php @@ -1,6 +1,6 @@ wantTo('ensure that contact works'); diff --git a/tests/acceptance/HomeCept.php b/tests/codeception/acceptance/HomeCept.php similarity index 100% rename from tests/acceptance/HomeCept.php rename to tests/codeception/acceptance/HomeCept.php diff --git a/tests/acceptance/LoginCept.php b/tests/codeception/acceptance/LoginCept.php similarity index 95% rename from tests/acceptance/LoginCept.php rename to tests/codeception/acceptance/LoginCept.php index c7c9ae306..ff093b3bd 100644 --- a/tests/acceptance/LoginCept.php +++ b/tests/codeception/acceptance/LoginCept.php @@ -1,6 +1,6 @@ wantTo('ensure that login works'); diff --git a/tests/acceptance/_bootstrap.php b/tests/codeception/acceptance/_bootstrap.php similarity index 100% rename from tests/acceptance/_bootstrap.php rename to tests/codeception/acceptance/_bootstrap.php diff --git a/tests/acceptance/_config.php b/tests/codeception/acceptance/_config.php similarity index 83% rename from tests/acceptance/_config.php rename to tests/codeception/acceptance/_config.php index 857a804f4..d620a7d9e 100644 --- a/tests/acceptance/_config.php +++ b/tests/codeception/acceptance/_config.php @@ -1,7 +1,7 @@ [ diff --git a/tests/_console_bootstrap.php b/tests/codeception/bin/_console_bootstrap.php similarity index 62% rename from tests/_console_bootstrap.php rename to tests/codeception/bin/_console_bootstrap.php index 81287f3d8..eff8b403f 100644 --- a/tests/_console_bootstrap.php +++ b/tests/codeception/bin/_console_bootstrap.php @@ -8,5 +8,7 @@ defined('STDIN') or define('STDIN', fopen('php://stdin', 'r')); defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w')); -require(__DIR__ . '/../vendor/autoload.php'); -require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php'); +defined('ROOT_DIR') or define('ROOT_DIR', dirname(dirname(dirname(__DIR__)))); + +require(ROOT_DIR . '/vendor/autoload.php'); +require(ROOT_DIR . '/vendor/yiisoft/yii2/Yii.php'); diff --git a/tests/codeception/bin/yii_acceptance b/tests/codeception/bin/yii_acceptance new file mode 100644 index 000000000..a02d9daf1 --- /dev/null +++ b/tests/codeception/bin/yii_acceptance @@ -0,0 +1,27 @@ +#!/usr/bin/env php + [ + 'db' => [ + 'dsn' => 'mysql:host=localhost;dbname=yii2_basic_acceptance', + ], + ], + ] +); + +$application = new yii\console\Application($config); +$exitCode = $application->run(); +exit($exitCode); diff --git a/tests/unit/yii.bat b/tests/codeception/bin/yii_acceptance.bat similarity index 91% rename from tests/unit/yii.bat rename to tests/codeception/bin/yii_acceptance.bat index 5e21e2e99..389f89325 100644 --- a/tests/unit/yii.bat +++ b/tests/codeception/bin/yii_acceptance.bat @@ -15,6 +15,6 @@ set YII_PATH=%~dp0 if "%PHP_COMMAND%" == "" set PHP_COMMAND=php.exe -"%PHP_COMMAND%" "%YII_PATH%yii" %* +"%PHP_COMMAND%" "%YII_PATH%yii_acceptance" %* @endlocal diff --git a/tests/codeception/bin/yii_functional b/tests/codeception/bin/yii_functional new file mode 100644 index 000000000..44051e2ca --- /dev/null +++ b/tests/codeception/bin/yii_functional @@ -0,0 +1,27 @@ +#!/usr/bin/env php + [ + 'db' => [ + 'dsn' => 'mysql:host=localhost;dbname=yii2_basic_functional', + ], + ], + ] +); + +$application = new yii\console\Application($config); +$exitCode = $application->run(); +exit($exitCode); diff --git a/tests/acceptance/yii.bat b/tests/codeception/bin/yii_functional.bat similarity index 91% rename from tests/acceptance/yii.bat rename to tests/codeception/bin/yii_functional.bat index 5e21e2e99..98fae8853 100644 --- a/tests/acceptance/yii.bat +++ b/tests/codeception/bin/yii_functional.bat @@ -15,6 +15,6 @@ set YII_PATH=%~dp0 if "%PHP_COMMAND%" == "" set PHP_COMMAND=php.exe -"%PHP_COMMAND%" "%YII_PATH%yii" %* +"%PHP_COMMAND%" "%YII_PATH%yii_functional" %* @endlocal diff --git a/tests/codeception/bin/yii_unit b/tests/codeception/bin/yii_unit new file mode 100644 index 000000000..e9b799903 --- /dev/null +++ b/tests/codeception/bin/yii_unit @@ -0,0 +1,27 @@ +#!/usr/bin/env php + [ + 'db' => [ + 'dsn' => 'mysql:host=localhost;dbname=yii2_basic_unit', + ], + ], + ] +); + +$application = new yii\console\Application($config); +$exitCode = $application->run(); +exit($exitCode); diff --git a/tests/functional/yii.bat b/tests/codeception/bin/yii_unit.bat similarity index 92% rename from tests/functional/yii.bat rename to tests/codeception/bin/yii_unit.bat index 5e21e2e99..511e61d22 100644 --- a/tests/functional/yii.bat +++ b/tests/codeception/bin/yii_unit.bat @@ -15,6 +15,6 @@ set YII_PATH=%~dp0 if "%PHP_COMMAND%" == "" set PHP_COMMAND=php.exe -"%PHP_COMMAND%" "%YII_PATH%yii" %* +"%PHP_COMMAND%" "%YII_PATH%yii_unit" %* @endlocal diff --git a/tests/functional.suite.yml b/tests/codeception/functional.suite.yml similarity index 85% rename from tests/functional.suite.yml rename to tests/codeception/functional.suite.yml index 916ef1aaa..3b5008139 100644 --- a/tests/functional.suite.yml +++ b/tests/codeception/functional.suite.yml @@ -13,4 +13,4 @@ modules: - Yii2 config: Yii2: - configFile: 'tests/functional/_config.php' + configFile: 'codeception/functional/_config.php' diff --git a/tests/functional/AboutCept.php b/tests/codeception/functional/AboutCept.php similarity index 78% rename from tests/functional/AboutCept.php rename to tests/codeception/functional/AboutCept.php index 1875c2e11..631206144 100644 --- a/tests/functional/AboutCept.php +++ b/tests/codeception/functional/AboutCept.php @@ -1,6 +1,6 @@ wantTo('ensure that about works'); diff --git a/tests/functional/ContactCept.php b/tests/codeception/functional/ContactCept.php similarity index 97% rename from tests/functional/ContactCept.php rename to tests/codeception/functional/ContactCept.php index 49d7735fd..f13b51cf2 100644 --- a/tests/functional/ContactCept.php +++ b/tests/codeception/functional/ContactCept.php @@ -1,6 +1,6 @@ wantTo('ensure that contact works'); diff --git a/tests/functional/HomeCept.php b/tests/codeception/functional/HomeCept.php similarity index 100% rename from tests/functional/HomeCept.php rename to tests/codeception/functional/HomeCept.php diff --git a/tests/functional/LoginCept.php b/tests/codeception/functional/LoginCept.php similarity index 95% rename from tests/functional/LoginCept.php rename to tests/codeception/functional/LoginCept.php index e5285cdb2..77189b885 100644 --- a/tests/functional/LoginCept.php +++ b/tests/codeception/functional/LoginCept.php @@ -1,6 +1,6 @@ wantTo('ensure that login works'); diff --git a/tests/functional/_bootstrap.php b/tests/codeception/functional/_bootstrap.php similarity index 100% rename from tests/functional/_bootstrap.php rename to tests/codeception/functional/_bootstrap.php diff --git a/tests/functional/_config.php b/tests/codeception/functional/_config.php similarity index 87% rename from tests/functional/_config.php rename to tests/codeception/functional/_config.php index 512e802bb..3d50fdbaf 100644 --- a/tests/functional/_config.php +++ b/tests/codeception/functional/_config.php @@ -5,7 +5,7 @@ $_SERVER['SCRIPT_NAME'] = TEST_ENTRY_URL; return yii\helpers\ArrayHelper::merge( - require(__DIR__ . '/../../config/web.php'), + require(__DIR__ . '/../../../config/web.php'), require(__DIR__ . '/../_config.php'), [ 'components' => [ diff --git a/tests/unit.suite.yml b/tests/codeception/unit.suite.yml similarity index 100% rename from tests/unit.suite.yml rename to tests/codeception/unit.suite.yml diff --git a/tests/unit/_bootstrap.php b/tests/codeception/unit/_bootstrap.php similarity index 100% rename from tests/unit/_bootstrap.php rename to tests/codeception/unit/_bootstrap.php diff --git a/tests/unit/_config.php b/tests/codeception/unit/_config.php similarity index 83% rename from tests/unit/_config.php rename to tests/codeception/unit/_config.php index 2559ef31e..36b011446 100644 --- a/tests/unit/_config.php +++ b/tests/codeception/unit/_config.php @@ -1,7 +1,7 @@ [ diff --git a/tests/unit/fixtures/.gitkeep b/tests/codeception/unit/fixtures/.gitkeep similarity index 100% rename from tests/unit/fixtures/.gitkeep rename to tests/codeception/unit/fixtures/.gitkeep diff --git a/tests/unit/fixtures/data/.gitkeep b/tests/codeception/unit/fixtures/data/.gitkeep similarity index 100% rename from tests/unit/fixtures/data/.gitkeep rename to tests/codeception/unit/fixtures/data/.gitkeep diff --git a/tests/unit/models/ContactFormTest.php b/tests/codeception/unit/models/ContactFormTest.php similarity index 98% rename from tests/unit/models/ContactFormTest.php rename to tests/codeception/unit/models/ContactFormTest.php index 6e69cecd3..8adda18c6 100644 --- a/tests/unit/models/ContactFormTest.php +++ b/tests/codeception/unit/models/ContactFormTest.php @@ -1,6 +1,6 @@ [ - 'db' => [ - 'dsn' => 'mysql:host=localhost;dbname=yii2_basic_functional', - ], - ], - ] -); diff --git a/tests/functional/yii b/tests/functional/yii deleted file mode 100644 index e587ba400..000000000 --- a/tests/functional/yii +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env php -run(); -exit($exitCode); diff --git a/tests/unit/_console.php b/tests/unit/_console.php deleted file mode 100644 index 04272a321..000000000 --- a/tests/unit/_console.php +++ /dev/null @@ -1,13 +0,0 @@ - [ - 'db' => [ - 'dsn' => 'mysql:host=localhost;dbname=yii2_basic_unit', - ], - ], - ] -); diff --git a/tests/unit/yii b/tests/unit/yii deleted file mode 100644 index e587ba400..000000000 --- a/tests/unit/yii +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env php -run(); -exit($exitCode); diff --git a/web/index-test.php b/web/index-test.php index 326608d21..dd8a4965c 100644 --- a/web/index-test.php +++ b/web/index-test.php @@ -11,6 +11,6 @@ require(__DIR__ . '/../vendor/autoload.php'); require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php'); -$config = require(__DIR__ . '/../tests/acceptance/_config.php'); +$config = require(__DIR__ . '/../tests/codeception/acceptance/_config.php'); (new yii\web\Application($config))->run(); From 9460b93de2cf919c6f13cd5b4634e76fa7f0ae02 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Sat, 16 Aug 2014 17:16:05 +0400 Subject: [PATCH 046/390] Removed db module from basic app, renamed _helpers to _support and _logs to _output --- tests/codeception.yml | 11 ++--------- tests/codeception/_data/dump.sql | 1 - tests/codeception/{_log => _output}/.gitignore | 0 3 files changed, 2 insertions(+), 10 deletions(-) delete mode 100644 tests/codeception/_data/dump.sql rename tests/codeception/{_log => _output}/.gitignore (100%) diff --git a/tests/codeception.yml b/tests/codeception.yml index 64952529e..851923d16 100644 --- a/tests/codeception.yml +++ b/tests/codeception.yml @@ -1,19 +1,12 @@ actor: Tester paths: tests: codeception - log: codeception/_log + log: codeception/_output data: codeception/_data - helpers: codeception/_helpers + helpers: codeception/_support settings: bootstrap: _bootstrap.php suite_class: \PHPUnit_Framework_TestSuite memory_limit: 1024M log: true colors: true -modules: - config: - Db: - dsn: '' - user: '' - password: '' - dump: codeception/_data/dump.sql diff --git a/tests/codeception/_data/dump.sql b/tests/codeception/_data/dump.sql deleted file mode 100644 index 4bc742ce6..000000000 --- a/tests/codeception/_data/dump.sql +++ /dev/null @@ -1 +0,0 @@ -/* Replace this file with actual dump of your database */ \ No newline at end of file diff --git a/tests/codeception/_log/.gitignore b/tests/codeception/_output/.gitignore similarity index 100% rename from tests/codeception/_log/.gitignore rename to tests/codeception/_output/.gitignore From 3673e6c004ea232fb236c1374cb6dd3b1203be10 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Sat, 16 Aug 2014 18:15:41 +0400 Subject: [PATCH 047/390] Renamed guy classes to actors, fixed phpdoc and code style --- tests/codeception/.gitignore | 6 +++--- tests/codeception/_pages/AboutPage.php | 4 ++++ tests/codeception/_pages/ContactPage.php | 8 ++++++-- tests/codeception/_pages/LoginPage.php | 10 +++++++--- tests/codeception/acceptance.suite.yml | 2 +- tests/codeception/acceptance/AboutCept.php | 2 +- tests/codeception/acceptance/ContactCept.php | 2 +- tests/codeception/acceptance/HomeCept.php | 2 +- tests/codeception/acceptance/LoginCept.php | 2 +- tests/codeception/functional.suite.yml | 2 +- tests/codeception/functional/AboutCept.php | 2 +- tests/codeception/functional/ContactCept.php | 2 +- tests/codeception/functional/HomeCept.php | 2 +- tests/codeception/functional/LoginCept.php | 2 +- tests/codeception/unit.suite.yml | 2 +- 15 files changed, 31 insertions(+), 19 deletions(-) diff --git a/tests/codeception/.gitignore b/tests/codeception/.gitignore index c5aa0743d..985dbb423 100644 --- a/tests/codeception/.gitignore +++ b/tests/codeception/.gitignore @@ -1,4 +1,4 @@ # these files are auto generated by codeception build -/unit/CodeGuy.php -/functional/TestGuy.php -/acceptance/WebGuy.php +/unit/UnitTester.php +/functional/FunctionalTester.php +/acceptance/AcceptanceTester.php diff --git a/tests/codeception/_pages/AboutPage.php b/tests/codeception/_pages/AboutPage.php index 727cd3859..b6ca34a29 100644 --- a/tests/codeception/_pages/AboutPage.php +++ b/tests/codeception/_pages/AboutPage.php @@ -4,6 +4,10 @@ use yii\codeception\BasePage; +/** + * Represents about page + * @property \AcceptanceTester|\FunctionalTester $actor + */ class AboutPage extends BasePage { public $route = 'site/about'; diff --git a/tests/codeception/_pages/ContactPage.php b/tests/codeception/_pages/ContactPage.php index 63c053c90..956125594 100644 --- a/tests/codeception/_pages/ContactPage.php +++ b/tests/codeception/_pages/ContactPage.php @@ -4,6 +4,10 @@ use yii\codeception\BasePage; +/** + * Represents contact page + * @property \AcceptanceTester|\FunctionalTester $actor + */ class ContactPage extends BasePage { public $route = 'site/contact'; @@ -15,8 +19,8 @@ public function submit(array $contactData) { foreach ($contactData as $field => $value) { $inputType = $field === 'body' ? 'textarea' : 'input'; - $this->guy->fillField($inputType . '[name="ContactForm[' . $field . ']"]', $value); + $this->actor->fillField($inputType . '[name="ContactForm[' . $field . ']"]', $value); } - $this->guy->click('contact-button'); + $this->actor->click('contact-button'); } } diff --git a/tests/codeception/_pages/LoginPage.php b/tests/codeception/_pages/LoginPage.php index 35ada9cd8..af1004963 100644 --- a/tests/codeception/_pages/LoginPage.php +++ b/tests/codeception/_pages/LoginPage.php @@ -4,6 +4,10 @@ use yii\codeception\BasePage; +/** + * Represents login page + * @property \AcceptanceTester|\FunctionalTester $actor + */ class LoginPage extends BasePage { public $route = 'site/login'; @@ -14,8 +18,8 @@ class LoginPage extends BasePage */ 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'); + $this->actor->fillField('input[name="LoginForm[username]"]', $username); + $this->actor->fillField('input[name="LoginForm[password]"]', $password); + $this->actor->click('login-button'); } } diff --git a/tests/codeception/acceptance.suite.yml b/tests/codeception/acceptance.suite.yml index bd10f82a1..a045043cd 100644 --- a/tests/codeception/acceptance.suite.yml +++ b/tests/codeception/acceptance.suite.yml @@ -8,7 +8,7 @@ # RUN `build` COMMAND AFTER ADDING/REMOVING MODULES. -class_name: WebGuy +class_name: AcceptanceTester modules: enabled: - PhpBrowser diff --git a/tests/codeception/acceptance/AboutCept.php b/tests/codeception/acceptance/AboutCept.php index 251cad274..2dcc6a13b 100644 --- a/tests/codeception/acceptance/AboutCept.php +++ b/tests/codeception/acceptance/AboutCept.php @@ -2,7 +2,7 @@ use codeception\_pages\AboutPage; -$I = new WebGuy($scenario); +$I = new AcceptanceTester($scenario); $I->wantTo('ensure that about works'); AboutPage::openBy($I); $I->see('About', 'h1'); diff --git a/tests/codeception/acceptance/ContactCept.php b/tests/codeception/acceptance/ContactCept.php index 50aa69acb..27858f8e9 100644 --- a/tests/codeception/acceptance/ContactCept.php +++ b/tests/codeception/acceptance/ContactCept.php @@ -2,7 +2,7 @@ use codeception\_pages\ContactPage; -$I = new WebGuy($scenario); +$I = new AcceptanceTester($scenario); $I->wantTo('ensure that contact works'); $contactPage = ContactPage::openBy($I); diff --git a/tests/codeception/acceptance/HomeCept.php b/tests/codeception/acceptance/HomeCept.php index 62456f930..369ab7f48 100644 --- a/tests/codeception/acceptance/HomeCept.php +++ b/tests/codeception/acceptance/HomeCept.php @@ -1,6 +1,6 @@ wantTo('ensure that home page works'); $I->amOnPage(Yii::$app->homeUrl); $I->see('My Company'); diff --git a/tests/codeception/acceptance/LoginCept.php b/tests/codeception/acceptance/LoginCept.php index ff093b3bd..6d07c0895 100644 --- a/tests/codeception/acceptance/LoginCept.php +++ b/tests/codeception/acceptance/LoginCept.php @@ -2,7 +2,7 @@ use codeception\_pages\LoginPage; -$I = new WebGuy($scenario); +$I = new AcceptanceTester($scenario); $I->wantTo('ensure that login works'); $loginPage = LoginPage::openBy($I); diff --git a/tests/codeception/functional.suite.yml b/tests/codeception/functional.suite.yml index 3b5008139..94ff0c976 100644 --- a/tests/codeception/functional.suite.yml +++ b/tests/codeception/functional.suite.yml @@ -6,7 +6,7 @@ # RUN `build` COMMAND AFTER ADDING/REMOVING MODULES. #basic/web/index.php -class_name: TestGuy +class_name: FunctionalTester modules: enabled: - Filesystem diff --git a/tests/codeception/functional/AboutCept.php b/tests/codeception/functional/AboutCept.php index 631206144..3edd61da3 100644 --- a/tests/codeception/functional/AboutCept.php +++ b/tests/codeception/functional/AboutCept.php @@ -2,7 +2,7 @@ use codeception\_pages\AboutPage; -$I = new TestGuy($scenario); +$I = new FunctionalTester($scenario); $I->wantTo('ensure that about works'); AboutPage::openBy($I); $I->see('About', 'h1'); diff --git a/tests/codeception/functional/ContactCept.php b/tests/codeception/functional/ContactCept.php index f13b51cf2..c5e83b4f1 100644 --- a/tests/codeception/functional/ContactCept.php +++ b/tests/codeception/functional/ContactCept.php @@ -2,7 +2,7 @@ use codeception\_pages\ContactPage; -$I = new TestGuy($scenario); +$I = new FunctionalTester($scenario); $I->wantTo('ensure that contact works'); $contactPage = ContactPage::openBy($I); diff --git a/tests/codeception/functional/HomeCept.php b/tests/codeception/functional/HomeCept.php index 3258ba333..80aa551fc 100644 --- a/tests/codeception/functional/HomeCept.php +++ b/tests/codeception/functional/HomeCept.php @@ -1,6 +1,6 @@ wantTo('ensure that home page works'); $I->amOnPage(Yii::$app->homeUrl); $I->see('My Company'); diff --git a/tests/codeception/functional/LoginCept.php b/tests/codeception/functional/LoginCept.php index 77189b885..4cb283ac9 100644 --- a/tests/codeception/functional/LoginCept.php +++ b/tests/codeception/functional/LoginCept.php @@ -2,7 +2,7 @@ use codeception\_pages\LoginPage; -$I = new TestGuy($scenario); +$I = new FunctionalTester($scenario); $I->wantTo('ensure that login works'); $loginPage = LoginPage::openBy($I); diff --git a/tests/codeception/unit.suite.yml b/tests/codeception/unit.suite.yml index f0573a843..a0582a536 100644 --- a/tests/codeception/unit.suite.yml +++ b/tests/codeception/unit.suite.yml @@ -3,4 +3,4 @@ # suite for unit (internal) tests. # RUN `build` COMMAND AFTER ADDING/REMOVING MODULES. -class_name: CodeGuy +class_name: UnitTester From e7dcdf7c7141eb5ff46442fce5577d8c46f3cb6a Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Sat, 16 Aug 2014 18:38:56 +0400 Subject: [PATCH 048/390] Exposed basic app entry URL via codeception.yml, refactored configs of advanced app to read from config and define entry script in a single place --- tests/codeception.yml | 4 ++++ tests/codeception/_bootstrap.php | 14 +++----------- tests/codeception/functional/_config.php | 2 -- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/tests/codeception.yml b/tests/codeception.yml index 851923d16..ba02c81b7 100644 --- a/tests/codeception.yml +++ b/tests/codeception.yml @@ -10,3 +10,7 @@ settings: memory_limit: 1024M log: true colors: true +config: + # the entry script URL (without host info) for functional and acceptance tests + # PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL + test_entry_url: /index-test.php \ No newline at end of file diff --git a/tests/codeception/_bootstrap.php b/tests/codeception/_bootstrap.php index ecd76de93..eb61f8f64 100644 --- a/tests/codeception/_bootstrap.php +++ b/tests/codeception/_bootstrap.php @@ -1,21 +1,13 @@ Date: Sun, 17 Aug 2014 18:45:58 +0400 Subject: [PATCH 049/390] Adjusted test configs structure --- tests/codeception/acceptance/ContactCept.php | 20 +++++++++---------- tests/codeception/acceptance/_bootstrap.php | 3 +-- ...{_console_bootstrap.php => _bootstrap.php} | 2 -- tests/codeception/bin/yii_acceptance | 4 ++-- tests/codeception/bin/yii_functional | 4 ++-- tests/codeception/bin/yii_unit | 4 ++-- .../_config.php => config/acceptance.php} | 6 ++++-- .../{_config.php => config/config.php} | 2 +- .../_config.php => config/functional.php} | 5 ++++- .../{unit/_config.php => config/unit.php} | 6 ++++-- tests/codeception/functional.suite.yml | 2 +- tests/codeception/functional/_bootstrap.php | 3 +-- web/index-test.php | 2 +- 13 files changed, 33 insertions(+), 30 deletions(-) rename tests/codeception/bin/{_console_bootstrap.php => _bootstrap.php} (99%) rename tests/codeception/{acceptance/_config.php => config/acceptance.php} (73%) rename tests/codeception/{_config.php => config/config.php} (78%) rename tests/codeception/{functional/_config.php => config/functional.php} (78%) rename tests/codeception/{unit/_config.php => config/unit.php} (74%) diff --git a/tests/codeception/acceptance/ContactCept.php b/tests/codeception/acceptance/ContactCept.php index 27858f8e9..c9adc7e15 100644 --- a/tests/codeception/acceptance/ContactCept.php +++ b/tests/codeception/acceptance/ContactCept.php @@ -21,11 +21,11 @@ $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->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 diff --git a/tests/codeception/acceptance/_bootstrap.php b/tests/codeception/acceptance/_bootstrap.php index 6ce3d175b..36f9f1d11 100644 --- a/tests/codeception/acceptance/_bootstrap.php +++ b/tests/codeception/acceptance/_bootstrap.php @@ -1,3 +1,2 @@ [ 'db' => [ diff --git a/tests/codeception/bin/yii_functional b/tests/codeception/bin/yii_functional index 44051e2ca..148420fe0 100644 --- a/tests/codeception/bin/yii_functional +++ b/tests/codeception/bin/yii_functional @@ -8,11 +8,11 @@ * @license http://www.yiiframework.com/license/ */ -require_once __DIR__ . '/_console_bootstrap.php'; +require_once __DIR__ . '/_bootstrap.php'; $config = yii\helpers\ArrayHelper::merge( require(ROOT_DIR . '/config/console.php'), - require(__DIR__ . '/../_config.php'), + require(__DIR__ . '/../config/config.php'), [ 'components' => [ 'db' => [ diff --git a/tests/codeception/bin/yii_unit b/tests/codeception/bin/yii_unit index e9b799903..5fb938e51 100644 --- a/tests/codeception/bin/yii_unit +++ b/tests/codeception/bin/yii_unit @@ -8,11 +8,11 @@ * @license http://www.yiiframework.com/license/ */ -require_once __DIR__ . '/_console_bootstrap.php'; +require_once __DIR__ . '/_bootstrap.php'; $config = yii\helpers\ArrayHelper::merge( require(ROOT_DIR . '/config/console.php'), - require(__DIR__ . '/../_config.php'), + require(__DIR__ . '/../config/config.php'), [ 'components' => [ 'db' => [ diff --git a/tests/codeception/acceptance/_config.php b/tests/codeception/config/acceptance.php similarity index 73% rename from tests/codeception/acceptance/_config.php rename to tests/codeception/config/acceptance.php index d620a7d9e..c80d4687a 100644 --- a/tests/codeception/acceptance/_config.php +++ b/tests/codeception/config/acceptance.php @@ -1,8 +1,10 @@ [ 'db' => [ diff --git a/tests/codeception/_config.php b/tests/codeception/config/config.php similarity index 78% rename from tests/codeception/_config.php rename to tests/codeception/config/config.php index 8629dd0d9..005d365c4 100644 --- a/tests/codeception/_config.php +++ b/tests/codeception/config/config.php @@ -1,6 +1,6 @@ [ diff --git a/tests/codeception/functional/_config.php b/tests/codeception/config/functional.php similarity index 78% rename from tests/codeception/functional/_config.php rename to tests/codeception/config/functional.php index 515c90487..13cfc6458 100644 --- a/tests/codeception/functional/_config.php +++ b/tests/codeception/config/functional.php @@ -2,9 +2,12 @@ $_SERVER['SCRIPT_FILENAME'] = TEST_ENTRY_FILE; $_SERVER['SCRIPT_NAME'] = TEST_ENTRY_URL; +/** + * Application configuration for functional tests + */ return yii\helpers\ArrayHelper::merge( require(__DIR__ . '/../../../config/web.php'), - require(__DIR__ . '/../_config.php'), + require(__DIR__ . '/config.php'), [ 'components' => [ 'db' => [ diff --git a/tests/codeception/unit/_config.php b/tests/codeception/config/unit.php similarity index 74% rename from tests/codeception/unit/_config.php rename to tests/codeception/config/unit.php index 36b011446..1b8772d5b 100644 --- a/tests/codeception/unit/_config.php +++ b/tests/codeception/config/unit.php @@ -1,8 +1,10 @@ [ 'db' => [ diff --git a/tests/codeception/functional.suite.yml b/tests/codeception/functional.suite.yml index 94ff0c976..ad7164cb6 100644 --- a/tests/codeception/functional.suite.yml +++ b/tests/codeception/functional.suite.yml @@ -13,4 +13,4 @@ modules: - Yii2 config: Yii2: - configFile: 'codeception/functional/_config.php' + configFile: 'codeception/config/functional.php' diff --git a/tests/codeception/functional/_bootstrap.php b/tests/codeception/functional/_bootstrap.php index 6ce3d175b..8aac0915b 100644 --- a/tests/codeception/functional/_bootstrap.php +++ b/tests/codeception/functional/_bootstrap.php @@ -1,3 +1,2 @@ run(); From bc2ec5c68453522b155f8a804ebd152272d52eaf Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Sun, 17 Aug 2014 18:55:24 +0400 Subject: [PATCH 050/390] Fixed copyright year in batch files --- config/web.php | 6 +++++- tests/codeception/bin/yii_acceptance.bat | 2 +- tests/codeception/bin/yii_functional.bat | 2 +- tests/codeception/bin/yii_unit.bat | 2 +- yii.bat | 2 +- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/config/web.php b/config/web.php index 1632a5aab..4fde1b686 100644 --- a/config/web.php +++ b/config/web.php @@ -9,7 +9,7 @@ 'components' => [ 'request' => [ // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation - 'cookieValidationKey' => '', + 'cookieValidationKey' => 'thisIsAKey', ], 'cache' => [ 'class' => 'yii\caching\FileCache', @@ -38,6 +38,10 @@ ], ], 'db' => require(__DIR__ . '/db.php'), + 'urlManager' => [ + 'enablePrettyUrl' => true, + 'showScriptName' => false, + ], ], 'params' => $params, ]; diff --git a/tests/codeception/bin/yii_acceptance.bat b/tests/codeception/bin/yii_acceptance.bat index 389f89325..3edcabe95 100644 --- a/tests/codeception/bin/yii_acceptance.bat +++ b/tests/codeception/bin/yii_acceptance.bat @@ -5,7 +5,7 @@ rem Yii command line bootstrap script for Windows. rem rem @author Qiang Xue rem @link http://www.yiiframework.com/ -rem @copyright Copyright © 2012 Yii Software LLC +rem @copyright Copyright (c) 2008 Yii Software LLC rem @license http://www.yiiframework.com/license/ rem ------------------------------------------------------------- diff --git a/tests/codeception/bin/yii_functional.bat b/tests/codeception/bin/yii_functional.bat index 98fae8853..2d04dcc71 100644 --- a/tests/codeception/bin/yii_functional.bat +++ b/tests/codeception/bin/yii_functional.bat @@ -5,7 +5,7 @@ rem Yii command line bootstrap script for Windows. rem rem @author Qiang Xue rem @link http://www.yiiframework.com/ -rem @copyright Copyright © 2012 Yii Software LLC +rem @copyright Copyright (c) 2008 Yii Software LLC rem @license http://www.yiiframework.com/license/ rem ------------------------------------------------------------- diff --git a/tests/codeception/bin/yii_unit.bat b/tests/codeception/bin/yii_unit.bat index 511e61d22..6852bf0ca 100644 --- a/tests/codeception/bin/yii_unit.bat +++ b/tests/codeception/bin/yii_unit.bat @@ -5,7 +5,7 @@ rem Yii command line bootstrap script for Windows. rem rem @author Qiang Xue rem @link http://www.yiiframework.com/ -rem @copyright Copyright © 2012 Yii Software LLC +rem @copyright Copyright (c) 2008 Yii Software LLC rem @license http://www.yiiframework.com/license/ rem ------------------------------------------------------------- diff --git a/yii.bat b/yii.bat index 5e21e2e99..d516b3a19 100644 --- a/yii.bat +++ b/yii.bat @@ -5,7 +5,7 @@ rem Yii command line bootstrap script for Windows. rem rem @author Qiang Xue rem @link http://www.yiiframework.com/ -rem @copyright Copyright © 2012 Yii Software LLC +rem @copyright Copyright (c) 2008 Yii Software LLC rem @license http://www.yiiframework.com/license/ rem ------------------------------------------------------------- From f85a0f7dd24cc643699e1c605f806166dfb3ec62 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Mon, 18 Aug 2014 01:56:36 +0400 Subject: [PATCH 051/390] Prefixed constants to avoid possible naming conflicts --- tests/codeception/_bootstrap.php | 8 ++++---- tests/codeception/bin/_bootstrap.php | 6 +++--- tests/codeception/bin/yii_acceptance | 2 +- tests/codeception/bin/yii_functional | 2 +- tests/codeception/bin/yii_unit | 2 +- tests/codeception/config/functional.php | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/codeception/_bootstrap.php b/tests/codeception/_bootstrap.php index eb61f8f64..5f5ae10b4 100644 --- a/tests/codeception/_bootstrap.php +++ b/tests/codeception/_bootstrap.php @@ -2,14 +2,14 @@ defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_ENV') or define('YII_ENV', 'test'); -defined('TEST_ENTRY_URL') or define('TEST_ENTRY_URL', \Codeception\Configuration::config()['config']['test_entry_url']); -defined('TEST_ENTRY_FILE') or define('TEST_ENTRY_FILE', dirname(dirname(__DIR__)) . '/web/index-test.php'); +defined('YII_TEST_ENTRY_URL') or define('YII_TEST_ENTRY_URL', \Codeception\Configuration::config()['config']['test_entry_url']); +defined('YII_TEST_ENTRY_FILE') or define('YII_TEST_ENTRY_FILE', dirname(dirname(__DIR__)) . '/web/index-test.php'); require_once(__DIR__ . '/../../vendor/autoload.php'); require_once(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php'); -$_SERVER['SCRIPT_FILENAME'] = TEST_ENTRY_FILE; -$_SERVER['SCRIPT_NAME'] = TEST_ENTRY_URL; +$_SERVER['SCRIPT_FILENAME'] = YII_TEST_ENTRY_FILE; +$_SERVER['SCRIPT_NAME'] = YII_TEST_ENTRY_URL; $_SERVER['SERVER_NAME'] = 'localhost'; Yii::setAlias('@codeception', __DIR__); diff --git a/tests/codeception/bin/_bootstrap.php b/tests/codeception/bin/_bootstrap.php index fcff15411..de57b2006 100644 --- a/tests/codeception/bin/_bootstrap.php +++ b/tests/codeception/bin/_bootstrap.php @@ -6,7 +6,7 @@ defined('STDIN') or define('STDIN', fopen('php://stdin', 'r')); defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w')); -defined('ROOT_DIR') or define('ROOT_DIR', dirname(dirname(dirname(__DIR__)))); +defined('YII_ROOT_DIR') or define('YII_ROOT_DIR', dirname(dirname(dirname(__DIR__)))); -require(ROOT_DIR . '/vendor/autoload.php'); -require(ROOT_DIR . '/vendor/yiisoft/yii2/Yii.php'); +require(YII_ROOT_DIR . '/vendor/autoload.php'); +require(YII_ROOT_DIR . '/vendor/yiisoft/yii2/Yii.php'); diff --git a/tests/codeception/bin/yii_acceptance b/tests/codeception/bin/yii_acceptance index 89a6e3c3e..f454a1cf7 100644 --- a/tests/codeception/bin/yii_acceptance +++ b/tests/codeception/bin/yii_acceptance @@ -11,7 +11,7 @@ require_once __DIR__ . '/_bootstrap.php'; $config = yii\helpers\ArrayHelper::merge( - require(ROOT_DIR . '/config/console.php'), + require(YII_ROOT_DIR . '/config/console.php'), require(__DIR__ . '/../config/config.php'), [ 'components' => [ diff --git a/tests/codeception/bin/yii_functional b/tests/codeception/bin/yii_functional index 148420fe0..af5563e4d 100644 --- a/tests/codeception/bin/yii_functional +++ b/tests/codeception/bin/yii_functional @@ -11,7 +11,7 @@ require_once __DIR__ . '/_bootstrap.php'; $config = yii\helpers\ArrayHelper::merge( - require(ROOT_DIR . '/config/console.php'), + require(YII_ROOT_DIR . '/config/console.php'), require(__DIR__ . '/../config/config.php'), [ 'components' => [ diff --git a/tests/codeception/bin/yii_unit b/tests/codeception/bin/yii_unit index 5fb938e51..92750bb15 100644 --- a/tests/codeception/bin/yii_unit +++ b/tests/codeception/bin/yii_unit @@ -11,7 +11,7 @@ require_once __DIR__ . '/_bootstrap.php'; $config = yii\helpers\ArrayHelper::merge( - require(ROOT_DIR . '/config/console.php'), + require(YII_ROOT_DIR . '/config/console.php'), require(__DIR__ . '/../config/config.php'), [ 'components' => [ diff --git a/tests/codeception/config/functional.php b/tests/codeception/config/functional.php index 13cfc6458..32cd7c899 100644 --- a/tests/codeception/config/functional.php +++ b/tests/codeception/config/functional.php @@ -1,6 +1,6 @@ Date: Tue, 19 Aug 2014 20:42:40 +0400 Subject: [PATCH 052/390] =?UTF-8?q?Renamed=20YII=5FROOT=5FDIR=20=E2=86=92?= =?UTF-8?q?=20YII=5FAPP=5FBASE=5FPATH?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/codeception/bin/_bootstrap.php | 6 +++--- tests/codeception/bin/yii_acceptance | 2 +- tests/codeception/bin/yii_functional | 2 +- tests/codeception/bin/yii_unit | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/codeception/bin/_bootstrap.php b/tests/codeception/bin/_bootstrap.php index de57b2006..e56da4efa 100644 --- a/tests/codeception/bin/_bootstrap.php +++ b/tests/codeception/bin/_bootstrap.php @@ -6,7 +6,7 @@ defined('STDIN') or define('STDIN', fopen('php://stdin', 'r')); defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w')); -defined('YII_ROOT_DIR') or define('YII_ROOT_DIR', dirname(dirname(dirname(__DIR__)))); +defined('YII_APP_BASE_PATH') or define('YII_APP_BASE_PATH', dirname(dirname(dirname(__DIR__)))); -require(YII_ROOT_DIR . '/vendor/autoload.php'); -require(YII_ROOT_DIR . '/vendor/yiisoft/yii2/Yii.php'); +require(YII_APP_BASE_PATH . '/vendor/autoload.php'); +require(YII_APP_BASE_PATH . '/vendor/yiisoft/yii2/Yii.php'); diff --git a/tests/codeception/bin/yii_acceptance b/tests/codeception/bin/yii_acceptance index f454a1cf7..f67a47fbb 100644 --- a/tests/codeception/bin/yii_acceptance +++ b/tests/codeception/bin/yii_acceptance @@ -11,7 +11,7 @@ require_once __DIR__ . '/_bootstrap.php'; $config = yii\helpers\ArrayHelper::merge( - require(YII_ROOT_DIR . '/config/console.php'), + require(YII_APP_BASE_PATH . '/config/console.php'), require(__DIR__ . '/../config/config.php'), [ 'components' => [ diff --git a/tests/codeception/bin/yii_functional b/tests/codeception/bin/yii_functional index af5563e4d..f6e3988a0 100644 --- a/tests/codeception/bin/yii_functional +++ b/tests/codeception/bin/yii_functional @@ -11,7 +11,7 @@ require_once __DIR__ . '/_bootstrap.php'; $config = yii\helpers\ArrayHelper::merge( - require(YII_ROOT_DIR . '/config/console.php'), + require(YII_APP_BASE_PATH . '/config/console.php'), require(__DIR__ . '/../config/config.php'), [ 'components' => [ diff --git a/tests/codeception/bin/yii_unit b/tests/codeception/bin/yii_unit index 92750bb15..1ab8e1fba 100644 --- a/tests/codeception/bin/yii_unit +++ b/tests/codeception/bin/yii_unit @@ -11,7 +11,7 @@ require_once __DIR__ . '/_bootstrap.php'; $config = yii\helpers\ArrayHelper::merge( - require(YII_ROOT_DIR . '/config/console.php'), + require(YII_APP_BASE_PATH . '/config/console.php'), require(__DIR__ . '/../config/config.php'), [ 'components' => [ From a3efcafd38d3b21d7c8a422f8ee621143567f18f Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Sun, 24 Aug 2014 14:14:35 +0400 Subject: [PATCH 053/390] Adjusted testing namespaces in application templates --- tests/codeception/_bootstrap.php | 2 +- tests/codeception/_pages/AboutPage.php | 2 +- tests/codeception/_pages/ContactPage.php | 2 +- tests/codeception/_pages/LoginPage.php | 2 +- tests/codeception/acceptance/AboutCept.php | 2 +- tests/codeception/acceptance/ContactCept.php | 2 +- tests/codeception/acceptance/LoginCept.php | 2 +- tests/codeception/functional/AboutCept.php | 2 +- tests/codeception/functional/ContactCept.php | 2 +- tests/codeception/functional/LoginCept.php | 2 +- tests/codeception/unit/models/ContactFormTest.php | 2 +- tests/codeception/unit/models/LoginFormTest.php | 2 +- tests/codeception/unit/models/UserTest.php | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/codeception/_bootstrap.php b/tests/codeception/_bootstrap.php index 5f5ae10b4..985593978 100644 --- a/tests/codeception/_bootstrap.php +++ b/tests/codeception/_bootstrap.php @@ -12,4 +12,4 @@ $_SERVER['SCRIPT_NAME'] = YII_TEST_ENTRY_URL; $_SERVER['SERVER_NAME'] = 'localhost'; -Yii::setAlias('@codeception', __DIR__); +Yii::setAlias('@tests', dirname(__DIR__)); diff --git a/tests/codeception/_pages/AboutPage.php b/tests/codeception/_pages/AboutPage.php index b6ca34a29..b56320d09 100644 --- a/tests/codeception/_pages/AboutPage.php +++ b/tests/codeception/_pages/AboutPage.php @@ -1,6 +1,6 @@ wantTo('ensure that about works'); diff --git a/tests/codeception/acceptance/ContactCept.php b/tests/codeception/acceptance/ContactCept.php index c9adc7e15..98ba2ef12 100644 --- a/tests/codeception/acceptance/ContactCept.php +++ b/tests/codeception/acceptance/ContactCept.php @@ -1,6 +1,6 @@ wantTo('ensure that contact works'); diff --git a/tests/codeception/acceptance/LoginCept.php b/tests/codeception/acceptance/LoginCept.php index 6d07c0895..4f022e1c2 100644 --- a/tests/codeception/acceptance/LoginCept.php +++ b/tests/codeception/acceptance/LoginCept.php @@ -1,6 +1,6 @@ wantTo('ensure that login works'); diff --git a/tests/codeception/functional/AboutCept.php b/tests/codeception/functional/AboutCept.php index 3edd61da3..ae7b45b30 100644 --- a/tests/codeception/functional/AboutCept.php +++ b/tests/codeception/functional/AboutCept.php @@ -1,6 +1,6 @@ wantTo('ensure that about works'); diff --git a/tests/codeception/functional/ContactCept.php b/tests/codeception/functional/ContactCept.php index c5e83b4f1..47604058d 100644 --- a/tests/codeception/functional/ContactCept.php +++ b/tests/codeception/functional/ContactCept.php @@ -1,6 +1,6 @@ wantTo('ensure that contact works'); diff --git a/tests/codeception/functional/LoginCept.php b/tests/codeception/functional/LoginCept.php index 4cb283ac9..991d27c3c 100644 --- a/tests/codeception/functional/LoginCept.php +++ b/tests/codeception/functional/LoginCept.php @@ -1,6 +1,6 @@ wantTo('ensure that login works'); diff --git a/tests/codeception/unit/models/ContactFormTest.php b/tests/codeception/unit/models/ContactFormTest.php index 8adda18c6..323482943 100644 --- a/tests/codeception/unit/models/ContactFormTest.php +++ b/tests/codeception/unit/models/ContactFormTest.php @@ -1,6 +1,6 @@ Date: Sun, 24 Aug 2014 15:26:57 +0400 Subject: [PATCH 054/390] Added faker to basic app console commands, adjusted readme to mention database setup --- tests/README.md | 26 +++++++++++++++++++++++--- tests/codeception/bin/yii_acceptance | 7 +++++++ tests/codeception/bin/yii_functional | 7 +++++++ tests/codeception/bin/yii_unit | 7 +++++++ tests/codeception/fixtures/.gitignore | 2 ++ tests/codeception/templates/.gitignore | 2 ++ 6 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 tests/codeception/fixtures/.gitignore create mode 100644 tests/codeception/templates/.gitignore diff --git a/tests/README.md b/tests/README.md index 1c4b50bca..34439f8a2 100644 --- a/tests/README.md +++ b/tests/README.md @@ -21,20 +21,40 @@ Changed current directory to Then add `/vendor/bin` to you `PATH` environment variable. Now we're able to use `codecept` from command line globally. -2. Build the test suites: +2. Install faker extension by running the following from template root directory where `composer.json` is: + +``` +composer require --dev yiisoft/yii2-faker:* +``` + +3. Create three databases that are used in tests: + +* `yii2_basic_unit` - for unit tests; +* `yii2_basic_functional` - for functional tests; +* `yii2_basic_acceptance` - for acceptance tests. + +Then update databases by applying migrations: + +``` +codeception/bin/yii_acceptance migrate +codeception/bin/yii_functional migrate +codeception/bin/yii_unit migrate +``` + +4. Build the test suites: ``` codecept build ``` -3. In order to be able to run acceptance tests you need to start a webserver. The simplest way is to use PHP built in +5. In order to be able to run acceptance tests you need to start a webserver. The simplest way is to use PHP built in webserver. In the `web` directory execute the following: ``` php -S localhost:8080 ``` -4. Now you can run the tests with the following commands: +6. Now you can run the tests with the following commands: ``` # run all available tests diff --git a/tests/codeception/bin/yii_acceptance b/tests/codeception/bin/yii_acceptance index f67a47fbb..99ac41747 100644 --- a/tests/codeception/bin/yii_acceptance +++ b/tests/codeception/bin/yii_acceptance @@ -14,6 +14,13 @@ $config = yii\helpers\ArrayHelper::merge( require(YII_APP_BASE_PATH . '/config/console.php'), require(__DIR__ . '/../config/config.php'), [ + 'controllerMap' => [ + 'fixture' => [ + 'class' => 'yii\faker\FixtureController', + 'fixtureDataPath' => dirname(__DIR__) . 'fixtures', + 'templatePath' => dirname(__DIR__) . 'templates' + ], + ], 'components' => [ 'db' => [ 'dsn' => 'mysql:host=localhost;dbname=yii2_basic_acceptance', diff --git a/tests/codeception/bin/yii_functional b/tests/codeception/bin/yii_functional index f6e3988a0..39efa983b 100644 --- a/tests/codeception/bin/yii_functional +++ b/tests/codeception/bin/yii_functional @@ -14,6 +14,13 @@ $config = yii\helpers\ArrayHelper::merge( require(YII_APP_BASE_PATH . '/config/console.php'), require(__DIR__ . '/../config/config.php'), [ + 'controllerMap' => [ + 'fixture' => [ + 'class' => 'yii\faker\FixtureController', + 'fixtureDataPath' => dirname(__DIR__) . 'fixtures', + 'templatePath' => dirname(__DIR__) . 'templates' + ], + ], 'components' => [ 'db' => [ 'dsn' => 'mysql:host=localhost;dbname=yii2_basic_functional', diff --git a/tests/codeception/bin/yii_unit b/tests/codeception/bin/yii_unit index 1ab8e1fba..f99ec5333 100644 --- a/tests/codeception/bin/yii_unit +++ b/tests/codeception/bin/yii_unit @@ -14,6 +14,13 @@ $config = yii\helpers\ArrayHelper::merge( require(YII_APP_BASE_PATH . '/config/console.php'), require(__DIR__ . '/../config/config.php'), [ + 'controllerMap' => [ + 'fixture' => [ + 'class' => 'yii\faker\FixtureController', + 'fixtureDataPath' => dirname(__DIR__) . 'fixtures', + 'templatePath' => dirname(__DIR__) . 'templates' + ], + ], 'components' => [ 'db' => [ 'dsn' => 'mysql:host=localhost;dbname=yii2_basic_unit', diff --git a/tests/codeception/fixtures/.gitignore b/tests/codeception/fixtures/.gitignore new file mode 100644 index 000000000..c96a04f00 --- /dev/null +++ b/tests/codeception/fixtures/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/tests/codeception/templates/.gitignore b/tests/codeception/templates/.gitignore new file mode 100644 index 000000000..c96a04f00 --- /dev/null +++ b/tests/codeception/templates/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file From 459ac478a2f2edab76f2a7058a104590fadc6605 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Mon, 25 Aug 2014 02:00:49 +0400 Subject: [PATCH 055/390] Used a single database and a single CLI entry point for all test types. Added faker to basic app dev requirements. --- composer.json | 3 +- tests/README.md | 12 ++----- tests/codeception/bin/{yii_unit => yii} | 5 --- .../bin/{yii_acceptance.bat => yii.bat} | 0 tests/codeception/bin/yii_acceptance | 34 ------------------- tests/codeception/bin/yii_functional | 34 ------------------- tests/codeception/bin/yii_functional.bat | 20 ----------- tests/codeception/bin/yii_unit.bat | 20 ----------- tests/codeception/config/acceptance.php | 6 +--- tests/codeception/config/config.php | 3 ++ tests/codeception/config/functional.php | 6 +--- tests/codeception/config/unit.php | 6 +--- 12 files changed, 10 insertions(+), 139 deletions(-) rename tests/codeception/bin/{yii_unit => yii} (84%) rename tests/codeception/bin/{yii_acceptance.bat => yii.bat} (100%) delete mode 100644 tests/codeception/bin/yii_acceptance delete mode 100644 tests/codeception/bin/yii_functional delete mode 100644 tests/codeception/bin/yii_functional.bat delete mode 100644 tests/codeception/bin/yii_unit.bat diff --git a/composer.json b/composer.json index 607accb1b..0966855a7 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,8 @@ "require-dev": { "yiisoft/yii2-codeception": "*", "yiisoft/yii2-debug": "*", - "yiisoft/yii2-gii": "*" + "yiisoft/yii2-gii": "*", + "yiisoft/yii2-faker": "*" }, "scripts": { "post-create-project-cmd": [ diff --git a/tests/README.md b/tests/README.md index 34439f8a2..f14db26a5 100644 --- a/tests/README.md +++ b/tests/README.md @@ -27,18 +27,10 @@ line globally. composer require --dev yiisoft/yii2-faker:* ``` -3. Create three databases that are used in tests: - -* `yii2_basic_unit` - for unit tests; -* `yii2_basic_functional` - for functional tests; -* `yii2_basic_acceptance` - for acceptance tests. - -Then update databases by applying migrations: +3. Create `yii2_basic_tests` database and update it by applying migrations: ``` -codeception/bin/yii_acceptance migrate -codeception/bin/yii_functional migrate -codeception/bin/yii_unit migrate +codeception/bin/yii migrate ``` 4. Build the test suites: diff --git a/tests/codeception/bin/yii_unit b/tests/codeception/bin/yii similarity index 84% rename from tests/codeception/bin/yii_unit rename to tests/codeception/bin/yii index f99ec5333..9046b488e 100644 --- a/tests/codeception/bin/yii_unit +++ b/tests/codeception/bin/yii @@ -21,11 +21,6 @@ $config = yii\helpers\ArrayHelper::merge( 'templatePath' => dirname(__DIR__) . 'templates' ], ], - 'components' => [ - 'db' => [ - 'dsn' => 'mysql:host=localhost;dbname=yii2_basic_unit', - ], - ], ] ); diff --git a/tests/codeception/bin/yii_acceptance.bat b/tests/codeception/bin/yii.bat similarity index 100% rename from tests/codeception/bin/yii_acceptance.bat rename to tests/codeception/bin/yii.bat diff --git a/tests/codeception/bin/yii_acceptance b/tests/codeception/bin/yii_acceptance deleted file mode 100644 index 99ac41747..000000000 --- a/tests/codeception/bin/yii_acceptance +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env php - [ - 'fixture' => [ - 'class' => 'yii\faker\FixtureController', - 'fixtureDataPath' => dirname(__DIR__) . 'fixtures', - 'templatePath' => dirname(__DIR__) . 'templates' - ], - ], - 'components' => [ - 'db' => [ - 'dsn' => 'mysql:host=localhost;dbname=yii2_basic_acceptance', - ], - ], - ] -); - -$application = new yii\console\Application($config); -$exitCode = $application->run(); -exit($exitCode); diff --git a/tests/codeception/bin/yii_functional b/tests/codeception/bin/yii_functional deleted file mode 100644 index 39efa983b..000000000 --- a/tests/codeception/bin/yii_functional +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env php - [ - 'fixture' => [ - 'class' => 'yii\faker\FixtureController', - 'fixtureDataPath' => dirname(__DIR__) . 'fixtures', - 'templatePath' => dirname(__DIR__) . 'templates' - ], - ], - 'components' => [ - 'db' => [ - 'dsn' => 'mysql:host=localhost;dbname=yii2_basic_functional', - ], - ], - ] -); - -$application = new yii\console\Application($config); -$exitCode = $application->run(); -exit($exitCode); diff --git a/tests/codeception/bin/yii_functional.bat b/tests/codeception/bin/yii_functional.bat deleted file mode 100644 index 2d04dcc71..000000000 --- a/tests/codeception/bin/yii_functional.bat +++ /dev/null @@ -1,20 +0,0 @@ -@echo off - -rem ------------------------------------------------------------- -rem Yii command line bootstrap script for Windows. -rem -rem @author Qiang Xue -rem @link http://www.yiiframework.com/ -rem @copyright Copyright (c) 2008 Yii Software LLC -rem @license http://www.yiiframework.com/license/ -rem ------------------------------------------------------------- - -@setlocal - -set YII_PATH=%~dp0 - -if "%PHP_COMMAND%" == "" set PHP_COMMAND=php.exe - -"%PHP_COMMAND%" "%YII_PATH%yii_functional" %* - -@endlocal diff --git a/tests/codeception/bin/yii_unit.bat b/tests/codeception/bin/yii_unit.bat deleted file mode 100644 index 6852bf0ca..000000000 --- a/tests/codeception/bin/yii_unit.bat +++ /dev/null @@ -1,20 +0,0 @@ -@echo off - -rem ------------------------------------------------------------- -rem Yii command line bootstrap script for Windows. -rem -rem @author Qiang Xue -rem @link http://www.yiiframework.com/ -rem @copyright Copyright (c) 2008 Yii Software LLC -rem @license http://www.yiiframework.com/license/ -rem ------------------------------------------------------------- - -@setlocal - -set YII_PATH=%~dp0 - -if "%PHP_COMMAND%" == "" set PHP_COMMAND=php.exe - -"%PHP_COMMAND%" "%YII_PATH%yii_unit" %* - -@endlocal diff --git a/tests/codeception/config/acceptance.php b/tests/codeception/config/acceptance.php index c80d4687a..c688575b6 100644 --- a/tests/codeception/config/acceptance.php +++ b/tests/codeception/config/acceptance.php @@ -6,10 +6,6 @@ require(__DIR__ . '/../../../config/web.php'), require(__DIR__ . '/config.php'), [ - 'components' => [ - 'db' => [ - 'dsn' => 'mysql:host=localhost;dbname=yii2_basic_acceptance', - ], - ], + ] ); diff --git a/tests/codeception/config/config.php b/tests/codeception/config/config.php index 005d365c4..bac901d63 100644 --- a/tests/codeception/config/config.php +++ b/tests/codeception/config/config.php @@ -4,6 +4,9 @@ */ return [ 'components' => [ + 'db' => [ + 'dsn' => 'mysql:host=localhost;dbname=yii2_basic_tests', + ], 'mailer' => [ 'useFileTransport' => true, ], diff --git a/tests/codeception/config/functional.php b/tests/codeception/config/functional.php index 32cd7c899..499ad5a9c 100644 --- a/tests/codeception/config/functional.php +++ b/tests/codeception/config/functional.php @@ -9,10 +9,6 @@ require(__DIR__ . '/../../../config/web.php'), require(__DIR__ . '/config.php'), [ - 'components' => [ - 'db' => [ - 'dsn' => 'mysql:host=localhost;dbname=yii2_basic_functional', - ], - ], + ] ); diff --git a/tests/codeception/config/unit.php b/tests/codeception/config/unit.php index 1b8772d5b..5bab5eaec 100644 --- a/tests/codeception/config/unit.php +++ b/tests/codeception/config/unit.php @@ -6,10 +6,6 @@ require(__DIR__ . '/../../../config/web.php'), require(__DIR__ . '/config.php'), [ - 'components' => [ - 'db' => [ - 'dsn' => 'mysql:host=localhost;dbname=yii2_basic_unit', - ], - ], + ] ); From 58842e3a249e6e3b9c4ae75e36ef3322dfd77017 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Tue, 26 Aug 2014 01:51:41 +0400 Subject: [PATCH 056/390] Used aliases for fixture directory definitions --- tests/codeception/bin/_bootstrap.php | 2 ++ tests/codeception/bin/yii | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/codeception/bin/_bootstrap.php b/tests/codeception/bin/_bootstrap.php index e56da4efa..c923193a3 100644 --- a/tests/codeception/bin/_bootstrap.php +++ b/tests/codeception/bin/_bootstrap.php @@ -10,3 +10,5 @@ require(YII_APP_BASE_PATH . '/vendor/autoload.php'); require(YII_APP_BASE_PATH . '/vendor/yiisoft/yii2/Yii.php'); + +Yii::setAlias('@tests', dirname(dirname(__DIR__))); diff --git a/tests/codeception/bin/yii b/tests/codeception/bin/yii index 9046b488e..fda028efc 100644 --- a/tests/codeception/bin/yii +++ b/tests/codeception/bin/yii @@ -17,8 +17,8 @@ $config = yii\helpers\ArrayHelper::merge( 'controllerMap' => [ 'fixture' => [ 'class' => 'yii\faker\FixtureController', - 'fixtureDataPath' => dirname(__DIR__) . 'fixtures', - 'templatePath' => dirname(__DIR__) . 'templates' + 'fixtureDataPath' => '@tests/codeception/fixtures', + 'templatePath' => '@tests/codeception/templates' ], ], ] From 078fb5b48fcb3ba1874f545d876b2e8e9b8fa02c Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Wed, 27 Aug 2014 16:44:00 -0400 Subject: [PATCH 057/390] new asset management WIP --- .bowerrc | 3 +++ bower.json | 8 ++++++++ 2 files changed, 11 insertions(+) create mode 100644 .bowerrc create mode 100644 bower.json diff --git a/.bowerrc b/.bowerrc new file mode 100644 index 000000000..16098e93d --- /dev/null +++ b/.bowerrc @@ -0,0 +1,3 @@ +{ + "directory" : "web/assets" +} \ No newline at end of file diff --git a/bower.json b/bower.json new file mode 100644 index 000000000..b3ec7cd2f --- /dev/null +++ b/bower.json @@ -0,0 +1,8 @@ +{ + "name": "yii2-basic", + "version": "1.0.0", + "dependencies": { + }, + "devDependencies": { + } +} From 7690a93b7fd285650691e86967773f88aab5f500 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Fri, 29 Aug 2014 14:54:49 -0400 Subject: [PATCH 058/390] new asset WIP [skip ci] --- bower.json | 2 +- web/assets/.gitignore | 2 -- web/assets/.gitkeep | 1 + 3 files changed, 2 insertions(+), 3 deletions(-) delete mode 100644 web/assets/.gitignore create mode 100644 web/assets/.gitkeep diff --git a/bower.json b/bower.json index b3ec7cd2f..2bcac4fbe 100644 --- a/bower.json +++ b/bower.json @@ -1,5 +1,5 @@ { - "name": "yii2-basic", + "name": "yii2-basic-app", "version": "1.0.0", "dependencies": { }, diff --git a/web/assets/.gitignore b/web/assets/.gitignore deleted file mode 100644 index c96a04f00..000000000 --- a/web/assets/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore \ No newline at end of file diff --git a/web/assets/.gitkeep b/web/assets/.gitkeep new file mode 100644 index 000000000..72e8ffc0d --- /dev/null +++ b/web/assets/.gitkeep @@ -0,0 +1 @@ +* From 74266596cf983f00ee279cae1d51e120623ccc35 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Tue, 2 Sep 2014 14:51:44 -0400 Subject: [PATCH 059/390] new asset WIP: renabled asset publishing --- .bowerrc | 4 ++-- web/assets/.gitignore | 2 ++ web/assets/.gitkeep | 1 - 3 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 web/assets/.gitignore delete mode 100644 web/assets/.gitkeep diff --git a/.bowerrc b/.bowerrc index 16098e93d..1669168f2 100644 --- a/.bowerrc +++ b/.bowerrc @@ -1,3 +1,3 @@ { - "directory" : "web/assets" -} \ No newline at end of file + "directory" : "vendor/bower" +} diff --git a/web/assets/.gitignore b/web/assets/.gitignore new file mode 100644 index 000000000..d6b7ef32c --- /dev/null +++ b/web/assets/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/web/assets/.gitkeep b/web/assets/.gitkeep deleted file mode 100644 index 72e8ffc0d..000000000 --- a/web/assets/.gitkeep +++ /dev/null @@ -1 +0,0 @@ -* From 8efbbcc66259d842d960c8b50428d17113d3e97b Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Tue, 2 Sep 2014 17:03:19 -0400 Subject: [PATCH 060/390] new asset WIP [skip ci] --- composer.json | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 0966855a7..72c67f28a 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,12 @@ "php": ">=5.4.0", "yiisoft/yii2": "*", "yiisoft/yii2-bootstrap": "*", - "yiisoft/yii2-swiftmailer": "*" + "yiisoft/yii2-swiftmailer": "*", + /* bower packages, added temporarily to test "composer-asset-plugin" */ + "bower-asset/bootstrap": "3.2.* | 3.1.* | 3.0.*", + "bower-asset/jquery": "2.1.1", + "bower-asset/jquery-ui": "1.11.*", + "bower-asset/typeahead.js": "0.10.*" }, "require-dev": { "yiisoft/yii2-codeception": "*", @@ -44,6 +49,10 @@ ], "config": [ "config/web.php" - ] + ], + "asset-installer-paths": { + "npm-asset-library": "vendor/npm", + "bower-asset-library": "vendor/bower" + } } } From d2840ad8fc1f3abe08f1a94274a3181dfed33fc1 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Tue, 2 Sep 2014 23:17:50 -0400 Subject: [PATCH 061/390] Added `yii\composer\Installer::postCreateProject()` and modified the syntax of calling installer methods in composer.json [skip ci] --- composer.json | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/composer.json b/composer.json index 0966855a7..ba8cfd03c 100644 --- a/composer.json +++ b/composer.json @@ -25,25 +25,26 @@ "yiisoft/yii2-gii": "*", "yiisoft/yii2-faker": "*" }, + "config": { + "process-timeout": 1800 + }, "scripts": { "post-create-project-cmd": [ - "yii\\composer\\Installer::setPermission", - "yii\\composer\\Installer::generateCookieValidationKey" + "yii\\composer\\Installer::postCreateProject" ] }, - "config": { - "process-timeout": 1800 - }, "extra": { - "writable": [ - "runtime", - "web/assets" - ], - "executable": [ - "yii" - ], - "config": [ - "config/web.php" - ] + "yii\\composer\\Installer::postCreateProject": { + "setPermission": [ + { + "runtime": "0777", + "web/assets": "0777", + "yii": "0755" + } + ], + "generateCookieValidationKey": [ + "config/web.php" + ] + } } } From a6b38ddef6b9354463aecc491fad0cb6ef8336a5 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Wed, 3 Sep 2014 10:02:31 -0400 Subject: [PATCH 062/390] cleaned up the key so that it can be filled up with a random key automatically when installed. --- config/web.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/web.php b/config/web.php index 4fde1b686..0b4c75295 100644 --- a/config/web.php +++ b/config/web.php @@ -9,7 +9,7 @@ 'components' => [ 'request' => [ // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation - 'cookieValidationKey' => 'thisIsAKey', + 'cookieValidationKey' => '', ], 'cache' => [ 'class' => 'yii\caching\FileCache', From f1df2e43363b70d3b746c3cfafa6d4551f9fcd70 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Thu, 4 Sep 2014 03:27:13 +0400 Subject: [PATCH 063/390] Fixes #4914 --- commands/HelloController.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/commands/HelloController.php b/commands/HelloController.php index 86ab8b853..9314fe7fd 100644 --- a/commands/HelloController.php +++ b/commands/HelloController.php @@ -27,4 +27,20 @@ public function actionIndex($message = 'hello world') { echo $message . "\n"; } + + public function actionTest() + { + echo 'Test?'; + } + +// public function getDescription($actionID = null) +// { +// return "I'm custom description for $actionID!"; +// } + + + public function getHelp($actionID = null) + { + return "I'm custom help for $actionID!"; + } } From 8017996cccc7f3f55bc5f21738ab89c542a7759f Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Thu, 4 Sep 2014 12:13:28 +0400 Subject: [PATCH 064/390] Reverted accidentally edited HelloController --- commands/HelloController.php | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/commands/HelloController.php b/commands/HelloController.php index 9314fe7fd..86ab8b853 100644 --- a/commands/HelloController.php +++ b/commands/HelloController.php @@ -27,20 +27,4 @@ public function actionIndex($message = 'hello world') { echo $message . "\n"; } - - public function actionTest() - { - echo 'Test?'; - } - -// public function getDescription($actionID = null) -// { -// return "I'm custom description for $actionID!"; -// } - - - public function getHelp($actionID = null) - { - return "I'm custom help for $actionID!"; - } } From cc50af25ec39fd4ac3955ea599816279a76623bd Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Sun, 14 Sep 2014 14:15:16 -0400 Subject: [PATCH 065/390] Finished console Gii. --- config/console.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/config/console.php b/config/console.php index 85297b3cb..31ed9c720 100644 --- a/config/console.php +++ b/config/console.php @@ -8,8 +8,11 @@ return [ 'id' => 'basic-console', 'basePath' => dirname(__DIR__), - 'bootstrap' => ['log'], + 'bootstrap' => ['log', 'gii'], 'controllerNamespace' => 'app\commands', + 'modules' => [ + 'gii' => 'yii\gii\Module', + ], 'components' => [ 'cache' => [ 'class' => 'yii\caching\FileCache', From 867182b31f8a7ab120f8517401109acc2a7290cc Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Tue, 16 Sep 2014 13:31:32 -0400 Subject: [PATCH 066/390] WIP --- README.md | 1 + composer.json | 7 +------ 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 452d030c2..43aaed8f7 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,7 @@ at [getcomposer.org](http://getcomposer.org/doc/00-intro.md#installation-nix). You can then install this application template using the following command: ~~~ +php composer.phar global require "fxp/composer-asset-plugin:~1.0" php composer.phar create-project --prefer-dist --stability=dev yiisoft/yii2-app-basic basic ~~~ diff --git a/composer.json b/composer.json index 72c67f28a..dc168d06e 100644 --- a/composer.json +++ b/composer.json @@ -17,12 +17,7 @@ "php": ">=5.4.0", "yiisoft/yii2": "*", "yiisoft/yii2-bootstrap": "*", - "yiisoft/yii2-swiftmailer": "*", - /* bower packages, added temporarily to test "composer-asset-plugin" */ - "bower-asset/bootstrap": "3.2.* | 3.1.* | 3.0.*", - "bower-asset/jquery": "2.1.1", - "bower-asset/jquery-ui": "1.11.*", - "bower-asset/typeahead.js": "0.10.*" + "yiisoft/yii2-swiftmailer": "*" }, "require-dev": { "yiisoft/yii2-codeception": "*", From 7411e65c5ebf1a7295a8f2b7b7db971976ca2119 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Tue, 16 Sep 2014 16:28:49 -0400 Subject: [PATCH 067/390] reverted a prior change. --- config/web.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/config/web.php b/config/web.php index 0b4c75295..1632a5aab 100644 --- a/config/web.php +++ b/config/web.php @@ -38,10 +38,6 @@ ], ], 'db' => require(__DIR__ . '/db.php'), - 'urlManager' => [ - 'enablePrettyUrl' => true, - 'showScriptName' => false, - ], ], 'params' => $params, ]; From 70c5f2eba08dbbe1d0ea97796c35797eaba04aad Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Tue, 16 Sep 2014 20:58:57 -0400 Subject: [PATCH 068/390] Fixed wrong instruction. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 43aaed8f7..bef61bd59 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ at [getcomposer.org](http://getcomposer.org/doc/00-intro.md#installation-nix). You can then install this application template using the following command: ~~~ -php composer.phar global require "fxp/composer-asset-plugin:~1.0" +php composer.phar global require "fxp/composer-asset-plugin:1.0.*@dev" php composer.phar create-project --prefer-dist --stability=dev yiisoft/yii2-app-basic basic ~~~ From 928d41cb5a97bf916d936b974cedc3d58c951a03 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Tue, 16 Sep 2014 23:26:40 -0400 Subject: [PATCH 069/390] removed empty bower.json files [skip ci] --- bower.json | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 bower.json diff --git a/bower.json b/bower.json deleted file mode 100644 index 2bcac4fbe..000000000 --- a/bower.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "yii2-basic-app", - "version": "1.0.0", - "dependencies": { - }, - "devDependencies": { - } -} From 1484e58b1bf8f43217a5d22c2a469773934975c5 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Fri, 19 Sep 2014 08:32:47 -0400 Subject: [PATCH 070/390] Switch to 1.0.0-beta1 for the composer asset plugin. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bef61bd59..b4f20c83f 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ at [getcomposer.org](http://getcomposer.org/doc/00-intro.md#installation-nix). You can then install this application template using the following command: ~~~ -php composer.phar global require "fxp/composer-asset-plugin:1.0.*@dev" +php composer.phar global require "fxp/composer-asset-plugin:1.0.0-beta1" php composer.phar create-project --prefer-dist --stability=dev yiisoft/yii2-app-basic basic ~~~ From 5c6b89762902a57202420ca013ba1463d60657b1 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Mon, 22 Sep 2014 13:10:46 +0200 Subject: [PATCH 071/390] Changed version constratints to be semantic versioning again - in composer the `~` operator is just a shortcut for `~1.0` = `>=1.0.0,<2.0.0` it does not prevent dev versions to be installed but neither does `1.*` - dev versions are constrolled via `minimum-stability` setting and the `@dev`, `@beta`, `@stable`,... settings. - setting bower packages that ship compiled files only with the stable release to use `@stable` in composer.json of the applictaions. This setting can be removed when we remove the `minimum-stability=dev` setting after GA. --- composer.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 56756ec81..64364dc9c 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,10 @@ "php": ">=5.4.0", "yiisoft/yii2": "*", "yiisoft/yii2-bootstrap": "*", - "yiisoft/yii2-swiftmailer": "*" + "yiisoft/yii2-swiftmailer": "*", + "bower-asset/jquery": "@stable", + "bower-asset/jquery-ui": "@stable", + "bower-asset/jquery.inputmask": "@stable" }, "require-dev": { "yiisoft/yii2-codeception": "*", From e0fb805eea2306fbd87b3ccf4c67bc0e4e145411 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Mon, 22 Sep 2014 17:34:18 +0200 Subject: [PATCH 072/390] improved version constraints for bower asset packages --- composer.json | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 64364dc9c..56756ec81 100644 --- a/composer.json +++ b/composer.json @@ -17,10 +17,7 @@ "php": ">=5.4.0", "yiisoft/yii2": "*", "yiisoft/yii2-bootstrap": "*", - "yiisoft/yii2-swiftmailer": "*", - "bower-asset/jquery": "@stable", - "bower-asset/jquery-ui": "@stable", - "bower-asset/jquery.inputmask": "@stable" + "yiisoft/yii2-swiftmailer": "*" }, "require-dev": { "yiisoft/yii2-codeception": "*", From 969b7a59968688709093013dcc8fd4a86fb4246f Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Sat, 27 Sep 2014 12:57:43 -0400 Subject: [PATCH 073/390] use 1.0.0-beta2 version for composer asset plugin. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b4f20c83f..61cb4a19c 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ at [getcomposer.org](http://getcomposer.org/doc/00-intro.md#installation-nix). You can then install this application template using the following command: ~~~ -php composer.phar global require "fxp/composer-asset-plugin:1.0.0-beta1" +php composer.phar global require "fxp/composer-asset-plugin:1.0.0-beta2" php composer.phar create-project --prefer-dist --stability=dev yiisoft/yii2-app-basic basic ~~~ From e3195677d58d7cfe0669a8cd98f33354c7296a71 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Sat, 27 Sep 2014 21:59:54 -0400 Subject: [PATCH 074/390] prepare for 2.0.0-rc release. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 56756ec81..e56ed648d 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "irc": "irc://irc.freenode.net/yii", "source": "https://github.com/yiisoft/yii2" }, - "minimum-stability": "dev", + "minimum-stability": "RC", "require": { "php": ">=5.4.0", "yiisoft/yii2": "*", From 039225e550fbb4712da713fc1648ee1817c74077 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Sun, 28 Sep 2014 01:44:31 -0400 Subject: [PATCH 075/390] prepare for next release. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e56ed648d..56756ec81 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "irc": "irc://irc.freenode.net/yii", "source": "https://github.com/yiisoft/yii2" }, - "minimum-stability": "RC", + "minimum-stability": "dev", "require": { "php": ">=5.4.0", "yiisoft/yii2": "*", From ac46b6dab6de9854b462ebee36ab6c3a24b481d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20H=C3=A4rtl?= Date: Mon, 29 Sep 2014 13:18:59 +0200 Subject: [PATCH 076/390] Issue 5160: Update base app to use bootstrap ActiveForm --- views/site/contact.php | 4 ++-- views/site/login.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/views/site/contact.php b/views/site/contact.php index fad2d7ced..e964a3426 100644 --- a/views/site/contact.php +++ b/views/site/contact.php @@ -1,10 +1,10 @@ title = 'Contact'; diff --git a/views/site/login.php b/views/site/login.php index df0c812aa..916be9808 100644 --- a/views/site/login.php +++ b/views/site/login.php @@ -1,9 +1,9 @@ title = 'Login'; From 2ab0180a5912e306c2646829af26957a4746739d Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Sun, 12 Oct 2014 13:09:06 -0400 Subject: [PATCH 077/390] 2.0.0 release. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 56756ec81..faf0732a1 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "irc": "irc://irc.freenode.net/yii", "source": "https://github.com/yiisoft/yii2" }, - "minimum-stability": "dev", + "minimum-stability": "stable", "require": { "php": ">=5.4.0", "yiisoft/yii2": "*", From 8ac36163c19b13cbb868c42ed0ee584926c17479 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Sun, 12 Oct 2014 16:44:45 -0400 Subject: [PATCH 078/390] prepare for next release. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index faf0732a1..56756ec81 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "irc": "irc://irc.freenode.net/yii", "source": "https://github.com/yiisoft/yii2" }, - "minimum-stability": "stable", + "minimum-stability": "dev", "require": { "php": ">=5.4.0", "yiisoft/yii2": "*", From 0a636b8cbd4874218fdec5f0917bc050f056582d Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Sun, 12 Oct 2014 18:13:22 -0400 Subject: [PATCH 079/390] Fixes #5509. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 61cb4a19c..36c3ec944 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ at [getcomposer.org](http://getcomposer.org/doc/00-intro.md#installation-nix). You can then install this application template using the following command: ~~~ -php composer.phar global require "fxp/composer-asset-plugin:1.0.0-beta2" +php composer.phar global require "fxp/composer-asset-plugin:1.0.0-beta3" php composer.phar create-project --prefer-dist --stability=dev yiisoft/yii2-app-basic basic ~~~ From e8aed03f1abcc35b8b7100d2bf226cff59729e24 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Sat, 18 Oct 2014 19:31:39 +0400 Subject: [PATCH 080/390] Fixed entry script name --- tests/codeception/bin/yii.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/codeception/bin/yii.bat b/tests/codeception/bin/yii.bat index 3edcabe95..d516b3a19 100644 --- a/tests/codeception/bin/yii.bat +++ b/tests/codeception/bin/yii.bat @@ -15,6 +15,6 @@ set YII_PATH=%~dp0 if "%PHP_COMMAND%" == "" set PHP_COMMAND=php.exe -"%PHP_COMMAND%" "%YII_PATH%yii_acceptance" %* +"%PHP_COMMAND%" "%YII_PATH%yii" %* @endlocal From d33ea353eba6f5df67ecfd52ccf54688efc61ed9 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Sun, 19 Oct 2014 01:22:26 +0400 Subject: [PATCH 081/390] Fixes #5598: added ImageMagick with PNG and GD with FreeType checks to requirements of basic and advanced applications, used better Captcha exception message --- requirements.php | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/requirements.php b/requirements.php index a38b9363f..4da063113 100644 --- a/requirements.php +++ b/requirements.php @@ -23,6 +23,28 @@ require_once($frameworkPath . '/requirements/YiiRequirementChecker.php'); $requirementsChecker = new YiiRequirementChecker(); +$gdMemo = $imagickMemo = 'Either GD PHP extension with FreeType support or ImageMagick PHP extension with PNG support is required for image CAPTCHA.'; +$gdOK = $imagickOK = false; + +if (extension_loaded('imagick')) { + $imagick = new Imagick(); + $imagickFormats = $imagick->queryFormats('PNG'); + if (in_array('PNG', $imagickFormats)) { + $imagickOK = true; + } else { + $imagickMemo = 'Imagick extension should be installed with PNG support in order to be used for image CAPTCHA.'; + } +} + +if (extension_loaded('gd')) { + $gdInfo = gd_info(); + if (!empty($gdInfo['FreeType Support'])) { + $gdOK = true; + } else { + $gdMemo = 'GD extension should be installed with FreeType support in order to be used for image CAPTCHA.'; + } +} + /** * Adjust requirements according to your application specifics. */ @@ -69,6 +91,21 @@ 'condition' => extension_loaded('apc'), 'by' => 'ApcCache', ), + // CAPTCHA: + array( + 'name' => 'GD PHP extension with FreeType support', + 'mandatory' => false, + 'condition' => $gdOK, + 'by' => 'Captcha', + 'memo' => $gdMemo, + ), + array( + 'name' => 'ImageMagick PHP extension with PNG support', + 'mandatory' => false, + 'condition' => $imagickOK, + 'by' => 'Captcha', + 'memo' => $imagickMemo, + ), // PHP ini : 'phpSafeMode' => array( 'name' => 'PHP safe mode', From d06d027a1ff35a2fcaa42afe9e87c3043faf0400 Mon Sep 17 00:00:00 2001 From: Alexander Mohorev Date: Sat, 25 Oct 2014 16:28:36 +0300 Subject: [PATCH 082/390] Correct order of property declaration --- models/LoginForm.php | 1 + 1 file changed, 1 insertion(+) diff --git a/models/LoginForm.php b/models/LoginForm.php index 687d29ded..7bd44d402 100644 --- a/models/LoginForm.php +++ b/models/LoginForm.php @@ -16,6 +16,7 @@ class LoginForm extends Model private $_user = false; + /** * @return array the validation rules. */ From c6908c8b438891550d821bfdbd76334ce75109a1 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Tue, 28 Oct 2014 02:03:02 +0300 Subject: [PATCH 083/390] Fixes #4827: default config for functional tests of both basic and advanced app now turns off CSRF validation while providing commented out alternative setting cookie domain to localhost --- tests/codeception/config/functional.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/codeception/config/functional.php b/tests/codeception/config/functional.php index 499ad5a9c..6d22bd97b 100644 --- a/tests/codeception/config/functional.php +++ b/tests/codeception/config/functional.php @@ -9,6 +9,17 @@ require(__DIR__ . '/../../../config/web.php'), require(__DIR__ . '/config.php'), [ - + 'components' => [ + 'request' => [ + // it's not recommended to run functional tests with CSRF validation enabled + 'enableCsrfValidation' => false, + // but if you absolutely need it set cookie domain to localhost + /* + 'csrfCookie' => [ + 'domain' => 'localhost', + ], + */ + ], + ], ] ); From 995c79103dade1c00a324274fd0a8d14320291ec Mon Sep 17 00:00:00 2001 From: Mark Ragazzo Date: Fri, 7 Nov 2014 23:20:03 +0400 Subject: [PATCH 084/390] fixed fixture controller config for applications --- tests/codeception/bin/yii | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/codeception/bin/yii b/tests/codeception/bin/yii index fda028efc..c7f2653ff 100644 --- a/tests/codeception/bin/yii +++ b/tests/codeception/bin/yii @@ -18,7 +18,8 @@ $config = yii\helpers\ArrayHelper::merge( 'fixture' => [ 'class' => 'yii\faker\FixtureController', 'fixtureDataPath' => '@tests/codeception/fixtures', - 'templatePath' => '@tests/codeception/templates' + 'templatePath' => '@tests/codeception/templates', + 'namespace' => 'tests\codeception\fixtures', ], ], ] From c10a6b46be2527cd8a8dabca1b94819519ff3fb6 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Sun, 23 Nov 2014 20:56:33 -0500 Subject: [PATCH 085/390] Fixes #6189 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 36c3ec944..36df77895 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ at [getcomposer.org](http://getcomposer.org/doc/00-intro.md#installation-nix). You can then install this application template using the following command: ~~~ -php composer.phar global require "fxp/composer-asset-plugin:1.0.0-beta3" +php composer.phar global require "fxp/composer-asset-plugin:1.0.0-beta4" php composer.phar create-project --prefer-dist --stability=dev yiisoft/yii2-app-basic basic ~~~ From 6b4ad97e43d09517a6b5681c3e753f8cd1dc58e6 Mon Sep 17 00:00:00 2001 From: Anton Andersen Date: Wed, 19 Nov 2014 14:37:13 +0300 Subject: [PATCH 086/390] Fixes #6103: Improved codeception config in app templates to ease testing of advanced app on multiple hosts --- tests/codeception.yml | 4 ++-- tests/codeception/_bootstrap.php | 5 +++-- tests/codeception/acceptance.suite.yml | 5 +++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/codeception.yml b/tests/codeception.yml index ba02c81b7..0a45a0c08 100644 --- a/tests/codeception.yml +++ b/tests/codeception.yml @@ -11,6 +11,6 @@ settings: log: true colors: true config: - # the entry script URL (without host info) for functional and acceptance tests + # the entry script URL (with host info) for functional and acceptance tests # PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL - test_entry_url: /index-test.php \ No newline at end of file + test_entry_url: http://localhost:8080/index-test.php \ No newline at end of file diff --git a/tests/codeception/_bootstrap.php b/tests/codeception/_bootstrap.php index 985593978..755029ef3 100644 --- a/tests/codeception/_bootstrap.php +++ b/tests/codeception/_bootstrap.php @@ -2,7 +2,7 @@ defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_ENV') or define('YII_ENV', 'test'); -defined('YII_TEST_ENTRY_URL') or define('YII_TEST_ENTRY_URL', \Codeception\Configuration::config()['config']['test_entry_url']); +defined('YII_TEST_ENTRY_URL') or define('YII_TEST_ENTRY_URL', parse_url(http://github.com/Codeception/Configuration::config()['config']['test_entry_url'], PHP_URL_PATH)); defined('YII_TEST_ENTRY_FILE') or define('YII_TEST_ENTRY_FILE', dirname(dirname(__DIR__)) . '/web/index-test.php'); require_once(__DIR__ . '/../../vendor/autoload.php'); @@ -10,6 +10,7 @@ $_SERVER['SCRIPT_FILENAME'] = YII_TEST_ENTRY_FILE; $_SERVER['SCRIPT_NAME'] = YII_TEST_ENTRY_URL; -$_SERVER['SERVER_NAME'] = 'localhost'; +$_SERVER['SERVER_NAME'] = parse_url(http://github.com/Codeception/Configuration::config()['config']['test_entry_url'], PHP_URL_HOST); +$_SERVER['SERVER_PORT'] = parse_url(http://github.com/Codeception/Configuration::config()['config']['test_entry_url'], PHP_URL_PORT) ?: '80'; Yii::setAlias('@tests', dirname(__DIR__)); diff --git a/tests/codeception/acceptance.suite.yml b/tests/codeception/acceptance.suite.yml index a045043cd..1781b0077 100644 --- a/tests/codeception/acceptance.suite.yml +++ b/tests/codeception/acceptance.suite.yml @@ -19,8 +19,9 @@ modules: # - WebDriver config: PhpBrowser: - url: 'http://localhost:8080/' +# PLEASE ADJUST IT TO THE ACTUAL ENTRY POINT WITHOUT PATH INFO + url: http://localhost:8080 # WebDriver: -# url: 'http://localhost/' +# url: http://localhost:8080 # browser: firefox # restart: true From abba09d7e6a656500ae4ce0ef1b1bb22225cd137 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Sun, 7 Dec 2014 11:42:41 -0500 Subject: [PATCH 087/390] prepare for 2.0.1 release --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 56756ec81..faf0732a1 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "irc": "irc://irc.freenode.net/yii", "source": "https://github.com/yiisoft/yii2" }, - "minimum-stability": "dev", + "minimum-stability": "stable", "require": { "php": ">=5.4.0", "yiisoft/yii2": "*", From dcc2e8fc6a2dc18615333cb44864bac7941eae67 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Sun, 7 Dec 2014 11:46:05 -0500 Subject: [PATCH 088/390] prepare for next release. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index faf0732a1..56756ec81 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "irc": "irc://irc.freenode.net/yii", "source": "https://github.com/yiisoft/yii2" }, - "minimum-stability": "stable", + "minimum-stability": "dev", "require": { "php": ">=5.4.0", "yiisoft/yii2": "*", From c6627551999ae6a266e774bbad57d0ce96bc34cd Mon Sep 17 00:00:00 2001 From: Mark Ragazzo Date: Wed, 10 Dec 2014 22:44:27 +0400 Subject: [PATCH 089/390] added code coverage ti yii2_basic --- tests/README.md | 48 +++++++++++++++++++++++++++++++++++++++++++ tests/codeception.yml | 20 ++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/tests/README.md b/tests/README.md index f14db26a5..b5c014176 100644 --- a/tests/README.md +++ b/tests/README.md @@ -59,5 +59,53 @@ codecept run functional codecept run unit ``` +Code coverage support +--------------------- + +By default, code coverage is disabled in `codeception.yaml` configuration file, you should uncomment needed rows to be able +to collect code coverage. You can run your tests and collect coverage with the following command: + +``` +#collect coverage for all tests +codecept run --coverage-html --coverage-xml + +#collect coverage only for unit tests +codecept run unit --coverage-html --coverage-xml + +#collect coverage for unit and functional tests +codecept run functional,unit --coverage-html --coverage-xml +``` + +You can see code coverage output under the `tests/_output` directory. + +###Remote code coverage + +When you run your tests not in the same process where code coverage is collected, then you should uncomment `remote` option and its +related options, to be able to collect code coverage correctly. To setup remote code coverage you should follow [instructions](http://codeception.com/docs/11-Codecoverage) +from codeception site. + +1. install Codeception c3 remote support `composer require "codeception/c3:*"`; + +2. copy c3.php file under your `web` directory and include; + +3. include `c3.php` file in your `index-test.php` file before application run, so it can catch needed requests. + +Configuration options that are used by remote code coverage: + +- c3_url: url pointing to entry script that includes `c3.php` file, so `Codeception` will be able to produce code coverage; +- remote: whether to enable remote code coverage or not; +- remote_config: path to the `codeception.yaml` configuration file, from the directory where `c3.php` file is located. This is needed + so that `Codeception` can create itself instance and collect code coverage correctly. + +By default `c3_url` and `remote_config` setup correctly, you only need to copy and include `c3.php` file in your `index-test.php` + +After that you should be able to collect code coverage from tests that run through `PhpBrowser` or `WebDriver` with same command +as for other tests: + +``` +#collect coverage from remote +codecept run acceptance --coverage-html --coverage-xml +``` + Please refer to [Codeception tutorial](http://codeception.com/docs/01-Introduction) for more details about writing and running acceptance, functional and unit tests. diff --git a/tests/codeception.yml b/tests/codeception.yml index 0a45a0c08..b71ba31c1 100644 --- a/tests/codeception.yml +++ b/tests/codeception.yml @@ -1,4 +1,24 @@ actor: Tester +#coverage: +# #c3_url: http://localhost:8080/index-test.php/ +# enabled: true +# #remote: true +# #remote_config: '../tests/codeception.yml' +# white_list: +# include: +# - ../models/* +# - ../controllers/* +# - ../commands/* +# - ../mail/* +# blacklist: +# include: +# - ../assets/* +# - ../config/* +# - ../runtime/* +# - ../vendor/* +# - ../views/* +# - ../web/* +# - ../tests/* paths: tests: codeception log: codeception/_output From aa583103a615d1d411e66d92cc37c7dd2e09d98a Mon Sep 17 00:00:00 2001 From: Mark Ragazzo Date: Wed, 10 Dec 2014 22:46:53 +0400 Subject: [PATCH 090/390] doc fix --- tests/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/README.md b/tests/README.md index b5c014176..3041b5f42 100644 --- a/tests/README.md +++ b/tests/README.md @@ -84,9 +84,9 @@ When you run your tests not in the same process where code coverage is collected related options, to be able to collect code coverage correctly. To setup remote code coverage you should follow [instructions](http://codeception.com/docs/11-Codecoverage) from codeception site. -1. install Codeception c3 remote support `composer require "codeception/c3:*"`; +1. install `Codeception c3` remote support `composer require "codeception/c3:*"`; -2. copy c3.php file under your `web` directory and include; +2. copy `c3.php` file under your `web` directory; 3. include `c3.php` file in your `index-test.php` file before application run, so it can catch needed requests. From aef33fd9698bdee5450581ed818e811c7e6aa10e Mon Sep 17 00:00:00 2001 From: Mark Ragazzo Date: Wed, 10 Dec 2014 23:01:08 +0400 Subject: [PATCH 091/390] fixed docs --- tests/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/README.md b/tests/README.md index 3041b5f42..8134fb3a7 100644 --- a/tests/README.md +++ b/tests/README.md @@ -62,7 +62,7 @@ codecept run unit Code coverage support --------------------- -By default, code coverage is disabled in `codeception.yaml` configuration file, you should uncomment needed rows to be able +By default, code coverage is disabled in `codeception.yml` configuration file, you should uncomment needed rows to be able to collect code coverage. You can run your tests and collect coverage with the following command: ``` @@ -94,7 +94,7 @@ Configuration options that are used by remote code coverage: - c3_url: url pointing to entry script that includes `c3.php` file, so `Codeception` will be able to produce code coverage; - remote: whether to enable remote code coverage or not; -- remote_config: path to the `codeception.yaml` configuration file, from the directory where `c3.php` file is located. This is needed +- remote_config: path to the `codeception.yml` configuration file, from the directory where `c3.php` file is located. This is needed so that `Codeception` can create itself instance and collect code coverage correctly. By default `c3_url` and `remote_config` setup correctly, you only need to copy and include `c3.php` file in your `index-test.php` From 8bcb38960fec5bb978b6b7cc86c0d1e284f66038 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Fri, 26 Dec 2014 23:18:52 +0300 Subject: [PATCH 092/390] Fixes #6624: Added delays to acceptance tests in order to make Selenium run more reliable --- tests/codeception/acceptance/ContactCept.php | 6 ++++++ tests/codeception/acceptance/LoginCept.php | 3 +++ 2 files changed, 9 insertions(+) diff --git a/tests/codeception/acceptance/ContactCept.php b/tests/codeception/acceptance/ContactCept.php index 98ba2ef12..4e8ee80b4 100644 --- a/tests/codeception/acceptance/ContactCept.php +++ b/tests/codeception/acceptance/ContactCept.php @@ -11,6 +11,9 @@ $I->amGoingTo('submit contact form with no data'); $contactPage->submit([]); +if (method_exists($I, 'wait')) { + $I->wait(3); // only for selenium +} $I->expectTo('see validations errors'); $I->see('Contact', 'h1'); $I->see('Name cannot be blank'); @@ -27,6 +30,9 @@ 'body' => 'test content', 'verifyCode' => 'testme', ]); +if (method_exists($I, 'wait')) { + $I->wait(3); // only for selenium +} $I->expectTo('see that email adress is wrong'); $I->dontSee('Name cannot be blank', '.help-inline'); $I->see('Email is not a valid email address.'); diff --git a/tests/codeception/acceptance/LoginCept.php b/tests/codeception/acceptance/LoginCept.php index 4f022e1c2..7575caf58 100644 --- a/tests/codeception/acceptance/LoginCept.php +++ b/tests/codeception/acceptance/LoginCept.php @@ -11,6 +11,9 @@ $I->amGoingTo('try to login with empty credentials'); $loginPage->login('', ''); +if (method_exists($I, 'wait')) { + $I->wait(3); // only for selenium +} $I->expectTo('see validations errors'); $I->see('Username cannot be blank.'); $I->see('Password cannot be blank.'); From b528289495bf9721d2b8c628d69caad42e45b0ce Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Fri, 2 Jan 2015 13:47:15 +0100 Subject: [PATCH 093/390] removed safe mode check this is not available in PHP >5.4.0 anyway. > This feature has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 5.4.0. http://php.net/manual/en/features.safe-mode.php --- requirements.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/requirements.php b/requirements.php index 4da063113..ee6b2cb53 100644 --- a/requirements.php +++ b/requirements.php @@ -107,13 +107,6 @@ 'memo' => $imagickMemo, ), // 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, From c302ff98ed31e7c247b36ab720a46e1a7837d315 Mon Sep 17 00:00:00 2001 From: Alex Solomaha Date: Sat, 24 Jan 2015 20:45:04 +0200 Subject: [PATCH 094/390] Odd symbol in meta tag There is no needed the "/" before closing. --- views/layouts/main.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/layouts/main.php b/views/layouts/main.php index b9dcfb97a..d5bba3a04 100644 --- a/views/layouts/main.php +++ b/views/layouts/main.php @@ -14,7 +14,7 @@ - + <?= Html::encode($this->title) ?> From 7b63966035f6418fc216b19d06206952c4a1b424 Mon Sep 17 00:00:00 2001 From: Davidson Alencar Date: Mon, 26 Jan 2015 08:52:46 -0200 Subject: [PATCH 095/390] adjust version composer-asset-plugin to 1.0.0 [ci skip] close #7024 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 36df77895..c5bec59a4 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ at [getcomposer.org](http://getcomposer.org/doc/00-intro.md#installation-nix). You can then install this application template using the following command: ~~~ -php composer.phar global require "fxp/composer-asset-plugin:1.0.0-beta4" +php composer.phar global require "fxp/composer-asset-plugin:1.0.0" php composer.phar create-project --prefer-dist --stability=dev yiisoft/yii2-app-basic basic ~~~ From d59a57c383fe0553f57a457734c3d2a67def272b Mon Sep 17 00:00:00 2001 From: Evgeniy Tkachenko Date: Thu, 29 Jan 2015 09:34:42 +0300 Subject: [PATCH 096/390] Fix undefined variable $scenario in test files. --- tests/codeception/acceptance/AboutCept.php | 2 ++ tests/codeception/acceptance/ContactCept.php | 2 ++ tests/codeception/acceptance/HomeCept.php | 2 ++ tests/codeception/acceptance/LoginCept.php | 2 ++ tests/codeception/functional/AboutCept.php | 2 ++ tests/codeception/functional/ContactCept.php | 2 ++ tests/codeception/functional/HomeCept.php | 2 ++ tests/codeception/functional/LoginCept.php | 2 ++ 8 files changed, 16 insertions(+) diff --git a/tests/codeception/acceptance/AboutCept.php b/tests/codeception/acceptance/AboutCept.php index 1ef220ebe..88a550698 100644 --- a/tests/codeception/acceptance/AboutCept.php +++ b/tests/codeception/acceptance/AboutCept.php @@ -2,6 +2,8 @@ use tests\codeception\_pages\AboutPage; +/* @var $scenario Codeception\Scenario */ + $I = new AcceptanceTester($scenario); $I->wantTo('ensure that about works'); AboutPage::openBy($I); diff --git a/tests/codeception/acceptance/ContactCept.php b/tests/codeception/acceptance/ContactCept.php index 4e8ee80b4..b51d1c085 100644 --- a/tests/codeception/acceptance/ContactCept.php +++ b/tests/codeception/acceptance/ContactCept.php @@ -2,6 +2,8 @@ use tests\codeception\_pages\ContactPage; +/* @var $scenario Codeception\Scenario */ + $I = new AcceptanceTester($scenario); $I->wantTo('ensure that contact works'); diff --git a/tests/codeception/acceptance/HomeCept.php b/tests/codeception/acceptance/HomeCept.php index 369ab7f48..1f9353595 100644 --- a/tests/codeception/acceptance/HomeCept.php +++ b/tests/codeception/acceptance/HomeCept.php @@ -1,5 +1,7 @@ wantTo('ensure that home page works'); $I->amOnPage(Yii::$app->homeUrl); diff --git a/tests/codeception/acceptance/LoginCept.php b/tests/codeception/acceptance/LoginCept.php index 7575caf58..90d063583 100644 --- a/tests/codeception/acceptance/LoginCept.php +++ b/tests/codeception/acceptance/LoginCept.php @@ -2,6 +2,8 @@ use tests\codeception\_pages\LoginPage; +/* @var $scenario Codeception\Scenario */ + $I = new AcceptanceTester($scenario); $I->wantTo('ensure that login works'); diff --git a/tests/codeception/functional/AboutCept.php b/tests/codeception/functional/AboutCept.php index ae7b45b30..09260612f 100644 --- a/tests/codeception/functional/AboutCept.php +++ b/tests/codeception/functional/AboutCept.php @@ -2,6 +2,8 @@ use tests\codeception\_pages\AboutPage; +/* @var $scenario Codeception\Scenario */ + $I = new FunctionalTester($scenario); $I->wantTo('ensure that about works'); AboutPage::openBy($I); diff --git a/tests/codeception/functional/ContactCept.php b/tests/codeception/functional/ContactCept.php index 47604058d..074820a70 100644 --- a/tests/codeception/functional/ContactCept.php +++ b/tests/codeception/functional/ContactCept.php @@ -2,6 +2,8 @@ use tests\codeception\_pages\ContactPage; +/* @var $scenario Codeception\Scenario */ + $I = new FunctionalTester($scenario); $I->wantTo('ensure that contact works'); diff --git a/tests/codeception/functional/HomeCept.php b/tests/codeception/functional/HomeCept.php index 80aa551fc..94efb09cd 100644 --- a/tests/codeception/functional/HomeCept.php +++ b/tests/codeception/functional/HomeCept.php @@ -1,5 +1,7 @@ wantTo('ensure that home page works'); $I->amOnPage(Yii::$app->homeUrl); diff --git a/tests/codeception/functional/LoginCept.php b/tests/codeception/functional/LoginCept.php index 991d27c3c..66e760989 100644 --- a/tests/codeception/functional/LoginCept.php +++ b/tests/codeception/functional/LoginCept.php @@ -2,6 +2,8 @@ use tests\codeception\_pages\LoginPage; +/* @var $scenario Codeception\Scenario */ + $I = new FunctionalTester($scenario); $I->wantTo('ensure that login works'); From d0d066faad37cb5258b75b9e40c1c21eddc2a952 Mon Sep 17 00:00:00 2001 From: Evgeniy Tkachenko Date: Thu, 29 Jan 2015 14:49:12 +0300 Subject: [PATCH 097/390] Move fixture configuration in config file --- tests/codeception/bin/yii | 12 +----------- tests/codeception/config/config.php | 10 ++++++++++ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/codeception/bin/yii b/tests/codeception/bin/yii index c7f2653ff..c6df160d8 100644 --- a/tests/codeception/bin/yii +++ b/tests/codeception/bin/yii @@ -12,17 +12,7 @@ require_once __DIR__ . '/_bootstrap.php'; $config = yii\helpers\ArrayHelper::merge( require(YII_APP_BASE_PATH . '/config/console.php'), - require(__DIR__ . '/../config/config.php'), - [ - 'controllerMap' => [ - 'fixture' => [ - 'class' => 'yii\faker\FixtureController', - 'fixtureDataPath' => '@tests/codeception/fixtures', - 'templatePath' => '@tests/codeception/templates', - 'namespace' => 'tests\codeception\fixtures', - ], - ], - ] + require(__DIR__ . '/../config/config.php') ); $application = new yii\console\Application($config); diff --git a/tests/codeception/config/config.php b/tests/codeception/config/config.php index bac901d63..e949051f2 100644 --- a/tests/codeception/config/config.php +++ b/tests/codeception/config/config.php @@ -3,6 +3,16 @@ * Application configuration shared by all test types */ return [ + [ + 'controllerMap' => [ + 'fixture' => [ + 'class' => 'yii\faker\FixtureController', + 'fixtureDataPath' => '@tests/codeception/fixtures', + 'templatePath' => '@tests/codeception/templates', + 'namespace' => 'tests\codeception\fixtures', + ], + ], + ], 'components' => [ 'db' => [ 'dsn' => 'mysql:host=localhost;dbname=yii2_basic_tests', From cea040a7cd327c52d6dbac22673dffc84731ad75 Mon Sep 17 00:00:00 2001 From: githubjeka Date: Thu, 29 Jan 2015 15:20:45 +0300 Subject: [PATCH 098/390] To fix break test --- tests/codeception/config/config.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/tests/codeception/config/config.php b/tests/codeception/config/config.php index e949051f2..ffc416bc6 100644 --- a/tests/codeception/config/config.php +++ b/tests/codeception/config/config.php @@ -3,14 +3,12 @@ * Application configuration shared by all test types */ return [ - [ - 'controllerMap' => [ - 'fixture' => [ - 'class' => 'yii\faker\FixtureController', - 'fixtureDataPath' => '@tests/codeception/fixtures', - 'templatePath' => '@tests/codeception/templates', - 'namespace' => 'tests\codeception\fixtures', - ], + 'controllerMap' => [ + 'fixture' => [ + 'class' => 'yii\faker\FixtureController', + 'fixtureDataPath' => '@tests/codeception/fixtures', + 'templatePath' => '@tests/codeception/templates', + 'namespace' => 'tests\codeception\fixtures', ], ], 'components' => [ From 22d6b9404b3473e3da2053094cc56fe414efc417 Mon Sep 17 00:00:00 2001 From: Alexander Kochetov Date: Thu, 26 Feb 2015 04:11:27 +0300 Subject: [PATCH 099/390] Fixed composer.json for basic app template --- composer.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 56756ec81..8479f76fe 100644 --- a/composer.json +++ b/composer.json @@ -15,15 +15,15 @@ "minimum-stability": "dev", "require": { "php": ">=5.4.0", - "yiisoft/yii2": "*", - "yiisoft/yii2-bootstrap": "*", - "yiisoft/yii2-swiftmailer": "*" + "yiisoft/yii2": "~2.0.0", + "yiisoft/yii2-bootstrap": "~2.0.0", + "yiisoft/yii2-swiftmailer": "~2.0.0" }, "require-dev": { - "yiisoft/yii2-codeception": "*", - "yiisoft/yii2-debug": "*", - "yiisoft/yii2-gii": "*", - "yiisoft/yii2-faker": "*" + "yiisoft/yii2-codeception": "~2.0.0", + "yiisoft/yii2-debug": "~2.0.0", + "yiisoft/yii2-gii": "~2.0.0", + "yiisoft/yii2-faker": "~2.0.0" }, "config": { "process-timeout": 1800 From 3bdaca21e4f176c934d2a25cd82f8016ad6d74f2 Mon Sep 17 00:00:00 2001 From: Alexander Kochetov Date: Thu, 26 Feb 2015 18:18:25 +0300 Subject: [PATCH 100/390] Removed min stability from composer.json for basic application template --- composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/composer.json b/composer.json index 8479f76fe..fdab5999a 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,6 @@ "irc": "irc://irc.freenode.net/yii", "source": "https://github.com/yiisoft/yii2" }, - "minimum-stability": "dev", "require": { "php": ">=5.4.0", "yiisoft/yii2": "~2.0.0", From 53443f822a438c2bc067053e93e4f06b99c3d1f0 Mon Sep 17 00:00:00 2001 From: Alexander Kochetov Date: Thu, 26 Feb 2015 18:20:50 +0300 Subject: [PATCH 101/390] Added prefered install option to composer.json for basic app template --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index fdab5999a..8b85c98af 100644 --- a/composer.json +++ b/composer.json @@ -25,6 +25,7 @@ "yiisoft/yii2-faker": "~2.0.0" }, "config": { + "preferred-install": "dist", "process-timeout": 1800 }, "scripts": { From ec62b3af3423464a14d7694a690c80de66f91aa6 Mon Sep 17 00:00:00 2001 From: Alexander Kochetov Date: Thu, 26 Feb 2015 18:21:58 +0300 Subject: [PATCH 102/390] Updated basic app template README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c5bec59a4..1207736ea 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ You can then install this application template using the following command: ~~~ php composer.phar global require "fxp/composer-asset-plugin:1.0.0" -php composer.phar create-project --prefer-dist --stability=dev yiisoft/yii2-app-basic basic +php composer.phar create-project yiisoft/yii2-app-basic basic ~~~ Now you should be able to access the application through the following URL, assuming `basic` is the directory From 413638137bfd0fcd61bbc37efdecc717fbb34fb4 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Fri, 27 Feb 2015 02:25:54 +0300 Subject: [PATCH 103/390] Reverted #7459, #7469, #7470 --- README.md | 2 +- composer.json | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 1207736ea..c5bec59a4 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ You can then install this application template using the following command: ~~~ php composer.phar global require "fxp/composer-asset-plugin:1.0.0" -php composer.phar create-project yiisoft/yii2-app-basic basic +php composer.phar create-project --prefer-dist --stability=dev yiisoft/yii2-app-basic basic ~~~ Now you should be able to access the application through the following URL, assuming `basic` is the directory diff --git a/composer.json b/composer.json index 8b85c98af..56756ec81 100644 --- a/composer.json +++ b/composer.json @@ -12,20 +12,20 @@ "irc": "irc://irc.freenode.net/yii", "source": "https://github.com/yiisoft/yii2" }, + "minimum-stability": "dev", "require": { "php": ">=5.4.0", - "yiisoft/yii2": "~2.0.0", - "yiisoft/yii2-bootstrap": "~2.0.0", - "yiisoft/yii2-swiftmailer": "~2.0.0" + "yiisoft/yii2": "*", + "yiisoft/yii2-bootstrap": "*", + "yiisoft/yii2-swiftmailer": "*" }, "require-dev": { - "yiisoft/yii2-codeception": "~2.0.0", - "yiisoft/yii2-debug": "~2.0.0", - "yiisoft/yii2-gii": "~2.0.0", - "yiisoft/yii2-faker": "~2.0.0" + "yiisoft/yii2-codeception": "*", + "yiisoft/yii2-debug": "*", + "yiisoft/yii2-gii": "*", + "yiisoft/yii2-faker": "*" }, "config": { - "preferred-install": "dist", "process-timeout": 1800 }, "scripts": { From 4ba6fe13b307a4a28f8e99cb81f0fbe7ddd3b08d Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Sun, 22 Mar 2015 20:14:19 +0100 Subject: [PATCH 104/390] added travis.yml --- .travis.yml | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..dc8724f4e --- /dev/null +++ b/.travis.yml @@ -0,0 +1,47 @@ +language: php + +php: + - 5.4 + - 5.5 + - 5.6 + - 7.0 +# - hhvm +# - hhvm-nightly + +# run build against hhvm but allow them to fail +# http://docs.travis-ci.com/user/build-configuration/#Rows-That-are-Allowed-To-Fail +matrix: + fast_finish: true + allow_failures: +# - php: hhvm-nightly + - php: 7.0 + +# faster builds on new travis setup not using sudo +sudo: false + +# cache vendor dirs +cache: + directories: + - vendor + - $HOME/.composer/cache + +install: + - travis_retry composer self-update && composer --version + - travis_retry composer global require "fxp/composer-asset-plugin:1.0.0" + - export PATH="$HOME/.composer/vendor/bin:$PATH" + - travis_retry composer install --dev --prefer-dist --no-interaction +# codeception + - travis_retry composer global require "codeception/codeception=2.0.*" "codeception/specify=*" "codeception/verify=*" +# setup application: + - | + sed -i "s/'cookieValidationKey' => ''/'cookieValidationKey' => 'testkey'/" config/web.php + cd tests + codecept build + cd .. + +script: + - | + cd web + php -S localhost:8080 > /dev/null 2>&1 & + cd ../tests + codecept run From 5b0679bddeb1139a5aa0f74d5ac5c1c415e0288b Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Sun, 22 Mar 2015 20:19:01 +0100 Subject: [PATCH 105/390] added travis and packagist badges --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index c5bec59a4..c0d14d56b 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,9 @@ The template contains the basic features including user login/logout and a conta It includes all commonly used configurations that would allow you to focus on adding new features to your application. +[![Latest Stable Version](https://poser.pugx.org/yiisoft/yii2-app-basic/v/stable.png)](https://packagist.org/packages/yiisoft/yii2-app-basic) +[![Total Downloads](https://poser.pugx.org/yiisoft/yii2-app-basic/downloads.png)](https://packagist.org/packages/yiisoft/yii2-app-basic) +[![Build Status](https://travis-ci.org/yiisoft/yii2-app-basic.svg?branch=master)](https://travis-ci.org/yiisoft/yii2-app-basic) DIRECTORY STRUCTURE ------------------- From b20814fea9e717215161aebcee329221770e1b31 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Sun, 22 Mar 2015 21:55:09 +0100 Subject: [PATCH 106/390] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c0d14d56b..7245bcb6a 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Yii 2 Basic Application Template ================================ -Yii 2 Basic Application Template is a skeleton Yii 2 application best for +Yii 2 Basic Application Template is a skeleton [Yii 2](http://www.yiiframework.com/) application best for rapidly creating small projects. The template contains the basic features including user login/logout and a contact page. From d091d08d17ebbd24be574a89b8050720dd511db7 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Thu, 2 Apr 2015 16:09:56 +0300 Subject: [PATCH 107/390] Renamed application template into project template in docs --- README.md | 10 +++++----- composer.json | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 7245bcb6a..587e755b8 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -Yii 2 Basic Application Template -================================ +Yii 2 Basic Project Template +============================ -Yii 2 Basic Application Template is a skeleton [Yii 2](http://www.yiiframework.com/) application best for +Yii 2 Basic Project Template is a skeleton [Yii 2](http://www.yiiframework.com/) application best for rapidly creating small projects. The template contains the basic features including user login/logout and a contact page. @@ -32,7 +32,7 @@ DIRECTORY STRUCTURE REQUIREMENTS ------------ -The minimum requirement by this application template that your Web server supports PHP 5.4.0. +The minimum requirement by this project template that your Web server supports PHP 5.4.0. INSTALLATION @@ -55,7 +55,7 @@ http://localhost/basic/web/ If you do not have [Composer](http://getcomposer.org/), you may install it by following the instructions at [getcomposer.org](http://getcomposer.org/doc/00-intro.md#installation-nix). -You can then install this application template using the following command: +You can then install this project template using the following command: ~~~ php composer.phar global require "fxp/composer-asset-plugin:1.0.0" diff --git a/composer.json b/composer.json index 56756ec81..a5cc0db57 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "yiisoft/yii2-app-basic", - "description": "Yii 2 Basic Application Template", - "keywords": ["yii2", "framework", "basic", "application template"], + "description": "Yii 2 Basic Project Template", + "keywords": ["yii2", "framework", "basic", "project template"], "homepage": "http://www.yiiframework.com/", "type": "project", "license": "BSD-3-Clause", From d72cfa6b634841569558326768b507eb5030ebd0 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Fri, 3 Apr 2015 00:48:16 +0300 Subject: [PATCH 108/390] Added .gitattributes --- .gitattributes | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..db48bac2b --- /dev/null +++ b/.gitattributes @@ -0,0 +1,7 @@ +# Ignore all test and documentation for archive +/.gitattributes export-ignore +/.gitignore export-ignore +/.scrutinizer.yml export-ignore +/.travis.yml export-ignore +/phpunit.xml.dist export-ignore +/docs export-ignore From 70148b06d83e22ce59399b565c2d86ff2a2d3d03 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Tue, 7 Apr 2015 12:32:38 +0300 Subject: [PATCH 109/390] Removed .gitignore from .gitattributes --- .gitattributes | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitattributes b/.gitattributes index db48bac2b..6b9d3d398 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,7 +1,5 @@ # Ignore all test and documentation for archive /.gitattributes export-ignore -/.gitignore export-ignore /.scrutinizer.yml export-ignore /.travis.yml export-ignore -/phpunit.xml.dist export-ignore /docs export-ignore From f71c712b8dd0036f78ef0e1394e8a229b31ae275 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Tue, 7 Apr 2015 13:00:08 +0300 Subject: [PATCH 110/390] Removed vendor from travis cache because it causes git build errors --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index dc8724f4e..8a9bd1cfb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,6 @@ sudo: false # cache vendor dirs cache: directories: - - vendor - $HOME/.composer/cache install: From 8ed0dfbdeb46f16b13e35fb76e5fd832ee8ad35a Mon Sep 17 00:00:00 2001 From: BlueZED Date: Wed, 22 Apr 2015 10:06:08 +0200 Subject: [PATCH 111/390] Fix for issue #5 Apply the template to the checkbox, not the field. --- views/site/login.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/views/site/login.php b/views/site/login.php index 916be9808..bca488c3f 100644 --- a/views/site/login.php +++ b/views/site/login.php @@ -27,9 +27,9 @@ field($model, 'password')->passwordInput() ?> - field($model, 'rememberMe', [ - 'template' => "

{input}
\n
{error}
", - ])->checkbox() ?> + field($model, 'rememberMe')->checkbox([ + 'template' => "
{input} {label}
\n
{error}
", + ]) ?>
From 8b4e2143ff7c3138b14a88fb6c7c03fc302048d1 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Wed, 6 May 2015 16:18:56 +0200 Subject: [PATCH 112/390] updated fxp/composer-asset-plugin version constraint --- .travis.yml | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8a9bd1cfb..72d788d58 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,7 +26,7 @@ cache: install: - travis_retry composer self-update && composer --version - - travis_retry composer global require "fxp/composer-asset-plugin:1.0.0" + - travis_retry composer global require "fxp/composer-asset-plugin:~1.0.0" - export PATH="$HOME/.composer/vendor/bin:$PATH" - travis_retry composer install --dev --prefer-dist --no-interaction # codeception diff --git a/README.md b/README.md index 587e755b8..e5a2d9f76 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ at [getcomposer.org](http://getcomposer.org/doc/00-intro.md#installation-nix). You can then install this project template using the following command: ~~~ -php composer.phar global require "fxp/composer-asset-plugin:1.0.0" +php composer.phar global require "fxp/composer-asset-plugin:~1.0.0" php composer.phar create-project --prefer-dist --stability=dev yiisoft/yii2-app-basic basic ~~~ From a8719e2ef34ded2a7e38f784b4c6ef667d01b157 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Sun, 10 May 2015 01:01:36 +0200 Subject: [PATCH 113/390] Update README.md fixed markdown to display steps correctly. --- tests/README.md | 66 ++++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/tests/README.md b/tests/README.md index 8134fb3a7..ddd70a53a 100644 --- a/tests/README.md +++ b/tests/README.md @@ -6,58 +6,58 @@ After creating the basic application, follow these steps to prepare for the test 1. Install Codeception if it's not yet installed: -``` -composer global require "codeception/codeception=2.0.*" -composer global require "codeception/specify=*" -composer global require "codeception/verify=*" -``` + ``` + composer global require "codeception/codeception=2.0.*" + composer global require "codeception/specify=*" + composer global require "codeception/verify=*" + ``` -If you've never used Composer for global packages run `composer global status`. It should output: + If you've never used Composer for global packages run `composer global status`. It should output: -``` -Changed current directory to -``` + ``` + Changed current directory to + ``` -Then add `/vendor/bin` to you `PATH` environment variable. Now we're able to use `codecept` from command -line globally. + Then add `/vendor/bin` to you `PATH` environment variable. Now we're able to use `codecept` from command + line globally. 2. Install faker extension by running the following from template root directory where `composer.json` is: -``` -composer require --dev yiisoft/yii2-faker:* -``` + ``` + composer require --dev yiisoft/yii2-faker:* + ``` 3. Create `yii2_basic_tests` database and update it by applying migrations: -``` -codeception/bin/yii migrate -``` + ``` + codeception/bin/yii migrate + ``` 4. Build the test suites: -``` -codecept build -``` + ``` + codecept build + ``` 5. In order to be able to run acceptance tests you need to start a webserver. The simplest way is to use PHP built in webserver. In the `web` directory execute the following: -``` -php -S localhost:8080 -``` + ``` + php -S localhost:8080 + ``` 6. Now you can run the tests with the following commands: -``` -# run all available tests -codecept run -# run acceptance tests -codecept run acceptance -# run functional tests -codecept run functional -# run unit tests -codecept run unit -``` + ``` + # run all available tests + codecept run + # run acceptance tests + codecept run acceptance + # run functional tests + codecept run functional + # run unit tests + codecept run unit + ``` Code coverage support --------------------- From 9954bb3b51c6196d23563c0301e46f53ca2c1390 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Sun, 10 May 2015 01:17:26 +0200 Subject: [PATCH 114/390] be more clear about migrations --- tests/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/README.md b/tests/README.md index ddd70a53a..eb2f24b6a 100644 --- a/tests/README.md +++ b/tests/README.md @@ -27,7 +27,7 @@ After creating the basic application, follow these steps to prepare for the test composer require --dev yiisoft/yii2-faker:* ``` -3. Create `yii2_basic_tests` database and update it by applying migrations: +3. Create `yii2_basic_tests` database and update it by applying migrations (you may skip this step if you do not have created any migrations yet): ``` codeception/bin/yii migrate From 6db812e9891200dd834c8bf47db39bddc6c9da74 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Sun, 10 May 2015 18:06:11 -0400 Subject: [PATCH 115/390] 2.0.4 release --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index a5cc0db57..3b5c61697 100644 --- a/composer.json +++ b/composer.json @@ -12,10 +12,10 @@ "irc": "irc://irc.freenode.net/yii", "source": "https://github.com/yiisoft/yii2" }, - "minimum-stability": "dev", + "minimum-stability": "stable", "require": { "php": ">=5.4.0", - "yiisoft/yii2": "*", + "yiisoft/yii2": ">=2.0.4", "yiisoft/yii2-bootstrap": "*", "yiisoft/yii2-swiftmailer": "*" }, From ff7b5adae524ec52fe0d99d3e1a7ccd4d4edbef1 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Sun, 10 May 2015 18:27:13 -0400 Subject: [PATCH 116/390] prepare for next release --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 3b5c61697..1dabd3bc1 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "irc": "irc://irc.freenode.net/yii", "source": "https://github.com/yiisoft/yii2" }, - "minimum-stability": "stable", + "minimum-stability": "dev", "require": { "php": ">=5.4.0", "yiisoft/yii2": ">=2.0.4", From ff0a3944bfb5edfd38fa8989603778178f186191 Mon Sep 17 00:00:00 2001 From: Evgeniy Tkachenko Date: Wed, 13 May 2015 14:14:06 +0300 Subject: [PATCH 117/390] Update config.php --- tests/codeception/config/config.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/codeception/config/config.php b/tests/codeception/config/config.php index ffc416bc6..d4e1f77ce 100644 --- a/tests/codeception/config/config.php +++ b/tests/codeception/config/config.php @@ -3,6 +3,7 @@ * Application configuration shared by all test types */ return [ + 'language' => 'en-US', 'controllerMap' => [ 'fixture' => [ 'class' => 'yii\faker\FixtureController', From 8a1f362e9f64b54a725e1b4b1ba42d6eae3512b5 Mon Sep 17 00:00:00 2001 From: MaximAL Date: Fri, 5 Jun 2015 17:39:43 +0300 Subject: [PATCH 118/390] Remove redundant `else`s --- controllers/SiteController.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/controllers/SiteController.php b/controllers/SiteController.php index f95994160..4ffba24cb 100644 --- a/controllers/SiteController.php +++ b/controllers/SiteController.php @@ -61,11 +61,10 @@ public function actionLogin() $model = new LoginForm(); if ($model->load(Yii::$app->request->post()) && $model->login()) { return $this->goBack(); - } else { - return $this->render('login', [ - 'model' => $model, - ]); } + return $this->render('login', [ + 'model' => $model, + ]); } public function actionLogout() @@ -82,11 +81,10 @@ public function actionContact() Yii::$app->session->setFlash('contactFormSubmitted'); return $this->refresh(); - } else { - return $this->render('contact', [ - 'model' => $model, - ]); } + return $this->render('contact', [ + 'model' => $model, + ]); } public function actionAbout() From a52ca24ecd14aacb307a5dd011ff2dc6690e0371 Mon Sep 17 00:00:00 2001 From: MaximAL Date: Fri, 5 Jun 2015 17:40:49 +0300 Subject: [PATCH 119/390] Update LoginForm.php --- models/LoginForm.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/models/LoginForm.php b/models/LoginForm.php index 7bd44d402..227168cf6 100644 --- a/models/LoginForm.php +++ b/models/LoginForm.php @@ -58,9 +58,8 @@ public function login() { if ($this->validate()) { return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600*24*30 : 0); - } else { - return false; } + return false; } /** From 0915b934abed59654094d399616f54a40e55ac1e Mon Sep 17 00:00:00 2001 From: MaximAL Date: Fri, 5 Jun 2015 17:41:11 +0300 Subject: [PATCH 120/390] Update ContactForm.php --- models/ContactForm.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/models/ContactForm.php b/models/ContactForm.php index d4052ee93..361b80b39 100644 --- a/models/ContactForm.php +++ b/models/ContactForm.php @@ -57,8 +57,7 @@ public function contact($email) ->send(); return true; - } else { - return false; } + return false; } } From 72c2d75419c95f99ee7cc0a800b45a95ae765622 Mon Sep 17 00:00:00 2001 From: Alex Solomaha Date: Thu, 9 Jul 2015 12:47:20 +0300 Subject: [PATCH 121/390] Views match Yii2 View Code Style close #18 --- views/layouts/main.php | 82 +++++++++++++++++++++-------------------- views/site/about.php | 4 +- views/site/contact.php | 83 ++++++++++++++++++++++++------------------ views/site/error.php | 4 +- views/site/index.php | 2 + views/site/login.php | 23 ++++++------ 6 files changed, 109 insertions(+), 89 deletions(-) diff --git a/views/layouts/main.php b/views/layouts/main.php index d5bba3a04..d5b1b49ee 100644 --- a/views/layouts/main.php +++ b/views/layouts/main.php @@ -1,13 +1,14 @@ beginPage() ?> @@ -21,47 +22,50 @@ head() ?> - beginBody() ?> -
- 'My Company', - 'brandUrl' => Yii::$app->homeUrl, - 'options' => [ - 'class' => 'navbar-inverse navbar-fixed-top', - ], - ]); - echo Nav::widget([ - 'options' => ['class' => 'navbar-nav navbar-right'], - 'items' => [ - ['label' => 'Home', 'url' => ['/site/index']], - ['label' => 'About', 'url' => ['/site/about']], - ['label' => 'Contact', 'url' => ['/site/contact']], - Yii::$app->user->isGuest ? - ['label' => 'Login', 'url' => ['/site/login']] : - ['label' => 'Logout (' . Yii::$app->user->identity->username . ')', - 'url' => ['/site/logout'], - 'linkOptions' => ['data-method' => 'post']], + +
+ 'My Company', + 'brandUrl' => Yii::$app->homeUrl, + 'options' => [ + 'class' => 'navbar-inverse navbar-fixed-top', + ], + ]); + echo Nav::widget([ + 'options' => ['class' => 'navbar-nav navbar-right'], + 'items' => [ + ['label' => 'Home', 'url' => ['/site/index']], + ['label' => 'About', 'url' => ['/site/about']], + ['label' => 'Contact', 'url' => ['/site/contact']], + Yii::$app->user->isGuest ? + ['label' => 'Login', 'url' => ['/site/login']] : + [ + 'label' => 'Logout (' . Yii::$app->user->identity->username . ')', + 'url' => ['/site/logout'], + 'linkOptions' => ['data-method' => 'post'] ], - ]); - NavBar::end(); - ?> + ], + ]); + NavBar::end(); + ?> -
- isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [], - ]) ?> - -
+
+ isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [], + ]) ?> +
+
+ +
+
+

© My Company

-
-
-

© My Company

-

-
-
+

+
+
endBody() ?> diff --git a/views/site/about.php b/views/site/about.php index 13d85a618..68d5cf3bd 100644 --- a/views/site/about.php +++ b/views/site/about.php @@ -1,7 +1,9 @@ title = 'About'; $this->params['breadcrumbs'][] = $this->title; ?> diff --git a/views/site/contact.php b/views/site/contact.php index e964a3426..22a75bbcc 100644 --- a/views/site/contact.php +++ b/views/site/contact.php @@ -1,12 +1,13 @@ title = 'Contact'; $this->params['breadcrumbs'][] = $this->title; ?> @@ -15,43 +16,53 @@ session->hasFlash('contactFormSubmitted')): ?> -
- Thank you for contacting us. We will respond to you as soon as possible. -
- -

- 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. - mailer->useFileTransport): ?> - Because the application is in development mode, the email is not sent but saved as - a file under mailer->fileTransportPath) ?>. - Please configure the useFileTransport property of the mail - application component to be false to enable email sending. - -

+
+ Thank you for contacting us. We will respond to you as soon as possible. +
+ +

+ 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. + mailer->useFileTransport): ?> + Because the application is in development mode, the email is not sent but saved as + a file under mailer->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. -

- -
-
- 'contact-form']); ?> - field($model, 'name') ?> - field($model, 'email') ?> - field($model, 'subject') ?> - field($model, 'body')->textArea(['rows' => 6]) ?> - field($model, 'verifyCode')->widget(Captcha::className(), [ - 'template' => '
{image}
{input}
', - ]) ?> -
- 'btn btn-primary', 'name' => 'contact-button']) ?> -
- +

+ If you have business inquiries or other questions, please fill out the following form to contact us. + Thank you. +

+ +
+
+ + 'contact-form']); ?> + + field($model, 'name') ?> + + field($model, 'email') ?> + + field($model, 'subject') ?> + + field($model, 'body')->textArea(['rows' => 6]) ?> + + field($model, 'verifyCode')->widget(Captcha::className(), [ + 'template' => '
{image}
{input}
', + ]) ?> + +
+ 'btn btn-primary', 'name' => 'contact-button']) ?> +
+ + + +
-
diff --git a/views/site/error.php b/views/site/error.php index b9812c488..0ba257465 100644 --- a/views/site/error.php +++ b/views/site/error.php @@ -1,12 +1,12 @@ title = $name; ?>
diff --git a/views/site/index.php b/views/site/index.php index a00ee4da6..f78061088 100644 --- a/views/site/index.php +++ b/views/site/index.php @@ -1,5 +1,7 @@ title = 'My Yii Application'; ?>
diff --git a/views/site/login.php b/views/site/login.php index bca488c3f..059ef8048 100644 --- a/views/site/login.php +++ b/views/site/login.php @@ -1,11 +1,12 @@ title = 'Login'; $this->params['breadcrumbs'][] = $this->title; ?> @@ -23,19 +24,19 @@ ], ]); ?> - field($model, 'username') ?> + field($model, 'username') ?> - field($model, 'password')->passwordInput() ?> + field($model, 'password')->passwordInput() ?> - field($model, 'rememberMe')->checkbox([ - 'template' => "
{input} {label}
\n
{error}
", - ]) ?> + field($model, 'rememberMe')->checkbox([ + 'template' => "
{input} {label}
\n
{error}
", + ]) ?> -
-
- 'btn btn-primary', 'name' => 'login-button']) ?> +
+
+ 'btn btn-primary', 'name' => 'login-button']) ?> +
-
From 757f5dc6bddedaa848c4f183eaccf6a72b95f181 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Sat, 11 Jul 2015 14:21:16 +0200 Subject: [PATCH 122/390] bump yii version for security fix --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 1dabd3bc1..4ad378784 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "minimum-stability": "dev", "require": { "php": ">=5.4.0", - "yiisoft/yii2": ">=2.0.4", + "yiisoft/yii2": ">=2.0.5", "yiisoft/yii2-bootstrap": "*", "yiisoft/yii2-swiftmailer": "*" }, From 734f8b419d3fa6c0685355450a58d534fdafb4ff Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Sat, 11 Jul 2015 18:05:41 +0200 Subject: [PATCH 123/390] removed duplicate declares these are now defined automatically by console application if needed. see https://github.com/yiisoft/yii2/issues/6853 --- tests/codeception/bin/_bootstrap.php | 4 ---- yii | 4 ---- 2 files changed, 8 deletions(-) diff --git a/tests/codeception/bin/_bootstrap.php b/tests/codeception/bin/_bootstrap.php index c923193a3..bbadc36ef 100644 --- a/tests/codeception/bin/_bootstrap.php +++ b/tests/codeception/bin/_bootstrap.php @@ -2,10 +2,6 @@ defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_ENV') or define('YII_ENV', 'test'); -// fcgi doesn't have STDIN and STDOUT defined by default -defined('STDIN') or define('STDIN', fopen('php://stdin', 'r')); -defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w')); - defined('YII_APP_BASE_PATH') or define('YII_APP_BASE_PATH', dirname(dirname(dirname(__DIR__)))); require(YII_APP_BASE_PATH . '/vendor/autoload.php'); diff --git a/yii b/yii index b032ebdbc..43aa26056 100755 --- a/yii +++ b/yii @@ -10,10 +10,6 @@ defined('YII_DEBUG') or define('YII_DEBUG', true); -// fcgi doesn't have STDIN and STDOUT defined by default -defined('STDIN') or define('STDIN', fopen('php://stdin', 'r')); -defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w')); - require(__DIR__ . '/vendor/autoload.php'); require(__DIR__ . '/vendor/yiisoft/yii2/Yii.php'); From 73ede01ebd2d4459d62de54923b1016ece7cbb1d Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Tue, 21 Jul 2015 00:57:16 +0300 Subject: [PATCH 124/390] More novice friendly config for gii/debug --- config/web.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/config/web.php b/config/web.php index 1632a5aab..fd03861d7 100644 --- a/config/web.php +++ b/config/web.php @@ -45,10 +45,14 @@ if (YII_ENV_DEV) { // configuration adjustments for 'dev' environment $config['bootstrap'][] = 'debug'; - $config['modules']['debug'] = 'yii\debug\Module'; + $config['modules']['debug'] = [ + 'class' => 'yii\debug\Module', + ]; $config['bootstrap'][] = 'gii'; - $config['modules']['gii'] = 'yii\gii\Module'; + $config['modules']['gii'] = [ + 'class' => 'yii\gii\Module', + ]; } return $config; From a418720887ea4220a8415bab443d22e51c168cad Mon Sep 17 00:00:00 2001 From: MaximAL Date: Tue, 28 Jul 2015 18:45:49 +0300 Subject: [PATCH 125/390] Add `cookieValidationKey` setting to the `Install from an Archive File` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Without this, basic application doesn’t work. --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index e5a2d9f76..09426cb81 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,15 @@ INSTALLATION Extract the archive file downloaded from [yiiframework.com](http://www.yiiframework.com/download/) to a directory named `basic` that is directly under the Web root. +Set cookie validation key in `config/web.php` file to some random secret string: + +```php +'request' => [ + // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation + 'cookieValidationKey' => '', +], +``` + You can then access the application through the following URL: ~~~ From 5598a50160cb133ea1c90b2bd807539275f3aab8 Mon Sep 17 00:00:00 2001 From: alcaneo Date: Tue, 4 Aug 2015 10:18:35 +0200 Subject: [PATCH 126/390] Add step to setup config file path in c3.php Hi, I've been struggling in making remote code coverage work and I finally figured out that the config file path was wrong. I haven't seen any documentation telling to update that path (weird). Furthermore, it is kind of impossible to debug as it generates a corrupted tar file (because of the error generated by the wrong config file path probably) that ends up by having an non-related error message (like "unable to decompress gzipped phar archive"). There is another way to do it, by setting the env var HTTP_X_CODECEPTION_CODECOVERAGE_CONFIG but, even though I don't like changing manually c3.php, I still prefer that than using env var as it wouldn't be linked anymore with your project but with your environment (that can be shared with other projects) settings. And I don't know if it would be possible that codeception set this var (as it actually knows the path) to make it available to c3.php, in fact I haven't seen anything setting this var up in codeception code. Cheers, Nico --- tests/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/README.md b/tests/README.md index eb2f24b6a..266bcf929 100644 --- a/tests/README.md +++ b/tests/README.md @@ -90,6 +90,8 @@ from codeception site. 3. include `c3.php` file in your `index-test.php` file before application run, so it can catch needed requests. +4. edit `c3.php` to update config file path (~ line 55) with `$config_file = realpath(__DIR__ . '../tests/codeception.yml');` + Configuration options that are used by remote code coverage: - c3_url: url pointing to entry script that includes `c3.php` file, so `Codeception` will be able to produce code coverage; From e01b9d1cbdff51c1edc69bbbd564d083cc37f91d Mon Sep 17 00:00:00 2001 From: alcaneo Date: Tue, 4 Aug 2015 10:49:22 +0200 Subject: [PATCH 127/390] Missing directory separator in config file path Ugly typo, my bad sorry --- tests/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/README.md b/tests/README.md index 266bcf929..2e1b1aedb 100644 --- a/tests/README.md +++ b/tests/README.md @@ -90,7 +90,7 @@ from codeception site. 3. include `c3.php` file in your `index-test.php` file before application run, so it can catch needed requests. -4. edit `c3.php` to update config file path (~ line 55) with `$config_file = realpath(__DIR__ . '../tests/codeception.yml');` +4. edit `c3.php` to update config file path (~ line 55) with `$config_file = realpath(__DIR__ . '/../tests/codeception.yml');` Configuration options that are used by remote code coverage: From bea667efdcbc4a861f888394cba48b79ad5e51f2 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Thu, 6 Aug 2015 00:21:54 +0200 Subject: [PATCH 128/390] updated tests readme close #4 --- tests/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/README.md b/tests/README.md index 2e1b1aedb..a34f68bb9 100644 --- a/tests/README.md +++ b/tests/README.md @@ -33,6 +33,9 @@ After creating the basic application, follow these steps to prepare for the test codeception/bin/yii migrate ``` + The command needs to be run in the `tests` directory. + The database configuration can be found at `tests/codeception/config/config.php`. + 4. Build the test suites: ``` From 3159d797b754d99c5d8adf8a492ba7522b467ddd Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Thu, 6 Aug 2015 00:23:55 +0200 Subject: [PATCH 129/390] prepare for release 2.0.6 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 4ad378784..1631da65c 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "irc": "irc://irc.freenode.net/yii", "source": "https://github.com/yiisoft/yii2" }, - "minimum-stability": "dev", + "minimum-stability": "stable", "require": { "php": ">=5.4.0", "yiisoft/yii2": ">=2.0.5", From 698c3b849ecca98f43ab30db8f0d1970f21f81af Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Thu, 6 Aug 2015 00:25:54 +0200 Subject: [PATCH 130/390] prepare for next release --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 1631da65c..4ad378784 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "irc": "irc://irc.freenode.net/yii", "source": "https://github.com/yiisoft/yii2" }, - "minimum-stability": "stable", + "minimum-stability": "dev", "require": { "php": ">=5.4.0", "yiisoft/yii2": ">=2.0.5", From 4cedb4db03e1cbdef80f66a64d2b3df1788ad265 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Tue, 8 Sep 2015 01:33:03 +0300 Subject: [PATCH 131/390] Added commented urlManager configuration example to config file --- config/web.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/config/web.php b/config/web.php index fd03861d7..90a82876b 100644 --- a/config/web.php +++ b/config/web.php @@ -38,6 +38,14 @@ ], ], 'db' => require(__DIR__ . '/db.php'), + /* + 'urlManager' => [ + 'enablePrettyUrl' => true, + 'showScriptName' => false, + 'rules' => [ + ], + ], + */ ], 'params' => $params, ]; From f60f7647c57d7ec535812c77fe34cc7b9020c403 Mon Sep 17 00:00:00 2001 From: Daniel Gomez Pan Date: Tue, 8 Sep 2015 23:18:39 +0200 Subject: [PATCH 132/390] remove gii module in production --- config/console.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/config/console.php b/config/console.php index 31ed9c720..e5315b913 100644 --- a/config/console.php +++ b/config/console.php @@ -5,14 +5,11 @@ $params = require(__DIR__ . '/params.php'); $db = require(__DIR__ . '/db.php'); -return [ +$config = [ 'id' => 'basic-console', 'basePath' => dirname(__DIR__), - 'bootstrap' => ['log', 'gii'], + 'bootstrap' => ['log'], 'controllerNamespace' => 'app\commands', - 'modules' => [ - 'gii' => 'yii\gii\Module', - ], 'components' => [ 'cache' => [ 'class' => 'yii\caching\FileCache', @@ -29,3 +26,11 @@ ], 'params' => $params, ]; + +if (YII_ENV_DEV) { + // configuration adjustments for 'dev' environment + $config['bootstrap'][] = 'gii'; + $config['modules']['gii'] = [ + 'class' => 'yii\gii\Module', + ]; +} From 23a48e8d2300b92d49010ca0662a803fc3e98ad2 Mon Sep 17 00:00:00 2001 From: Anatoly Garkusha Date: Fri, 11 Sep 2015 16:16:28 +0300 Subject: [PATCH 133/390] Modify config/console.php add return $config --- config/console.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/console.php b/config/console.php index e5315b913..7c810de99 100644 --- a/config/console.php +++ b/config/console.php @@ -34,3 +34,5 @@ 'class' => 'yii\gii\Module', ]; } + +return $config; From 1dd087dbf10fb7b1b67a5932a395039fee4c17ed Mon Sep 17 00:00:00 2001 From: andreybolonin Date: Fri, 25 Sep 2015 14:54:10 +0300 Subject: [PATCH 134/390] OPcache checking less php 5.5 --- requirements.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/requirements.php b/requirements.php index ee6b2cb53..ee3184f72 100644 --- a/requirements.php +++ b/requirements.php @@ -85,12 +85,6 @@ 'by' => 'MemCache', 'memo' => extension_loaded('memcached') ? 'To use memcached set MemCache::useMemcached to true.' : '' ), - array( - 'name' => 'APC extension', - 'mandatory' => false, - 'condition' => extension_loaded('apc'), - 'by' => 'ApcCache', - ), // CAPTCHA: array( 'name' => 'GD PHP extension with FreeType support', @@ -124,9 +118,20 @@ 'phpSmtp' => array( 'name' => 'PHP mail SMTP', 'mandatory' => false, - 'condition' => strlen(ini_get('SMTP'))>0, + 'condition' => strlen(ini_get('SMTP')) > 0, 'by' => 'Email sending', 'memo' => 'PHP mail SMTP server required', ), ); + +// OPcache check +if (!version_compare(phpversion(), '5.5', '>=')) { + $requirements[] = array( + 'name' => 'APC extension', + 'mandatory' => false, + 'condition' => extension_loaded('apc'), + 'by' => 'ApcCache', + ); +} + $requirementsChecker->checkYii()->check($requirements)->render(); From f68cd5d1f5b2931c4e372ef77f46af891bde8b01 Mon Sep 17 00:00:00 2001 From: Daniel Gomez Pan Date: Sun, 27 Sep 2015 22:24:43 +0200 Subject: [PATCH 135/390] update composer-asset-plugin --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 09426cb81..9a1a4b317 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ at [getcomposer.org](http://getcomposer.org/doc/00-intro.md#installation-nix). You can then install this project template using the following command: ~~~ -php composer.phar global require "fxp/composer-asset-plugin:~1.0.0" +php composer.phar global require "fxp/composer-asset-plugin:~1.0.3" php composer.phar create-project --prefer-dist --stability=dev yiisoft/yii2-app-basic basic ~~~ From 0bfc5f9af50c0ed081318e3fb4cde8f79a6f02e9 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Wed, 21 Oct 2015 01:05:51 +0300 Subject: [PATCH 136/390] Allow logout when JavaScript is disabled --- views/layouts/main.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/views/layouts/main.php b/views/layouts/main.php index d5b1b49ee..b0f613de1 100644 --- a/views/layouts/main.php +++ b/views/layouts/main.php @@ -39,13 +39,18 @@ ['label' => 'Home', 'url' => ['/site/index']], ['label' => 'About', 'url' => ['/site/about']], ['label' => 'Contact', 'url' => ['/site/contact']], - Yii::$app->user->isGuest ? - ['label' => 'Login', 'url' => ['/site/login']] : - [ - 'label' => 'Logout (' . Yii::$app->user->identity->username . ')', - 'url' => ['/site/logout'], - 'linkOptions' => ['data-method' => 'post'] - ], + Yii::$app->user->isGuest ? ( + ['label' => 'Login', 'url' => ['/site/login']] + ) : ( + '
  • ' + . Html::beginForm(['/site/logout'], 'post') + . Html::submitButton( + 'Logout (' . Yii::$app->user->identity->username . ')', + ['class' => 'btn btn-link'] + ) + . Html::endForm() + . '
  • ' + ) ], ]); NavBar::end(); From 4e8ed67326ceb00b78e2f1e8c92ec0140dcbf27e Mon Sep 17 00:00:00 2001 From: Yasser Hassan Date: Wed, 21 Oct 2015 03:07:07 +0200 Subject: [PATCH 137/390] Modified default @tests value and updated READMEs. --- README.md | 7 ++++--- config/console.php | 9 ++++++++- tests/README.md | 11 +++++++++++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9a1a4b317..d658d52fd 100644 --- a/README.md +++ b/README.md @@ -96,6 +96,7 @@ return [ ]; ``` -**NOTE:** Yii won't create the database for you, this has to be done manually before you can access it. - -Also check and edit the other files in the `config/` directory to customize your application. +**NOTES:** +- Yii won't create the database for you, this has to be done manually before you can access it. +- Check and edit the other files in the `config/` directory to customize your application as required. +- Refer to the README in the `tests` direcotry for information specific to basic application tests. diff --git a/config/console.php b/config/console.php index 7c810de99..7306e2764 100644 --- a/config/console.php +++ b/config/console.php @@ -1,6 +1,6 @@ $db, ], 'params' => $params, + /* + 'controllerMap' => [ + 'fixture' => [ // Fixture generation command line. + 'class' => 'yii\faker\FixtureController', + ], + ], + */ ]; if (YII_ENV_DEV) { diff --git a/tests/README.md b/tests/README.md index a34f68bb9..15cb0b8f6 100644 --- a/tests/README.md +++ b/tests/README.md @@ -62,6 +62,17 @@ webserver. In the `web` directory execute the following: codecept run unit ``` +Fixtures Default Configuration +------------------------------ +The `fixture` commands refer to the following `ActiveFixture` configuration by default: + +- Fixtures path: `@tests/unit/fixtures` +- Fixtures data path: `@tests/unit/fixtures/data` +- Template files path: `@tests/unit/templates/fixtures` +- Namespace: `tests\unit\fixtures` + +Where `@tests` refers to `@app/tests/codeception`. + Code coverage support --------------------- From b4f23d82f553737a0afe9de3e8b1b10751448527 Mon Sep 17 00:00:00 2001 From: Jason McCallister Date: Wed, 21 Oct 2015 18:06:24 -0700 Subject: [PATCH 138/390] Update the command for Faker Updates the syntax for the command to composer require yii2-faker. --- tests/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/README.md b/tests/README.md index 15cb0b8f6..fd80fe55c 100644 --- a/tests/README.md +++ b/tests/README.md @@ -24,7 +24,7 @@ After creating the basic application, follow these steps to prepare for the test 2. Install faker extension by running the following from template root directory where `composer.json` is: ``` - composer require --dev yiisoft/yii2-faker:* + composer require --dev "yiisoft/yii2-faker:*" ``` 3. Create `yii2_basic_tests` database and update it by applying migrations (you may skip this step if you do not have created any migrations yet): From edd5c574c8e4a6b70e152f036af3dadae6b53a19 Mon Sep 17 00:00:00 2001 From: Jani Mikkonen Date: Thu, 12 Nov 2015 14:06:30 +0200 Subject: [PATCH 139/390] Update travis composer-asset-plugin --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 72d788d58..cb7617b3c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,7 +26,7 @@ cache: install: - travis_retry composer self-update && composer --version - - travis_retry composer global require "fxp/composer-asset-plugin:~1.0.0" + - travis_retry composer global require "fxp/composer-asset-plugin:~1.1.0" - export PATH="$HOME/.composer/vendor/bin:$PATH" - travis_retry composer install --dev --prefer-dist --no-interaction # codeception From 1c7ac9d07a807b7304f6202977c77cab188a52f6 Mon Sep 17 00:00:00 2001 From: Jani Mikkonen Date: Thu, 12 Nov 2015 14:08:02 +0200 Subject: [PATCH 140/390] Update docs composer-asset-plugin [skip ci] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d658d52fd..2a413917b 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ at [getcomposer.org](http://getcomposer.org/doc/00-intro.md#installation-nix). You can then install this project template using the following command: ~~~ -php composer.phar global require "fxp/composer-asset-plugin:~1.0.3" +php composer.phar global require "fxp/composer-asset-plugin:~1.1.0" php composer.phar create-project --prefer-dist --stability=dev yiisoft/yii2-app-basic basic ~~~ From fd77e14939bcf4de36df6d1afccb049f9caa0af1 Mon Sep 17 00:00:00 2001 From: niks999 Date: Sun, 29 Nov 2015 12:33:37 +0530 Subject: [PATCH 141/390] Fix typo in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2a413917b..f8ce641ed 100644 --- a/README.md +++ b/README.md @@ -99,4 +99,4 @@ return [ **NOTES:** - Yii won't create the database for you, this has to be done manually before you can access it. - Check and edit the other files in the `config/` directory to customize your application as required. -- Refer to the README in the `tests` direcotry for information specific to basic application tests. +- Refer to the README in the `tests` directory for information specific to basic application tests. From 7cf2418d88aeb77a7facdd0766eafadb0deecd8f Mon Sep 17 00:00:00 2001 From: MaximAL Date: Tue, 1 Dec 2015 19:58:38 +0300 Subject: [PATCH 142/390] Autofocus on username field Useful UX improvement --- views/site/login.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/site/login.php b/views/site/login.php index 059ef8048..559be64f9 100644 --- a/views/site/login.php +++ b/views/site/login.php @@ -24,7 +24,7 @@ ], ]); ?> - field($model, 'username') ?> + field($model, 'username')->textInput(['autofocus' => 'autofocus']) ?> field($model, 'password')->passwordInput() ?> From 4b2e0713e3ba282f9c992e157953147ba7d821c2 Mon Sep 17 00:00:00 2001 From: MaximAL Date: Tue, 1 Dec 2015 20:11:46 +0300 Subject: [PATCH 143/390] HTML5 shorthand for attribute value --- views/site/login.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/site/login.php b/views/site/login.php index 559be64f9..498f46fce 100644 --- a/views/site/login.php +++ b/views/site/login.php @@ -24,7 +24,7 @@ ], ]); ?> - field($model, 'username')->textInput(['autofocus' => 'autofocus']) ?> + field($model, 'username')->textInput(['autofocus' => true]) ?> field($model, 'password')->passwordInput() ?> From 3527b6712c6b2a93c6f12f0673ec14cd14f3b7ed Mon Sep 17 00:00:00 2001 From: MaximAL Date: Tue, 1 Dec 2015 20:16:24 +0300 Subject: [PATCH 144/390] Update contact.php --- views/site/contact.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/site/contact.php b/views/site/contact.php index 22a75bbcc..b98840918 100644 --- a/views/site/contact.php +++ b/views/site/contact.php @@ -43,7 +43,7 @@ 'contact-form']); ?> - field($model, 'name') ?> + field($model, 'name')->textInput(['autofocus' => true]) ?> field($model, 'email') ?> From ce4ad9c851a89cc9fcee9375d4429419d4f206ce Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Wed, 2 Dec 2015 01:12:00 +0100 Subject: [PATCH 145/390] Added missing environment definition in console fixes https://github.com/yiisoft/yii2/issues/10300 --- yii | 1 + 1 file changed, 1 insertion(+) diff --git a/yii b/yii index 43aa26056..fc7090f77 100755 --- a/yii +++ b/yii @@ -9,6 +9,7 @@ */ defined('YII_DEBUG') or define('YII_DEBUG', true); +defined('YII_ENV') or define('YII_ENV', 'dev'); require(__DIR__ . '/vendor/autoload.php'); require(__DIR__ . '/vendor/yiisoft/yii2/Yii.php'); From ad3e23a27a36acff551e4f100fb8f8efbe2f08f2 Mon Sep 17 00:00:00 2001 From: Daniel Gomez Pan Date: Sat, 16 Jan 2016 17:53:38 +0200 Subject: [PATCH 146/390] Updated travis.yml to run on PHP7 --- .travis.yml | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index cb7617b3c..7ff498f3c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,16 +5,7 @@ php: - 5.5 - 5.6 - 7.0 -# - hhvm -# - hhvm-nightly - -# run build against hhvm but allow them to fail -# http://docs.travis-ci.com/user/build-configuration/#Rows-That-are-Allowed-To-Fail -matrix: - fast_finish: true - allow_failures: -# - php: hhvm-nightly - - php: 7.0 + - hhvm # faster builds on new travis setup not using sudo sudo: false From 7f7fcb61204f56da71809190137da270578ab0bc Mon Sep 17 00:00:00 2001 From: SilverFire - Dmitry Naumenko Date: Sat, 16 Jan 2016 19:08:23 +0200 Subject: [PATCH 147/390] Updated travis.yml commented HHVM --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7ff498f3c..0d2db1c64 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ php: - 5.5 - 5.6 - 7.0 - - hhvm +# - hhvm # faster builds on new travis setup not using sudo sudo: false From 5eaf2dc07904a0a1ccf23faadf31729345fca919 Mon Sep 17 00:00:00 2001 From: SilverFire - Dmitry Naumenko Date: Sat, 16 Jan 2016 19:11:06 +0200 Subject: [PATCH 148/390] Updated travis.yml fxp-plugin updated to 1.1.1 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0d2db1c64..24b5d54ae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,7 @@ cache: install: - travis_retry composer self-update && composer --version - - travis_retry composer global require "fxp/composer-asset-plugin:~1.1.0" + - travis_retry composer global require "fxp/composer-asset-plugin:~1.1.1" - export PATH="$HOME/.composer/vendor/bin:$PATH" - travis_retry composer install --dev --prefer-dist --no-interaction # codeception From aa6c28ed1352fd9736cbe11aafc7ff045479bba3 Mon Sep 17 00:00:00 2001 From: Daniel Gomez Pan Date: Sun, 17 Jan 2016 19:24:05 +0100 Subject: [PATCH 149/390] Update composer-asset-plugin --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f8ce641ed..598f9637b 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ at [getcomposer.org](http://getcomposer.org/doc/00-intro.md#installation-nix). You can then install this project template using the following command: ~~~ -php composer.phar global require "fxp/composer-asset-plugin:~1.1.0" +php composer.phar global require "fxp/composer-asset-plugin:~1.1.1" php composer.phar create-project --prefer-dist --stability=dev yiisoft/yii2-app-basic basic ~~~ From df2a935b329df2596f325736e321a5cd518c1935 Mon Sep 17 00:00:00 2001 From: Edo Freriks Date: Mon, 1 Feb 2016 00:39:43 +0100 Subject: [PATCH 150/390] #47, Typo fix address tests --- tests/codeception/acceptance/ContactCept.php | 2 +- tests/codeception/functional/ContactCept.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/codeception/acceptance/ContactCept.php b/tests/codeception/acceptance/ContactCept.php index b51d1c085..f848443da 100644 --- a/tests/codeception/acceptance/ContactCept.php +++ b/tests/codeception/acceptance/ContactCept.php @@ -35,7 +35,7 @@ if (method_exists($I, 'wait')) { $I->wait(3); // only for selenium } -$I->expectTo('see that email adress is wrong'); +$I->expectTo('see that email address is wrong'); $I->dontSee('Name cannot be blank', '.help-inline'); $I->see('Email is not a valid email address.'); $I->dontSee('Subject cannot be blank', '.help-inline'); diff --git a/tests/codeception/functional/ContactCept.php b/tests/codeception/functional/ContactCept.php index 074820a70..b17a7576d 100644 --- a/tests/codeception/functional/ContactCept.php +++ b/tests/codeception/functional/ContactCept.php @@ -29,7 +29,7 @@ 'body' => 'test content', 'verifyCode' => 'testme', ]); -$I->expectTo('see that email adress is wrong'); +$I->expectTo('see that email address is wrong'); $I->dontSee('Name cannot be blank', '.help-inline'); $I->see('Email is not a valid email address.'); $I->dontSee('Subject cannot be blank', '.help-inline'); From 940451bc8f264217977dca5ee097035c9426c743 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Sun, 14 Feb 2016 15:56:01 +0100 Subject: [PATCH 151/390] prepare for 2.0.7 release --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 4ad378784..1631da65c 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "irc": "irc://irc.freenode.net/yii", "source": "https://github.com/yiisoft/yii2" }, - "minimum-stability": "dev", + "minimum-stability": "stable", "require": { "php": ">=5.4.0", "yiisoft/yii2": ">=2.0.5", From acb438affb993f51d9712852635c8135239e9e8a Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Sun, 14 Feb 2016 15:56:44 +0100 Subject: [PATCH 152/390] prepare for next release --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 1631da65c..4ad378784 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "irc": "irc://irc.freenode.net/yii", "source": "https://github.com/yiisoft/yii2" }, - "minimum-stability": "stable", + "minimum-stability": "dev", "require": { "php": ">=5.4.0", "yiisoft/yii2": ">=2.0.5", From f002567220b9ce9670f4d7fd71701df17c87a86b Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Wed, 9 Mar 2016 18:47:19 +0300 Subject: [PATCH 153/390] Removed unnecessary slash --- controllers/SiteController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/SiteController.php b/controllers/SiteController.php index 4ffba24cb..df1a0d376 100644 --- a/controllers/SiteController.php +++ b/controllers/SiteController.php @@ -54,7 +54,7 @@ public function actionIndex() public function actionLogin() { - if (!\Yii::$app->user->isGuest) { + if (!Yii::$app->user->isGuest) { return $this->goHome(); } From 27fbea32d82a57f98d56ad1e2f60295e5fdda5a0 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Mon, 21 Mar 2016 22:10:44 +0300 Subject: [PATCH 154/390] Added issue templates --- .gitattributes | 1 + .github/CONTRIBUTING.md | 7 +++++++ .github/ISSUE_TEMPLATE.md | 14 ++++++++++++++ .github/PULL_REQUEST_TEMPLATE.md | 7 +++++++ 4 files changed, 29 insertions(+) create mode 100644 .github/CONTRIBUTING.md create mode 100644 .github/ISSUE_TEMPLATE.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.gitattributes b/.gitattributes index 6b9d3d398..3e9092c68 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,5 @@ # Ignore all test and documentation for archive +/.github export-ignore /.gitattributes export-ignore /.scrutinizer.yml export-ignore /.travis.yml export-ignore diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 000000000..b0924689b --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,7 @@ +Contributing to Yii2 +==================== + +- [Report an issue](docs/internals/report-an-issue.md) +- [Translate documentation or messages](docs/internals/translation-workflow.md) +- [Give us feedback or start a design discussion](http://www.yiiframework.com/forum/index.php/forum/42-general-discussions-for-yii-20/) +- [Contribute to the core code or fix bugs](docs/internals/git-workflow.md) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 000000000..52ec8692f --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,14 @@ +### What steps will reproduce the problem? + +### What's expected? + +### What do you get instead? + + +### Additional info + +| Q | A +| ---------------- | --- +| Yii vesion | +| PHP version | +| Operating system | diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 000000000..968a845de --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,7 @@ +| Q | A +| ------------- | --- +| Is bugfix? | yes/no +| New feature? | yes/no +| Breaks BC? | yes/no +| Tests pass? | yes/no +| Fixed issues | comma-separated list of tickets # fixed by the PR, if any From c97c8c605d7a8b6f8ed1646093f131ca80bd1444 Mon Sep 17 00:00:00 2001 From: Bulat Damdinov Date: Wed, 23 Mar 2016 19:55:38 +0800 Subject: [PATCH 155/390] #51 logout btn --- views/layouts/main.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/layouts/main.php b/views/layouts/main.php index b0f613de1..2974d6d89 100644 --- a/views/layouts/main.php +++ b/views/layouts/main.php @@ -43,7 +43,7 @@ ['label' => 'Login', 'url' => ['/site/login']] ) : ( '
  • ' - . Html::beginForm(['/site/logout'], 'post') + . Html::beginForm(['/site/logout'], 'post', ['class' => 'navbar-form']) . Html::submitButton( 'Logout (' . Yii::$app->user->identity->username . ')', ['class' => 'btn btn-link'] From af67434e7e57b6133219bd1ebfdbaee67c73e0d9 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Thu, 14 Apr 2016 11:45:41 +0300 Subject: [PATCH 156/390] Fixed links in CONTRIBUTING.md --- .github/CONTRIBUTING.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index b0924689b..3d8d32c25 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -1,7 +1,7 @@ Contributing to Yii2 ==================== -- [Report an issue](docs/internals/report-an-issue.md) -- [Translate documentation or messages](docs/internals/translation-workflow.md) +- [Report an issue](https://github.com/yiisoft/yii2/blob/master/docs/internals/report-an-issue.md) +- [Translate documentation or messages](https://github.com/yiisoft/yii2/blob/master/docs/internals/translation-workflow.md) - [Give us feedback or start a design discussion](http://www.yiiframework.com/forum/index.php/forum/42-general-discussions-for-yii-20/) -- [Contribute to the core code or fix bugs](docs/internals/git-workflow.md) +- [Contribute to the core code or fix bugs](https://github.com/yiisoft/yii2/blob/master/docs/internals/git-workflow.md) From 6962834f3715a5a9a27556ca53f8527ff1737828 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Thu, 28 Apr 2016 18:06:20 +0200 Subject: [PATCH 157/390] release version 2.0.8 --- composer.json | 2 +- models/ContactForm.php | 3 ++- models/LoginForm.php | 3 +++ models/User.php | 5 +++-- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 4ad378784..1631da65c 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "irc": "irc://irc.freenode.net/yii", "source": "https://github.com/yiisoft/yii2" }, - "minimum-stability": "dev", + "minimum-stability": "stable", "require": { "php": ">=5.4.0", "yiisoft/yii2": ">=2.0.5", diff --git a/models/ContactForm.php b/models/ContactForm.php index 361b80b39..37f48b312 100644 --- a/models/ContactForm.php +++ b/models/ContactForm.php @@ -16,6 +16,7 @@ class ContactForm extends Model public $body; public $verifyCode; + /** * @return array the validation rules. */ @@ -43,7 +44,7 @@ public function attributeLabels() /** * Sends an email to the specified email address using the information collected by this model. - * @param string $email the target email address + * @param string $email the target email address * @return boolean whether the model passes validation */ public function contact($email) diff --git a/models/LoginForm.php b/models/LoginForm.php index 227168cf6..7ef5c99b3 100644 --- a/models/LoginForm.php +++ b/models/LoginForm.php @@ -7,6 +7,9 @@ /** * LoginForm is the model behind the login form. + * + * @property User|null $user This property is read-only. + * */ class LoginForm extends Model { diff --git a/models/User.php b/models/User.php index cbfb9fefc..163a64fcd 100644 --- a/models/User.php +++ b/models/User.php @@ -27,6 +27,7 @@ class User extends \yii\base\Object implements \yii\web\IdentityInterface ], ]; + /** * @inheritdoc */ @@ -52,7 +53,7 @@ public static function findIdentityByAccessToken($token, $type = null) /** * Finds user by username * - * @param string $username + * @param string $username * @return static|null */ public static function findByUsername($username) @@ -93,7 +94,7 @@ public function validateAuthKey($authKey) /** * Validates password * - * @param string $password password to validate + * @param string $password password to validate * @return boolean if password provided is valid for current user */ public function validatePassword($password) From 655b5c3502972ebdb701558b0906cf8d524e92c0 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Thu, 28 Apr 2016 18:06:57 +0200 Subject: [PATCH 158/390] prepare for next release --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 1631da65c..4ad378784 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "irc": "irc://irc.freenode.net/yii", "source": "https://github.com/yiisoft/yii2" }, - "minimum-stability": "stable", + "minimum-stability": "dev", "require": { "php": ">=5.4.0", "yiisoft/yii2": ">=2.0.5", From dd0c43247f2a7f45a276be220c98ea8fd81f0d2f Mon Sep 17 00:00:00 2001 From: Bulat Damdinov Date: Tue, 24 May 2016 18:14:58 +0800 Subject: [PATCH 159/390] fixed link for AcceptanceTest Selenuim Webdriver --- tests/codeception/acceptance.suite.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/codeception/acceptance.suite.yml b/tests/codeception/acceptance.suite.yml index 1781b0077..d36d7360b 100644 --- a/tests/codeception/acceptance.suite.yml +++ b/tests/codeception/acceptance.suite.yml @@ -13,7 +13,7 @@ modules: enabled: - 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 +# This will require you to install selenium. See http://codeception.com/docs/03-AcceptanceTests#selenium-webdriver # "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 From ddeab345bb178025fcb3931b0be4f3c84b0b74ab Mon Sep 17 00:00:00 2001 From: Kalinin Alexandr Date: Sun, 19 Jun 2016 16:56:22 +0300 Subject: [PATCH 160/390] Update SiteController.php (#61) [skip ci] --- controllers/SiteController.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/controllers/SiteController.php b/controllers/SiteController.php index df1a0d376..36dc9591b 100644 --- a/controllers/SiteController.php +++ b/controllers/SiteController.php @@ -11,6 +11,9 @@ class SiteController extends Controller { + /** + * @inheritdoc + */ public function behaviors() { return [ @@ -34,6 +37,9 @@ public function behaviors() ]; } + /** + * @inheritdoc + */ public function actions() { return [ @@ -47,11 +53,21 @@ public function actions() ]; } + /** + * Displays homepage. + * + * @return string + */ public function actionIndex() { return $this->render('index'); } + /** + * Login action. + * + * @return string + */ public function actionLogin() { if (!Yii::$app->user->isGuest) { @@ -67,6 +83,11 @@ public function actionLogin() ]); } + /** + * Logout action. + * + * @return string + */ public function actionLogout() { Yii::$app->user->logout(); @@ -74,6 +95,11 @@ public function actionLogout() return $this->goHome(); } + /** + * Displays contact page. + * + * @return string + */ public function actionContact() { $model = new ContactForm(); @@ -87,6 +113,11 @@ public function actionContact() ]); } + /** + * Displays about page. + * + * @return string + */ public function actionAbout() { return $this->render('about'); From c200693b05704bbe50ffe88513b62715ea737f1c Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Sat, 2 Jul 2016 19:51:35 +0300 Subject: [PATCH 161/390] Fixes #62: Changed usage of deprecated getMock() to current createMock() --- tests/codeception/unit/models/ContactFormTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/codeception/unit/models/ContactFormTest.php b/tests/codeception/unit/models/ContactFormTest.php index 323482943..9bc36d174 100644 --- a/tests/codeception/unit/models/ContactFormTest.php +++ b/tests/codeception/unit/models/ContactFormTest.php @@ -26,7 +26,7 @@ protected function tearDown() public function testContact() { - $model = $this->getMock('app\models\ContactForm', ['validate']); + $model = $this->createMock('app\models\ContactForm', ['validate']); $model->expects($this->once())->method('validate')->will($this->returnValue(true)); $model->attributes = [ From e6cdaa5a1abc25f619d53a7745de33e645b48359 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Sat, 2 Jul 2016 20:13:40 +0300 Subject: [PATCH 162/390] Fixed test to mock form properly --- tests/codeception/unit/models/ContactFormTest.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/codeception/unit/models/ContactFormTest.php b/tests/codeception/unit/models/ContactFormTest.php index 9bc36d174..7dc4fe433 100644 --- a/tests/codeception/unit/models/ContactFormTest.php +++ b/tests/codeception/unit/models/ContactFormTest.php @@ -2,6 +2,7 @@ namespace tests\codeception\unit\models; +use app\models\ContactForm; use Yii; use yii\codeception\TestCase; use Codeception\Specify; @@ -26,7 +27,10 @@ protected function tearDown() public function testContact() { - $model = $this->createMock('app\models\ContactForm', ['validate']); + /** @var ContactForm $model */ + $model = $this->getMockBuilder('app\models\ContactForm') + ->setMethods(['validate']) + ->getMock(); $model->expects($this->once())->method('validate')->will($this->returnValue(true)); $model->attributes = [ @@ -36,9 +40,8 @@ public function testContact() 'body' => 'body of current message', ]; - $model->contact('admin@example.com'); - - $this->specify('email should be send', function () { + $this->specify('email should be send', function () use ($model) { + expect('ContactForm::contact() should return true', $model->contact('admin@example.com'))->true(); expect('email file should exist', file_exists($this->getMessageFile()))->true(); }); From d579eb6434e070c1ca8820b61371db4d2d1e64f4 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Sat, 2 Jul 2016 20:22:42 +0300 Subject: [PATCH 163/390] Changed php -S to ./yii serve in tests readme --- tests/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/README.md b/tests/README.md index fd80fe55c..4b2519665 100644 --- a/tests/README.md +++ b/tests/README.md @@ -42,11 +42,11 @@ After creating the basic application, follow these steps to prepare for the test codecept build ``` -5. In order to be able to run acceptance tests you need to start a webserver. The simplest way is to use PHP built in -webserver. In the `web` directory execute the following: +5. In order to be able to run acceptance tests you need to start a webserver. The simplest way is to use built-in Yii +command: ``` - php -S localhost:8080 + ./yii serve ``` 6. Now you can run the tests with the following commands: From e0954011ce9ae0227c12e174a58e15ff3503c90d Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Tue, 5 Jul 2016 01:17:16 +0300 Subject: [PATCH 164/390] Added "cd tests" as suggested in https://github.com/yiisoft/yii2-app-basic/issues/63#issuecomment-230354273 --- tests/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/README.md b/tests/README.md index 4b2519665..35142d612 100644 --- a/tests/README.md +++ b/tests/README.md @@ -30,6 +30,7 @@ After creating the basic application, follow these steps to prepare for the test 3. Create `yii2_basic_tests` database and update it by applying migrations (you may skip this step if you do not have created any migrations yet): ``` + cd tests codeception/bin/yii migrate ``` From 6545745e88677afb4637bad127c4926120882e99 Mon Sep 17 00:00:00 2001 From: Mohamed Cherif Bouchelaghem Date: Mon, 11 Jul 2016 13:43:55 +0100 Subject: [PATCH 165/390] configure Codeception::Scpecify to not deep clone properties by default (#57) --- tests/codeception/_bootstrap.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/codeception/_bootstrap.php b/tests/codeception/_bootstrap.php index 755029ef3..f24347fe5 100644 --- a/tests/codeception/_bootstrap.php +++ b/tests/codeception/_bootstrap.php @@ -14,3 +14,10 @@ $_SERVER['SERVER_PORT'] = parse_url(http://github.com/Codeception/Configuration::config()['config']['test_entry_url'], PHP_URL_PORT) ?: '80'; Yii::setAlias('@tests', dirname(__DIR__)); + +/** + * this configure codeception specify to not deep clone objects properties + * it can be configure localy in your tests + * @see https://github.com/Codeception/Specify/tree/master/docs + */ +\Codeception\Specify\Config::setDeepClone(false); From 5319c23281f4543da41f7f5ed72837f597fe9ab4 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Mon, 11 Jul 2016 15:43:39 +0200 Subject: [PATCH 166/390] release version 2.0.9 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 4ad378784..1631da65c 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "irc": "irc://irc.freenode.net/yii", "source": "https://github.com/yiisoft/yii2" }, - "minimum-stability": "dev", + "minimum-stability": "stable", "require": { "php": ">=5.4.0", "yiisoft/yii2": ">=2.0.5", From 548af0eacdd8d000bde121b122d0f36e2c218605 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Mon, 11 Jul 2016 15:43:58 +0200 Subject: [PATCH 167/390] prepare for next release --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 1631da65c..4ad378784 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "irc": "irc://irc.freenode.net/yii", "source": "https://github.com/yiisoft/yii2" }, - "minimum-stability": "stable", + "minimum-stability": "dev", "require": { "php": ">=5.4.0", "yiisoft/yii2": ">=2.0.5", From 71ee8a08a0fbe6856d50075d92a35b10be39ab77 Mon Sep 17 00:00:00 2001 From: Davert Date: Thu, 14 Jul 2016 17:20:08 +0300 Subject: [PATCH 168/390] dependencies should be stable --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 4ad378784..1631da65c 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "irc": "irc://irc.freenode.net/yii", "source": "https://github.com/yiisoft/yii2" }, - "minimum-stability": "dev", + "minimum-stability": "stable", "require": { "php": ">=5.4.0", "yiisoft/yii2": ">=2.0.5", From 75a273eb40535cc3e4ed27211e53ee243bccebaa Mon Sep 17 00:00:00 2001 From: Oleg Kostiushko Date: Thu, 14 Jul 2016 19:19:59 +0300 Subject: [PATCH 169/390] Acceptance test refactoring - Contact form (#2) * directory _support should exists before build with ignore inside * added test for contact page availability * added test for empty contact form submit * added test for submit contact form * remove test contact page * delete old contact page test * test index-test instead index * change stage description --- tests/codeception/_pages/ContactPage.php | 26 --------- tests/codeception/_support/.gitignore | 2 + tests/codeception/acceptance/ContactCept.php | 57 -------------------- tests/codeception/acceptance/ContactCest.php | 33 ++++++++++++ 4 files changed, 35 insertions(+), 83 deletions(-) delete mode 100644 tests/codeception/_pages/ContactPage.php create mode 100644 tests/codeception/_support/.gitignore delete mode 100644 tests/codeception/acceptance/ContactCept.php create mode 100644 tests/codeception/acceptance/ContactCest.php diff --git a/tests/codeception/_pages/ContactPage.php b/tests/codeception/_pages/ContactPage.php deleted file mode 100644 index 5701e2cb4..000000000 --- a/tests/codeception/_pages/ContactPage.php +++ /dev/null @@ -1,26 +0,0 @@ - $value) { - $inputType = $field === 'body' ? 'textarea' : 'input'; - $this->actor->fillField($inputType . '[name="ContactForm[' . $field . ']"]', $value); - } - $this->actor->click('contact-button'); - } -} diff --git a/tests/codeception/_support/.gitignore b/tests/codeception/_support/.gitignore new file mode 100644 index 000000000..c96a04f00 --- /dev/null +++ b/tests/codeception/_support/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/tests/codeception/acceptance/ContactCept.php b/tests/codeception/acceptance/ContactCept.php deleted file mode 100644 index f848443da..000000000 --- a/tests/codeception/acceptance/ContactCept.php +++ /dev/null @@ -1,57 +0,0 @@ -wantTo('ensure that contact works'); - -$contactPage = ContactPage::openBy($I); - -$I->see('Contact', 'h1'); - -$I->amGoingTo('submit contact form with no data'); -$contactPage->submit([]); -if (method_exists($I, 'wait')) { - $I->wait(3); // only for selenium -} -$I->expectTo('see validations errors'); -$I->see('Contact', 'h1'); -$I->see('Name cannot be blank'); -$I->see('Email cannot be blank'); -$I->see('Subject cannot be blank'); -$I->see('Body cannot be blank'); -$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', -]); -if (method_exists($I, 'wait')) { - $I->wait(3); // only for selenium -} -$I->expectTo('see that email address is wrong'); -$I->dontSee('Name cannot be blank', '.help-inline'); -$I->see('Email is not a valid email address.'); -$I->dontSee('Subject cannot be blank', '.help-inline'); -$I->dontSee('Body cannot be blank', '.help-inline'); -$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', -]); -if (method_exists($I, 'wait')) { - $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/codeception/acceptance/ContactCest.php b/tests/codeception/acceptance/ContactCest.php new file mode 100644 index 000000000..0a317ce50 --- /dev/null +++ b/tests/codeception/acceptance/ContactCest.php @@ -0,0 +1,33 @@ +amOnPage('index-test.php?r=site%2Fcontact'); + } + + public function contactPageWorks(AcceptanceTester $I) + { + $I->wantTo('ensure that contact page works'); + $I->see('Contact', 'h1'); + } + + public function contactFormCanBeSubmitted(AcceptanceTester $I) + { + $I->amGoingTo('submit contact form with correct data'); + $I->fillField('#contactform-name', 'tester'); + $I->fillField('#contactform-email', 'tester@example.com'); + $I->fillField('#contactform-subject', 'test subject'); + $I->fillField('#contactform-body', 'test content'); + $I->fillField('#contactform-verifycode', 'testme'); + + $I->click('contact-button'); + + $I->dontSeeElement('#contact-form'); + $I->see('Thank you for contacting us. We will respond to you as soon as possible.'); + } +} From aaee0841e13f46614911e05e83670a60fe2bc1e7 Mon Sep 17 00:00:00 2001 From: Maxim Shcherbakov Date: Thu, 14 Jul 2016 19:20:28 +0300 Subject: [PATCH 170/390] Acceptance tests refactoring (#1) --- .../codeception/_support/AcceptanceTester.php | 26 +++++++++++++ .../codeception/_support/FunctionalTester.php | 26 +++++++++++++ tests/codeception/_support/UnitTester.php | 26 +++++++++++++ .../_support/_generated/.gitignore | 2 + tests/codeception/acceptance.suite.yml | 2 + tests/codeception/acceptance/AboutCept.php | 10 ----- tests/codeception/acceptance/AboutCest.php | 11 ++++++ tests/codeception/acceptance/HomeCept.php | 11 ------ tests/codeception/acceptance/HomeCest.php | 16 ++++++++ tests/codeception/acceptance/LoginCept.php | 37 ------------------- tests/codeception/acceptance/LoginCest.php | 19 ++++++++++ 11 files changed, 128 insertions(+), 58 deletions(-) create mode 100644 tests/codeception/_support/AcceptanceTester.php create mode 100644 tests/codeception/_support/FunctionalTester.php create mode 100644 tests/codeception/_support/UnitTester.php create mode 100644 tests/codeception/_support/_generated/.gitignore delete mode 100644 tests/codeception/acceptance/AboutCept.php create mode 100644 tests/codeception/acceptance/AboutCest.php delete mode 100644 tests/codeception/acceptance/HomeCept.php create mode 100644 tests/codeception/acceptance/HomeCest.php delete mode 100644 tests/codeception/acceptance/LoginCept.php create mode 100644 tests/codeception/acceptance/LoginCest.php diff --git a/tests/codeception/_support/AcceptanceTester.php b/tests/codeception/_support/AcceptanceTester.php new file mode 100644 index 000000000..4c7dcbb6d --- /dev/null +++ b/tests/codeception/_support/AcceptanceTester.php @@ -0,0 +1,26 @@ +wantTo('ensure that about works'); -AboutPage::openBy($I); -$I->see('About', 'h1'); diff --git a/tests/codeception/acceptance/AboutCest.php b/tests/codeception/acceptance/AboutCest.php new file mode 100644 index 000000000..a3cbef66b --- /dev/null +++ b/tests/codeception/acceptance/AboutCest.php @@ -0,0 +1,11 @@ +amOnPage(['site/about']); + $I->amOnPage('index.php?r=site%2Fabout'); + $I->see('About', 'h1'); + } +} diff --git a/tests/codeception/acceptance/HomeCept.php b/tests/codeception/acceptance/HomeCept.php deleted file mode 100644 index 1f9353595..000000000 --- a/tests/codeception/acceptance/HomeCept.php +++ /dev/null @@ -1,11 +0,0 @@ -wantTo('ensure that home page works'); -$I->amOnPage(Yii::$app->homeUrl); -$I->see('My Company'); -$I->seeLink('About'); -$I->click('About'); -$I->see('This is the About page.'); diff --git a/tests/codeception/acceptance/HomeCest.php b/tests/codeception/acceptance/HomeCest.php new file mode 100644 index 000000000..cd7b22436 --- /dev/null +++ b/tests/codeception/acceptance/HomeCest.php @@ -0,0 +1,16 @@ +amOnPage(Yii::$app->homeUrl); + $I->amOnPage('index.php?r=site%2Findex'); + $I->see('My Company'); + + $I->seeLink('About'); + $I->click('About'); + + $I->see('This is the About page.'); + } +} diff --git a/tests/codeception/acceptance/LoginCept.php b/tests/codeception/acceptance/LoginCept.php deleted file mode 100644 index 90d063583..000000000 --- a/tests/codeception/acceptance/LoginCept.php +++ /dev/null @@ -1,37 +0,0 @@ -wantTo('ensure that login works'); - -$loginPage = LoginPage::openBy($I); - -$I->see('Login', 'h1'); - -$I->amGoingTo('try to login with empty credentials'); -$loginPage->login('', ''); -if (method_exists($I, 'wait')) { - $I->wait(3); // only for selenium -} -$I->expectTo('see validations errors'); -$I->see('Username cannot be blank.'); -$I->see('Password cannot be blank.'); - -$I->amGoingTo('try to login with wrong credentials'); -$loginPage->login('admin', 'wrong'); -if (method_exists($I, 'wait')) { - $I->wait(3); // only for selenium -} -$I->expectTo('see validations errors'); -$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->expectTo('see user info'); -$I->see('Logout (admin)'); diff --git a/tests/codeception/acceptance/LoginCest.php b/tests/codeception/acceptance/LoginCest.php new file mode 100644 index 000000000..97f39800a --- /dev/null +++ b/tests/codeception/acceptance/LoginCest.php @@ -0,0 +1,19 @@ +amOnPage(['site/login']); + $I->amOnPage('index.php?r=site%2Flogin'); + $I->see('Login', 'h1'); + + $I->amGoingTo('try to login with correct credentials'); + $I->fillField('input[name="LoginForm[username]"]', 'admin'); + $I->fillField('input[name="LoginForm[password]"]', 'admin'); + $I->click('login-button'); + + $I->expectTo('see user info'); + $I->see('Logout (admin)'); + } +} From b1015559e013357b16acd1cdd8ab13eb95015509 Mon Sep 17 00:00:00 2001 From: Davert Date: Thu, 14 Jul 2016 21:03:28 +0300 Subject: [PATCH 171/390] refactoring --- .gitignore | 2 + tests/codeception.yml => codeception.yml | 17 +- composer.json | 2 + composer.lock | 1025 +++++++ config/test.php | 35 + config/web.php | 2 +- tests/_bootstrap.php | 10 + tests/{codeception => }/_output/.gitignore | 0 tests/{codeception => }/_pages/AboutPage.php | 0 tests/_pages/ContactPage.php | 26 + tests/{codeception => }/_pages/LoginPage.php | 0 tests/_support/AcceptanceTester.php | 26 + tests/_support/FunctionalTester.php | 26 + tests/_support/UnitTester.php | 26 + .../_generated/AcceptanceTesterActions.php | 2247 ++++++++++++++ .../_generated/FunctionalTesterActions.php | 2691 +++++++++++++++++ .../_support/_generated/UnitTesterActions.php | 576 ++++ tests/acceptance.suite.yml.example | 27 + tests/acceptance/AboutCept.php | 10 + tests/acceptance/ContactCept.php | 57 + tests/acceptance/HomeCept.php | 11 + tests/acceptance/LoginCept.php | 37 + .../acceptance/_bootstrap.php | 0 tests/{codeception => }/bin/_bootstrap.php | 0 tests/{codeception => }/bin/yii | 0 tests/{codeception => }/bin/yii.bat | 0 tests/codeception/_bootstrap.php | 23 - tests/codeception/config/config.php | 26 - tests/codeception/functional/_bootstrap.php | 2 - tests/{codeception => }/config/acceptance.php | 2 +- tests/{codeception => }/config/functional.php | 5 +- tests/{codeception => }/config/unit.php | 2 +- tests/{codeception => }/fixtures/.gitignore | 0 tests/{codeception => }/functional.suite.yml | 6 +- .../functional/AboutCept.php | 0 .../functional/ContactCept.php | 0 .../{codeception => }/functional/HomeCept.php | 0 .../functional/LoginCept.php | 0 tests/functional/_bootstrap.php | 1 + tests/{codeception => }/templates/.gitignore | 0 tests/{codeception => }/unit.suite.yml | 6 + tests/{codeception => }/unit/_bootstrap.php | 0 .../{codeception => }/unit/fixtures/.gitkeep | 0 .../unit/fixtures/data/.gitkeep | 0 .../unit/models/ContactFormTest.php | 0 .../unit/models/LoginFormTest.php | 0 .../unit/models/UserTest.php | 0 .../unit/templates/fixtures/.gitkeep | 0 48 files changed, 6853 insertions(+), 73 deletions(-) rename tests/codeception.yml => codeception.yml (60%) create mode 100644 composer.lock create mode 100644 config/test.php create mode 100644 tests/_bootstrap.php rename tests/{codeception => }/_output/.gitignore (100%) rename tests/{codeception => }/_pages/AboutPage.php (100%) create mode 100644 tests/_pages/ContactPage.php rename tests/{codeception => }/_pages/LoginPage.php (100%) create mode 100644 tests/_support/AcceptanceTester.php create mode 100644 tests/_support/FunctionalTester.php create mode 100644 tests/_support/UnitTester.php create mode 100644 tests/_support/_generated/AcceptanceTesterActions.php create mode 100644 tests/_support/_generated/FunctionalTesterActions.php create mode 100644 tests/_support/_generated/UnitTesterActions.php create mode 100644 tests/acceptance.suite.yml.example create mode 100644 tests/acceptance/AboutCept.php create mode 100644 tests/acceptance/ContactCept.php create mode 100644 tests/acceptance/HomeCept.php create mode 100644 tests/acceptance/LoginCept.php rename tests/{codeception => }/acceptance/_bootstrap.php (100%) rename tests/{codeception => }/bin/_bootstrap.php (100%) rename tests/{codeception => }/bin/yii (100%) rename tests/{codeception => }/bin/yii.bat (100%) delete mode 100644 tests/codeception/_bootstrap.php delete mode 100644 tests/codeception/config/config.php delete mode 100644 tests/codeception/functional/_bootstrap.php rename tests/{codeception => }/config/acceptance.php (75%) rename tests/{codeception => }/config/functional.php (79%) rename tests/{codeception => }/config/unit.php (74%) rename tests/{codeception => }/fixtures/.gitignore (100%) rename tests/{codeception => }/functional.suite.yml (76%) rename tests/{codeception => }/functional/AboutCept.php (100%) rename tests/{codeception => }/functional/ContactCept.php (100%) rename tests/{codeception => }/functional/HomeCept.php (100%) rename tests/{codeception => }/functional/LoginCept.php (100%) create mode 100644 tests/functional/_bootstrap.php rename tests/{codeception => }/templates/.gitignore (100%) rename tests/{codeception => }/unit.suite.yml (56%) rename tests/{codeception => }/unit/_bootstrap.php (100%) rename tests/{codeception => }/unit/fixtures/.gitkeep (100%) rename tests/{codeception => }/unit/fixtures/data/.gitkeep (100%) rename tests/{codeception => }/unit/models/ContactFormTest.php (100%) rename tests/{codeception => }/unit/models/LoginFormTest.php (100%) rename tests/{codeception => }/unit/models/UserTest.php (100%) rename tests/{codeception => }/unit/templates/fixtures/.gitkeep (100%) diff --git a/.gitignore b/.gitignore index 45bf7bf41..9af11e24d 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,5 @@ composer.phar phpunit.phar # local phpunit config /phpunit.xml + +tests/_output/* \ No newline at end of file diff --git a/tests/codeception.yml b/codeception.yml similarity index 60% rename from tests/codeception.yml rename to codeception.yml index b71ba31c1..d5d1aaf24 100644 --- a/tests/codeception.yml +++ b/codeception.yml @@ -1,4 +1,5 @@ actor: Tester +# To enable code coverage: #coverage: # #c3_url: http://localhost:8080/index-test.php/ # enabled: true @@ -20,17 +21,11 @@ actor: Tester # - ../web/* # - ../tests/* paths: - tests: codeception - log: codeception/_output - data: codeception/_data - helpers: codeception/_support + tests: tests + log: tests/_output + data: tests/_data + helpers: tests/_support settings: bootstrap: _bootstrap.php - suite_class: \PHPUnit_Framework_TestSuite memory_limit: 1024M - log: true - colors: true -config: - # the entry script URL (with host info) for functional and acceptance tests - # PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL - test_entry_url: http://localhost:8080/index-test.php \ No newline at end of file + colors: true \ No newline at end of file diff --git a/composer.json b/composer.json index 1631da65c..137ee77a6 100644 --- a/composer.json +++ b/composer.json @@ -21,6 +21,8 @@ }, "require-dev": { "yiisoft/yii2-codeception": "*", + "codeception/specify": "*", + "codeception/verify": "*", "yiisoft/yii2-debug": "*", "yiisoft/yii2-gii": "*", "yiisoft/yii2-faker": "*" diff --git a/composer.lock b/composer.lock new file mode 100644 index 000000000..ce0248cb8 --- /dev/null +++ b/composer.lock @@ -0,0 +1,1025 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "hash": "93894a180950d67c2b9edc7a95038f87", + "content-hash": "c8959aaf297f5e79479a01ef1dd73b02", + "packages": [ + { + "name": "bower-asset/bootstrap", + "version": "v3.3.5", + "source": { + "type": "git", + "url": "https://github.com/twbs/bootstrap.git", + "reference": "16b48259a62f576e52c903c476bd42b90ab22482" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/twbs/bootstrap/zipball/16b48259a62f576e52c903c476bd42b90ab22482", + "reference": "16b48259a62f576e52c903c476bd42b90ab22482", + "shasum": "" + }, + "require": { + "bower-asset/jquery": ">=1.9.1" + }, + "type": "bower-asset-library", + "extra": { + "bower-asset-main": [ + "less/bootstrap.less", + "dist/js/bootstrap.js" + ], + "bower-asset-ignore": [ + "/.*", + "_config.yml", + "CNAME", + "composer.json", + "CONTRIBUTING.md", + "docs", + "js/tests", + "test-infra" + ] + }, + "license": [ + "MIT" + ], + "description": "The most popular front-end framework for developing responsive, mobile first projects on the web.", + "keywords": [ + "css", + "framework", + "front-end", + "js", + "less", + "mobile-first", + "responsive", + "web" + ] + }, + { + "name": "bower-asset/jquery", + "version": "2.2.4", + "source": { + "type": "git", + "url": "https://github.com/jquery/jquery-dist.git", + "reference": "c0185ab7c75aab88762c5aae780b9d83b80eda72" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/jquery/jquery-dist/zipball/c0185ab7c75aab88762c5aae780b9d83b80eda72", + "reference": "c0185ab7c75aab88762c5aae780b9d83b80eda72", + "shasum": "" + }, + "type": "bower-asset-library", + "extra": { + "bower-asset-main": "dist/jquery.js", + "bower-asset-ignore": [ + "package.json" + ] + }, + "license": [ + "MIT" + ], + "keywords": [ + "browser", + "javascript", + "jquery", + "library" + ] + }, + { + "name": "bower-asset/jquery.inputmask", + "version": "3.2.7", + "source": { + "type": "git", + "url": "https://github.com/RobinHerbots/jquery.inputmask.git", + "reference": "5a72c563b502b8e05958a524cdfffafe9987be38" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/RobinHerbots/jquery.inputmask/zipball/5a72c563b502b8e05958a524cdfffafe9987be38", + "reference": "5a72c563b502b8e05958a524cdfffafe9987be38", + "shasum": "" + }, + "require": { + "bower-asset/jquery": ">=1.7" + }, + "type": "bower-asset-library", + "extra": { + "bower-asset-main": [ + "./dist/inputmask/inputmask.js" + ], + "bower-asset-ignore": [ + "**/*", + "!dist/*", + "!dist/inputmask/*", + "!dist/min/*", + "!dist/min/inputmask/*", + "!extra/bindings/*", + "!extra/dependencyLibs/*", + "!extra/phone-codes/*" + ] + }, + "license": [ + "http://opensource.org/licenses/mit-license.php" + ], + "description": "jquery.inputmask is a jquery plugin which create an input mask.", + "keywords": [ + "form", + "input", + "inputmask", + "jquery", + "mask", + "plugins" + ] + }, + { + "name": "bower-asset/punycode", + "version": "v1.3.2", + "source": { + "type": "git", + "url": "https://github.com/bestiejs/punycode.js.git", + "reference": "38c8d3131a82567bfef18da09f7f4db68c84f8a3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/bestiejs/punycode.js/zipball/38c8d3131a82567bfef18da09f7f4db68c84f8a3", + "reference": "38c8d3131a82567bfef18da09f7f4db68c84f8a3", + "shasum": "" + }, + "type": "bower-asset-library", + "extra": { + "bower-asset-main": "punycode.js", + "bower-asset-ignore": [ + "coverage", + "tests", + ".*", + "component.json", + "Gruntfile.js", + "node_modules", + "package.json" + ] + } + }, + { + "name": "bower-asset/yii2-pjax", + "version": "v2.0.6", + "source": { + "type": "git", + "url": "https://github.com/yiisoft/jquery-pjax.git", + "reference": "60728da6ade5879e807a49ce59ef9a72039b8978" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/yiisoft/jquery-pjax/zipball/60728da6ade5879e807a49ce59ef9a72039b8978", + "reference": "60728da6ade5879e807a49ce59ef9a72039b8978", + "shasum": "" + }, + "require": { + "bower-asset/jquery": ">=1.8" + }, + "type": "bower-asset-library", + "extra": { + "bower-asset-main": "./jquery.pjax.js", + "bower-asset-ignore": [ + ".travis.yml", + "Gemfile", + "Gemfile.lock", + "CONTRIBUTING.md", + "vendor/", + "script/", + "test/" + ] + }, + "license": [ + "MIT" + ] + }, + { + "name": "cebe/markdown", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/cebe/markdown.git", + "reference": "54a2c49de31cc44e864ebf0500a35ef21d0010b2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/cebe/markdown/zipball/54a2c49de31cc44e864ebf0500a35ef21d0010b2", + "reference": "54a2c49de31cc44e864ebf0500a35ef21d0010b2", + "shasum": "" + }, + "require": { + "lib-pcre": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "cebe/indent": "*", + "facebook/xhprof": "*@dev", + "phpunit/phpunit": "4.1.*" + }, + "bin": [ + "bin/markdown" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "psr-4": { + "cebe\\markdown\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Carsten Brandt", + "email": "mail@cebe.cc", + "homepage": "http://cebe.cc/", + "role": "Creator" + } + ], + "description": "A super fast, highly extensible markdown parser for PHP", + "homepage": "https://github.com/cebe/markdown#readme", + "keywords": [ + "extensible", + "fast", + "gfm", + "markdown", + "markdown-extra" + ], + "time": "2015-03-06 05:28:07" + }, + { + "name": "ezyang/htmlpurifier", + "version": "v4.7.0", + "source": { + "type": "git", + "url": "https://github.com/ezyang/htmlpurifier.git", + "reference": "ae1828d955112356f7677c465f94f7deb7d27a40" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/ae1828d955112356f7677c465f94f7deb7d27a40", + "reference": "ae1828d955112356f7677c465f94f7deb7d27a40", + "shasum": "" + }, + "require": { + "php": ">=5.2" + }, + "type": "library", + "autoload": { + "psr-0": { + "HTMLPurifier": "library/" + }, + "files": [ + "library/HTMLPurifier.composer.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL" + ], + "authors": [ + { + "name": "Edward Z. Yang", + "email": "admin@htmlpurifier.org", + "homepage": "http://ezyang.com/" + } + ], + "description": "Standards compliant HTML filter written in PHP", + "homepage": "http://htmlpurifier.org/", + "keywords": [ + "html" + ], + "time": "2015-08-05 01:03:42" + }, + { + "name": "swiftmailer/swiftmailer", + "version": "v5.4.3", + "source": { + "type": "git", + "url": "https://github.com/swiftmailer/swiftmailer.git", + "reference": "4cc92842069c2bbc1f28daaaf1d2576ec4dfe153" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/4cc92842069c2bbc1f28daaaf1d2576ec4dfe153", + "reference": "4cc92842069c2bbc1f28daaaf1d2576ec4dfe153", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "mockery/mockery": "~0.9.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.4-dev" + } + }, + "autoload": { + "files": [ + "lib/swift_required.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Chris Corbyn" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "Swiftmailer, free feature-rich PHP mailer", + "homepage": "http://swiftmailer.org/", + "keywords": [ + "email", + "mail", + "mailer" + ], + "time": "2016-07-08 11:51:25" + }, + { + "name": "yiisoft/yii2", + "version": "2.0.9", + "source": { + "type": "git", + "url": "https://github.com/yiisoft/yii2-framework.git", + "reference": "2b75151ea60e1fd820046416eee2e89c3dda1133" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/yiisoft/yii2-framework/zipball/2b75151ea60e1fd820046416eee2e89c3dda1133", + "reference": "2b75151ea60e1fd820046416eee2e89c3dda1133", + "shasum": "" + }, + "require": { + "bower-asset/jquery": "2.2.*@stable | 2.1.*@stable | 1.11.*@stable | 1.12.*@stable", + "bower-asset/jquery.inputmask": "~3.2.2", + "bower-asset/punycode": "1.3.*", + "bower-asset/yii2-pjax": "~2.0.1", + "cebe/markdown": "~1.0.0 | ~1.1.0", + "ext-ctype": "*", + "ext-mbstring": "*", + "ezyang/htmlpurifier": "~4.6", + "lib-pcre": "*", + "php": ">=5.4.0", + "yiisoft/yii2-composer": "~2.0.4" + }, + "bin": [ + "yii" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "yii\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Qiang Xue", + "email": "qiang.xue@gmail.com", + "homepage": "http://www.yiiframework.com/", + "role": "Founder and project lead" + }, + { + "name": "Alexander Makarov", + "email": "sam@rmcreative.ru", + "homepage": "http://rmcreative.ru/", + "role": "Core framework development" + }, + { + "name": "Maurizio Domba", + "homepage": "http://mdomba.info/", + "role": "Core framework development" + }, + { + "name": "Carsten Brandt", + "email": "mail@cebe.cc", + "homepage": "http://cebe.cc/", + "role": "Core framework development" + }, + { + "name": "Timur Ruziev", + "email": "resurtm@gmail.com", + "homepage": "http://resurtm.com/", + "role": "Core framework development" + }, + { + "name": "Paul Klimov", + "email": "klimov.paul@gmail.com", + "role": "Core framework development" + }, + { + "name": "Dmitry Naumenko", + "email": "d.naumenko.a@gmail.com", + "role": "Core framework development" + } + ], + "description": "Yii PHP Framework Version 2", + "homepage": "http://www.yiiframework.com/", + "keywords": [ + "framework", + "yii2" + ], + "time": "2016-07-11 13:36:42" + }, + { + "name": "yiisoft/yii2-bootstrap", + "version": "2.0.6", + "source": { + "type": "git", + "url": "https://github.com/yiisoft/yii2-bootstrap.git", + "reference": "3fd2b8c950cce79d60e9702d6bcb24eb3c80f6c5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/yiisoft/yii2-bootstrap/zipball/3fd2b8c950cce79d60e9702d6bcb24eb3c80f6c5", + "reference": "3fd2b8c950cce79d60e9702d6bcb24eb3c80f6c5", + "shasum": "" + }, + "require": { + "bower-asset/bootstrap": "3.3.* | 3.2.* | 3.1.*", + "yiisoft/yii2": ">=2.0.6" + }, + "type": "yii2-extension", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + }, + "asset-installer-paths": { + "npm-asset-library": "vendor/npm", + "bower-asset-library": "vendor/bower" + } + }, + "autoload": { + "psr-4": { + "yii\\bootstrap\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Qiang Xue", + "email": "qiang.xue@gmail.com" + } + ], + "description": "The Twitter Bootstrap extension for the Yii framework", + "keywords": [ + "bootstrap", + "yii2" + ], + "time": "2016-03-17 03:29:28" + }, + { + "name": "yiisoft/yii2-composer", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/yiisoft/yii2-composer.git", + "reference": "7452fd908a5023b8bb5ea1b123a174ca080de464" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/yiisoft/yii2-composer/zipball/7452fd908a5023b8bb5ea1b123a174ca080de464", + "reference": "7452fd908a5023b8bb5ea1b123a174ca080de464", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0" + }, + "type": "composer-plugin", + "extra": { + "class": "yii\\composer\\Plugin", + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "yii\\composer\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Qiang Xue", + "email": "qiang.xue@gmail.com" + } + ], + "description": "The composer plugin for Yii extension installer", + "keywords": [ + "composer", + "extension installer", + "yii2" + ], + "time": "2016-02-06 00:49:24" + }, + { + "name": "yiisoft/yii2-swiftmailer", + "version": "2.0.5", + "source": { + "type": "git", + "url": "https://github.com/yiisoft/yii2-swiftmailer.git", + "reference": "e2c6315caff30a9271a7afad4d684627721dc69a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/yiisoft/yii2-swiftmailer/zipball/e2c6315caff30a9271a7afad4d684627721dc69a", + "reference": "e2c6315caff30a9271a7afad4d684627721dc69a", + "shasum": "" + }, + "require": { + "swiftmailer/swiftmailer": "~5.0", + "yiisoft/yii2": ">=2.0.4" + }, + "type": "yii2-extension", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "yii\\swiftmailer\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Paul Klimov", + "email": "klimov.paul@gmail.com" + } + ], + "description": "The SwiftMailer integration for the Yii framework", + "keywords": [ + "email", + "mail", + "mailer", + "swift", + "swiftmailer", + "yii2" + ], + "time": "2016-03-17 03:58:49" + } + ], + "packages-dev": [ + { + "name": "bower-asset/typeahead.js", + "version": "v0.11.1", + "source": { + "type": "git", + "url": "https://github.com/twitter/typeahead.js.git", + "reference": "588440f66559714280628a4f9799f0c4eb880a4a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/twitter/typeahead.js/zipball/588440f66559714280628a4f9799f0c4eb880a4a", + "reference": "588440f66559714280628a4f9799f0c4eb880a4a", + "shasum": "" + }, + "require": { + "bower-asset/jquery": ">=1.7" + }, + "require-dev": { + "bower-asset/jasmine-ajax": "~1.3.1", + "bower-asset/jasmine-jquery": "~1.5.2", + "bower-asset/jquery": "~1.7" + }, + "type": "bower-asset-library", + "extra": { + "bower-asset-main": "dist/typeahead.bundle.js" + } + }, + { + "name": "codeception/specify", + "version": "0.4.3", + "source": { + "type": "git", + "url": "https://github.com/Codeception/Specify.git", + "reference": "8efcd017687ebdae9c4d95bcbc1dc22a28561874" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Codeception/Specify/zipball/8efcd017687ebdae9c4d95bcbc1dc22a28561874", + "reference": "8efcd017687ebdae9c4d95bcbc1dc22a28561874", + "shasum": "" + }, + "require": { + "myclabs/deep-copy": "~1.1", + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "autoload": { + "psr-0": { + "Codeception\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "authors": [ + { + "name": "Michael Bodnarchuk", + "email": "davert.php@mailican.com" + } + ], + "description": "BDD code blocks for PHPUnit and Codeception", + "time": "2015-11-26 23:35:52" + }, + { + "name": "codeception/verify", + "version": "0.3.0", + "source": { + "type": "git", + "url": "https://github.com/Codeception/Verify.git", + "reference": "d3721cfc668d96b41acbda3ecd01d3499381db64" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Codeception/Verify/zipball/d3721cfc668d96b41acbda3ecd01d3499381db64", + "reference": "d3721cfc668d96b41acbda3ecd01d3499381db64", + "shasum": "" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "autoload": { + "files": [ + "src/Codeception/function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "authors": [ + { + "name": "Michael Bodnarchuk", + "email": "davert.php@mailican.com" + } + ], + "description": "BDD assertion library for PHPUnit", + "time": "2015-11-26 23:23:25" + }, + { + "name": "fzaninotto/faker", + "version": "v1.6.0", + "source": { + "type": "git", + "url": "https://github.com/fzaninotto/Faker.git", + "reference": "44f9a286a04b80c76a4e5fb7aad8bb539b920123" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/fzaninotto/Faker/zipball/44f9a286a04b80c76a4e5fb7aad8bb539b920123", + "reference": "44f9a286a04b80c76a4e5fb7aad8bb539b920123", + "shasum": "" + }, + "require": { + "php": "^5.3.3|^7.0" + }, + "require-dev": { + "ext-intl": "*", + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "~1.5" + }, + "type": "library", + "extra": { + "branch-alias": [] + }, + "autoload": { + "psr-4": { + "Faker\\": "src/Faker/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "François Zaninotto" + } + ], + "description": "Faker is a PHP library that generates fake data for you.", + "keywords": [ + "data", + "faker", + "fixtures" + ], + "time": "2016-04-29 12:21:54" + }, + { + "name": "myclabs/deep-copy", + "version": "1.5.1", + "source": { + "type": "git", + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "a8773992b362b58498eed24bf85005f363c34771" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/a8773992b362b58498eed24bf85005f363c34771", + "reference": "a8773992b362b58498eed24bf85005f363c34771", + "shasum": "" + }, + "require": { + "php": ">=5.4.0" + }, + "require-dev": { + "doctrine/collections": "1.*", + "phpunit/phpunit": "~4.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Create deep copies (clones) of your objects", + "homepage": "https://github.com/myclabs/DeepCopy", + "keywords": [ + "clone", + "copy", + "duplicate", + "object", + "object graph" + ], + "time": "2015-11-20 12:04:31" + }, + { + "name": "phpspec/php-diff", + "version": "v1.1.0", + "source": { + "type": "git", + "url": "https://github.com/phpspec/php-diff.git", + "reference": "0464787bfa7cd13576c5a1e318709768798bec6a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpspec/php-diff/zipball/0464787bfa7cd13576c5a1e318709768798bec6a", + "reference": "0464787bfa7cd13576c5a1e318709768798bec6a", + "shasum": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "Diff": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Chris Boulton", + "homepage": "http://github.com/chrisboulton" + } + ], + "description": "A comprehensive library for generating differences between two hashable objects (strings or arrays).", + "time": "2016-04-07 12:29:16" + }, + { + "name": "yiisoft/yii2-codeception", + "version": "2.0.5", + "source": { + "type": "git", + "url": "https://github.com/yiisoft/yii2-codeception.git", + "reference": "c916a36d09fc128b05a374e7922bc56854334d56" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/yiisoft/yii2-codeception/zipball/c916a36d09fc128b05a374e7922bc56854334d56", + "reference": "c916a36d09fc128b05a374e7922bc56854334d56", + "shasum": "" + }, + "require": { + "yiisoft/yii2": ">=2.0.4" + }, + "type": "yii2-extension", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "yii\\codeception\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Mark Jebri", + "email": "mark.github@yandex.ru" + } + ], + "description": "The Codeception integration for the Yii framework", + "keywords": [ + "codeception", + "yii2" + ], + "time": "2016-03-17 03:41:26" + }, + { + "name": "yiisoft/yii2-debug", + "version": "2.0.6", + "source": { + "type": "git", + "url": "https://github.com/yiisoft/yii2-debug.git", + "reference": "55ed2e853ed8050a34415f63a4da84f88a56f895" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/yiisoft/yii2-debug/zipball/55ed2e853ed8050a34415f63a4da84f88a56f895", + "reference": "55ed2e853ed8050a34415f63a4da84f88a56f895", + "shasum": "" + }, + "require": { + "yiisoft/yii2": ">=2.0.4", + "yiisoft/yii2-bootstrap": "*" + }, + "type": "yii2-extension", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "yii\\debug\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Qiang Xue", + "email": "qiang.xue@gmail.com" + } + ], + "description": "The debugger extension for the Yii framework", + "keywords": [ + "debug", + "debugger", + "yii2" + ], + "time": "2016-03-17 03:50:19" + }, + { + "name": "yiisoft/yii2-faker", + "version": "2.0.3", + "source": { + "type": "git", + "url": "https://github.com/yiisoft/yii2-faker.git", + "reference": "b88ca69ee226a3610b2c26c026c3203d7ac50f6c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/yiisoft/yii2-faker/zipball/b88ca69ee226a3610b2c26c026c3203d7ac50f6c", + "reference": "b88ca69ee226a3610b2c26c026c3203d7ac50f6c", + "shasum": "" + }, + "require": { + "fzaninotto/faker": "*", + "yiisoft/yii2": "*" + }, + "type": "yii2-extension", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "yii\\faker\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Mark Jebri", + "email": "mark.github@yandex.ru" + } + ], + "description": "Fixture generator. The Faker integration for the Yii framework.", + "keywords": [ + "Fixture", + "faker", + "yii2" + ], + "time": "2015-03-01 06:22:44" + }, + { + "name": "yiisoft/yii2-gii", + "version": "2.0.5", + "source": { + "type": "git", + "url": "https://github.com/yiisoft/yii2-gii.git", + "reference": "1bd6df6804ca077ec022587905a0d43eb286f507" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/yiisoft/yii2-gii/zipball/1bd6df6804ca077ec022587905a0d43eb286f507", + "reference": "1bd6df6804ca077ec022587905a0d43eb286f507", + "shasum": "" + }, + "require": { + "bower-asset/typeahead.js": "0.10.* | ~0.11.0", + "phpspec/php-diff": ">=1.0.2", + "yiisoft/yii2": ">=2.0.4", + "yiisoft/yii2-bootstrap": "~2.0" + }, + "type": "yii2-extension", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + }, + "asset-installer-paths": { + "npm-asset-library": "vendor/npm", + "bower-asset-library": "vendor/bower" + } + }, + "autoload": { + "psr-4": { + "yii\\gii\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Qiang Xue", + "email": "qiang.xue@gmail.com" + } + ], + "description": "The Gii extension for the Yii framework", + "keywords": [ + "code generator", + "gii", + "yii2" + ], + "time": "2016-03-18 14:09:46" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": ">=5.4.0" + }, + "platform-dev": [] +} diff --git a/config/test.php b/config/test.php new file mode 100644 index 000000000..03b6580dd --- /dev/null +++ b/config/test.php @@ -0,0 +1,35 @@ + 'basic-tests', + 'basePath' => dirname(__DIR__), + 'language' => 'en-US', + 'components' => [ + 'db' => $dbParams, + 'mailer' => [ + 'useFileTransport' => true, + ], + 'urlManager' => [ + 'showScriptName' => true, + ], + 'request' => [ + // it's not recommended to run functional tests with CSRF validation enabled + 'enableCsrfValidation' => false, + // but if you absolutely need it set cookie domain to localhost + /* + 'csrfCookie' => [ + 'domain' => 'localhost', + ], + */ + ], + ], + 'params' => $params, +]; diff --git a/config/web.php b/config/web.php index 90a82876b..a45b77cd8 100644 --- a/config/web.php +++ b/config/web.php @@ -9,7 +9,7 @@ 'components' => [ 'request' => [ // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation - 'cookieValidationKey' => '', + 'cookieValidationKey' => '12334543543', ], 'cache' => [ 'class' => 'yii\caching\FileCache', diff --git a/tests/_bootstrap.php b/tests/_bootstrap.php new file mode 100644 index 000000000..c7f5cfc4f --- /dev/null +++ b/tests/_bootstrap.php @@ -0,0 +1,10 @@ + $value) { + $inputType = $field === 'body' ? 'textarea' : 'input'; + $this->actor->fillField($inputType . '[name="ContactForm[' . $field . ']"]', $value); + } + $this->actor->click('contact-button'); + } +} diff --git a/tests/codeception/_pages/LoginPage.php b/tests/_pages/LoginPage.php similarity index 100% rename from tests/codeception/_pages/LoginPage.php rename to tests/_pages/LoginPage.php diff --git a/tests/_support/AcceptanceTester.php b/tests/_support/AcceptanceTester.php new file mode 100644 index 000000000..4c7dcbb6d --- /dev/null +++ b/tests/_support/AcceptanceTester.php @@ -0,0 +1,26 @@ +getScenario()->runStep(new \Codeception\Step\Action('setHeader', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Authenticates user for HTTP_AUTH + * + * @param $username + * @param $password + * @see \Codeception\Module\PhpBrowser::amHttpAuthenticated() + */ + public function amHttpAuthenticated($username, $password) { + return $this->getScenario()->runStep(new \Codeception\Step\Condition('amHttpAuthenticated', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Open web page at the given absolute URL and sets its hostname as the base host. + * + * ``` php + * amOnUrl('http://codeception.com/'); + * $I->amOnPage('/quickstart'); // moves to http://codeception.com/quickstart + * ?> + * ``` + * @see \Codeception\Module\PhpBrowser::amOnUrl() + */ + public function amOnUrl($url) { + return $this->getScenario()->runStep(new \Codeception\Step\Condition('amOnUrl', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Changes the subdomain for the 'url' configuration parameter. + * Does not open a page; use `amOnPage` for that. + * + * ``` php + * amOnSubdomain('user'); + * $I->amOnPage('/'); + * // moves to http://user.mysite.com/ + * ?> + * ``` + * + * @param $subdomain + * + * @return mixed + * @see \Codeception\Module\PhpBrowser::amOnSubdomain() + */ + public function amOnSubdomain($subdomain) { + return $this->getScenario()->runStep(new \Codeception\Step\Condition('amOnSubdomain', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Low-level API method. + * If Codeception commands are not enough, use [Guzzle HTTP Client](http://guzzlephp.org/) methods directly + * + * Example: + * + * ``` php + * executeInGuzzle(function (\GuzzleHttp\Client $client) { + * $client->get('/get', ['query' => ['foo' => 'bar']]); + * }); + * ?> + * ``` + * + * It is not recommended to use this command on a regular basis. + * If Codeception lacks important Guzzle Client methods, implement them and submit patches. + * + * @param callable $function + * @see \Codeception\Module\PhpBrowser::executeInGuzzle() + */ + public function executeInGuzzle($function) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('executeInGuzzle', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Sets the HTTP header to the passed value - which is used on + * subsequent HTTP requests through PhpBrowser. + * + * Example: + * ```php + * setHeader('X-Requested-With', 'Codeception'); + * $I->amOnPage('test-headers.php'); + * ?> + * ``` + * + * @param string $name the name of the request header + * @param string $value the value to set it to for subsequent + * requests + * @see \Codeception\Lib\InnerBrowser::haveHttpHeader() + */ + public function haveHttpHeader($name, $value) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('haveHttpHeader', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Deletes the header with the passed name. Subsequent requests + * will not have the deleted header in its request. + * + * Example: + * ```php + * haveHttpHeader('X-Requested-With', 'Codeception'); + * $I->amOnPage('test-headers.php'); + * // ... + * $I->deleteHeader('X-Requested-With'); + * $I->amOnPage('some-other-page.php'); + * ?> + * ``` + * + * @param string $name the name of the header to delete. + * @see \Codeception\Lib\InnerBrowser::deleteHeader() + */ + public function deleteHeader($name) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('deleteHeader', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Opens the page for the given relative URI. + * + * ``` php + * amOnPage('/'); + * // opens /register page + * $I->amOnPage('/register'); + * ``` + * + * @param $page + * @see \Codeception\Lib\InnerBrowser::amOnPage() + */ + public function amOnPage($page) { + return $this->getScenario()->runStep(new \Codeception\Step\Condition('amOnPage', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Perform a click on a link or a button, given by a locator. + * If a fuzzy locator is given, the page will be searched for a button, link, or image matching the locator string. + * For buttons, the "value" attribute, "name" attribute, and inner text are searched. + * For links, the link text is searched. + * For images, the "alt" attribute and inner text of any parent links are searched. + * + * The second parameter is a context (CSS or XPath locator) to narrow the search. + * + * Note that if the locator matches a button of type `submit`, the form will be submitted. + * + * ``` php + * click('Logout'); + * // button of form + * $I->click('Submit'); + * // CSS button + * $I->click('#form input[type=submit]'); + * // XPath + * $I->click('//form/*[@type=submit]'); + * // link in context + * $I->click('Logout', '#nav'); + * // using strict locator + * $I->click(['link' => 'Login']); + * ?> + * ``` + * + * @param $link + * @param $context + * @see \Codeception\Lib\InnerBrowser::click() + */ + public function click($link, $context = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('click', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current page contains the given string (case insensitive). + * + * You can specify a specific HTML element (via CSS or XPath) as the second + * parameter to only search within that element. + * + * ``` php + * see('Logout'); // I can suppose user is logged in + * $I->see('Sign Up', 'h1'); // I can suppose it's a signup page + * $I->see('Sign Up', '//body/h1'); // with XPath + * ``` + * + * Note that the search is done after stripping all HTML tags from the body, + * so `$I->see('strong')` will return true for strings like: + * + * - `

    I am Stronger than thou

    ` + * - `` + * + * But will *not* be true for strings like: + * + * - `Home` + * - `
    Home` + * - `` + * + * For checking the raw source code, use `seeInSource()`. + * + * @param $text + * @param null $selector + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::see() + */ + public function canSee($text, $selector = null) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('see', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current page contains the given string (case insensitive). + * + * You can specify a specific HTML element (via CSS or XPath) as the second + * parameter to only search within that element. + * + * ``` php + * see('Logout'); // I can suppose user is logged in + * $I->see('Sign Up', 'h1'); // I can suppose it's a signup page + * $I->see('Sign Up', '//body/h1'); // with XPath + * ``` + * + * Note that the search is done after stripping all HTML tags from the body, + * so `$I->see('strong')` will return true for strings like: + * + * - `

    I am Stronger than thou

    ` + * - `` + * + * But will *not* be true for strings like: + * + * - `Home` + * - `
    Home` + * - `` + * + * For checking the raw source code, use `seeInSource()`. + * + * @param $text + * @param null $selector + * @see \Codeception\Lib\InnerBrowser::see() + */ + public function see($text, $selector = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('see', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current page doesn't contain the text specified (case insensitive). + * Give a locator as the second parameter to match a specific region. + * + * ```php + * dontSee('Login'); // I can suppose user is already logged in + * $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page + * $I->dontSee('Sign Up','//body/h1'); // with XPath + * ``` + * + * Note that the search is done after stripping all HTML tags from the body, + * so `$I->dontSee('strong')` will fail on strings like: + * + * - `

    I am Stronger than thou

    ` + * - `` + * + * But will ignore strings like: + * + * - `Home` + * - `
    Home` + * - `` + * + * For checking the raw source code, use `seeInSource()`. + * + * @param $text + * @param null $selector + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSee() + */ + public function cantSee($text, $selector = null) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSee', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current page doesn't contain the text specified (case insensitive). + * Give a locator as the second parameter to match a specific region. + * + * ```php + * dontSee('Login'); // I can suppose user is already logged in + * $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page + * $I->dontSee('Sign Up','//body/h1'); // with XPath + * ``` + * + * Note that the search is done after stripping all HTML tags from the body, + * so `$I->dontSee('strong')` will fail on strings like: + * + * - `

    I am Stronger than thou

    ` + * - `` + * + * But will ignore strings like: + * + * - `Home` + * - `
    Home` + * - `` + * + * For checking the raw source code, use `seeInSource()`. + * + * @param $text + * @param null $selector + * @see \Codeception\Lib\InnerBrowser::dontSee() + */ + public function dontSee($text, $selector = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSee', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current page contains the given string in its + * raw source code. + * + * ``` php + * seeInSource('

    Green eggs & ham

    '); + * ``` + * + * @param $raw + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeInSource() + */ + public function canSeeInSource($raw) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInSource', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current page contains the given string in its + * raw source code. + * + * ``` php + * seeInSource('

    Green eggs & ham

    '); + * ``` + * + * @param $raw + * @see \Codeception\Lib\InnerBrowser::seeInSource() + */ + public function seeInSource($raw) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInSource', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current page contains the given string in its + * raw source code. + * + * ```php + * dontSeeInSource('

    Green eggs & ham

    '); + * ``` + * + * @param $raw + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSeeInSource() + */ + public function cantSeeInSource($raw) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInSource', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current page contains the given string in its + * raw source code. + * + * ```php + * dontSeeInSource('

    Green eggs & ham

    '); + * ``` + * + * @param $raw + * @see \Codeception\Lib\InnerBrowser::dontSeeInSource() + */ + public function dontSeeInSource($raw) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInSource', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that there's a link with the specified text. + * Give a full URL as the second parameter to match links with that exact URL. + * + * ``` php + * seeLink('Logout'); // matches Logout + * $I->seeLink('Logout','/logout'); // matches Logout + * ?> + * ``` + * + * @param $text + * @param null $url + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeLink() + */ + public function canSeeLink($text, $url = null) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeLink', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that there's a link with the specified text. + * Give a full URL as the second parameter to match links with that exact URL. + * + * ``` php + * seeLink('Logout'); // matches Logout + * $I->seeLink('Logout','/logout'); // matches Logout + * ?> + * ``` + * + * @param $text + * @param null $url + * @see \Codeception\Lib\InnerBrowser::seeLink() + */ + public function seeLink($text, $url = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeLink', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the page doesn't contain a link with the given string. + * If the second parameter is given, only links with a matching "href" attribute will be checked. + * + * ``` php + * dontSeeLink('Logout'); // I suppose user is not logged in + * $I->dontSeeLink('Checkout now', '/store/cart.php'); + * ?> + * ``` + * + * @param $text + * @param null $url + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSeeLink() + */ + public function cantSeeLink($text, $url = null) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeLink', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the page doesn't contain a link with the given string. + * If the second parameter is given, only links with a matching "href" attribute will be checked. + * + * ``` php + * dontSeeLink('Logout'); // I suppose user is not logged in + * $I->dontSeeLink('Checkout now', '/store/cart.php'); + * ?> + * ``` + * + * @param $text + * @param null $url + * @see \Codeception\Lib\InnerBrowser::dontSeeLink() + */ + public function dontSeeLink($text, $url = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeLink', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that current URI contains the given string. + * + * ``` php + * seeInCurrentUrl('home'); + * // to match: /users/1 + * $I->seeInCurrentUrl('/users/'); + * ?> + * ``` + * + * @param $uri + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeInCurrentUrl() + */ + public function canSeeInCurrentUrl($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInCurrentUrl', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that current URI contains the given string. + * + * ``` php + * seeInCurrentUrl('home'); + * // to match: /users/1 + * $I->seeInCurrentUrl('/users/'); + * ?> + * ``` + * + * @param $uri + * @see \Codeception\Lib\InnerBrowser::seeInCurrentUrl() + */ + public function seeInCurrentUrl($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInCurrentUrl', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current URI doesn't contain the given string. + * + * ``` php + * dontSeeInCurrentUrl('/users/'); + * ?> + * ``` + * + * @param $uri + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSeeInCurrentUrl() + */ + public function cantSeeInCurrentUrl($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInCurrentUrl', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current URI doesn't contain the given string. + * + * ``` php + * dontSeeInCurrentUrl('/users/'); + * ?> + * ``` + * + * @param $uri + * @see \Codeception\Lib\InnerBrowser::dontSeeInCurrentUrl() + */ + public function dontSeeInCurrentUrl($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInCurrentUrl', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current URL is equal to the given string. + * Unlike `seeInCurrentUrl`, this only matches the full URL. + * + * ``` php + * seeCurrentUrlEquals('/'); + * ?> + * ``` + * + * @param $uri + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlEquals() + */ + public function canSeeCurrentUrlEquals($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCurrentUrlEquals', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current URL is equal to the given string. + * Unlike `seeInCurrentUrl`, this only matches the full URL. + * + * ``` php + * seeCurrentUrlEquals('/'); + * ?> + * ``` + * + * @param $uri + * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlEquals() + */ + public function seeCurrentUrlEquals($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCurrentUrlEquals', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current URL doesn't equal the given string. + * Unlike `dontSeeInCurrentUrl`, this only matches the full URL. + * + * ``` php + * dontSeeCurrentUrlEquals('/'); + * ?> + * ``` + * + * @param $uri + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlEquals() + */ + public function cantSeeCurrentUrlEquals($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCurrentUrlEquals', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current URL doesn't equal the given string. + * Unlike `dontSeeInCurrentUrl`, this only matches the full URL. + * + * ``` php + * dontSeeCurrentUrlEquals('/'); + * ?> + * ``` + * + * @param $uri + * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlEquals() + */ + public function dontSeeCurrentUrlEquals($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeCurrentUrlEquals', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current URL matches the given regular expression. + * + * ``` php + * seeCurrentUrlMatches('~$/users/(\d+)~'); + * ?> + * ``` + * + * @param $uri + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlMatches() + */ + public function canSeeCurrentUrlMatches($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCurrentUrlMatches', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the current URL matches the given regular expression. + * + * ``` php + * seeCurrentUrlMatches('~$/users/(\d+)~'); + * ?> + * ``` + * + * @param $uri + * @see \Codeception\Lib\InnerBrowser::seeCurrentUrlMatches() + */ + public function seeCurrentUrlMatches($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCurrentUrlMatches', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that current url doesn't match the given regular expression. + * + * ``` php + * dontSeeCurrentUrlMatches('~$/users/(\d+)~'); + * ?> + * ``` + * + * @param $uri + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlMatches() + */ + public function cantSeeCurrentUrlMatches($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCurrentUrlMatches', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that current url doesn't match the given regular expression. + * + * ``` php + * dontSeeCurrentUrlMatches('~$/users/(\d+)~'); + * ?> + * ``` + * + * @param $uri + * @see \Codeception\Lib\InnerBrowser::dontSeeCurrentUrlMatches() + */ + public function dontSeeCurrentUrlMatches($uri) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeCurrentUrlMatches', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Executes the given regular expression against the current URI and returns the first match. + * If no parameters are provided, the full URI is returned. + * + * ``` php + * grabFromCurrentUrl('~$/user/(\d+)/~'); + * $uri = $I->grabFromCurrentUrl(); + * ?> + * ``` + * + * @param null $uri + * + * @return mixed + * @see \Codeception\Lib\InnerBrowser::grabFromCurrentUrl() + */ + public function grabFromCurrentUrl($uri = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('grabFromCurrentUrl', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the specified checkbox is checked. + * + * ``` php + * seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms + * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user agreed to terms, If there is only one checkbox in form. + * $I->seeCheckboxIsChecked('//form/input[@type=checkbox and @name=agree]'); + * ?> + * ``` + * + * @param $checkbox + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeCheckboxIsChecked() + */ + public function canSeeCheckboxIsChecked($checkbox) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCheckboxIsChecked', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the specified checkbox is checked. + * + * ``` php + * seeCheckboxIsChecked('#agree'); // I suppose user agreed to terms + * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user agreed to terms, If there is only one checkbox in form. + * $I->seeCheckboxIsChecked('//form/input[@type=checkbox and @name=agree]'); + * ?> + * ``` + * + * @param $checkbox + * @see \Codeception\Lib\InnerBrowser::seeCheckboxIsChecked() + */ + public function seeCheckboxIsChecked($checkbox) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCheckboxIsChecked', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Check that the specified checkbox is unchecked. + * + * ``` php + * dontSeeCheckboxIsChecked('#agree'); // I suppose user didn't agree to terms + * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user didn't check the first checkbox in form. + * ?> + * ``` + * + * @param $checkbox + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSeeCheckboxIsChecked() + */ + public function cantSeeCheckboxIsChecked($checkbox) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCheckboxIsChecked', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Check that the specified checkbox is unchecked. + * + * ``` php + * dontSeeCheckboxIsChecked('#agree'); // I suppose user didn't agree to terms + * $I->seeCheckboxIsChecked('#signup_form input[type=checkbox]'); // I suppose user didn't check the first checkbox in form. + * ?> + * ``` + * + * @param $checkbox + * @see \Codeception\Lib\InnerBrowser::dontSeeCheckboxIsChecked() + */ + public function dontSeeCheckboxIsChecked($checkbox) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeCheckboxIsChecked', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the given input field or textarea contains the given value. + * For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath. + * + * ``` php + * seeInField('Body','Type your comment here'); + * $I->seeInField('form textarea[name=body]','Type your comment here'); + * $I->seeInField('form input[type=hidden]','hidden_value'); + * $I->seeInField('#searchform input','Search'); + * $I->seeInField('//form/*[@name=search]','Search'); + * $I->seeInField(['name' => 'search'], 'Search'); + * ?> + * ``` + * + * @param $field + * @param $value + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeInField() + */ + public function canSeeInField($field, $value) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInField', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the given input field or textarea contains the given value. + * For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath. + * + * ``` php + * seeInField('Body','Type your comment here'); + * $I->seeInField('form textarea[name=body]','Type your comment here'); + * $I->seeInField('form input[type=hidden]','hidden_value'); + * $I->seeInField('#searchform input','Search'); + * $I->seeInField('//form/*[@name=search]','Search'); + * $I->seeInField(['name' => 'search'], 'Search'); + * ?> + * ``` + * + * @param $field + * @param $value + * @see \Codeception\Lib\InnerBrowser::seeInField() + */ + public function seeInField($field, $value) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInField', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that an input field or textarea doesn't contain the given value. + * For fuzzy locators, the field is matched by label text, CSS and XPath. + * + * ``` php + * dontSeeInField('Body','Type your comment here'); + * $I->dontSeeInField('form textarea[name=body]','Type your comment here'); + * $I->dontSeeInField('form input[type=hidden]','hidden_value'); + * $I->dontSeeInField('#searchform input','Search'); + * $I->dontSeeInField('//form/*[@name=search]','Search'); + * $I->dontSeeInField(['name' => 'search'], 'Search'); + * ?> + * ``` + * + * @param $field + * @param $value + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSeeInField() + */ + public function cantSeeInField($field, $value) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInField', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that an input field or textarea doesn't contain the given value. + * For fuzzy locators, the field is matched by label text, CSS and XPath. + * + * ``` php + * dontSeeInField('Body','Type your comment here'); + * $I->dontSeeInField('form textarea[name=body]','Type your comment here'); + * $I->dontSeeInField('form input[type=hidden]','hidden_value'); + * $I->dontSeeInField('#searchform input','Search'); + * $I->dontSeeInField('//form/*[@name=search]','Search'); + * $I->dontSeeInField(['name' => 'search'], 'Search'); + * ?> + * ``` + * + * @param $field + * @param $value + * @see \Codeception\Lib\InnerBrowser::dontSeeInField() + */ + public function dontSeeInField($field, $value) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInField', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks if the array of form parameters (name => value) are set on the form matched with the + * passed selector. + * + * ``` php + * seeInFormFields('form[name=myform]', [ + * 'input1' => 'value', + * 'input2' => 'other value', + * ]); + * ?> + * ``` + * + * For multi-select elements, or to check values of multiple elements with the same name, an + * array may be passed: + * + * ``` php + * seeInFormFields('.form-class', [ + * 'multiselect' => [ + * 'value1', + * 'value2', + * ], + * 'checkbox[]' => [ + * 'a checked value', + * 'another checked value', + * ], + * ]); + * ?> + * ``` + * + * Additionally, checkbox values can be checked with a boolean. + * + * ``` php + * seeInFormFields('#form-id', [ + * 'checkbox1' => true, // passes if checked + * 'checkbox2' => false, // passes if unchecked + * ]); + * ?> + * ``` + * + * Pair this with submitForm for quick testing magic. + * + * ``` php + * 'value', + * 'field2' => 'another value', + * 'checkbox1' => true, + * // ... + * ]; + * $I->submitForm('//form[@id=my-form]', $form, 'submitButton'); + * // $I->amOnPage('/path/to/form-page') may be needed + * $I->seeInFormFields('//form[@id=my-form]', $form); + * ?> + * ``` + * + * @param $formSelector + * @param $params + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeInFormFields() + */ + public function canSeeInFormFields($formSelector, $params) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInFormFields', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks if the array of form parameters (name => value) are set on the form matched with the + * passed selector. + * + * ``` php + * seeInFormFields('form[name=myform]', [ + * 'input1' => 'value', + * 'input2' => 'other value', + * ]); + * ?> + * ``` + * + * For multi-select elements, or to check values of multiple elements with the same name, an + * array may be passed: + * + * ``` php + * seeInFormFields('.form-class', [ + * 'multiselect' => [ + * 'value1', + * 'value2', + * ], + * 'checkbox[]' => [ + * 'a checked value', + * 'another checked value', + * ], + * ]); + * ?> + * ``` + * + * Additionally, checkbox values can be checked with a boolean. + * + * ``` php + * seeInFormFields('#form-id', [ + * 'checkbox1' => true, // passes if checked + * 'checkbox2' => false, // passes if unchecked + * ]); + * ?> + * ``` + * + * Pair this with submitForm for quick testing magic. + * + * ``` php + * 'value', + * 'field2' => 'another value', + * 'checkbox1' => true, + * // ... + * ]; + * $I->submitForm('//form[@id=my-form]', $form, 'submitButton'); + * // $I->amOnPage('/path/to/form-page') may be needed + * $I->seeInFormFields('//form[@id=my-form]', $form); + * ?> + * ``` + * + * @param $formSelector + * @param $params + * @see \Codeception\Lib\InnerBrowser::seeInFormFields() + */ + public function seeInFormFields($formSelector, $params) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInFormFields', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks if the array of form parameters (name => value) are not set on the form matched with + * the passed selector. + * + * ``` php + * dontSeeInFormFields('form[name=myform]', [ + * 'input1' => 'non-existent value', + * 'input2' => 'other non-existent value', + * ]); + * ?> + * ``` + * + * To check that an element hasn't been assigned any one of many values, an array can be passed + * as the value: + * + * ``` php + * dontSeeInFormFields('.form-class', [ + * 'fieldName' => [ + * 'This value shouldn\'t be set', + * 'And this value shouldn\'t be set', + * ], + * ]); + * ?> + * ``` + * + * Additionally, checkbox values can be checked with a boolean. + * + * ``` php + * dontSeeInFormFields('#form-id', [ + * 'checkbox1' => true, // fails if checked + * 'checkbox2' => false, // fails if unchecked + * ]); + * ?> + * ``` + * + * @param $formSelector + * @param $params + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSeeInFormFields() + */ + public function cantSeeInFormFields($formSelector, $params) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInFormFields', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks if the array of form parameters (name => value) are not set on the form matched with + * the passed selector. + * + * ``` php + * dontSeeInFormFields('form[name=myform]', [ + * 'input1' => 'non-existent value', + * 'input2' => 'other non-existent value', + * ]); + * ?> + * ``` + * + * To check that an element hasn't been assigned any one of many values, an array can be passed + * as the value: + * + * ``` php + * dontSeeInFormFields('.form-class', [ + * 'fieldName' => [ + * 'This value shouldn\'t be set', + * 'And this value shouldn\'t be set', + * ], + * ]); + * ?> + * ``` + * + * Additionally, checkbox values can be checked with a boolean. + * + * ``` php + * dontSeeInFormFields('#form-id', [ + * 'checkbox1' => true, // fails if checked + * 'checkbox2' => false, // fails if unchecked + * ]); + * ?> + * ``` + * + * @param $formSelector + * @param $params + * @see \Codeception\Lib\InnerBrowser::dontSeeInFormFields() + */ + public function dontSeeInFormFields($formSelector, $params) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInFormFields', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Submits the given form on the page, optionally with the given form + * values. Pass the form field's values as an array in the second + * parameter. + * + * Although this function can be used as a short-hand version of + * `fillField()`, `selectOption()`, `click()` etc. it has some important + * differences: + * + * * Only field *names* may be used, not CSS/XPath selectors nor field labels + * * If a field is sent to this function that does *not* exist on the page, + * it will silently be added to the HTTP request. This is helpful for testing + * some types of forms, but be aware that you will *not* get an exception + * like you would if you called `fillField()` or `selectOption()` with + * a missing field. + * + * Fields that are not provided will be filled by their values from the page, + * or from any previous calls to `fillField()`, `selectOption()` etc. + * You don't need to click the 'Submit' button afterwards. + * This command itself triggers the request to form's action. + * + * You can optionally specify which button's value to include + * in the request with the last parameter (as an alternative to + * explicitly setting its value in the second parameter), as + * button values are not otherwise included in the request. + * + * Examples: + * + * ``` php + * submitForm('#login', [ + * 'login' => 'davert', + * 'password' => '123456' + * ]); + * // or + * $I->submitForm('#login', [ + * 'login' => 'davert', + * 'password' => '123456' + * ], 'submitButtonName'); + * + * ``` + * + * For example, given this sample "Sign Up" form: + * + * ``` html + *
    + * Login: + *
    + * Password: + *
    + * Do you agree to our terms? + *
    + * Select pricing plan: + * + * + *
    + * ``` + * + * You could write the following to submit it: + * + * ``` php + * submitForm( + * '#userForm', + * [ + * 'user' => [ + * 'login' => 'Davert', + * 'password' => '123456', + * 'agree' => true + * ] + * ], + * 'submitButton' + * ); + * ``` + * Note that "2" will be the submitted value for the "plan" field, as it is + * the selected option. + * + * You can also emulate a JavaScript submission by not specifying any + * buttons in the third parameter to submitForm. + * + * ```php + * submitForm( + * '#userForm', + * [ + * 'user' => [ + * 'login' => 'Davert', + * 'password' => '123456', + * 'agree' => true + * ] + * ] + * ); + * ``` + * + * This function works well when paired with `seeInFormFields()` + * for quickly testing CRUD interfaces and form validation logic. + * + * ``` php + * 'value', + * 'field2' => 'another value', + * 'checkbox1' => true, + * // ... + * ]; + * $I->submitForm('#my-form', $form, 'submitButton'); + * // $I->amOnPage('/path/to/form-page') may be needed + * $I->seeInFormFields('#my-form', $form); + * ``` + * + * Parameter values can be set to arrays for multiple input fields + * of the same name, or multi-select combo boxes. For checkboxes, + * you can use either the string value or boolean `true`/`false` which will + * be replaced by the checkbox's value in the DOM. + * + * ``` php + * submitForm('#my-form', [ + * 'field1' => 'value', + * 'checkbox' => [ + * 'value of first checkbox', + * 'value of second checkbox', + * ], + * 'otherCheckboxes' => [ + * true, + * false, + * false + * ], + * 'multiselect' => [ + * 'first option value', + * 'second option value' + * ] + * ]); + * ``` + * + * Mixing string and boolean values for a checkbox's value is not supported + * and may produce unexpected results. + * + * Field names ending in `[]` must be passed without the trailing square + * bracket characters, and must contain an array for its value. This allows + * submitting multiple values with the same name, consider: + * + * ```php + * submitForm('#my-form', [ + * 'field[]' => 'value', + * 'field[]' => 'another value', // 'field[]' is already a defined key + * ]); + * ``` + * + * The solution is to pass an array value: + * + * ```php + * submitForm('#my-form', [ + * 'field' => [ + * 'value', + * 'another value', + * ] + * ]); + * ``` + * + * @param $selector + * @param $params + * @param $button + * @see \Codeception\Lib\InnerBrowser::submitForm() + */ + public function submitForm($selector, $params, $button = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('submitForm', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Fills a text field or textarea with the given string. + * + * ``` php + * fillField("//input[@type='text']", "Hello World!"); + * $I->fillField(['name' => 'email'], 'jon@mail.com'); + * ?> + * ``` + * + * @param $field + * @param $value + * @see \Codeception\Lib\InnerBrowser::fillField() + */ + public function fillField($field, $value) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('fillField', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Selects an option in a select tag or in radio button group. + * + * ``` php + * selectOption('form select[name=account]', 'Premium'); + * $I->selectOption('form input[name=payment]', 'Monthly'); + * $I->selectOption('//form/select[@name=account]', 'Monthly'); + * ?> + * ``` + * + * Provide an array for the second argument to select multiple options: + * + * ``` php + * selectOption('Which OS do you use?', array('Windows','Linux')); + * ?> + * ``` + * + * Or provide an associative array for the second argument to specifically define which selection method should be used: + * + * ``` php + * selectOption('Which OS do you use?', array('text' => 'Windows')); // Only search by text 'Windows' + * $I->selectOption('Which OS do you use?', array('value' => 'windows')); // Only search by value 'windows' + * ?> + + ``` + * + * @param $select + * @param $option + * @see \Codeception\Lib\InnerBrowser::selectOption() + */ + public function selectOption($select, $option) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('selectOption', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Ticks a checkbox. For radio buttons, use the `selectOption` method instead. + * + * ``` php + * checkOption('#agree'); + * ?> + * ``` + * + * @param $option + * @see \Codeception\Lib\InnerBrowser::checkOption() + */ + public function checkOption($option) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('checkOption', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Unticks a checkbox. + * + * ``` php + * uncheckOption('#notify'); + * ?> + * ``` + * + * @param $option + * @see \Codeception\Lib\InnerBrowser::uncheckOption() + */ + public function uncheckOption($option) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('uncheckOption', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Attaches a file relative to the Codeception data directory to the given file upload field. + * + * ``` php + * attachFile('input[@type="file"]', 'prices.xls'); + * ?> + * ``` + * + * @param $field + * @param $filename + * @see \Codeception\Lib\InnerBrowser::attachFile() + */ + public function attachFile($field, $filename) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('attachFile', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * If your page triggers an ajax request, you can perform it manually. + * This action sends a GET ajax request with specified params. + * + * See ->sendAjaxPostRequest for examples. + * + * @param $uri + * @param $params + * @see \Codeception\Lib\InnerBrowser::sendAjaxGetRequest() + */ + public function sendAjaxGetRequest($uri, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('sendAjaxGetRequest', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * If your page triggers an ajax request, you can perform it manually. + * This action sends a POST ajax request with specified params. + * Additional params can be passed as array. + * + * Example: + * + * Imagine that by clicking checkbox you trigger ajax request which updates user settings. + * We emulate that click by running this ajax request manually. + * + * ``` php + * sendAjaxPostRequest('/updateSettings', array('notifications' => true)); // POST + * $I->sendAjaxGetRequest('/updateSettings', array('notifications' => true)); // GET + * + * ``` + * + * @param $uri + * @param $params + * @see \Codeception\Lib\InnerBrowser::sendAjaxPostRequest() + */ + public function sendAjaxPostRequest($uri, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('sendAjaxPostRequest', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * If your page triggers an ajax request, you can perform it manually. + * This action sends an ajax request with specified method and params. + * + * Example: + * + * You need to perform an ajax request specifying the HTTP method. + * + * ``` php + * sendAjaxRequest('PUT', '/posts/7', array('title' => 'new title')); + * + * ``` + * + * @param $method + * @param $uri + * @param $params + * @see \Codeception\Lib\InnerBrowser::sendAjaxRequest() + */ + public function sendAjaxRequest($method, $uri, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('sendAjaxRequest', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Finds and returns the text contents of the given element. + * If a fuzzy locator is used, the element is found using CSS, XPath, + * and by matching the full page source by regular expression. + * + * ``` php + * grabTextFrom('h1'); + * $heading = $I->grabTextFrom('descendant-or-self::h1'); + * $value = $I->grabTextFrom('~ + * ``` + * + * @param $cssOrXPathOrRegex + * + * @return mixed + * @see \Codeception\Lib\InnerBrowser::grabTextFrom() + */ + public function grabTextFrom($cssOrXPathOrRegex) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('grabTextFrom', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Grabs the value of the given attribute value from the given element. + * Fails if element is not found. + * + * ``` php + * grabAttributeFrom('#tooltip', 'title'); + * ?> + * ``` + * + * + * @param $cssOrXpath + * @param $attribute + * + * @return mixed + * @see \Codeception\Lib\InnerBrowser::grabAttributeFrom() + */ + public function grabAttributeFrom($cssOrXpath, $attribute) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('grabAttributeFrom', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Grabs either the text content, or attribute values, of nodes + * matched by $cssOrXpath and returns them as an array. + * + * ```html + * First + * Second + * Third + * ``` + * + * ```php + * grabMultiple('a'); + * + * // would return ['#first', '#second', '#third'] + * $aLinks = $I->grabMultiple('a', 'href'); + * ?> + * ``` + * + * @param $cssOrXpath + * @param $attribute + * @return string[] + * @see \Codeception\Lib\InnerBrowser::grabMultiple() + */ + public function grabMultiple($cssOrXpath, $attribute = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('grabMultiple', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * @param $field + * + * @return array|mixed|null|string + * @see \Codeception\Lib\InnerBrowser::grabValueFrom() + */ + public function grabValueFrom($field) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('grabValueFrom', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Sets a cookie with the given name and value. + * You can set additional cookie params like `domain`, `path`, `expires`, `secure` in array passed as last argument. + * + * ``` php + * setCookie('PHPSESSID', 'el4ukv0kqbvoirg7nkp4dncpk3'); + * ?> + * ``` + * + * @param $name + * @param $val + * @param array $params + * + * @return mixed + * @see \Codeception\Lib\InnerBrowser::setCookie() + */ + public function setCookie($name, $val, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('setCookie', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Grabs a cookie value. + * You can set additional cookie params like `domain`, `path` in array passed as last argument. + * + * @param $cookie + * + * @param array $params + * @return mixed + * @see \Codeception\Lib\InnerBrowser::grabCookie() + */ + public function grabCookie($cookie, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('grabCookie', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that a cookie with the given name is set. + * You can set additional cookie params like `domain`, `path` as array passed in last argument. + * + * ``` php + * seeCookie('PHPSESSID'); + * ?> + * ``` + * + * @param $cookie + * @param array $params + * @return mixed + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeCookie() + */ + public function canSeeCookie($cookie, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeCookie', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that a cookie with the given name is set. + * You can set additional cookie params like `domain`, `path` as array passed in last argument. + * + * ``` php + * seeCookie('PHPSESSID'); + * ?> + * ``` + * + * @param $cookie + * @param array $params + * @return mixed + * @see \Codeception\Lib\InnerBrowser::seeCookie() + */ + public function seeCookie($cookie, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeCookie', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that there isn't a cookie with the given name. + * You can set additional cookie params like `domain`, `path` as array passed in last argument. + * + * @param $cookie + * + * @param array $params + * @return mixed + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSeeCookie() + */ + public function cantSeeCookie($cookie, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeCookie', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that there isn't a cookie with the given name. + * You can set additional cookie params like `domain`, `path` as array passed in last argument. + * + * @param $cookie + * + * @param array $params + * @return mixed + * @see \Codeception\Lib\InnerBrowser::dontSeeCookie() + */ + public function dontSeeCookie($cookie, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeCookie', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Unsets cookie with the given name. + * You can set additional cookie params like `domain`, `path` in array passed as last argument. + * + * @param $cookie + * + * @param array $params + * @return mixed + * @see \Codeception\Lib\InnerBrowser::resetCookie() + */ + public function resetCookie($name, $params = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('resetCookie', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the given element exists on the page and is visible. + * You can also specify expected attributes of this element. + * + * ``` php + * seeElement('.error'); + * $I->seeElement('//form/input[1]'); + * $I->seeElement('input', ['name' => 'login']); + * $I->seeElement('input', ['value' => '123456']); + * + * // strict locator in first arg, attributes in second + * $I->seeElement(['css' => 'form input'], ['name' => 'login']); + * ?> + * ``` + * + * @param $selector + * @param array $attributes + * @return + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeElement() + */ + public function canSeeElement($selector, $attributes = null) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeElement', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the given element exists on the page and is visible. + * You can also specify expected attributes of this element. + * + * ``` php + * seeElement('.error'); + * $I->seeElement('//form/input[1]'); + * $I->seeElement('input', ['name' => 'login']); + * $I->seeElement('input', ['value' => '123456']); + * + * // strict locator in first arg, attributes in second + * $I->seeElement(['css' => 'form input'], ['name' => 'login']); + * ?> + * ``` + * + * @param $selector + * @param array $attributes + * @return + * @see \Codeception\Lib\InnerBrowser::seeElement() + */ + public function seeElement($selector, $attributes = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeElement', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the given element is invisible or not present on the page. + * You can also specify expected attributes of this element. + * + * ``` php + * dontSeeElement('.error'); + * $I->dontSeeElement('//form/input[1]'); + * $I->dontSeeElement('input', ['name' => 'login']); + * $I->dontSeeElement('input', ['value' => '123456']); + * ?> + * ``` + * + * @param $selector + * @param array $attributes + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSeeElement() + */ + public function cantSeeElement($selector, $attributes = null) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeElement', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the given element is invisible or not present on the page. + * You can also specify expected attributes of this element. + * + * ``` php + * dontSeeElement('.error'); + * $I->dontSeeElement('//form/input[1]'); + * $I->dontSeeElement('input', ['name' => 'login']); + * $I->dontSeeElement('input', ['value' => '123456']); + * ?> + * ``` + * + * @param $selector + * @param array $attributes + * @see \Codeception\Lib\InnerBrowser::dontSeeElement() + */ + public function dontSeeElement($selector, $attributes = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeElement', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that there are a certain number of elements matched by the given locator on the page. + * + * ``` php + * seeNumberOfElements('tr', 10); + * $I->seeNumberOfElements('tr', [0,10]); //between 0 and 10 elements + * ?> + * ``` + * @param $selector + * @param mixed $expected : + * - string: strict number + * - array: range of numbers [0,10] + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeNumberOfElements() + */ + public function canSeeNumberOfElements($selector, $expected) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeNumberOfElements', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that there are a certain number of elements matched by the given locator on the page. + * + * ``` php + * seeNumberOfElements('tr', 10); + * $I->seeNumberOfElements('tr', [0,10]); //between 0 and 10 elements + * ?> + * ``` + * @param $selector + * @param mixed $expected : + * - string: strict number + * - array: range of numbers [0,10] + * @see \Codeception\Lib\InnerBrowser::seeNumberOfElements() + */ + public function seeNumberOfElements($selector, $expected) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeNumberOfElements', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the given option is selected. + * + * ``` php + * seeOptionIsSelected('#form input[name=payment]', 'Visa'); + * ?> + * ``` + * + * @param $selector + * @param $optionText + * + * @return mixed + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeOptionIsSelected() + */ + public function canSeeOptionIsSelected($selector, $optionText) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeOptionIsSelected', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the given option is selected. + * + * ``` php + * seeOptionIsSelected('#form input[name=payment]', 'Visa'); + * ?> + * ``` + * + * @param $selector + * @param $optionText + * + * @return mixed + * @see \Codeception\Lib\InnerBrowser::seeOptionIsSelected() + */ + public function seeOptionIsSelected($selector, $optionText) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeOptionIsSelected', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the given option is not selected. + * + * ``` php + * dontSeeOptionIsSelected('#form input[name=payment]', 'Visa'); + * ?> + * ``` + * + * @param $selector + * @param $optionText + * + * @return mixed + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSeeOptionIsSelected() + */ + public function cantSeeOptionIsSelected($selector, $optionText) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeOptionIsSelected', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the given option is not selected. + * + * ``` php + * dontSeeOptionIsSelected('#form input[name=payment]', 'Visa'); + * ?> + * ``` + * + * @param $selector + * @param $optionText + * + * @return mixed + * @see \Codeception\Lib\InnerBrowser::dontSeeOptionIsSelected() + */ + public function dontSeeOptionIsSelected($selector, $optionText) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeOptionIsSelected', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Asserts that current page has 404 response status code. + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seePageNotFound() + */ + public function canSeePageNotFound() { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seePageNotFound', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Asserts that current page has 404 response status code. + * @see \Codeception\Lib\InnerBrowser::seePageNotFound() + */ + public function seePageNotFound() { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seePageNotFound', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that response code is equal to value provided. + * + * ```php + * seeResponseCodeIs(200); + * + * // recommended \Codeception\Util\HttpCode + * $I->seeResponseCodeIs(\Codeception\Util\HttpCode::OK); + * ``` + * + * @param $code + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeResponseCodeIs() + */ + public function canSeeResponseCodeIs($code) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeResponseCodeIs', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that response code is equal to value provided. + * + * ```php + * seeResponseCodeIs(200); + * + * // recommended \Codeception\Util\HttpCode + * $I->seeResponseCodeIs(\Codeception\Util\HttpCode::OK); + * ``` + * + * @param $code + * @see \Codeception\Lib\InnerBrowser::seeResponseCodeIs() + */ + public function seeResponseCodeIs($code) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeResponseCodeIs', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that response code is equal to value provided. + * + * ```php + * dontSeeResponseCodeIs(200); + * + * // recommended \Codeception\Util\HttpCode + * $I->dontSeeResponseCodeIs(\Codeception\Util\HttpCode::OK); + * ``` + * @param $code + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSeeResponseCodeIs() + */ + public function cantSeeResponseCodeIs($code) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeResponseCodeIs', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that response code is equal to value provided. + * + * ```php + * dontSeeResponseCodeIs(200); + * + * // recommended \Codeception\Util\HttpCode + * $I->dontSeeResponseCodeIs(\Codeception\Util\HttpCode::OK); + * ``` + * @param $code + * @see \Codeception\Lib\InnerBrowser::dontSeeResponseCodeIs() + */ + public function dontSeeResponseCodeIs($code) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeResponseCodeIs', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the page title contains the given string. + * + * ``` php + * seeInTitle('Blog - Post #1'); + * ?> + * ``` + * + * @param $title + * + * @return mixed + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::seeInTitle() + */ + public function canSeeInTitle($title) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeInTitle', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the page title contains the given string. + * + * ``` php + * seeInTitle('Blog - Post #1'); + * ?> + * ``` + * + * @param $title + * + * @return mixed + * @see \Codeception\Lib\InnerBrowser::seeInTitle() + */ + public function seeInTitle($title) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeInTitle', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the page title does not contain the given string. + * + * @param $title + * + * @return mixed + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Lib\InnerBrowser::dontSeeInTitle() + */ + public function cantSeeInTitle($title) { + return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInTitle', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks that the page title does not contain the given string. + * + * @param $title + * + * @return mixed + * @see \Codeception\Lib\InnerBrowser::dontSeeInTitle() + */ + public function dontSeeInTitle($title) { + return $this->getScenario()->runStep(new \Codeception\Step\Assertion('dontSeeInTitle', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Switch to iframe or frame on the page. + * + * Example: + * ``` html + *