Skip to content
Browse files

Merge pull request #72 from LouisLandry/master

Some modifications to fix unit tests, etc.
  • Loading branch information...
2 parents 21a0433 + d3f5c3d commit ecf6ffae5d1b09a9303a18791953eaf0d367f60f @LouisLandry LouisLandry committed Jul 4, 2011
View
4 README
@@ -1,4 +0,0 @@
-Joomla Platform
-
-Please ensure you add the following path to your local .gitignore file:
-tests/test_application/cache
View
27 README.markdown
@@ -0,0 +1,27 @@
+Joomla Platform
+===============
+
+The *Joomla Platform* is a platform for writing Web and command line applications in PHP. It is free and open source software,
+distributed under the GNU General Public License version 2 or later. The Joomla Content Management System (CMS) is built on
+top of the *Joomla Platform*. For more information about the Joomla CMS visit: http://www.joomla.org/about-joomla.html
+
+You can find out more about Joomla development *(though not platform specific)* at: http://docs.joomla.org/Developers
+
+You can discuss *Joomla Platform* development at: http://groups.google.com/group/joomla-dev-framework
+
+
+Requirements
+------------
+
+* PHP 5.3+
+
+
+Installation
+------------
+
+Get the source code from GIT:
+
+ git clone git://github.com/joomla/joomla-platform.git
+
+_Please ensure you add the following path to your local .gitignore file: tests/test_application/cache_
+
View
16 libraries/joomla/application/cli.php
@@ -10,7 +10,7 @@
defined('JPATH_PLATFORM') or die;
jimport('joomla.application.applicationexception');
-jimport('joomla.application.input.cli');
+jimport('joomla.application.input');
jimport('joomla.event.dispatcher');
jimport('joomla.log.log');
jimport('joomla.registry.registry');
@@ -57,7 +57,9 @@ protected function __construct()
}
// Get the command line options
- $this->input = new JInputCli();
+ if (class_exists('JInput')) {
+ $this->input = new JInputCli();
+ }
// Create the registry with a default namespace of config
$this->config = new JRegistry();
@@ -80,13 +82,19 @@ protected function __construct()
* This method must be invoked as: $cli = JCli::getInstance();
*
* @return JCli A JCli object
+ *
* @since 11.1
*/
- public static function & getInstance()
+ public static function & getInstance($name = null)
{
// Only create the object if it doesn't exist.
if (empty(self::$instance)) {
- self::$instance = new JCli();
+ if (class_exists($name) && ($name instanceof JCli)) {
+ self::$instance = new $name();
+ }
+ else {
+ self::$instance = new JCli();
+ }
}
return self::$instance;
View
10 libraries/joomla/application/cli/daemon.php
@@ -19,7 +19,7 @@
* @package Joomla.Platform
* @subpackage Application
* @since 11.1
- *
+ *
* @see http://www.php.net/manual/en/book.pcntl.php
* @see http://php.net/manual/en/features.commandline.php
*/
@@ -40,8 +40,8 @@ class JDaemon extends JCli
/**
* Exiting status
* True if the daemon is in the process of exiting.
- *
- * @var boolean
+ *
+ * @var boolean
* @since 11.1
*/
protected $exiting = false;
@@ -87,7 +87,9 @@ protected function __construct()
// Set some system limits.
set_time_limit($this->config->get('max_execution_time', 0));
- ini_set('memory_limit',isset($config['max_memory_limit']) ? $config['max_memory_limit'] : $this->config->get('max_memory_limit', '256M'));
+ if ($this->config->get('max_memory_limit') !== null) {
+ ini_set('memory_limit', $this->config->get('max_memory_limit', '256M'));
+ }
// Flush content immediatly.
ob_implicit_flush();
View
83 libraries/joomla/environment/uri.php
@@ -85,6 +85,30 @@ class JURI extends JObject
protected $_vars = array ();
/**
+ * @var array An array of JURI instances.
+ * @since 11.1
+ */
+ protected static $instances = array();
+
+ /**
+ * @var array The current calculated base url segments.
+ * @since 11.1
+ */
+ protected static $base = array();
+
+ /**
+ * @var array The current calculated root url segments.
+ * @since 11.1
+ */
+ protected static $root = array();
+
+ /**
+ * @var string The current url.
+ * @since 11.1
+ */
+ protected static $current;
+
+ /**
* Constructor.
* You can pass a URI string to the constructor to initialise a specific URI.
*
@@ -121,9 +145,8 @@ public function __toString()
*/
public static function getInstance($uri = 'SERVER')
{
- static $instances = array();
- if (!isset($instances[$uri])) {
+ if (empty(self::$instances[$uri])) {
// Are we obtaining the URI from the server?
if ($uri == 'SERVER') {
// Determine if the request was over SSL (HTTPS).
@@ -163,9 +186,9 @@ public static function getInstance($uri = 'SERVER')
}
// Create the new JURI instance
- $instances[$uri] = new JURI($theURI);
+ self::$instances[$uri] = new JURI($theURI);
}
- return $instances[$uri];
+ return self::$instances[$uri];
}
/**
@@ -178,24 +201,22 @@ public static function getInstance($uri = 'SERVER')
*/
public static function base($pathonly = false)
{
- static $base;
-
// Get the base request path.
- if (!isset($base)) {
+ if (empty(self::$base)) {
$config = JFactory::getConfig();
$live_site = $config->get('live_site');
if (trim($live_site) != '') {
$uri = self::getInstance($live_site);
- $base['prefix'] = $uri->toString(array('scheme', 'host', 'port'));
- $base['path'] = rtrim($uri->toString(array('path')), '/\\');
+ self::$base['prefix'] = $uri->toString(array('scheme', 'host', 'port'));
+ self::$base['path'] = rtrim($uri->toString(array('path')), '/\\');
if (JPATH_BASE == JPATH_ADMINISTRATOR) {
- $base['path'] .= '/administrator';
+ self::$base['path'] .= '/administrator';
}
}
else {
$uri = self::getInstance();
- $base['prefix'] = $uri->toString(array('scheme', 'host', 'port'));
+ self::$base['prefix'] = $uri->toString(array('scheme', 'host', 'port'));
if (strpos(php_sapi_name(), 'cgi') !== false && !ini_get('cgi.fix_pathinfo') && !empty($_SERVER['REQUEST_URI'])) {
// PHP-CGI on Apache with "cgi.fix_pathinfo = 0"
@@ -209,11 +230,11 @@ public static function base($pathonly = false)
$script_name = $_SERVER['SCRIPT_NAME'];
}
- $base['path'] = rtrim(dirname($script_name), '/\\');
+ self::$base['path'] = rtrim(dirname($script_name), '/\\');
}
}
- return $pathonly === false ? $base['prefix'].$base['path'].'/' : $base['path'];
+ return $pathonly === false ? self::$base['prefix'].self::$base['path'].'/' : self::$base['path'];
}
/**
@@ -226,21 +247,19 @@ public static function base($pathonly = false)
*/
public static function root($pathonly = false, $path = null)
{
- static $root;
-
// Get the scheme
- if (!isset($root)) {
- $uri = self::getInstance(self::base());
- $root['prefix'] = $uri->toString(array('scheme', 'host', 'port'));
- $root['path'] = rtrim($uri->toString(array('path')), '/\\');
+ if (empty(self::$root)) {
+ $uri = self::getInstance(self::base());
+ self::$root['prefix'] = $uri->toString(array('scheme', 'host', 'port'));
+ self::$root['path'] = rtrim($uri->toString(array('path')), '/\\');
}
// Get the scheme
if (isset($path)) {
- $root['path'] = $path;
+ self::$root['path'] = $path;
}
- return $pathonly === false ? $root['prefix'].$root['path'].'/' : $root['path'];
+ return $pathonly === false ? self::$root['prefix'].self::$root['path'].'/' : self::$root['path'];
}
/**
@@ -251,15 +270,27 @@ public static function root($pathonly = false, $path = null)
*/
public static function current()
{
- static $current;
-
// Get the current URL.
- if (!isset($current)) {
+ if (empty(self::$current)) {
$uri = self::getInstance();
- $current = $uri->toString(array('scheme', 'host', 'port', 'path'));
+ self::$current = $uri->toString(array('scheme', 'host', 'port', 'path'));
}
- return $current;
+ return self::$current;
+ }
+
+ /**
+ * Method to reset class static members for testing and other various issues.
+ *
+ * @return void
+ * @since 11.1
+ */
+ public static function reset()
+ {
+ self::$instances = array();
+ self::$base = array();
+ self::$root = array();
+ self::$current = '';
}
/**
View
9 tests/suite/joomla/environment/JURITest.php
@@ -30,6 +30,15 @@ class JURITest extends PHPUnit_Framework_TestCase
*/
protected function setUp()
{
+ parent::setUp();
+
+ JURI::reset();
+
+ $_SERVER['HTTP_HOST'] = 'www.example.com:80';
+ $_SERVER['SCRIPT_NAME'] = '/joomla/index.php';
+ $_SERVER['PHP_SELF'] = '/joomla/index.php';
+ $_SERVER['REQUEST_URI'] = '/joomla/index.php?var=value 10';
+
$this->object = new JURI;
}
View
4 tests/suite/joomla/html/JHtmlTest.php
@@ -309,7 +309,9 @@ public function testImage()
rmdir(JPATH_THEMES .'/'. $template);
// we create the file that JHtml::image will look for
- mkdir(JPATH_ROOT .'/media/'. $urlpath .'images', 0777, true);
+ if (!is_dir(JPATH_ROOT .'/media/'. $urlpath .'images')) {
+ mkdir(JPATH_ROOT .'/media/'. $urlpath .'images', 0777, true);
+ }
file_put_contents(JPATH_ROOT .'/media/'. $urlpath .'images/'. $urlfilename, 'test');
// we do a test for the case that the image is in the templates directory

0 comments on commit ecf6ffa

Please sign in to comment.
Something went wrong with that request. Please try again.