Skip to content
This repository has been archived by the owner on Dec 17, 2021. It is now read-only.

Commit

Permalink
Add in some very basic unit testing code to make sure that at least o…
Browse files Browse the repository at this point in the history
…ne test returns with a result so that initial builds don't break in Travis CI.
  • Loading branch information
Philip Arthur Moore committed Jun 18, 2014
1 parent 5a53049 commit 0e63871
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 2 deletions.
4 changes: 4 additions & 0 deletions phpunit.config.xml
Expand Up @@ -16,8 +16,12 @@
strict="false"
bootstrap="tests/bootstrap.php">
<testsuites>
<!-- Default test suite to run all tests. -->
<testsuite>
<directory prefix="test-" suffix=".php">./tests/</directory>
</testsuite>
</testsuites>
<logging>
<log type="coverage-html" target="coverage" title="PHPUnit" charset="UTF-8" yui="true" highlight="true" />
</logging>
</phpunit>
84 changes: 82 additions & 2 deletions tests/bootstrap.php
Expand Up @@ -2,14 +2,94 @@
/**
* Subtitles Unit Tests Bootstrap
*
* @since 1.0.1
* @package Subtitles
*
* @since 1.0.2
*/

/**
* Turn on error reporting.
*
* @since 1.0.1
* @link http://www.php.net//manual/en/function.error-reporting.php
*
* @since 1.0.2
*/
error_reporting( E_ALL ); // Report all PHP Errors.
ini_set( 'error_reporting', E_ALL ); // Same as above.
ini_set( 'display_errors', 'on' ); // Display errors.

/**
* PHPUnit by defaults disables Xdebug backtrace, but we'll put this
* here to be explicit about it.
*
* @link http://xdebug.org/docs/all_functions#xdebug_disable
*
* @since 1.0.2
*/
if( function_exists( 'xdebug_disable' ) ) {
xdebug_disable();
} // end if xdebug_disable check

/**
* Output a little bit of helpful information about the testing suite,
* which is the same information that we use within the main plugin
* file. For the version, we're just keeping it in line with the version
* of Subtitles. The unit testing suite and the plugin are all the same thing
* as far as versioning goes, but we won't do version bumps on Subtitles
* for improvements to the testing suite, since this isn't something that gets
* shipped with the public plugin on WordPress.org.
*
* @since 1.0.2
*/
echo "Subtitles WordPress Plugin Unit Testing Suite v1.0.2" . PHP_EOL;
echo "Author: Philip Arthur Moore" . PHP_EOL;
echo "License: GNU General Public License v2 or later" . PHP_EOL . PHP_EOL;

/**
* Define Subtitles plugin directory.
* This should output (something)/(something)/subtitles/
*
* @since 1.0.2
*/
define( 'SUBTITLES_PLUGIN_DIR', dirname( dirname( __FILE__ ) ) . '/' );

/**
* Define Subtitles unit tests directory.
* This should output (something)/(something)/subtitles/tests/
*
* @since 1.0.2
*/
define( 'SUBTITLES_TESTS_DIR', dirname( __FILE__ ) ) . '/';

/**
* Activate Subtitles in WordPress so that it can be tested.
*
* After this, the value for $GLOBALS[ 'wp_tests_options' ] should be 'subtitles/subtitles.php'.
*
* @since 1.0.2
*/
$GLOBALS[ 'wp_tests_options' ] = array(
'active_plugins' => array( basename( dirname( dirname( __FILE__ ) ) ) . '/subtitles.php' ),
);

/**
* If the development repository for WordPress has been defined, then use it.
* The constant for that will be WP_DEVELOP_DIR. If the constant isn't defined,
* then assume that Subtitles has been installed in a checkout (git or svn) of
* the WordPress development version.
*
* getenv( 'WP_DEVELOP_DIR' ) is a boolean.
*
* @since 1.0.2
*/
if( false !== getenv( 'WP_DEVELOP_DIR' ) ) {
// functions used before loading WordPress
require getenv( 'WP_DEVELOP_DIR' ) . '/tests/phpunit/includes/functions.php';
// Installs WordPress for running the tests and loads WordPress and the test libraries
require getenv( 'WP_DEVELOP_DIR' ) . '/tests/phpunit/includes/bootstrap.php';
} else {
// functions used before loading WordPress
require '../../../../tests/phpunit/includes/functions.php';
// Installs WordPress for running the tests and loads WordPress and the test libraries
require '../../../../tests/phpunit/includes/bootstrap.php';
}
7 changes: 7 additions & 0 deletions tests/test-unit-tests.php
@@ -0,0 +1,7 @@
<?php
class SampleTest extends WP_UnitTestCase {
function testSample() {
// replace this with some actual testing code
$this->assertTrue( true );
}
}

0 comments on commit 0e63871

Please sign in to comment.