Permalink
Browse files

Merge remote-tracking branch 'upstream/master' into plgtpl

  • Loading branch information...
2 parents 505c2ae + fc189e3 commit b83f9c88d66a0cccbca25daa0cba50898560591f @phproberto phproberto committed Jul 31, 2012
View
@@ -1,4 +1,5 @@
/coverage
+/coverage-legacy
/logs
/pdepend
/code-browser
@@ -0,0 +1,76 @@
+<?php
+/**
+ * Prepares a minimalist framework for unit testing.
+ *
+ * Joomla is assumed to include the /unittest/ directory.
+ * eg, /path/to/joomla/unittest/
+ *
+ * @package Joomla.UnitTest
+ *
+ * @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
+ * @license GNU General Public License version 2 or later; see LICENSE
+ * @link http://www.phpunit.de/manual/current/en/installation.html
+ */
+
+// Setup the Pharsanity!
+Phar::interceptFileFuncs();
+
+// Set the Joomla execution flag.
+define('_JEXEC', 1);
+
+// Fix magic quotes.
+@ini_set('magic_quotes_runtime', 0);
+
+// Maximise error reporting.
+error_reporting(E_ALL & ~E_STRICT);
+ini_set('display_errors', 1);
+
+/*
+ * Ensure that required path constants are defined. These can be overridden within the phpunit.xml file
+ * if you chose to create a custom version of that file.
+ */
+if (!defined('JPATH_TESTS'))
+{
+ define('JPATH_TESTS', __DIR__);
+}
+if (!defined('JPATH_PLATFORM'))
+{
+ define('JPATH_PLATFORM', 'phar://' . __FILE__ . '/lib');
+}
+if (!defined('JPATH_BASE'))
+{
+ define('JPATH_BASE', JPATH_TESTS . '/tmp');
+}
+if (!defined('JPATH_ROOT'))
+{
+ define('JPATH_ROOT', JPATH_BASE);
+}
+if (!defined('JPATH_CACHE'))
+{
+ define('JPATH_CACHE', JPATH_BASE . '/cache');
+}
+if (!defined('JPATH_CONFIGURATION'))
+{
+ define('JPATH_CONFIGURATION', JPATH_BASE);
+}
+if (!defined('JPATH_MANIFESTS'))
+{
+ define('JPATH_MANIFESTS', JPATH_BASE . '/manifests');
+}
+if (!defined('JPATH_PLUGINS'))
+{
+ define('JPATH_PLUGINS', JPATH_BASE . '/plugins');
+}
+if (!defined('JPATH_THEMES'))
+{
+ define('JPATH_THEMES', JPATH_BASE . '/themes');
+}
+
+// Import the platform.
+require_once JPATH_PLATFORM . '/import.php';
+
+// Register the core Joomla test classes.
+JLoader::registerPrefix('Test', 'phar://' . __FILE__ . '/core');
+
+// End of the Phar Stub.
+__HALT_COMPILER();?>
View
@@ -0,0 +1,68 @@
+<?php
+/**
+ * @package Joomla.Platform
+ *
+ * @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
+ * @license GNU General Public License version 2 or later; see LICENSE
+ */
+
+// Setup the Pharsanity!
+Phar::interceptFileFuncs();
+
+// Set the platform root path as a constant if necessary.
+if (!defined('JPATH_PLATFORM'))
+{
+ define('JPATH_PLATFORM', 'phar://' . __FILE__);
+}
+
+// Detect the native operating system type.
+$os = strtoupper(substr(PHP_OS, 0, 3));
+if (!defined('IS_WIN'))
+{
+ define('IS_WIN', ($os === 'WIN') ? true : false);
+}
+if (!defined('IS_MAC'))
+{
+ define('IS_MAC', ($os === 'MAC') ? true : false);
+}
+if (!defined('IS_UNIX'))
+{
+ define('IS_UNIX', (($os !== 'MAC') && ($os !== 'WIN')) ? true : false);
+}
+
+// Import the platform version library if necessary.
+if (!class_exists('JPlatform'))
+{
+ require_once JPATH_PLATFORM . '/platform.php';
+}
+
+// Import the library loader if necessary.
+if (!class_exists('JLoader'))
+{
+ require_once JPATH_PLATFORM . '/loader.php';
+}
+
+// Make sure that the Joomla Platform has been successfully loaded.
+if (!class_exists('JLoader'))
+{
+ throw new RuntimeException('Joomla Platform not loaded.');
+}
+
+// Setup the autoloaders.
+JLoader::setup();
+
+// Import the base Joomla Platform libraries.
+JLoader::import('joomla.factory');
+
+// Register classes for compatability with PHP 5.3
+if (version_compare(PHP_VERSION, '5.4.0', '<'))
+{
+ JLoader::register('JsonSerializable', JPATH_PLATFORM . '/compat/jsonserializable.php');
+}
+
+// Register classes that don't follow one file per class naming conventions.
+JLoader::register('JText', JPATH_PLATFORM . '/joomla/language/text.php');
+JLoader::register('JRoute', JPATH_PLATFORM . '/joomla/application/route.php');
+
+// End of the Phar Stub.
+__HALT_COMPILER();?>
@@ -50,7 +50,7 @@ class_exists('JLoader') or die;
// Register classes for compatability with PHP 5.3
if (version_compare(PHP_VERSION, '5.4.0', '<'))
{
- JLoader::register('JsonSerializable', __DIR__ . '/compat/jsonserializable.php');
+ JLoader::register('JsonSerializable', JPATH_PLATFORM . '/compat/jsonserializable.php');
}
// Register classes that don't follow one file per class naming conventions.
@@ -98,7 +98,10 @@ public static function check($userId, $action, $asset = null)
// Default to the root asset node.
if (empty($asset))
{
- $asset = 1;
+ $db = JFactory::getDbo();
+ $assets = JTable::getInstance('Asset', 'JTable', array('dbo' => $db));
+ $rootId = $assets->getRootId();
+ $asset = $rootId;
}
// Get the rules for the asset recursively to root if not already retrieved.
@@ -138,7 +141,9 @@ public static function checkGroup($groupId, $action, $asset = null)
// Default to the root asset node.
if (empty($asset))
{
- $asset = 1;
+ $db = JFactory::getDbo();
+ $assets = JTable::getInstance('Asset', 'JTable', array('dbo' => $db));
+ $rootId = $assets->getRootId();
}
// Get the rules for the asset recursively to root if not already retrieved.
@@ -225,12 +230,10 @@ public static function getAssetRules($asset, $recursive = false)
// If the asset identifier is numeric assume it is a primary key, else lookup by name.
if (is_numeric($asset))
{
- // Get the root even if the asset is not found
$query->where('(a.id = ' . (int) $asset . ')');
}
else
{
- // Get the root even if the asset is not found
$query->where('(a.name = ' . $db->quote($asset) . ')');
}
@@ -246,16 +249,19 @@ public static function getAssetRules($asset, $recursive = false)
$result = $db->loadColumn();
// Get the root even if the asset is not found and in recursive mode
- if ($recursive && empty($result))
+ if (empty($result))
{
+ $db = JFactory::getDbo();
+ $assets = JTable::getInstance('Asset', 'JTable', array('dbo' => $db));
+ $rootId = $assets->getRootId();
$query = $db->getQuery(true);
$query->select('rules');
$query->from('#__assets');
- $query->where('parent_id = 0');
+ $query->where('id = ' . $db->quote($rootId));
$db->setQuery($query);
- $result = $db->loadColumn();
+ $result = $db->loadResult();
+ $result = array($result);
}
-
// Instantiate and return the JAccessRules object for the asset rules.
$rules = new JAccessRules;
$rules->mergeCollection($result);
@@ -455,9 +461,7 @@ public static function getAuthorisedViewLevels($userId)
* @deprecated 12.3 Use JAccess::getActionsFromFile or JAccess::getActionsFromData instead.
*
* @codeCoverageIgnore
- *
- * @todo Need to decouple this method from the CMS. Maybe check if $component is a
- * valid file (or create a getActionsFromFile method).
+ *
*/
public static function getActions($component, $section = 'component')
{
@@ -68,7 +68,7 @@ public function request($method, JUri $uri, $data = null, array $headers = null,
$options[CURLOPT_NOBODY] = ($method === 'HEAD');
// Initialize the certificate store
- $options[CURLOPT_CAINFO] = __DIR__ . '/cacert.pem';
+ $options[CURLOPT_CAINFO] = $this->options->get('curl.certpath', __DIR__ . '/cacert.pem');
// If data exists let's encode it and make sure our Content-type header is set.
if (isset($data))
@@ -184,24 +184,31 @@ public function __construct($lang = null, $debug = false)
// Look for a language specific localise class
$class = str_replace('-', '_', $lang . 'Localise');
- if (!class_exists($class) && defined('JPATH_SITE'))
+ $paths = array();
+ if (defined('JPATH_SITE'))
{
- // Class does not exist. Try to find it in the Site Language Folder
- $localise = JPATH_SITE . "/language/$lang/$lang.localise.php";
- if (file_exists($localise))
- {
- require_once $localise;
- }
+ // Note: Manual indexing to enforce load order.
+ $paths[0] = JPATH_SITE . "/language/overrides/$lang.localise.php";
+ $paths[2] = JPATH_SITE . "/language/$lang/$lang.localise.php";
+ }
+
+ if (defined('JPATH_ADMINISTRATOR'))
+ {
+ // Note: Manual indexing to enforce load order.
+ $paths[1] = JPATH_ADMINISTRATOR . "/language/overrides/$lang.localise.php";
+ $paths[3] = JPATH_ADMINISTRATOR . "/language/$lang/$lang.localise.php";
}
- if (!class_exists($class) && defined('JPATH_ADMINISTRATOR'))
+ ksort($paths);
+ $path = reset($paths);
+
+ while (!class_exists($class) && $path)
{
- // Class does not exist. Try to find it in the Administrator Language Folder
- $localise = JPATH_ADMINISTRATOR . "/language/$lang/$lang.localise.php";
- if (file_exists($localise))
+ if (file_exists($path))
{
- require_once $localise;
+ require_once $path;
}
+ $path = next($paths);
}
if (class_exists($class))
@@ -43,20 +43,28 @@ class JPaginationObject
public $prefix;
/**
+ * @var boolean Flag whether the object is the 'active' page
+ * @since 12.2
+ */
+ public $active;
+
+ /**
* Class constructor.
*
* @param string $text The link text.
* @param integer $prefix The prefix used for request variables.
* @param integer $base The number of rows as a base offset.
* @param string $link The link URL.
+ * @param boolean $active Flag whether the object is the 'active' page
*
* @since 11.1
*/
- public function __construct($text, $prefix = '', $base = null, $link = null)
+ public function __construct($text, $prefix = '', $base = null, $link = null, $active = false)
{
$this->text = $text;
$this->prefix = $prefix;
$this->base = $base;
$this->link = $link;
+ $this->active = $active;
}
}
@@ -721,6 +721,10 @@ protected function _buildDataObject()
$data->pages[$i]->base = $offset;
$data->pages[$i]->link = JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $offset);
}
+ elseif ($i = $this->pagesCurrent)
+ {
+ $data->pages[$i]->active = true;
+ }
}
return $data;
}
@@ -278,7 +278,8 @@ protected function _getAssetTitle()
/**
* Method to get the parent asset under which to register this one.
- * By default, all assets are registered to the ROOT node with ID 1.
+ * By default, all assets are registered to the ROOT node with ID,
+ * which will default to 1 if none exists.
* The extended class can define a table and id to lookup. If the
* asset does not exist it will be created.
*
@@ -292,9 +293,11 @@ protected function _getAssetTitle()
protected function _getAssetParentId($table = null, $id = null)
{
// For simple cases, parent to the asset root.
- if (empty($table) || empty($id))
+ $assets = self::getInstance('Asset', 'JTable', array('dbo' => $this->getDbo()));
+ $rootId = $assets->getRootId();
+ if (!empty($rootId))
{
- return 1;
+ return $rootId;
}
return 1;
@@ -570,6 +573,10 @@ public function store($updateNulls = false)
{
// Initialise variables.
$k = $this->_tbl_key;
+ if (!empty($this->asset_id))
+ {
+ $currentAssetId = $this->asset_id;
+ }
// The asset id field is managed privately by this class.
if ($this->_trackAssets)
@@ -642,7 +649,8 @@ public function store($updateNulls = false)
return false;
}
- if (empty($this->asset_id))
+ // Create an asset_id or heal one that is corrupted.
+ if (empty($this->asset_id) || ($currentAssetId != $this->asset_id && !empty($this->asset_id)))
{
// Update the asset_id field in this table.
$this->asset_id = (int) $asset->id;
View
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<packager minify="false" alias="joomla-test.phar" destination="build/joomla-test.phar">
+ <code stub="build/bootstrap.stub.php">
+ <file localPath="lib">libraries/import.php</file>
+ <file localPath="lib">libraries/loader.php</file>
+ <file localPath="lib">libraries/platform.php</file>
+ <folder recursive="true" localPath="lib/compat">libraries/compat</folder>
+ <folder recursive="true" localPath="lib/joomla">libraries/joomla</folder>
+ <folder recursive="true" localPath="lib/phpmailer">libraries/phpmailer</folder>
+ <folder recursive="true" localPath="lib/phputf8">libraries/phputf8</folder>
+ <folder recursive="true" localPath="lib/simplepie">libraries/simplepie</folder>
+ <folder recursive="true" localPath="core">tests/core</folder>
+ </code>
+
+ <metadata>
+ <element name="version" value="1.0" />
+ <element name="authors">
+ <element name="OpenSourceMatters, Inc.">
+ <element name="email" value="admin@joomla.org" />
+ </element>
+ </element>
+ </metadata>
+</packager>
Oops, something went wrong.

0 comments on commit b83f9c8

Please sign in to comment.