Skip to content

Commit

Permalink
Add Travis CI and PHPUnit structure
Browse files Browse the repository at this point in the history
  • Loading branch information
sheabunge committed Jul 6, 2013
1 parent 302bde4 commit 6f318ed
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
language: php

php:
- 5.3
- 5.4

env:
- WP_VERSION=master WP_MULTISITE=0
- WP_VERSION=master WP_MULTISITE=1
- WP_VERSION=3.5.1 WP_MULTISITE=0
- WP_VERSION=3.5.1 WP_MULTISITE=1

before_install:
- git submodule update --init --recursive

before_script:
# set up WP install
- WP_CORE_DIR=/tmp/wordpress/
- mkdir -p $WP_CORE_DIR
- wget -nv -O /tmp/wordpress.tar.gz https://github.com/WordPress/WordPress/tarball/$WP_VERSION
- tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR
# set up testing suite
- export WP_TESTS_DIR=/tmp/wordpress-tests/
- svn co --ignore-externals --quiet 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
- cd -
# set up database
- mysql -e 'CREATE DATABASE wordpress_test;' -uroot

script: phpunit
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Code Snippets

[![Build Status](https://travis-ci.org/bungeshea/code-snippets.png?branch=develop)](https://travis-ci.org/bungeshea/code-snippets)

* __Requires at least:__ [WordPress 3.3](http://wordpress.org/download/) or later
* __Tested up to:__ WordPress 3.6
* __Stable version:__ [1.7.1.2](http://downloads.wordpress.org/plugin/code-snippets.latest-stable.zip)
Expand Down
14 changes: 14 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<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>
</phpunit>
15 changes: 15 additions & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

require_once getenv( 'WP_TESTS_DIR' ) . '/includes/functions.php';

function _manually_load_plugin() {
require dirname( __FILE__ ) . '/../code-snippets.php';
}
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );

require getenv( 'WP_TESTS_DIR' ) . '/includes/bootstrap.php';

class Code_Snippets_TestCase extends WP_UnitTestCase {
// Put convenience methods here

}
8 changes: 8 additions & 0 deletions tests/test-unit-tests.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

class Code_Snippets_Test_Unit_Tests extends Code_Snippets_TestCase {

function test_true_is_true() {
$this->assertTrue( true ); // The unit tests are running
}
}

0 comments on commit 6f318ed

Please sign in to comment.