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.
This commit is contained in:
Alexander Makarov
2014-08-15 03:30:47 +04:00
parent dcf62a1339
commit 7eb403bf45
193 changed files with 680 additions and 1090 deletions

View File

@ -4,23 +4,8 @@ Acceptance Tests
> Note: This section is under development.
- http://codeception.com/docs/04-AcceptanceTests
- https://github.com/yiisoft/yii2/blob/master/apps/advanced/README.md#testing
- https://github.com/yiisoft/yii2/blob/master/apps/basic/tests/README.md
How to run webserver
--------------------
Running basic and advanced template acceptance tests
----------------------------------------------------
In order to perform acceptance tests you need a web server. Since PHP 5.4 has built-in one, we can use it. For the basic
application template it would be:
```
cd web
php -S localhost:8080
```
In order for the tests to work correctly you need to adjust `TEST_ENTRY_URL` in `_bootstrap.php` file. It should point
to `index-test.php` of your webserver. Since we're running directly from its directory the line would be:
```php
defined('TEST_ENTRY_URL') or define('TEST_ENTRY_URL', '/index-test.php');
```
Please refer to instructions provided in `apps/advanced/tests/README.md` and `apps/basic/tests/README.md`.

View File

@ -1,8 +1,11 @@
Functional Tests
----------------
================
> Note: This section is under development.
- http://codeception.com/docs/05-FunctionalTests
- https://github.com/yiisoft/yii2/blob/master/apps/advanced/README.md#testing
- https://github.com/yiisoft/yii2/blob/master/apps/basic/tests/README.md
Running basic and advanced template functional tests
----------------------------------------------------
Please refer to instructions provided in `apps/advanced/tests/README.md` and `apps/basic/tests/README.md`.

View File

@ -34,4 +34,11 @@ composer global require "codeception/specify=*"
composer global require "codeception/verify=*"
```
That's it. Now we're able to use `codecept` from command line.
If you've never used Composer for global packages run `composer global status`. It should output:
```
Changed current directory to <directory>
```
Then add `<directory>/vendor/bin` to you `PATH` environment variable. Now we're able to use `codecept` from command
line globally.

View File

@ -3,11 +3,6 @@ Unit Tests
> Note: This section is under development.
TODO:
- https://github.com/yiisoft/yii2/blob/master/apps/advanced/README.md#testing
- https://github.com/yiisoft/yii2/blob/master/apps/basic/tests/README.md
A unit test verifies that a single unit of code is working as expected. In object-oriented programming, the most basic
code unit is a class. A unit test thus mainly needs to verify that each of the class interface methods works properly.
That is, given different input parameters, the test verifies the method returns expected results.
@ -16,4 +11,9 @@ Unit tests are usually developed by people who write the classes being tested.
Unit testing in Yii is built on top of PHPUnit and, optionally, Codeception so it's recommended to go through their docs:
- [PHPUnit docs starting from chapter 2](http://phpunit.de/manual/current/en/writing-tests-for-phpunit.html).
- [Codeception Unit Tests](http://codeception.com/docs/06-UnitTests).
- [Codeception Unit Tests](http://codeception.com/docs/06-UnitTests).
Running basic and advanced template unit tests
----------------------------------------------
Please refer to instructions provided in `apps/advanced/tests/README.md` and `apps/basic/tests/README.md`.

View File

@ -29,57 +29,6 @@ You can now execute unit tests by running `phpunit`.
You may limit the tests to a group of tests you are working on e.g. to run only tests for the validators and redis
`phpunit --group=validators,redis`.
Functional and acceptance tests
-------------------------------
In order to run functional and acceptance tests you need to install additional composer packages for the application you're going
to test. Add the following four packages to your `composer.json` `require-dev` section:
```
"yiisoft/yii2-codeception": "*",
```
For advanced application you may need `yiisoft/yii2-faker: *` as well.
Then for the basic application template run `./build/build app/link basic`. For advanced template command is
`./build/build app/link advanced`.
After package installation is complete you can run the following for basic app:
```
cd apps/basic
codecept build
codecept run
```
For advanced application frontend it will be:
```
cd apps/advanced/frontend
codecept build
codecept run
```
Note that you need a running webserver in order to pass acceptance tests. That can be easily achieved with PHP's built-in
webserver:
```
cd apps/advanced/frontend/www
php -S 127.0.0.1:8080
```
Note that you should have Codeception and PHPUnit installed globally:
```
composer global require "phpunit/phpunit=4.1.*"
composer global require "codeception/codeception=2.0.*"
composer global require "codeception/specify=*"
composer global require "codeception/verify=*"
```
After running commands you'll see "Changed current directory to /your/global/composer/dir" message. If it's the
first time you're installing a package globally you need to add `/your/global/composer/dir/vendor/bin/` to your `PATH`.
Extensions
----------
@ -89,3 +38,7 @@ Just add them to the `composer.json` as you would normally do e.g. add `"yiisoft
Running `./build/build app/link basic` will install the extension and its dependecies and create
a symlink to `extensions/redis` so you are not working the composer vendor dir but the yii2 repo directly.
Functional and acceptance tests for applications
------------------------------------------------
See `apps/advanced/tests/README.md` and `apps/basic/tests/README.md` to learn about how to run Codeception tests.