Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Drupal 7 bootstrap for php unit
<?php
/**
* Script to bootstrap Drupal 7 for PHPUnit tests.
* On multisite installation, set $http_host variable
* to the site you want to test.
*
* Put this file into drupal root directory and
* and specify it in phpunit.xml file.
*/
// There are problems (notices) with host and REMOTE_ADDR, which fill
// all console log.
$_SERVER['HTTP_HOST'] = 'localhost';
$_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;
define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment