Skip to content

Instantly share code, notes, and snippets.

@jsivakumaran
Last active June 17, 2016 15:22
Show Gist options
  • Save jsivakumaran/369e50ee07e6ab815638a6133f7d4676 to your computer and use it in GitHub Desktop.
Save jsivakumaran/369e50ee07e6ab815638a6133f7d4676 to your computer and use it in GitHub Desktop.
Install Codeception on yii2 project
Step 1.
//install the plugins
composer global require "codeception/codeception=2.0.*"
composer global require "codeception/specify=*"
composer global require "codeception/verify=*"
Step2.
//Might need to install missing php-xml if needed
Step3.
//add codecept to $PATH - copy and paste the following three commands in the terminal
echo 'pathmunge /root/.composer/vendor/bin' > /etc/profile.d/codecept.sh
chmod +x /etc/profile.d/codecept.sh
. /etc/profile
Step4.
//Then Follow along on tests/README.md
//Step 3 however should be
A. Go into phpmyadmin and create a new database called yii2_advanced_tests
B. Then in the terminal type - tests/codeception/bin/yii migrate
C. Remove system_configuration entry in phpmyadmin - then import sql file like regularly
Step5.
//codecept bootstrap from root folder
Step6.
http://codeception.com/docs/05-UnitTests
//Follow along to create a unit test using the codecept test generators
Step7.
//After Creating a Test
codecept build
codecept run
//And repeat as many times as desired
For Acceptance Tests - https://www.youtube.com/watch?v=GJdiZNZGBr8
1. Run a server: php -S localhost:8080 from /var/www/html/YiiTest
2. Generate a test: codecept generate:cept acceptance NameOfTest
3. Modify the test:
<?php
$I = new AcceptanceTester($scenario)
$I->wantTo('Check the homepage loads');
$I->amOnPage('/');
$I->see('Checkout');
4. Run the test: codecept run
A: For the first test you need to modify the acceptance.suite.yml file to url:http://localhost:8080/frontend/web
References
http://codeception.com/docs/
https://www.youtube.com/watch?v=GJdiZNZGBr8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment