Unit Testing with current version of Craft Has Craft stopped shipping with unit tests? I'm trying to unit test a plugin and have noticed from several previous answers (e.g PHPUnit testing for Craft plugins or controllers) that it was possible at some stage using Craft's local tests. Have these since been removed? There no longer seems to be a tests folder inside the latest download of Craft/app.

What is the current best practice for setting up Unit Tests using Craft 2 in a plugin?
I found a bootstrap that works for me apart from an issue with the database connection.

I can't find the link now but here is the code:

&lt;?php
define("CRAFT_ENVIRONMENT", "dev");
// PHP sucks at resolving symlinked directories
define('CRAFT_BASE_PATH', realpath(str_replace("plugins/myplugin", '', dirname(__FILE__))).'/');

// Define app constants
defined('CRAFT_APP_PATH')          || define('CRAFT_APP_PATH',          CRAFT_BASE_PATH.'app/');
defined('CRAFT_CONFIG_PATH')       || define('CRAFT_CONFIG_PATH',       CRAFT_BASE_PATH.'config/');
defined('CRAFT_VENDOR_PATH')       || define('CRAFT_VENDOR_PATH',       CRAFT_BASE_PATH.'app/vendor/');
defined('CRAFT_FRAMEWORK_PATH') || define('CRAFT_FRAMEWORK_PATH', CRAFT_APP_PATH.'framework/');;
defined('CRAFT_PLUGINS_PATH')      || define('CRAFT_PLUGINS_PATH',      CRAFT_BASE_PATH.'plugins/');
defined('CRAFT_STORAGE_PATH')      || define('CRAFT_STORAGE_PATH',      CRAFT_BASE_PATH.'storage/');
defined('CRAFT_TEMPLATES_PATH')    || define('CRAFT_TEMPLATES_PATH',    CRAFT_BASE_PATH.'templates/');
defined('CRAFT_TRANSLATIONS_PATH') || define('CRAFT_TRANSLATIONS_PATH', CRAFT_BASE_PATH.'translations/');
defined('YII_TRACE_LEVEL')          || define('YII_TRACE_LEVEL', 3);
// Load Yii
require_once CRAFT_APP_PATH.'framework/yiit.php';
Yii::$enableIncludePath = false;
require_once CRAFT_APP_PATH.'Craft.php';
require_once CRAFT_APP_PATH.'etc/web/WebApp.php';
require_once CRAFT_APP_PATH.'Info.php';
// Craft shits itself if there is no server or request path
$_SERVER['HTTP_HOST'] = 'dev.copywheat';
$_SERVER['REQUEST_URI'] = '/';
// Load test database
$config = require_once CRAFT_APP_PATH.'etc/config/test.php';
$config['params']['dbConfig'] = array();

// Create app instance
$app = new \Craft\WebApp($config);
// Load plugin
require_once CRAFT_PLUGINS_PATH.'myplugin/mypluginPlugin.php';


I'm still having issues with the db connection.  Have had to resort to modifying the craft/app/etc/config/defaults.db in order to override the environment file which does work for me at the moment.