Skip to content

Instantly share code, notes, and snippets.

@dsmeringe
Last active December 12, 2015 07:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dsmeringe/4739033 to your computer and use it in GitHub Desktop.
Save dsmeringe/4739033 to your computer and use it in GitHub Desktop.
Short guide on how to setup PHPUnit properly for Yii framework projects

Quick start for Yii with PHPUnit

install PHPUnit

prepend with sudo on mac

pear install --alldeps --force phpunit/phpunit
pear install phpunit/PHPUnit_Selenium
pear install phpunit/phpunit_story
pear install phpunit/dbunit

Get Selenium server (was Selenium RC)

http://seleniumhq.org/download/ it's runt with; $ java -jar selenium-server-standalone-VERSION_NO.jar

Configure Yii

  • Update config/test.php OR create local test config file (if you work in a team). Might want to enable a test database there too. I added this to my tests/bootstrap.php to handle a local config.

      //use standard test config if local variant doesn't exist.
      if (!file_exists($config))
          $config=dirname(__FILE__).'/../config/test.php';
    
  • Update tests/WebTestCase.php similarly to use your local site for testing.

Now dive into TDD and Yii :)

http://www.yiiframework.com/doc/guide/1.1/en/test.overview

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment