Skip to content

Instantly share code, notes, and snippets.

@kumatch
Created July 15, 2010 05:29
Show Gist options
  • Save kumatch/476544 to your computer and use it in GitHub Desktop.
Save kumatch/476544 to your computer and use it in GitHub Desktop.
Stagehand_Testrunner prepare scripts for CakePHP.
<?php
if (!include(CORE_PATH . 'cake' . DS . 'bootstrap.php')) {
trigger_error("CakePHP core could not be found.", E_USER_ERROR);
}
Configure::write('debug', 0);
$version = Configure::version();
if (preg_match('/^1.2/', $version)) {
$corePath = Configure::corePaths('cake');
} else {
$corePath = App::core('cake');
}
if (isset($corePath[0])) {
define('TEST_CAKE_CORE_INCLUDE_PATH', rtrim($corePath[0], DS) . DS);
} else {
define('TEST_CAKE_CORE_INCLUDE_PATH', CAKE_CORE_INCLUDE_PATH);
}
require_once 'simpletest/unit_tester.php';
require_once 'simpletest/mock_objects.php';
require_once 'simpletest/web_tester.php';
require_once CAKE_TESTS_LIB . 'cake_web_test_case.php';
$cakeTestCase = str_replace(array('<?php', "App::import('Vendor', 'simpletest'"),
array('', "//App::import('Vendor', 'simpletest'"),
file_get_contents(CAKE_TESTS_LIB . 'cake_test_case.php', true)
);
eval($cakeTestCase);
<?php
/**
* Use the DS to separate the directories in other defines
*/
if (!defined('DS')) {
define('DS', DIRECTORY_SEPARATOR);
}
/**
* The full path to the directory which holds "app", WITHOUT a trailing DS.
*
*/
if (!defined('ROOT')) {
$checkBasePath = dirname(dirname(dirname(__FILE__)));
if (file_exists($checkBasePath . '/cake')
&& is_dir($checkBasePath . '/cake')
) {
define('ROOT', $checkBasePath);
} else {
define('ROOT', dirname($checkBasePath));
}
}
/**
* The actual directory name for the "app".
*
*/
if (!defined('APP_DIR')) {
define('APP_DIR', 'app');
}
/**
* The absolute path to the "cake" directory, WITHOUT a trailing DS.
*
*/
if (!defined('CAKE_CORE_INCLUDE_PATH')) {
define('CAKE_CORE_INCLUDE_PATH', ROOT);
}
/**
* Editing below this line should not be necessary.
* Change at your own risk.
*
*/
if (!defined('WEBROOT_DIR')) {
define('WEBROOT_DIR', 'webroot');
}
if (!defined('WWW_ROOT')) {
define('WWW_ROOT', ROOT . DS . APP_DIR . DS. WEBROOT_DIR . DS);
}
if (!defined('CORE_PATH')) {
if (function_exists('ini_set')
&& ini_set('include_path', CAKE_CORE_INCLUDE_PATH . PATH_SEPARATOR .
ROOT . DS . APP_DIR . DS . PATH_SEPARATOR .
ini_get('include_path')
)
) {
define('APP_PATH', null);
define('CORE_PATH', null);
} else {
define('APP_PATH', ROOT . DS . APP_DIR . DS);
define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
}
}
<?php
set_time_limit(0);
ini_set('display_errors', 1);
define('DISABLE_DEFAULT_ERROR_HANDLING', false);
include dirname(__FILE__) . '/paths_static.php';
include dirname(__FILE__) . '/bootstrap.php';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment