Skip to content
Browse files

set up PHPUnit

  • Loading branch information...
1 parent 7945529 commit 08f6269ce6dde39a201bddfb614f036ab7c9d3ad @scribu committed Feb 20, 2013
Showing with 67 additions and 0 deletions.
  1. +40 −0 .travis.yml
  2. +20 −0 phpunit.xml
  3. +7 −0 tests/bootstrap.php
View
40 .travis.yml
@@ -0,0 +1,40 @@
+language: php
+
+php:
+ - 5.3
+ - 5.4
+
+env:
+ - WP_VERSION=master WP_MULTISITE=0
+ - WP_VERSION=3.4.2 WP_MULTISITE=0
+ - WP_VERSION=master WP_MULTISITE=1
+ - WP_VERSION=3.4.2 WP_MULTISITE=1
+
+before_install:
+ - git submodule update --init --recursive
+
+before_script:
+ # set up WP install
+ - WP_CORE_DIR=/tmp/wordpress/
+ - wget -nv -O /tmp/wordpress.tar.gz https://github.com/WordPress/WordPress/tarball/$WP_VERSION
+ - mkdir -p $WP_CORE_DIR
+ - tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR
+ - plugin_slug=$(basename $(pwd))
+ - plugin_dir=$WP_CORE_DIR/wp-content/plugins/$plugin_slug
+ - cd ..
+ - mv $plugin_slug $plugin_dir
+ # set up testing suite
+ - export WP_TESTS_DIR=/tmp/wordpress-tests/
+ - svn co --ignore-externals http://unit-tests.svn.wordpress.org/trunk/ $WP_TESTS_DIR
+ - cd $WP_TESTS_DIR
+ - cp wp-tests-config-sample.php wp-tests-config.php
+ - sed -i "s:dirname( __FILE__ ) . '/wordpress/':'$WP_CORE_DIR':" wp-tests-config.php
+ - sed -i "s/yourdbnamehere/wordpress_test/" wp-tests-config.php
+ - sed -i "s/yourusernamehere/root/" wp-tests-config.php
+ - sed -i "s/yourpasswordhere//" wp-tests-config.php
+ # set up database
+ - mysql -e 'CREATE DATABASE wordpress_test;' -uroot
+ # prepare for running the tests
+ - cd $plugin_dir
+
+script: phpunit
View
20 phpunit.xml
@@ -0,0 +1,20 @@
+<phpunit
+ bootstrap="tests/bootstrap.php"
+ backupGlobals="false"
+ colors="true"
+ convertErrorsToExceptions="true"
+ convertNoticesToExceptions="true"
+ convertWarningsToExceptions="true"
+ >
+ <testsuites>
+ <testsuite>
+ <directory prefix="test-" suffix=".php">./tests/</directory>
+ </testsuite>
+ </testsuites>
+ <filter>
+ <whitelist>
+ <directory suffix=".php">./core</directory>
+ <directory suffix=".php">./admin</directory>
+ </whitelist>
+ </filter>
+</phpunit>
View
7 tests/bootstrap.php
@@ -0,0 +1,7 @@
+<?php
+
+$GLOBALS['wp_tests_options'] = array(
+ 'active_plugins' => array( basename( dirname( dirname( __FILE__ ) ) ) . '/plugin.php' ),
+);
+
+require getenv( 'WP_TESTS_DIR' ) . '/includes/bootstrap.php';

0 comments on commit 08f6269

Please sign in to comment.
Something went wrong with that request. Please try again.