This quick start guide is geared towards installing PHPUnit on OSX in order to run the WordPress unit tests. It uses homebrew to install PHP using homebrew-php. You can likely skip this step if you've already got php and pear installed properly.
If you use MAMP, then try these instructions to use MAMP's php and pear to install PHPUnit.
ruby <(curl -fsSkL raw.github.com/mxcl/homebrew/go)
brew tap homebrew/dupes
brew tap josegonzalez/homebrew-php
brew install php54 --with-mysql --with-fpm --with-homebrew-openssl --with-imap --with-pgsql --with-intl
brew install php54-xdebug
sudo chmod u+w /usr/local/Cellar/php54/5.4.5/lib/php/.lock
sudo chmod g+w /usr/local/Cellar/php54/5.4.5/lib/php/.lock
pear update-channels
pear channel-discover pear.phpunit.de
pear channel-discover components.ez.no
pear channel-discover pear.symfony-project.com
pear install phpunit/PHPUnit
Then add this to your $PATH
: /usr/local/Cellar/php54/5.4.5/bin
svn co http://unit-test.svn.wordpress.org/trunk/ wp-unit-tests
cd wp-unit-tests && svn up
The test suite will destroy all data in the database, so create one dedicated to running the suite.
mysql -u root -p -e "DROP DATABASE wpunit; CREATE DATABASE wpunit; GRANT ALL PRIVILEGES ON wpunit.* TO wpunit@localhost IDENTIFIED BY 'wpunit'; FLUSH PRIVILEGES;"
cp wp-tests-config-sample.php wp-tests-config.php
Then edit wp-tests-config.php to connect to your database.
phpunit
phpunit tests/query.php
- http://unit-test.trac.wordpress.org/
- http://www.maxcutler.com/2012/06/30/wordpress-unit-tests-sprint-a-primer/
- http://www.slideshare.net/slideshow/embed_code/5555994
- http://seleniumhq.org/
- http://phpadvent.org/2011/integration-testing-by-wez-furlong
- http://behat.org/
- http://www.phprack.com/
- http://www.phpspec.net/
Instead of installing all those channel dependencies manually, try:
Then PEAR will automatically add the appropriate channels for dependencies. A big time-saver when the package maintainer is splitting packages across channels.