6.3. Codeception Framework usage - shinokada/php_notes GitHub Wiki

Laravel and codeception

Install Laravel from composer

composer create-project laravel/laravel
cd laravel

Install codecept through laravel/composer.json.

"require-dev":{
    "codeception/codeception": "2.1.*@dev"
  }

In terminal composer install --dev.

Laravel require mcrypt, so you may need to install mcrypt.

// either 
codecept bootstrap
// or create it under app directory
codecept bootstrap app 
// if installed it under app move codeception.yml to root
mv app/codeception.yml codeception.yml

// running codecept will give an error
codecept run

// edit codeception.yml path
paths:
  tests: app/tests
  log: app/tests/_log
  data: app/tests/_data
  helpers: app/tests/_helpers
  ....
  dump: app/tests/_data/dump.sql
  ....

// now you can run codecept run
codecept run

Functional testing

In app/tests/functional.suite.yml, add Laravel5 to enabled.

class_name: FunctionalTester
modules:
    enabled: [Filesystem, FunctionalHelper, Laravel5]

In terminal run codecept build. This will add methods such as amOnPage etc. Doc The functional test does not require the server running.

In terminal

codecept generate:cept functional MyFirstFunctional

This will create app/tests/functional/MyFirstFunctionalCept.php. Add the following to the file.

$I = new FunctionalTester($scenario);
$I->wantTo('verify the home page');
$I->amOnPage('/');
$I->see('hello there');

Run in the terminal.

codecept run functional
⚠️ **GitHub.com Fallback** ⚠️