README.md 1.54 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Yii 2.0 Unit tests
==================

DIRECTORY STRUCTURE
-------------------

      unit/                Unit tests to run with PHPUnit
          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
      web/                 webapp for functional testing


HOW TO RUN THE TESTS
--------------------

Carsten Brandt committed
18
Make sure you have PHPUnit installed and that you installed all composer dependencies (run `composer update` in the repo base directory).
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40

Run PHPUnit in the yii repo base directory.

```php
phpunit
```

You can run tests for specific groups only:

```php
phpunit --group=mysql,base,i18n
```

You can get a list of available groups via `phpunit --list-groups`.

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`
Carsten Brandt committed
41 42 43 44 45 46 47 48 49 50 51
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';
```