Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- define('DRUPAL_ROOT', 'your/path/to/drupal');
- require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
- $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
- // Bootstrap Drupal.
- drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
- // Proceed with PHPUnit tests as usual from here.
- class MyTest extends PHPUnit_Framework_TestCase {
- ...
- <?php
- $path = CWD;
- $site_dir = NULL;
- $dpl_dir = NULL;
- while ($path != '/') {
- if (file_exists($path . '/settings.php')) {
- $site_dir = $path;
- }
- if (file_exists($path . '/index.php') && file_exists($path . '/includes/bootstrap.inc')) {
- $dpl_dir = $path;
- break;
- }
- $path = dirname($path);
- }
- if (!$dpl_dir) {
- echo "No drupal directory found in or above current working directory. Aborting. n";
- exit(1);
- }
- if (!$site_dir) {
- $site_dir = $dpl_dir . '/sites/default';
- if (!file_exists($site_dir . '/settings.php')) {
- echo "No configured site found. Aborting.n";
- exit(1);
- }
- }
- $_SERVER['HTTP_HOST'] = basename($site_dir);
- $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
- define('DRUPAL_ROOT', $dpl_dir);
- set_include_path($dpl_dir . PATH_SEPARATOR . get_include_path());
- require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
- drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
- #!/bin/bash
- # get dirname of the script
- DIR="$(dirname $(readlink "$0"))"
- # assume the boostrap script is stored in the same directory
- php "$DIR/drun-phpunit.php" "$(pwd)" --bootstrap "$DIR/bootstrap.inc.php" "$@"
- <?php
- require_once 'PHP/CodeCoverage/Filter.php';
- PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'PHPUNIT');
- if (extension_loaded('xdebug')) {
- xdebug_disable();
- }
- if (strpos('/usr/bin/php', '@php_bin') === 0) {
- set_include_path(dirname(__FILE__) . PATH_SEPARATOR . get_include_path());
- }
- require_once 'PHPUnit/Autoload.php';
- define('PHPUnit_MAIN_METHOD', 'PHPUnit_TextUI_Command::main');
- define('CWD', $_SERVER['argv'][1]);
- unset($_SERVER['argv'][1]);
- $command = new PHPUnit_TextUI_Command;
- $command->run($_SERVER['argv']);
- <?xml version="1.0" encoding="UTF-8"?>
- <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="phpunit.xsd"
- bootstrap="drupal_phpunit_bootstrap.php"
- verbose="true">
- </phpunit>
- <?php
- $_SERVER['HTTP_HOST'] = 'your.url';
- $_SERVER['SCRIPT_NAME'] = '/index.php';
- $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
- $_SERVER['REQUEST_METHOD'] = 'GET';
- $_SERVER['SERVER_NAME'] = NULL;
- $_SERVER['SERVER_SOFTWARE'] = NULL;
- $_SERVER['HTTP_USER_AGENT'] = NULL;
- // Fix for behat drupal instantiation.
- define('DRUPAL_ROOT', dirname(realpath(__FILE__)));
- require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
- drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
Add Comment
Please, Sign In to add comment