Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save permanovd/cb9c02920c49a29c97653f4f697147b1 to your computer and use it in GitHub Desktop.
Save permanovd/cb9c02920c49a29c97653f4f697147b1 to your computer and use it in GitHub Desktop.
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