diff --git a/.bowerrc b/.bowerrc new file mode 100644 index 000000000..a39b5b0fb --- /dev/null +++ b/.bowerrc @@ -0,0 +1,3 @@ +{ + "directory" : "vendor/bower-asset" +} diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 000000000..011c056bb --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,8 @@ +# Reformat code te be PSR-2 compatible +93cc82c4bf42cea403e1acaab201338bea304b6e +# Convert to short syntax (array) +332030325fbad38a64c5e60980d3b14b6434d6dd +# Convert to short syntax +b0fcdfab1aecaeb620f75a83f15aa02bc25765a0 +# Fix codestyle +0f91f32ecff52ef479addb0a5013342d59fe0697 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..705fb391d --- /dev/null +++ b/.gitattributes @@ -0,0 +1,7 @@ +# Ignore all test and documentation for archive +/.github export-ignore +/.git-blame-ignore-revs export-ignore +/.gitattributes export-ignore +/.scrutinizer.yml export-ignore +/.travis.yml export-ignore +/docs export-ignore diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 000000000..ea75bda5f --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,7 @@ +Contributing to Yii2 +==================== + +- [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](https://www.yiiframework.com/forum/index.php/forum/42-general-discussions-for-yii-20/) +- [Contribute to the core code or fix bugs](https://github.com/yiisoft/yii2/blob/master/docs/internals/git-workflow.md) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 000000000..692239301 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,4 @@ +# These are supported funding model platforms + +open_collective: yiisoft +tidelift: "packagist/yiisoft/yii2-app-basic" diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 000000000..a2ee92439 --- /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 version | +| 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 diff --git a/.github/SECURITY.md b/.github/SECURITY.md new file mode 100644 index 000000000..405acca4e --- /dev/null +++ b/.github/SECURITY.md @@ -0,0 +1,6 @@ +# Security Policy + +Please use the [security issue form](https://www.yiiframework.com/security) to report to us any security issue you find in Yii. +DO NOT use the issue tracker or discuss it in the public forum as it will cause more damage than help. + +Please note that as a non-commercial OpenSource project we are not able to pay bounties at the moment. diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..a5beac653 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,83 @@ +on: + - pull_request + - push + +name: build + +jobs: + tests: + name: PHP ${{ matrix.php }} - ${{ matrix.os }} + + env: + extensions: dom, json, gd, imagick + key: cache-v4 + + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: + - ubuntu-latest + - windows-latest + + php: + - "7.4" + - "8.0" + - "8.1" + - "8.2" + - "8.3" + - "8.4" + + steps: + - name: Checkout + uses: actions/checkout@v5 + + - name: Setup cache environment + id: cache-env + uses: shivammathur/cache-extensions@v1 + with: + php-version: ${{ matrix.php }} + extensions: ${{ env.extensions }} + key: ${{ env.key }} + + - name: Cache extensions + uses: actions/cache@v4 + with: + path: ${{ steps.cache-env.outputs.dir }} + key: ${{ steps.cache-env.outputs.key }} + restore-keys: ${{ steps.cache-env.outputs.key }} + + - name: Install PHP with extensions + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: ${{ env.extensions }} + ini-values: date.timezone='UTC' + + - name: Determine composer cache directory on Linux + if: matrix.os == 'ubuntu-latest' + run: | + echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV + + - name: Determine composer cache directory on Windows + if: matrix.os == 'windows-latest' + run: | + echo "COMPOSER_CACHE_DIR=~\AppData\Local\Composer" >> $GITHUB_ENV + + - name: Cache dependencies installed with composer + uses: actions/cache@v4 + with: + path: ${{ steps.cache-env.outputs.dir }} + key: php${{ matrix.php }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.json') }} + restore-keys: | + php${{ matrix.php }}-composer-${{ matrix.dependencies }}- + + - name: Install dependencies with composer php PHP [5.6 - 8.0] + run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi + + - name: Run tests with codeception + run: | + sed -i "s/'cookieValidationKey' => ''/'cookieValidationKey' => 'testkey'/" config/web.php + php -S 127.0.0.1:8080 -t public > ./runtime/yii.log 2>&1 & + vendor/bin/codecept run + shell: bash diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..05fb29d1b --- /dev/null +++ b/.gitignore @@ -0,0 +1,36 @@ +# phpstorm project files +.idea + +# visual studio code project files +.vscode + +# 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 + +tests/_output/* +tests/_support/_generated + +#vagrant folder +/.vagrant \ No newline at end of file diff --git a/LICENSE.md b/LICENSE.md index e98f03df8..ee872b9ab 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,3 @@ -The Yii framework is free software. It is released under the terms of -the following BSD License. - Copyright © 2008 by Yii Software LLC (http://www.yiisoft.com) All rights reserved. diff --git a/README.md b/README.md index d025b5e07..981a7f9d9 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,21 @@ -Yii 2 Basic Application Template -================================ - -Yii 2 Basic Application Template is a skeleton Yii 2 application best for +
+
+
+
+
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.
'; +if (!isset($frameworkPath)) { + $searchPaths = array( + dirname(__FILE__) . '/vendor/yiisoft/yii2', + dirname(__FILE__) . '/../vendor/yiisoft/yii2', + ); + foreach ($searchPaths as $path) { + if (is_dir($path)) { + $frameworkPath = $path; + break; + } + } +} + +if (!isset($frameworkPath) || !is_dir($frameworkPath)) { + $message = "The path to yii framework seems to be incorrect.
\n" + . 'You need to install Yii framework via composer or adjust the framework path in file ' . basename(__FILE__) . ".
\n" + . 'Please refer to the README on how to install Yii.
\n"; + + if (!empty($_SERVER['argv'])) { + // do not print HTML when used in console mode + echo strip_tags($message); + } else { + echo $message; + } + exit(1); } 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. */ $requirements = array( - // Database : - array( - 'name' => 'PDO extension', - 'mandatory' => true, - 'condition' => extension_loaded('pdo'), - 'by' => 'All DB-related classes', - ), - array( - 'name' => 'PDO SQLite extension', - 'mandatory' => false, - 'condition' => extension_loaded('pdo_sqlite'), - 'by' => 'All DB-related classes', - 'memo' => 'Required for SQLite database.', - ), - array( - 'name' => 'PDO MySQL extension', - 'mandatory' => false, - 'condition' => extension_loaded('pdo_mysql'), - 'by' => 'All DB-related classes', - 'memo' => 'Required for MySQL database.', - ), - array( - 'name' => 'PDO PostgreSQL extension', - 'mandatory' => false, - 'condition' => extension_loaded('pdo_pgsql'), - 'by' => 'All DB-related classes', - 'memo' => 'Required for PostgreSQL database.', - ), - // Cache : - array( - 'name' => 'Memcache extension', - 'mandatory' => false, - 'condition' => extension_loaded('memcache') || extension_loaded('memcached'), - 'by' => 'CMemCache', - 'memo' => extension_loaded('memcached') ? 'To use memcached set CMemCache::useMemcached totrue.' : ''
- ),
- array(
- 'name' => 'APC extension',
- 'mandatory' => false,
- 'condition' => extension_loaded('apc'),
- 'by' => 'CApcCache',
- ),
- // Additional PHP extensions :
- array(
- 'name' => 'Mcrypt extension',
- 'mandatory' => false,
- 'condition' => extension_loaded('mcrypt'),
- 'by' => 'CSecurityManager',
- 'memo' => 'Required by encrypt and decrypt methods.'
- ),
- // PHP ini :
- 'phpSafeMode' => array(
- 'name' => 'PHP safe mode',
- 'mandatory' => false,
- 'condition' => $requirementsChecker->checkPhpIniOff("safe_mode"),
- 'by' => 'File uploading and console command execution',
- 'memo' => '"safe_mode" should be disabled at php.ini',
- ),
- 'phpExposePhp' => array(
- 'name' => 'Expose PHP',
- 'mandatory' => false,
- 'condition' => $requirementsChecker->checkPhpIniOff("expose_php"),
- 'by' => 'Security reasons',
- 'memo' => '"expose_php" should be disabled at php.ini',
- ),
- 'phpAllowUrlInclude' => array(
- 'name' => 'PHP allow url include',
- 'mandatory' => false,
- 'condition' => $requirementsChecker->checkPhpIniOff("allow_url_include"),
- 'by' => 'Security reasons',
- 'memo' => '"allow_url_include" should be disabled at php.ini',
- ),
- 'phpSmtp' => array(
- 'name' => 'PHP mail SMTP',
- 'mandatory' => false,
- 'condition' => strlen(ini_get('SMTP'))>0,
- 'by' => 'Email sending',
- 'memo' => 'PHP mail SMTP server required',
- ),
+ // Database :
+ array(
+ 'name' => 'PDO extension',
+ 'mandatory' => true,
+ 'condition' => extension_loaded('pdo'),
+ 'by' => 'All DB-related classes',
+ ),
+ array(
+ 'name' => 'PDO SQLite extension',
+ 'mandatory' => false,
+ 'condition' => extension_loaded('pdo_sqlite'),
+ 'by' => 'All DB-related classes',
+ 'memo' => 'Required for SQLite database.',
+ ),
+ array(
+ 'name' => 'PDO MySQL extension',
+ 'mandatory' => false,
+ 'condition' => extension_loaded('pdo_mysql'),
+ 'by' => 'All DB-related classes',
+ 'memo' => 'Required for MySQL database.',
+ ),
+ array(
+ 'name' => 'PDO PostgreSQL extension',
+ 'mandatory' => false,
+ 'condition' => extension_loaded('pdo_pgsql'),
+ 'by' => 'All DB-related classes',
+ 'memo' => 'Required for PostgreSQL database.',
+ ),
+ // Cache :
+ array(
+ 'name' => 'Memcache extension',
+ 'mandatory' => false,
+ 'condition' => extension_loaded('memcache') || extension_loaded('memcached'),
+ 'by' => 'MemCache',
+ 'memo' => extension_loaded('memcached') ? 'To use memcached set MemCache::useMemcached to true.' : ''
+ ),
+ // 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 :
+ '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();
+
+// OPcache check
+if (!version_compare(phpversion(), '5.5', '>=')) {
+ $requirements[] = array(
+ 'name' => 'APC extension',
+ 'mandatory' => false,
+ 'condition' => extension_loaded('apc'),
+ 'by' => 'ApcCache',
+ );
+}
+
+$result = $requirementsChecker->checkYii()->check($requirements)->getResult();
+$requirementsChecker->render();
+exit($result['summary']['errors'] === 0 ? 0 : 1);
diff --git a/tests/.gitignore b/tests/.gitignore
deleted file mode 100644
index c5aa0743d..000000000
--- a/tests/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-# these files are auto generated by codeception build
-/unit/CodeGuy.php
-/functional/TestGuy.php
-/acceptance/WebGuy.php
diff --git a/tests/README.md b/tests/README.md
deleted file mode 100644
index a745bf6bc..000000000
--- a/tests/README.md
+++ /dev/null
@@ -1,33 +0,0 @@
-This folder contains various tests for the basic application.
-These tests 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:
-
- ```
- php composer.phar require --dev "codeception/codeception: 1.8.*@dev" "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:
-
- ```
- vendor/bin/codecept build
- ```
-
-Now you can run the tests with the following commands:
-
-```
-# run all available tests
-vendor/bin/codecept run
-# run acceptance tests
-vendor/bin/codecept run acceptance
-# run functional tests
-vendor/bin/codecept run functional
-# run unit tests
-vendor/bin/codecept run unit
-```
-
-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/_bootstrap.php b/tests/_bootstrap.php
index 4890b3ed7..4b8424f73 100644
--- a/tests/_bootstrap.php
+++ b/tests/_bootstrap.php
@@ -1,23 +1,7 @@
[
- 'mail' => [
- 'useFileTransport' => true,
- ],
- 'urlManager' => [
- 'showScriptName' => true,
- ],
- ],
-];
diff --git a/tests/_console_bootstrap.php b/tests/_console_bootstrap.php
deleted file mode 100644
index 81287f3d8..000000000
--- a/tests/_console_bootstrap.php
+++ /dev/null
@@ -1,12 +0,0 @@
- $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
deleted file mode 100644
index 503a4205f..000000000
--- a/tests/_pages/LoginPage.php
+++ /dev/null
@@ -1,21 +0,0 @@
-guy->fillField('input[name="LoginForm[username]"]', $username);
- $this->guy->fillField('input[name="LoginForm[password]"]', $password);
- $this->guy->click('login-button');
- }
-}
diff --git a/tests/_support/AcceptanceTester.php b/tests/_support/AcceptanceTester.php
new file mode 100644
index 000000000..3fb3a9f03
--- /dev/null
+++ b/tests/_support/AcceptanceTester.php
@@ -0,0 +1,26 @@
+wantTo('ensure that about works');
-AboutPage::openBy($I);
-$I->see('About', 'h1');
diff --git a/tests/acceptance/AboutCest.php b/tests/acceptance/AboutCest.php
new file mode 100644
index 000000000..8a7be5af1
--- /dev/null
+++ b/tests/acceptance/AboutCest.php
@@ -0,0 +1,12 @@
+amOnPage(Url::toRoute('/site/about'));
+ $I->see('About', 'h1');
+ }
+}
diff --git a/tests/acceptance/ContactCept.php b/tests/acceptance/ContactCept.php
deleted file mode 100644
index 25f5735e4..000000000
--- a/tests/acceptance/ContactCept.php
+++ /dev/null
@@ -1,49 +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([]);
-$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',
-]);
-$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.');
-$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/acceptance/ContactCest.php b/tests/acceptance/ContactCest.php
new file mode 100644
index 000000000..ac74fdb1f
--- /dev/null
+++ b/tests/acceptance/ContactCest.php
@@ -0,0 +1,34 @@
+amOnPage(Url::toRoute('/site/contact'));
+ }
+
+ 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->wait(2); // wait for button to be clicked
+
+ $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/HomeCept.php b/tests/acceptance/HomeCept.php
deleted file mode 100644
index 62456f930..000000000
--- a/tests/acceptance/HomeCept.php
+++ /dev/null
@@ -1,9 +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/acceptance/HomeCest.php b/tests/acceptance/HomeCest.php
new file mode 100644
index 000000000..98fb6b9f7
--- /dev/null
+++ b/tests/acceptance/HomeCest.php
@@ -0,0 +1,18 @@
+amOnPage(Url::toRoute('/site/index'));
+ $I->see('My Company');
+
+ $I->seeLink('About');
+ $I->click('About');
+ $I->wait(2); // wait for page to be opened
+
+ $I->see('This is the About page.');
+ }
+}
diff --git a/tests/acceptance/LoginCept.php b/tests/acceptance/LoginCept.php
deleted file mode 100644
index 5d6a3878e..000000000
--- a/tests/acceptance/LoginCept.php
+++ /dev/null
@@ -1,29 +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('', '');
-$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');
-$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/acceptance/LoginCest.php b/tests/acceptance/LoginCest.php
new file mode 100644
index 000000000..6f5cb2f38
--- /dev/null
+++ b/tests/acceptance/LoginCest.php
@@ -0,0 +1,21 @@
+amOnPage(Url::toRoute('/site/login'));
+ $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->wait(2); // wait for button to be clicked
+
+ $I->expectTo('see user info');
+ $I->see('Logout');
+ }
+}
diff --git a/tests/acceptance/_bootstrap.php b/tests/acceptance/_bootstrap.php
index 6ce3d175b..b3d9bbc7f 100644
--- a/tests/acceptance/_bootstrap.php
+++ b/tests/acceptance/_bootstrap.php
@@ -1,3 +1 @@
[
- 'db' => [
- 'dsn' => 'mysql:host=localhost;dbname=yii2_basic_acceptance',
- ],
- ],
- ]
-);
diff --git a/tests/acceptance/_console.php b/tests/acceptance/_console.php
deleted file mode 100644
index f89eecfc2..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/tests/bin/yii b/tests/bin/yii
new file mode 100755
index 000000000..39df4013d
--- /dev/null
+++ b/tests/bin/yii
@@ -0,0 +1,29 @@
+#!/usr/bin/env php
+ [
+ 'db' => require __DIR__ . '/../../config/test_db.php'
+ ]
+ ]
+);
+
+
+$application = new yii\console\Application($config);
+$exitCode = $application->run();
+exit($exitCode);
diff --git a/tests/acceptance/yii.bat b/tests/bin/yii.bat
similarity index 71%
rename from tests/acceptance/yii.bat
rename to tests/bin/yii.bat
index 5e21e2e99..ce14c92bc 100644
--- a/tests/acceptance/yii.bat
+++ b/tests/bin/yii.bat
@@ -4,9 +4,9 @@ rem -------------------------------------------------------------
rem Yii command line bootstrap script for Windows.
rem
rem @author Qiang Xue - This is the About page. You may modify the following file to customize its content: -
++ This is the About page. You may modify the following file to customize its content: +
-= __FILE__ ?>
+ = __FILE__ ?>
- Note that if you turn on the Yii debugger, you should be able
- to view the mail message on the mail panel of the debugger.
- mail->useFileTransport): ?>
- Because the application is in development mode, the email is not sent but saved as
- a file under = Yii::getAlias(Yii::$app->mail->fileTransportPath); ?>.
- Please configure the useFileTransport property of the mail
- application component to be false to enable email sending.
-
-
- If you have business inquiries or other questions, please fill out the following form to contact us. Thank you. -
- -
+ 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 = Yii::getAlias(Yii::$app->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. +
+ +- The above error occurred while the Web server was processing your request. -
-- Please contact us if you think this is a server error. Thank you. -
++ The above error occurred while the Web server was processing your request. +
++ Please contact us if you think this is a server error. Thank you. +
You have successfully created your Yii-powered application.
+You have successfully created your Yii-powered application.
- -Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et - dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip - ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu - fugiat nulla pariatur.
+Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et + dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip + ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu + fugiat nulla pariatur.
- -Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et - dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip - ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu - fugiat nulla pariatur.
+Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et + dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip + ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu + fugiat nulla pariatur.
- -Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et - dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip - ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu - fugiat nulla pariatur.
+Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et + dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip + ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu + fugiat nulla pariatur.
- -Please fill out the following fields to login:
+ +Please fill out the following fields to login:
+ 'login-form', + 'fieldConfig' => [ + 'template' => "{label}\n{input}\n{error}", + 'labelOptions' => ['class' => 'col-lg-1 col-form-label mr-lg-3'], + 'inputOptions' => ['class' => 'col-lg-3 form-control'], + 'errorOptions' => ['class' => 'col-lg-7 invalid-feedback'], + ], + ]); ?> - 'login-form', - 'options' => ['class' => 'form-horizontal'], - 'fieldConfig' => [ - 'template' => "{label}\napp\models\User::$users.
+ app\models\User::$users.
-