Commits

Louis Landry  committed 3623283 Merge
  • Participants
  • Parent commits ae60c4a, 85949ba

Comments (0)

Files changed (308)

File CHANGELOG

File contents unchanged.

File libraries/config.example.php

File contents unchanged.

File libraries/import.php

File contents unchanged.

File libraries/index.html

File contents unchanged.

File libraries/joomla/access/access.php

File contents unchanged.

File libraries/joomla/access/rule.php

File contents unchanged.

File libraries/joomla/access/rules.php

File contents unchanged.

File libraries/joomla/application/application.php

File contents unchanged.

File libraries/joomla/application/categories.php

File contents unchanged.

File libraries/joomla/application/component/controller.php

File contents unchanged.

File libraries/joomla/application/component/controlleradmin.php

File contents unchanged.

File libraries/joomla/application/component/controllerform.php

File contents unchanged.

File libraries/joomla/application/component/helper.php

File contents unchanged.

File libraries/joomla/application/component/model.php

File contents unchanged.

File libraries/joomla/application/component/modeladmin.php

File contents unchanged.

File libraries/joomla/application/component/modelform.php

File contents unchanged.

File libraries/joomla/application/component/modelitem.php

File contents unchanged.

File libraries/joomla/application/component/modellist.php

File contents unchanged.

File libraries/joomla/application/component/view.php

File contents unchanged.

File libraries/joomla/application/helper.php

File contents unchanged.

File libraries/joomla/application/menu.php

File contents unchanged.

File libraries/joomla/application/module/helper.php

File contents unchanged.

File libraries/joomla/application/pathway.php

File contents unchanged.

File libraries/joomla/application/router.php

File contents unchanged.

File libraries/joomla/base/adapter.php

File contents unchanged.

File libraries/joomla/base/adapterinstance.php

File contents unchanged.

File libraries/joomla/base/node.php

File contents unchanged.

File libraries/joomla/base/object.php

File contents unchanged.

File libraries/joomla/base/observable.php

File contents unchanged.

File libraries/joomla/base/observer.php

File contents unchanged.

File libraries/joomla/base/tree.php

File contents unchanged.

File libraries/joomla/cache/cache.php

File contents unchanged.

File libraries/joomla/cache/controller.php

File contents unchanged.

File libraries/joomla/cache/controller/callback.php

File contents unchanged.

File libraries/joomla/cache/controller/output.php

File contents unchanged.

File libraries/joomla/cache/controller/page.php

File contents unchanged.

File libraries/joomla/cache/controller/view.php

File contents unchanged.

File libraries/joomla/cache/storage.php

File contents unchanged.

File libraries/joomla/cache/storage/apc.php

File contents unchanged.

File libraries/joomla/cache/storage/cachelite.php

File contents unchanged.

File libraries/joomla/cache/storage/eaccelerator.php

File contents unchanged.

File libraries/joomla/cache/storage/file.php

File contents unchanged.

File libraries/joomla/cache/storage/helpers/helper.php

File contents unchanged.

File libraries/joomla/cache/storage/memcache.php

File contents unchanged.

File libraries/joomla/cache/storage/wincache.php

File contents unchanged.

File libraries/joomla/cache/storage/xcache.php

File contents unchanged.

File libraries/joomla/client/ftp.php

File contents unchanged.

File libraries/joomla/client/helper.php

File contents unchanged.

File libraries/joomla/client/ldap.php

File contents unchanged.

File libraries/joomla/database/database.php

File contents unchanged.

File libraries/joomla/database/database/mysql.php

File contents unchanged.

File libraries/joomla/database/database/mysqli.php

File contents unchanged.

File libraries/joomla/database/databasequery.php

File contents unchanged.

File libraries/joomla/database/table.php

File contents unchanged.

File libraries/joomla/database/table/asset.php

File contents unchanged.

File libraries/joomla/database/table/category.php

File contents unchanged.

File libraries/joomla/database/table/content.php

File contents unchanged.

File libraries/joomla/database/table/extension.php

File contents unchanged.

File libraries/joomla/database/table/menu.php

File contents unchanged.

File libraries/joomla/database/table/menutype.php

File contents unchanged.

File libraries/joomla/database/table/module.php

File contents unchanged.

File libraries/joomla/database/table/session.php

File contents unchanged.

File libraries/joomla/database/table/update.php

File contents unchanged.

File libraries/joomla/database/table/user.php

File contents unchanged.

File libraries/joomla/database/table/usergroup.php

File contents unchanged.

File libraries/joomla/database/table/viewlevel.php

File contents unchanged.

File libraries/joomla/database/tablenested.php

File contents unchanged.

File libraries/joomla/document/document.php

File contents unchanged.

File libraries/joomla/document/error/error.php

File contents unchanged.

File libraries/joomla/document/feed/feed.php

File contents unchanged.

File libraries/joomla/document/feed/renderer/atom.php

File contents unchanged.

File libraries/joomla/document/feed/renderer/rss.php

File contents unchanged.

File libraries/joomla/document/html/html.php

File contents unchanged.

File libraries/joomla/document/html/renderer/component.php

File contents unchanged.

File libraries/joomla/document/html/renderer/head.php

File contents unchanged.

File libraries/joomla/document/html/renderer/message.php

File contents unchanged.

File libraries/joomla/document/html/renderer/module.php

File contents unchanged.

File libraries/joomla/document/html/renderer/modules.php

File contents unchanged.

File libraries/joomla/document/json/json.php

File contents unchanged.

File libraries/joomla/document/raw/raw.php

File contents unchanged.

File libraries/joomla/document/renderer.php

File contents unchanged.

File libraries/joomla/document/xml/xml.php

File contents unchanged.

File libraries/joomla/environment/browser.php

File contents unchanged.

File libraries/joomla/environment/request.php

File contents unchanged.

File libraries/joomla/environment/response.php

File contents unchanged.

File libraries/joomla/environment/uri.php

File contents unchanged.

File libraries/joomla/error/error.php

File contents unchanged.

File libraries/joomla/error/exception.php

File contents unchanged.

File libraries/joomla/error/log.php

File contents unchanged.

File libraries/joomla/error/profiler.php

File contents unchanged.

File libraries/joomla/event/dispatcher.php

File contents unchanged.

File libraries/joomla/event/event.php

File contents unchanged.

File libraries/joomla/factory.php

File contents unchanged.

File libraries/joomla/filesystem/archive.php

File contents unchanged.

File libraries/joomla/filesystem/archive/bzip2.php

File contents unchanged.

File libraries/joomla/filesystem/archive/gzip.php

File contents unchanged.

File libraries/joomla/filesystem/archive/tar.php

File contents unchanged.

File libraries/joomla/filesystem/archive/zip.php

File contents unchanged.

File libraries/joomla/filesystem/file.php

File contents unchanged.

File libraries/joomla/filesystem/folder.php

File contents unchanged.

File libraries/joomla/filesystem/helper.php

File contents unchanged.

File libraries/joomla/filesystem/path.php

File contents unchanged.

File libraries/joomla/filesystem/streams/string.php

File contents unchanged.

File libraries/joomla/filter/filterinput.php

File contents unchanged.

File libraries/joomla/filter/filteroutput.php

File contents unchanged.

File libraries/joomla/form/fields/accesslevel.php

File contents unchanged.

File libraries/joomla/form/fields/cachehandler.php

File contents unchanged.

File libraries/joomla/form/fields/calendar.php

File contents unchanged.

File libraries/joomla/form/fields/category.php

File contents unchanged.

File libraries/joomla/form/fields/checkbox.php

File contents unchanged.

File libraries/joomla/form/fields/checkboxes.php

File contents unchanged.

File libraries/joomla/form/fields/combo.php

File contents unchanged.

File libraries/joomla/form/fields/componentlayout.php

File contents unchanged.

File libraries/joomla/form/fields/contentlanguage.php

File contents unchanged.

File libraries/joomla/form/fields/editor.php

File contents unchanged.

File libraries/joomla/form/fields/editors.php

File contents unchanged.

File libraries/joomla/form/fields/email.php

File contents unchanged.

File libraries/joomla/form/fields/file.php

File contents unchanged.

File libraries/joomla/form/fields/filelist.php

File contents unchanged.

File libraries/joomla/form/fields/folderlist.php

File contents unchanged.

File libraries/joomla/form/fields/groupedlist.php

File contents unchanged.

File libraries/joomla/form/fields/helpsite.php

File contents unchanged.

File libraries/joomla/form/fields/hidden.php

File contents unchanged.

File libraries/joomla/form/fields/imagelist.php

File contents unchanged.

File libraries/joomla/form/fields/integer.php

File contents unchanged.

File libraries/joomla/form/fields/language.php

File contents unchanged.

File libraries/joomla/form/fields/list.php

File contents unchanged.

File libraries/joomla/form/fields/media.php

File contents unchanged.

File libraries/joomla/form/fields/menu.php

File contents unchanged.

File libraries/joomla/form/fields/menuitem.php

File contents unchanged.

File libraries/joomla/form/fields/modulelayout.php

File contents unchanged.

File libraries/joomla/form/fields/password.php

File contents unchanged.

File libraries/joomla/form/fields/radio.php

File contents unchanged.

File libraries/joomla/form/fields/rules.php

File contents unchanged.

File libraries/joomla/form/fields/sessionhandler.php

File contents unchanged.

File libraries/joomla/form/fields/spacer.php

File contents unchanged.

File libraries/joomla/form/fields/sql.php

File contents unchanged.

File libraries/joomla/form/fields/tel.php

File contents unchanged.

File libraries/joomla/form/fields/templatestyle.php

File contents unchanged.

File libraries/joomla/form/fields/text.php

File contents unchanged.

File libraries/joomla/form/fields/textarea.php

File contents unchanged.

File libraries/joomla/form/fields/timezone.php

File contents unchanged.

File libraries/joomla/form/fields/url.php

File contents unchanged.

File libraries/joomla/form/fields/usergroup.php

File contents unchanged.

File libraries/joomla/form/form.php

File contents unchanged.

File libraries/joomla/form/formfield.php

File contents unchanged.

File libraries/joomla/form/formrule.php

File contents unchanged.

File libraries/joomla/form/helper.php

File contents unchanged.

File libraries/joomla/form/rules/boolean.php

File contents unchanged.

File libraries/joomla/form/rules/email.php

File contents unchanged.

File libraries/joomla/form/rules/equals.php

File contents unchanged.

File libraries/joomla/form/rules/rules.php

File contents unchanged.

File libraries/joomla/form/rules/username.php

File contents unchanged.

File libraries/joomla/html/editor.php

File contents unchanged.

File libraries/joomla/html/html.php

File contents unchanged.

File libraries/joomla/html/html/access.php

File contents unchanged.

File libraries/joomla/html/html/behavior.php

File contents unchanged.

File libraries/joomla/html/html/category.php

File contents unchanged.

File libraries/joomla/html/html/content.php

File contents unchanged.

File libraries/joomla/html/html/contentlanguage.php

File contents unchanged.

File libraries/joomla/html/html/email.php

File contents unchanged.

File libraries/joomla/html/html/form.php

File contents unchanged.

File libraries/joomla/html/html/grid.php

File contents unchanged.

File libraries/joomla/html/html/image.php

File contents unchanged.

File libraries/joomla/html/html/jgrid.php

File contents unchanged.

File libraries/joomla/html/html/list.php

File contents unchanged.

File libraries/joomla/html/html/menu.php

File contents unchanged.

File libraries/joomla/html/html/number.php

File contents unchanged.

File libraries/joomla/html/html/rules.php

File contents unchanged.

File libraries/joomla/html/html/select.php

File contents unchanged.

File libraries/joomla/html/html/sliders.php

File contents unchanged.

File libraries/joomla/html/html/string.php

File contents unchanged.

File libraries/joomla/html/html/tabs.php

File contents unchanged.

File libraries/joomla/html/pagination.php

File contents unchanged.

File libraries/joomla/html/pane.php

File contents unchanged.

File libraries/joomla/html/parameter.php

File contents unchanged.

File libraries/joomla/html/parameter/element.php

File contents unchanged.

File libraries/joomla/html/parameter/element/calendar.php

File contents unchanged.

File libraries/joomla/html/parameter/element/category.php

File contents unchanged.

File libraries/joomla/html/parameter/element/componentlayouts.php

File contents unchanged.

File libraries/joomla/html/parameter/element/contentlanguages.php

File contents unchanged.

File libraries/joomla/html/parameter/element/editors.php

File contents unchanged.

File libraries/joomla/html/parameter/element/filelist.php

File contents unchanged.

File libraries/joomla/html/parameter/element/folderlist.php

File contents unchanged.

File libraries/joomla/html/parameter/element/helpsites.php

File contents unchanged.

File libraries/joomla/html/parameter/element/hidden.php

File contents unchanged.

File libraries/joomla/html/parameter/element/imagelist.php

File contents unchanged.

File libraries/joomla/html/parameter/element/languages.php

File contents unchanged.

File libraries/joomla/html/parameter/element/list.php

File contents unchanged.

File libraries/joomla/html/parameter/element/menu.php

File contents unchanged.

File libraries/joomla/html/parameter/element/menuitem.php

File contents unchanged.

File libraries/joomla/html/parameter/element/modulelayouts.php

File contents unchanged.

File libraries/joomla/html/parameter/element/password.php

File contents unchanged.

File libraries/joomla/html/parameter/element/radio.php

File contents unchanged.

File libraries/joomla/html/parameter/element/spacer.php

File contents unchanged.

File libraries/joomla/html/parameter/element/sql.php

File contents unchanged.

File libraries/joomla/html/parameter/element/text.php

File contents unchanged.

File libraries/joomla/html/parameter/element/textarea.php

File contents unchanged.

File libraries/joomla/html/parameter/element/timezones.php

File contents unchanged.

File libraries/joomla/html/parameter/element/usergroup.php

File contents unchanged.

File libraries/joomla/html/toolbar.php

File contents unchanged.

File libraries/joomla/html/toolbar/button.php

File contents unchanged.

File libraries/joomla/html/toolbar/button/confirm.php

File contents unchanged.

File libraries/joomla/html/toolbar/button/custom.php

File contents unchanged.

File libraries/joomla/html/toolbar/button/help.php

File contents unchanged.

File libraries/joomla/html/toolbar/button/link.php

File contents unchanged.

File libraries/joomla/html/toolbar/button/popup.php

File contents unchanged.

File libraries/joomla/html/toolbar/button/separator.php

File contents unchanged.

File libraries/joomla/html/toolbar/button/standard.php

File contents unchanged.

File libraries/joomla/installer/adapters/component.php

File contents unchanged.

File libraries/joomla/installer/adapters/file.php

File contents unchanged.

File libraries/joomla/installer/adapters/language.php

File contents unchanged.

File libraries/joomla/installer/adapters/library.php

File contents unchanged.

File libraries/joomla/installer/adapters/module.php

File contents unchanged.

File libraries/joomla/installer/adapters/package.php

File contents unchanged.

File libraries/joomla/installer/adapters/plugin.php

File contents unchanged.

File libraries/joomla/installer/adapters/template.php

File contents unchanged.

File libraries/joomla/installer/extension.php

File contents unchanged.

File libraries/joomla/installer/helper.php

File contents unchanged.

File libraries/joomla/installer/installer.php

File contents unchanged.

File libraries/joomla/installer/librarymanifest.php

File contents unchanged.

File libraries/joomla/installer/packagemanifest.php

File contents unchanged.

File libraries/joomla/language/help.php

File contents unchanged.

File libraries/joomla/language/helper.php

File contents unchanged.

File libraries/joomla/language/language.php

File contents unchanged.

File libraries/joomla/mail/helper.php

File contents unchanged.

File libraries/joomla/mail/mail.php

File contents unchanged.

File libraries/joomla/methods.php

File contents unchanged.

File libraries/joomla/plugin/helper.php

File contents unchanged.

File libraries/joomla/plugin/plugin.php

File contents unchanged.

File libraries/joomla/registry/format.php

File contents unchanged.

File libraries/joomla/registry/format/ini.php

File contents unchanged.

File libraries/joomla/registry/format/json.php

File contents unchanged.

File libraries/joomla/registry/format/php.php

File contents unchanged.

File libraries/joomla/registry/format/xml.php

File contents unchanged.

File libraries/joomla/registry/registry.php

File contents unchanged.

File libraries/joomla/session/session.php

File contents unchanged.

File libraries/joomla/session/storage.php

File contents unchanged.

File libraries/joomla/session/storage/apc.php

File contents unchanged.

File libraries/joomla/session/storage/database.php

File contents unchanged.

File libraries/joomla/session/storage/eaccelerator.php

File contents unchanged.

File libraries/joomla/session/storage/memcache.php

File contents unchanged.

File libraries/joomla/session/storage/none.php

File contents unchanged.

File libraries/joomla/session/storage/wincache.php

File contents unchanged.

File libraries/joomla/session/storage/xcache.php

File contents unchanged.

File libraries/joomla/updater/update.php

File contents unchanged.

File libraries/joomla/user/authentication.php

File contents unchanged.

File libraries/joomla/user/helper.php

File contents unchanged.

File libraries/joomla/user/user.php

File contents unchanged.

File libraries/joomla/utilities/arrayhelper.php

File contents unchanged.

File libraries/joomla/utilities/buffer.php

File contents unchanged.

File libraries/joomla/utilities/date.php

File contents unchanged.

File libraries/joomla/utilities/simplecrypt.php

File contents unchanged.

File libraries/joomla/utilities/simplexml.php

File contents unchanged.

File libraries/joomla/utilities/string.php

File contents unchanged.

File libraries/joomla/utilities/utility.php

File contents unchanged.

File libraries/joomla/utilities/xmlelement.php

File contents unchanged.

File libraries/loader.php

File contents unchanged.

File libraries/version.php

File contents unchanged.

File tests/bootstrap.php

+<?php
+/**
+ * Prepares a minimalist framework for unit testing.
+ *
+ * Joomla is assumed to include the /unittest/ directory.
+ * eg, /path/to/joomla/unittest/
+ *
+ * @version		$Id: bootstrap.php 20196 2011-01-09 02:40:25Z ian $
+ * @copyright	Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
+ * @license		GNU General Public License version 2 or later; see LICENSE.txt
+ * @link		http://www.phpunit.de/manual/current/en/installation.html
+ */
+define('_JEXEC', 1);
+
+// Load the custom initialisation file if it exists.
+if (file_exists('config.php')) {
+	include 'config.php';
+}
+
+// Include helper class
+require_once(dirname(__FILE__).'/includes/JUnitHelper.php');
+
+// Define expected Joomla constants.
+define('DS', '/');
+
+if (!defined('JPATH_BASE'))
+{
+	// JPATH_BASE can be defined in init.php
+	// This gets around problems with soft linking the unittest folder into a Joomla tree,
+	// or using the unittest framework from a central location.
+	define('JPATH_BASE', JUnitHelper::normalize(dirname(__FILE__)).'/test_application');
+}
+
+if (!defined('JPATH_TESTS'))
+{
+	define('JPATH_TESTS', dirname(__FILE__));
+}
+
+//// Fix magic quotes.
+@ini_set('magic_quotes_runtime', 0);
+
+// Maximise error reporting.
+
+@ini_set('zend.ze1_compatibility_mode', '0');
+error_reporting(E_ALL);
+ini_set('display_errors', 1);
+
+// Include the base test cases.
+require_once JPATH_TESTS.'/includes/JoomlaTestCase.php';
+require_once JPATH_TESTS.'/includes/JoomlaDatabaseTestCase.php';
+
+// Include relative constants, JLoader and the jimport and jexit functions.
+require_once JPATH_BASE.'/defines.php';
+require_once JPATH_PLATFORM.'/import.php';
+
+
+// Exclude all of the tests from code coverage reports
+PHP_CodeCoverage_Filter::getInstance()->addDirectoryToBlacklist(JPATH_TESTS);
+
+// Set error handling.
+JError::setErrorHandling(E_NOTICE, 'ignore');
+JError::setErrorHandling(E_WARNING, 'ignore');
+JError::setErrorHandling(E_ERROR, 'ignore');
+

File tests/config.php-dist

+<?php
+class JTestConfig
+{
+	public $dbtype		= 'mysql';
+	public $host		= '127.0.0.1';
+	public $user		= 'utuser';
+	public $password	= 'ut1234';
+	public $db			= 'joomla_ut';
+	public $dbprefix	= 'jos_';
+	public $ftp_host	= '127.0.0.1';
+	public $ftp_port	= '21';
+	public $ftp_user	= '';
+	public $ftp_pass	= '';
+	public $ftp_root	= '';
+	public $ftp_enable	= 0;
+	public $tmp_path	= '/tmp';
+	public $log_path	= '/var/logs';
+	public $mailer		= 'mail';
+	public $mailfrom	= 'admin@localhost.home';
+	public $fromname	= '';
+	public $sendmail	= '/usr/sbin/sendmail';
+	public $smtpauth	= '0';
+	public $smtpsecure = 'none';
+	public $smtpport	= '25';
+	public $smtpuser	= '';
+	public $smtppass	= '';
+	public $smtphost	= 'localhost';
+	public $debug		= 0;
+	public $caching		= '0';
+	public $cachetime	= '900';
+	public $language	= 'en-GB';
+	public $secret		= null;
+	public $editor		= 'none';
+	public $offset		= 0;
+	public $lifetime	= 15;
+}

File tests/includes/JUnitHelper.php

+<?php
+
+abstract class JUnitHelper
+{
+	public static function normalize($path)
+	{
+		return strtr($path, '\\', '/');
+	}
+}

File tests/includes/JoomlaDatabaseTestCase.php

+<?php
+/**
+ * JoomlaTestCase.php -- unit testing file for JUtilities
+ *
+ * @version		$Id: JoomlaDatabaseTestCase.php 20196 2011-01-09 02:40:25Z ian $
+ * @package	Joomla.UnitTest
+ * @copyright	Copyright (C) 2005 - 2011 Open Source Matters. All rights reserved.
+ * @license		GNU General Public License version 2 or later; see LICENSE.txt
+ */
+
+require_once 'PHPUnit/Extensions/Database/TestCase.php';
+require_once 'PHPUnit/Extensions/Database/DataSet/XmlDataSet.php';
+
+/**
+ * Test case class for Joomla Unit Testing
+ *
+ * @package	Joomla.UnitTest
+ *
+ */
+abstract class JoomlaDatabaseTestCase extends PHPUnit_Extensions_Database_TestCase
+{
+
+	public static $database;
+
+	public static $dbo;
+
+	/**
+	 * @var factoryState
+	 */
+	protected $factoryState = array ();
+
+	/**
+	 * @var errorState
+	 */
+	protected $savedErrorState;
+
+	/**
+	 * @var actualError
+	 */
+	protected static $actualError;
+
+	/**
+	 * Saves the current state of the JError error handlers.
+	 *
+	 * @return	void
+	 */
+	protected function saveErrorHandlers()
+	{
+		$this->savedErrorState = array ();
+		$this->savedErrorState[E_NOTICE] = JError :: getErrorHandling(E_NOTICE);
+		$this->savedErrorState[E_WARNING] = JError :: getErrorHandling(E_WARNING);
+		$this->savedErrorState[E_ERROR] = JError :: getErrorHandling(E_ERROR);
+	}
+
+	public static function setUpBeforeClass()
+	{
+		jimport('joomla.database.database');
+		jimport('joomla.database.table');
+
+		// Load the config if available.
+		@ include_once JPATH_TESTS . '/config.php';
+		if (class_exists('JTestConfig')) {
+			$config = new JTestConfig;
+		}
+
+		if (!is_object(self :: $dbo)) {
+			$options = array (
+				'driver' => isset ($config) ? $config->dbtype : 'mysql',
+				'host' => isset ($config) ? $config->host : '127.0.0.1',
+				'user' => isset ($config) ? $config->user : 'utuser',
+				'password' => isset ($config) ? $config->password : 'ut1234',
+				'database' => isset ($config) ? $config->db : 'joomla_ut',
+				'prefix' => isset ($config) ? $config->dbprefix : 'jos_'
+			);
+
+			self :: $dbo = JDatabase :: getInstance($options);
+
+			if (JError :: isError(self :: $dbo)) {
+				//ignore errors
+				define('DB_NOT_AVAILABLE', true);
+			}
+		}
+		self :: $database = JFactory :: $database;
+		JFactory :: $database = self :: $dbo;
+	}
+
+	public static function tearDownAfterClass()
+	{
+		//JFactory::$database = self::$database;
+	}
+
+	/**
+	 * Sets the JError error handlers.
+	 *
+	 * @param	array	araay of values and options to set the handlers
+	 *
+	 * @return	void
+	 */
+	protected function setErrorHandlers($errorHandlers)
+	{
+		$mode = null;
+		$options = null;
+
+		foreach ($errorHandlers as $type => $params) {
+			$mode = $params['mode'];
+			if (isset ($params['options'])) {
+				JError :: setErrorHandling($type, $mode, $params['options']);
+			} else {
+				JError :: setErrorHandling($type, $mode);
+			}
+		}
+	}
+
+	/**
+	 * Sets the JError error handlers to callback mode and points them at the test
+	 * logging method.
+	 *
+	 * @return	void
+	 */
+	protected function setErrorCallback($testName)
+	{
+		$callbackHandlers = array (
+			E_NOTICE => array (
+				'mode' => 'callback',
+				'options' => array (
+					$testName,
+					'errorCallback'
+				)
+			),
+			E_WARNING => array (
+				'mode' => 'callback',
+				'options' => array (
+					$testName,
+					'errorCallback'
+				)
+			),
+			E_ERROR => array (
+				'mode' => 'callback',
+				'options' => array (
+					$testName,
+					'errorCallback'
+				)
+			),
+
+		);
+		$this->setErrorHandlers($callbackHandlers);
+	}
+
+	/**
+	 * Receives the callback from JError and logs the required error information for the test.
+	 *
+	 * @param	JException	The JException object from JError
+	 *
+	 * @return	bool	To not continue with JError processing
+	 */
+	static function errorCallback($error)
+	{
+		return false;
+	}
+
+	/**
+	 * Saves the Factory pointers
+	 *
+	 * @return void
+	 */
+	protected function saveFactoryState()
+	{
+		$this->savedFactoryState['application'] = JFactory :: $application;
+		$this->savedFactoryState['config'] = JFactory :: $config;
+		$this->savedFactoryState['session'] = JFactory :: $session;
+		$this->savedFactoryState['language'] = JFactory :: $language;
+		$this->savedFactoryState['document'] = JFactory :: $document;
+		$this->savedFactoryState['acl'] = JFactory :: $acl;
+		//$this->savedFactoryState['database'] = JFactory::$database;
+		$this->savedFactoryState['mailer'] = JFactory :: $mailer;
+	}
+
+	/**
+	 * Sets the Factory pointers
+	 *
+	 * @return void
+	 */
+	protected function restoreFactoryState()
+	{
+		JFactory :: $application = $this->savedFactoryState['application'];
+		JFactory :: $config = $this->savedFactoryState['config'];
+		JFactory :: $session = $this->savedFactoryState['session'];
+		JFactory :: $language = $this->savedFactoryState['language'];
+		JFactory :: $document = $this->savedFactoryState['document'];
+		JFactory :: $acl = $this->savedFactoryState['acl'];
+		//JFactory::$database = $this->savedFactoryState['database'];
+		JFactory :: $mailer = $this->savedFactoryState['mailer'];
+	}
+
+	/**
+	 * Sets the connection to the database
+	 *
+	 * @return connection
+	 */
+	protected function getConnection()
+	{
+		// Load the config if available.
+		@ include_once JPATH_TESTS . '/config.php';
+		if (class_exists('JTestConfig')) {
+			$config = new JTestConfig;
+		}
+
+		$options = array (
+			'driver' => ((isset ($config)) && ($config->dbtype != 'mysqli')) ? $config->dbtype : 'mysql',
+			'host' => isset ($config) ? $config->host : '127.0.0.1',
+			'user' => isset ($config) ? $config->user : 'utuser',
+			'password' => isset ($config) ? $config->password : 'ut1234',
+			'database' => isset ($config) ? $config->db : 'joomla_ut',
+			'prefix' => isset ($config) ? $config->dbprefix : 'jos_'
+		);
+
+		$pdo = new PDO($options['driver'].':host='.$options['host'].';dbname='.$options['database'], $options['user'], $options['password']);
+		return $this->createDefaultDBConnection($pdo, $options['database']);
+	}
+	/**
+	 * Gets the data set to be loaded into the database during setup
+	 *
+	 * @return xml dataset
+	 */
+	protected function getDataSet()
+	{
+		return $this->createXMLDataSet(JPATH_BASE . '/tests/unit/stubs/test.xml');
+	}
+}

File tests/includes/JoomlaTestCase.php

+<?php
+/**
+ * JoomlaTestCase.php -- unit testing file for JUtilities
+ *
+ * @version		$Id: JoomlaTestCase.php 20196 2011-01-09 02:40:25Z ian $
+ * @package	Joomla.UnitTest
+ * @copyright	Copyright (C) 2005 - 2011 Open Source Matters. All rights reserved.
+ * @license		GNU General Public License version 2 or later; see LICENSE.txt
+ */
+
+/**
+ * Test case class for Joomla Unit Testing
+ *
+ * @package	Joomla.UnitTest
+ *
+ */
+abstract class JoomlaTestCase extends PHPUnit_Framework_TestCase
+{
+	/**
+	 * @var factoryState
+	 */
+	protected $factoryState = array();
+
+	/**
+	 * @var errorState
+	 */
+	protected $savedErrorState;
+
+	/**
+	 * @var actualError
+	 */
+	protected static $actualError;
+
+	/**
+	 * @var errors
+	 */
+	protected $expectedErrors = null;
+
+	/**
+	 * Saves the current state of the JError error handlers.
+	 *
+	 * @return	void
+	 */
+	protected function saveErrorHandlers()
+	{
+		$this->savedErrorState = array();
+		$this->savedErrorState[E_NOTICE] = JError::getErrorHandling(E_NOTICE);
+		$this->savedErrorState[E_WARNING] = JError::getErrorHandling(E_WARNING);
+		$this->savedErrorState[E_ERROR] = JError::getErrorHandling(E_ERROR);
+	}
+
+	/**
+	 * Sets the JError error handlers.
+	 *
+	 * @param	array	araay of values and options to set the handlers
+	 *
+	 * @return	void
+	 */
+	protected function setErrorHandlers( $errorHandlers )
+	{
+		$mode = null;
+		$options = null;
+
+		foreach ($errorHandlers as $type => $params)
+		{
+			$mode = $params['mode'];
+			if (isset($params['options']))
+			{
+				JError::setErrorHandling($type, $mode, $params['options']);
+			}
+			else
+			{
+				JError::setErrorHandling($type, $mode);
+			}
+		}
+	}
+
+	/**
+	 * Sets the JError error handlers to callback mode and points them at the test
+	 * logging method.
+	 *
+	 * @return	void
+	 */
+	protected function setErrorCallback( $testName )
+	{
+		$callbackHandlers = array(
+			E_NOTICE => array(
+				'mode' => 'callback',
+				'options' => array($testName, 'errorCallback')
+				),
+			E_WARNING => array(
+				'mode' => 'callback',
+				'options' => array($testName, 'errorCallback')
+				),
+			E_ERROR => array(
+				'mode' => 'callback',
+				'options' => array($testName, 'errorCallback')
+				),
+			);
+		$this->setErrorHandlers($callbackHandlers);
+	}
+
+	protected function setUp()
+	{
+		parent::setUp();
+		$this->setExpectedError();
+	}
+
+	protected function tearDown()
+	{
+		if (is_array($this->expectedErrors) && !empty($this->expectedErrors)) {
+			$this->fail('An expected error was not raised.');
+		}
+
+		JError::setErrorHandling(E_NOTICE, 'ignore');
+		JError::setErrorHandling(E_WARNING, 'ignore');
+		JError::setErrorHandling(E_ERROR, 'ignore');
+
+		parent::tearDown();
+	}
+
+	/**
+	 * Receives the callback from JError and logs the required error information for the test.
+	 *
+	 * @param	JException	The JException object from JError
+	 *
+	 * @return	bool	To not continue with JError processing
+	 */
+	static function errorCallback( $error )
+	{
+
+	}
+
+	/**
+	 * Callback receives the error from JError and deals with it appropriately
+	 * If a test expects a JError to be raised, it should call this setExpectedError first
+	 * If you don't call this method first, the test will fail
+	 */
+	public function expectedErrorCallback($error)
+	{
+		foreach($this->expectedErrors AS $key => $err)
+		{
+			$thisError = true;
+
+			foreach ($err AS $prop => $value)
+			{
+				if ($error->get($prop) !== $value) {
+					$thisError = false;
+				}
+			}
+
+			if ($thisError) {
+				unset($this->expectedErrors[$key]);
+				return $error;
+			}
+
+		}
+		$this->fail('An unexpected error occurred - '.$error->get('message'));
+		return $error;
+	}
+
+	/**
+	 * Tells the unit tests that a method or action you are about to attempt
+	 * is expected to result in JError::raiseSomething being called.
+	 *
+	 * If you don't call this method first, the test will fail.
+	 * If you call this method during your test and the error does not occur, then your test
+	 * will also fail because we assume you were testing to see that an error did occur when it was
+	 * supposed to.
+	 *
+	 * If passed without argument, the array is initialized if it hsn't been already
+	 */
+	public function setExpectedError($error = null) {
+		if (!is_array($this->expectedErrors)) {
+			$this->expectedErrors = array();
+			JError::setErrorHandling(E_NOTICE, 'callback', array($this, 'expectedErrorCallback'));
+			JError::setErrorHandling(E_WARNING, 'callback', array($this, 'expectedErrorCallback'));
+			JError::setErrorHandling(E_ERROR, 'callback', array($this, 'expectedErrorCallback'));
+		}
+		if (!is_null($error)) {
+			$this->expectedErrors[] = $error;
+		}
+	}
+
+
+	/**
+	 * Saves the Factory pointers
+	 *
+	 * @return void
+	 */
+	protected function saveFactoryState()
+	{
+		$this->savedFactoryState['application'] = JFactory::$application;
+		$this->savedFactoryState['config'] = JFactory::$config;
+		$this->savedFactoryState['session'] = JFactory::$session;
+		$this->savedFactoryState['language'] = JFactory::$language;
+		$this->savedFactoryState['document'] = JFactory::$document;
+		$this->savedFactoryState['acl'] = JFactory::$acl;
+		$this->savedFactoryState['database'] = JFactory::$database;
+		$this->savedFactoryState['mailer'] = JFactory::$mailer;
+	}
+
+	/**
+	 * Sets the Factory pointers
+	 *
+	 * @return void
+	 */
+	protected function restoreFactoryState()
+	{
+		JFactory::$application = $this->savedFactoryState['application'];
+		JFactory::$config = $this->savedFactoryState['config'];
+		JFactory::$session = $this->savedFactoryState['session'];
+		JFactory::$language = $this->savedFactoryState['language'];
+		JFactory::$document = $this->savedFactoryState['document'];
+		JFactory::$acl = $this->savedFactoryState['acl'];
+		JFactory::$database = $this->savedFactoryState['database'];
+		JFactory::$mailer = $this->savedFactoryState['mailer'];
+	}
+}

File tests/objects/bogusload.php

+<?php
+class BogusLoad
+{
+	public $someMethodCalled = false;
+
+	public function someMethod ()
+	{
+		$this->someMethodCalled = true;
+	}
+}
+?>

File tests/objects/index.html

+<html>
+<body>
+</body>
+</html>

File tests/phpunit.xml

+<phpunit
+	bootstrap="bootstrap.php"
+	colors="false"
+	stopOnFailure="false"
+	testdox="true"
+	verbose="true"
+	backupStaticAttributes="false"
+	backupGlobals="false">
+	<testsuite name="AllTests">
+		<directory>suite</directory>
+	</testsuite>
+</phpunit>

File tests/suite/JLoaderTest.php

+<?php
+/**
+ * JLoaderTest