Testing environment setup

Note: This section is under development.

Yii2 has officially maintained integration with Codeception testing framework that allows you to create the following test types:

  • Unit testing - verifies that a single unit of code is working as expected;
  • Functional testing - verifies scenarios from a user's perspective via browser emulation;
  • Acceptance testing - verifies scenarios from a user's perspective in a browser.

Yii provides ready to use test sets for all three test types in both yii2-basic and yii2-advanced application templates.

In order to run tests you need to install Codeception. A good way to install it is the following:

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