Created
May 11, 2011 13:21
-
-
Save dave1010/966439 to your computer and use it in GitHub Desktop.
PHPUnit config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
deny from all | |
# put this in your tests and test-reports folders if you don't want the world seeing them |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (empty($_SERVER["argc"])) { | |
echo "Error: This script must be run from the command line"; | |
die(1); | |
} | |
if (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 50300) { | |
echo "Error: This script must be run from PHP >= 5.3.0"; | |
die(1); | |
} | |
$_SERVER['HTTP_HOST'] = trim(file_get_contents(__DIR__ . '/host')); | |
define('CLI', true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<phpunit | |
colors="true" | |
verbose="true" | |
bootstrap="test-bootstrap.php" | |
> | |
<!-- | |
1. Put your tests in a folder called "tests" (with an .htaccess "deny from all") | |
2. If there are any slow tests, annotate the test method with a "@group slow" PHP-doc-style comment. These tests will me ignored by default. | |
3. To run tests: | |
$ cd my-project | |
$ phpunit | |
4. To run slow tests: | |
$ cd my-project | |
$ phpunit --no-configuration --group slow tests | |
5. To run a specific test case: | |
$ cd my-project | |
$ phpunit --no-configuration tests/myTests.php | |
5. To run a specific tests (e.g. WidgetAddTest, WidgetDeleteTest): | |
$ cd my-project | |
$ phpunit --no-configuration --filter Widget tests | |
6. Lovely test reports can be found in the test-reports directory (with an .htaccess "deny from all") | |
--> | |
<testsuites> | |
<testsuite name="My Test Suite"> | |
<directory>tests</directory> | |
</testsuite> | |
</testsuites> | |
<groups> | |
<exclude> | |
<group>slow</group> | |
</exclude> | |
</groups> | |
<logging> | |
<log type="coverage-html" target="test-reports" charset="UTF-8" yui="true" /> | |
</logging> | |
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// bootstrap your system | |
error_reporting(E_ALL | E_STRICT); | |
// e.g: | |
// include 'example-bootstrap.php'; | |
// or | |
// include 'wordpress-bootstrap.php'; | |
// or | |
// function __autoload($class) { include $class . '.php'; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// HTTP_HOST is not set (as it's not Apache) | |
if (!file_exists(__DIR__ . '/host')) { | |
echo "Error: Host file requred in '" . __DIR__ . "/host' with contents of \$_SERVER['HTTP_HOST']. Aborting"; | |
die(1); | |
} | |
// Make WP think it's running under Apache | |
$_SERVER["REQUEST_METHOD"] = 'GET'; | |
$_SERVER["SERVER_PROTOCOL"] = 'HTTP/1.0'; | |
$_SERVER["SERVER_PORT"] = '80'; | |
$_SERVER["SERVER_NAME"] = $_SERVER["HTTP_HOST"]; | |
$_SERVER["REMOTE_ADDR"] = 'localhost'; | |
$_SERVER["REMOTE_PORT"] = '80'; | |
// Random WP things that need to be done | |
global $PHP_SELF; | |
global $wp_embed; | |
global $wpdb; | |
global $wp_version; | |
define( 'DOING_AJAX', true ); | |
$GLOBALS[ '_wp_deprecated_widgets_callbacks' ] = array(); | |
require_once( 'wp-load.php' ); | |
function cli_die($message) { | |
debug_print_backtrace(); | |
die('DIE: ' . $message); | |
} | |
add_filter('wp_die_handler', 'cli_die'); | |
ini_set('memory_limit', -1); | |
while (ob_get_level()) { | |
// Who knows what some WP plugins are up to? | |
ob_end_flush(); | |
} | |
/* | |
if (!defined('HIDE_BANNER')) { | |
echo "--------------------------------------\n"; | |
echo "-- WordPress Command Line Interface --\n"; | |
echo "-- " . get_option('siteurl') . " --\n"; | |
echo "-- " . DB_USER . "@" . DB_HOST . "/" . DB_NAME . " --\n"; | |
echo "--------------------------------------\n"; | |
echo "\n"; | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment