Yii2 framework backup
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

145 lines
3.4 KiB

Yii 2.0 Unit tests
==================
DIRECTORY STRUCTURE
-------------------
10 years ago
data/ models, config and other test data
config.php this file contains configuration for database and caching backends
framework/ the framework unit tests
runtime/ the application runtime dir for the yii test app
HOW TO RUN THE TESTS
--------------------
10 years ago
Make sure you have PHPUnit installed and that you installed all composer dependencies (run `composer update` in the repo base directory).
Run PHPUnit in the yii repo base directory.
```
phpunit
```
You can run tests for specific groups only:
```
phpunit --group=mysql,base,i18n
```
You can get a list of available groups via `phpunit --list-groups`.
A single test class could be run like the follwing:
```
phpunit tests/framework/base/ObjectTest.php
```
TEST CONFIGURATION
------------------
PHPUnit configuration is in `phpunit.xml.dist` in repository root folder.
You can create your own phpunit.xml to override dist config.
Database and other backend system configuration can be found in `unit/data/config.php`
adjust them to your needs to allow testing databases and caching in your environment.
You can override configuration values by creating a `config.local.php` file
and manipulate the `$config` variable.
For example to change MySQL username and password your `config.local.php` should
contain the following:
```php
<?php
$config['databases']['mysql']['username'] = 'yiitest';
$config['databases']['mysql']['password'] = 'changeme';
```
updated debug settings (+56 squashed commits) Squashed commits: [c42f30c] updated base image, added docs & local test script [88f0c40] debug [6220c94] fixed network isolation [c63c7c3] test mssql only on test/mssql branch [74efc78] fixed isolation in after_script [02b895b] updated test setup [3335f39] updated retry [bd123b2] updated service checks [45e4c90] updated build [d54da7a] updated after_script [5a4c726] :factory: wait for mysql [08db878] fixed typo [ea53c1e] updated build stages [9807ce3] fixed typos [cf9f64e] fixed mssql testing [08001d6] added db create for mssql [62f6b65] run travis (gitlab simulation) only in travis branch [cf63da4] streamlined build [76808ac] updated test jobs [18d79b5] fixed test error [7b2bce6] updated build & composer.lock [244623a] updated build [86bd71b] fixed cleanup [86ab2e8] fixed cleanup [091d4b8] fixed tests [2d315b5] fixed build config [2913644] fixed project names [f53b823] refactored build config [5a791fb] refactored docker db-tests [b4479b0] revert [a975fa5] updated gitlab build [4e4e5e4] updated mssql setup [d6ff03b] added sleep workaround [578b102] removed host volumes in test [928f50b] fixed path [967ab10] updated tests [520f317] bootstrap cubrid [5f245e1] :factory: fixed cubrid tests [940dbbc] :factory: pinned cubrid version 9.3.6.0002 [8d5ea69] :memo: dockerized test commands [9954b54] updated cubrid [fb3afac] updated docs [3f63ced] updated isolation [bdc3c83] :factory: build cubrid [b777911] :factory: disabled mssql, updated cubrid [36534e7] added travis-a-like stage [6546f02] updated GitLab build [c046096] updated test setup - added mssql and cubrid stack [5a0e635] disabled host-volume [75cf342] fixed test [8de0794] fixed testing [465d27a] added stages [63aa950] added script [68eecef] fixed typo [00e4b88] updated Docker build [f9072cc] added dockerized test setup
8 years ago
DOCKERIZED TESTING
------------------
*This section is under construction*
Start test stack and enter PHP container
cd tests
docker-compose up -d
docker-compose run --rm php bash
Run a group of unit tests
$ vendor/bin/phpunit -v --group base --debug
Run phpunit directly
cd tests
docker-compose run --rm php vendor/bin/phpunit -v --group caching,db
docker-compose run --rm php vendor/bin/phpunit -v --exclude base,caching,db,i18n,log,mutex,rbac,validators,web
### Cubrid
cd tests
docker-compose -f docker-compose.cubrid.yml up -d
docker-compose -f docker-compose.cubrid.yml run --rm php vendor/bin/phpunit -v --group cubrid
### MSSQL
**experimental**
- needs 3.5 GB RAM, Docker-host with >4.5 GB is recommended for testing
- database CLI `tsgkadot/mssql-tools`
Example commands
cd tests
Using a shell
docker-compose run --rm sqlcmd sqlcmd -S mssql -U sa -P Microsoft-12345
Create database with sqlcmd
$ sqlcmd -S mssql -U sa -P Microsoft-12345 -Q "CREATE DATABASE yii2test"
Create database (one-liner)
docker-compose run --rm sqlcmd sqlcmd -S mssql -U sa -P Microsoft-12345 -Q "CREATE DATABASE yii2test"
updated debug settings (+56 squashed commits) Squashed commits: [c42f30c] updated base image, added docs & local test script [88f0c40] debug [6220c94] fixed network isolation [c63c7c3] test mssql only on test/mssql branch [74efc78] fixed isolation in after_script [02b895b] updated test setup [3335f39] updated retry [bd123b2] updated service checks [45e4c90] updated build [d54da7a] updated after_script [5a4c726] :factory: wait for mysql [08db878] fixed typo [ea53c1e] updated build stages [9807ce3] fixed typos [cf9f64e] fixed mssql testing [08001d6] added db create for mssql [62f6b65] run travis (gitlab simulation) only in travis branch [cf63da4] streamlined build [76808ac] updated test jobs [18d79b5] fixed test error [7b2bce6] updated build & composer.lock [244623a] updated build [86bd71b] fixed cleanup [86ab2e8] fixed cleanup [091d4b8] fixed tests [2d315b5] fixed build config [2913644] fixed project names [f53b823] refactored build config [5a791fb] refactored docker db-tests [b4479b0] revert [a975fa5] updated gitlab build [4e4e5e4] updated mssql setup [d6ff03b] added sleep workaround [578b102] removed host volumes in test [928f50b] fixed path [967ab10] updated tests [520f317] bootstrap cubrid [5f245e1] :factory: fixed cubrid tests [940dbbc] :factory: pinned cubrid version 9.3.6.0002 [8d5ea69] :memo: dockerized test commands [9954b54] updated cubrid [fb3afac] updated docs [3f63ced] updated isolation [bdc3c83] :factory: build cubrid [b777911] :factory: disabled mssql, updated cubrid [36534e7] added travis-a-like stage [6546f02] updated GitLab build [c046096] updated test setup - added mssql and cubrid stack [5a0e635] disabled host-volume [75cf342] fixed test [8de0794] fixed testing [465d27a] added stages [63aa950] added script [68eecef] fixed typo [00e4b88] updated Docker build [f9072cc] added dockerized test setup
8 years ago
Run MSSQL tests
docker-compose run --rm php
$ vendor/bin/phpunit --group mssql
### Run tests locally
#### Via shell script
cd tests
sh test-local.sh default
8 years ago
#### Via runner
**experimental**
docker-compose configuration
updated debug settings (+56 squashed commits) Squashed commits: [c42f30c] updated base image, added docs & local test script [88f0c40] debug [6220c94] fixed network isolation [c63c7c3] test mssql only on test/mssql branch [74efc78] fixed isolation in after_script [02b895b] updated test setup [3335f39] updated retry [bd123b2] updated service checks [45e4c90] updated build [d54da7a] updated after_script [5a4c726] :factory: wait for mysql [08db878] fixed typo [ea53c1e] updated build stages [9807ce3] fixed typos [cf9f64e] fixed mssql testing [08001d6] added db create for mssql [62f6b65] run travis (gitlab simulation) only in travis branch [cf63da4] streamlined build [76808ac] updated test jobs [18d79b5] fixed test error [7b2bce6] updated build & composer.lock [244623a] updated build [86bd71b] fixed cleanup [86ab2e8] fixed cleanup [091d4b8] fixed tests [2d315b5] fixed build config [2913644] fixed project names [f53b823] refactored build config [5a791fb] refactored docker db-tests [b4479b0] revert [a975fa5] updated gitlab build [4e4e5e4] updated mssql setup [d6ff03b] added sleep workaround [578b102] removed host volumes in test [928f50b] fixed path [967ab10] updated tests [520f317] bootstrap cubrid [5f245e1] :factory: fixed cubrid tests [940dbbc] :factory: pinned cubrid version 9.3.6.0002 [8d5ea69] :memo: dockerized test commands [9954b54] updated cubrid [fb3afac] updated docs [3f63ced] updated isolation [bdc3c83] :factory: build cubrid [b777911] :factory: disabled mssql, updated cubrid [36534e7] added travis-a-like stage [6546f02] updated GitLab build [c046096] updated test setup - added mssql and cubrid stack [5a0e635] disabled host-volume [75cf342] fixed test [8de0794] fixed testing [465d27a] added stages [63aa950] added script [68eecef] fixed typo [00e4b88] updated Docker build [f9072cc] added dockerized test setup
8 years ago
runner:
image: schmunk42/gitlab-runner
entrypoint: bash
working_dir: /project
volumes:
- ../:/project
- /var/run/docker.sock:/var/run/docker.sock
environment:
- RUNNER_BUILDS_DIR=${PWD}/..
8 years ago
Start runner bash
updated debug settings (+56 squashed commits) Squashed commits: [c42f30c] updated base image, added docs & local test script [88f0c40] debug [6220c94] fixed network isolation [c63c7c3] test mssql only on test/mssql branch [74efc78] fixed isolation in after_script [02b895b] updated test setup [3335f39] updated retry [bd123b2] updated service checks [45e4c90] updated build [d54da7a] updated after_script [5a4c726] :factory: wait for mysql [08db878] fixed typo [ea53c1e] updated build stages [9807ce3] fixed typos [cf9f64e] fixed mssql testing [08001d6] added db create for mssql [62f6b65] run travis (gitlab simulation) only in travis branch [cf63da4] streamlined build [76808ac] updated test jobs [18d79b5] fixed test error [7b2bce6] updated build & composer.lock [244623a] updated build [86bd71b] fixed cleanup [86ab2e8] fixed cleanup [091d4b8] fixed tests [2d315b5] fixed build config [2913644] fixed project names [f53b823] refactored build config [5a791fb] refactored docker db-tests [b4479b0] revert [a975fa5] updated gitlab build [4e4e5e4] updated mssql setup [d6ff03b] added sleep workaround [578b102] removed host volumes in test [928f50b] fixed path [967ab10] updated tests [520f317] bootstrap cubrid [5f245e1] :factory: fixed cubrid tests [940dbbc] :factory: pinned cubrid version 9.3.6.0002 [8d5ea69] :memo: dockerized test commands [9954b54] updated cubrid [fb3afac] updated docs [3f63ced] updated isolation [bdc3c83] :factory: build cubrid [b777911] :factory: disabled mssql, updated cubrid [36534e7] added travis-a-like stage [6546f02] updated GitLab build [c046096] updated test setup - added mssql and cubrid stack [5a0e635] disabled host-volume [75cf342] fixed test [8de0794] fixed testing [465d27a] added stages [63aa950] added script [68eecef] fixed typo [00e4b88] updated Docker build [f9072cc] added dockerized test setup
8 years ago
docker-compose -f docker-compose.runner.yml run runner
8 years ago
Execute jobs via shell runner (with docker-compose support)
updated debug settings (+56 squashed commits) Squashed commits: [c42f30c] updated base image, added docs & local test script [88f0c40] debug [6220c94] fixed network isolation [c63c7c3] test mssql only on test/mssql branch [74efc78] fixed isolation in after_script [02b895b] updated test setup [3335f39] updated retry [bd123b2] updated service checks [45e4c90] updated build [d54da7a] updated after_script [5a4c726] :factory: wait for mysql [08db878] fixed typo [ea53c1e] updated build stages [9807ce3] fixed typos [cf9f64e] fixed mssql testing [08001d6] added db create for mssql [62f6b65] run travis (gitlab simulation) only in travis branch [cf63da4] streamlined build [76808ac] updated test jobs [18d79b5] fixed test error [7b2bce6] updated build & composer.lock [244623a] updated build [86bd71b] fixed cleanup [86ab2e8] fixed cleanup [091d4b8] fixed tests [2d315b5] fixed build config [2913644] fixed project names [f53b823] refactored build config [5a791fb] refactored docker db-tests [b4479b0] revert [a975fa5] updated gitlab build [4e4e5e4] updated mssql setup [d6ff03b] added sleep workaround [578b102] removed host volumes in test [928f50b] fixed path [967ab10] updated tests [520f317] bootstrap cubrid [5f245e1] :factory: fixed cubrid tests [940dbbc] :factory: pinned cubrid version 9.3.6.0002 [8d5ea69] :memo: dockerized test commands [9954b54] updated cubrid [fb3afac] updated docs [3f63ced] updated isolation [bdc3c83] :factory: build cubrid [b777911] :factory: disabled mssql, updated cubrid [36534e7] added travis-a-like stage [6546f02] updated GitLab build [c046096] updated test setup - added mssql and cubrid stack [5a0e635] disabled host-volume [75cf342] fixed test [8de0794] fixed testing [465d27a] added stages [63aa950] added script [68eecef] fixed typo [00e4b88] updated Docker build [f9072cc] added dockerized test setup
8 years ago
$ gitlab-runner exec shell build
$ gitlab-runner exec shell test