Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge remote-tracking branch 'joomla/master' into uncompressed

  • Loading branch information...
commit fc6615ae1712ccf2eb18fe21e24d34a5e5268f13 2 parents 6b7dc4d + 1ef1d09
@chdemko authored
View
8 libraries/joomla/application/component/controller.php
@@ -810,19 +810,17 @@ public function getModel($name = '', $prefix = '', $config = array())
*/
public function getName()
{
- $name = $this->name;
-
- if (empty($name))
+ if (empty($this->name))
{
$r = null;
if (!preg_match('/(.*)Controller/i', get_class($this), $r))
{
JError::raiseError(500, JText::_('JLIB_APPLICATION_ERROR_CONTROLLER_GET_NAME'));
}
- $name = strtolower($r[1]);
+ $this->name = strtolower($r[1]);
}
- return $name;
+ return $this->name;
}
/**
View
8 libraries/joomla/application/component/model.php
@@ -369,19 +369,17 @@ public function getDbo()
*/
public function getName()
{
- $name = $this->name;
-
- if (empty($name))
+ if (empty($this->name))
{
$r = null;
if (!preg_match('/Model(.*)/i', get_class($this), $r))
{
JError::raiseError(500, 'JLIB_APPLICATION_ERROR_MODEL_GET_NAME');
}
- $name = strtolower($r[1]);
+ $this->name = strtolower($r[1]);
}
- return $name;
+ return $this->name;
}
/**
View
8 libraries/joomla/application/component/modellist.php
@@ -118,7 +118,7 @@ public function getItems()
$store = $this->getStoreId();
// Try to load the data from internal storage.
- if (!empty($this->cache[$store]))
+ if (isset($this->cache[$store]))
{
return $this->cache[$store];
}
@@ -168,7 +168,7 @@ public function getPagination()
$store = $this->getStoreId('getPagination');
// Try to load the data from internal storage.
- if (!empty($this->cache[$store]))
+ if (isset($this->cache[$store]))
{
return $this->cache[$store];
}
@@ -221,7 +221,7 @@ public function getTotal()
$store = $this->getStoreId('getTotal');
// Try to load the data from internal storage.
- if (!empty($this->cache[$store]))
+ if (isset($this->cache[$store]))
{
return $this->cache[$store];
}
@@ -255,7 +255,7 @@ public function getStart()
$store = $this->getStoreId('getstart');
// Try to load the data from internal storage.
- if (!empty($this->cache[$store]))
+ if (isset($this->cache[$store]))
{
return $this->cache[$store];
}
View
8 libraries/joomla/application/component/view.php
@@ -445,9 +445,7 @@ public function getLayoutTemplate()
*/
public function getName()
{
- $name = $this->_name;
-
- if (empty($name))
+ if (empty($this->name))
{
$r = null;
if (!preg_match('/View((view)*(.*(view)?.*))$/i', get_class($this), $r))
@@ -458,10 +456,10 @@ public function getName()
{
JError::raiseWarning('SOME_ERROR_CODE', JText::_('JLIB_APPLICATION_ERROR_VIEW_GET_NAME_SUBSTRING'));
}
- $name = strtolower($r[3]);
+ $this->name = strtolower($r[3]);
}
- return $name;
+ return $this->name;
}
/**
View
2  libraries/joomla/installer/adapters/file.php
@@ -245,7 +245,7 @@ public function install()
$row->set('client_id', 0);
$row->set('params', '');
$row->set('system_data', '');
- $row->set('manifest_cache', '');
+ $row->set('manifest_cache', $this->parent->generateManifestCache());
if (!$row->store())
{
View
4 libraries/joomla/session/session.php
@@ -552,7 +552,7 @@ public function restart()
$this->_state = 'restart';
//regenerate session id
- $id = $this->_createId(strlen($this->getId()));
+ $id = $this->_createId();
session_id($id);
$this->_start();
$this->_state = 'active';
@@ -590,7 +590,7 @@ public function fork()
$cookie = session_get_cookie_params();
// Create new session id
- $id = $this->_createId(strlen($this->getId()));
+ $id = $this->_createId();
// Kill session
session_destroy();
View
2  tests/suite/joomla/application/component/JControllerFormInspector.php
@@ -1,6 +1,6 @@
<?php
/**
- * @version $Id: JControllerHelper.php 20196 2011-01-09 02:40:25Z ian $
+ * @version $Id: JControllerFormInspector.php 20196 2011-01-09 02:40:25Z ian $
* @copyright Copyright (C) 2005 - 2011 Open Source Matters. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
View
58 tests/suite/joomla/application/component/JControllerHelper.php
@@ -1,58 +0,0 @@
-<?php
-/**
- * @version $Id: JControllerHelper.php 20196 2011-01-09 02:40:25Z ian $
- * @copyright Copyright (C) 2005 - 2011 Open Source Matters. All rights reserved.
- * @license GNU General Public License version 2 or later; see LICENSE.txt
- */
-
-/**
- * @package Joomla.UnitTest
- * @subpackage Application.Component
- */
-class JControllerInspector extends JController
-{
- public function addPath($type, $path)
- {
- return parent::addPath($type, $path);
- }
-
- public function getPaths()
- {
- return $this->paths;
- }
-
- /**
- * Method for inspecting protected variables.
- *
- * @return mixed The value of the class variable.
- *
- * @since 11.1
- */
- public function __get($name)
- {
- if (property_exists($this, $name)) {
- return $this->$name;
- }
- else {
- trigger_error('Undefined or private property: ' . __CLASS__.'::'.$name, E_USER_ERROR);
- return;
- }
- }
-}
-
-class TestController extends JController
-{
- public function task1() {}
-
- public function task2() {}
-
- protected function task3() {}
-
- private function _task4() {}
-
-}
-
-class TestTestController extends TestController
-{
- public function task5() {}
-}
View
82 tests/suite/joomla/application/component/JControllerInspector.php
@@ -0,0 +1,82 @@
+<?php
+/**
+ * @version $Id: JControllerHelper.php 20196 2011-01-09 02:40:25Z ian $
+ * @copyright Copyright (C) 2005 - 2011 Open Source Matters. All rights reserved.
+ * @license GNU General Public License version 2 or later; see LICENSE.txt
+ */
+
+/**
+ * General inspector class for JController.
+ *
+ * @package Joomla.UnitTest
+ * @subpackage Application.Component
+ * @since 11.3
+ */
+class JControllerInspector extends JController
+{
+ public function getPaths()
+ {
+ return $this->paths;
+ }
+
+ /**
+ * Method for inspecting protected variables.
+ *
+ * @return mixed The value of the class variable.
+ */
+ public function __get($name)
+ {
+ if (property_exists($this, $name))
+ {
+ return $this->$name;
+ }
+ else
+ {
+ trigger_error('Undefined or private property: ' . __CLASS__ . '::' . $name, E_USER_ERROR);
+ return null;
+ }
+ }
+
+ /**
+ * Sets any property from the class.
+ *
+ * @param string $property The name of the class property.
+ * @param string $value The value of the class property.
+ *
+ * @return void
+ */
+ public function __set($property, $value)
+ {
+ $this->$property = $value;
+ }
+
+ /**
+ * Calls any inaccessible method from the class.
+ *
+ * @param string $name Name of the method to invoke
+ * @param array $parameters Parameters to be handed over to the original method
+ *
+ * @return mixed The return value of the method
+ */
+ public function __call($name, $parameters = false)
+ {
+ return call_user_func_array(array($this,$name), $parameters);
+ }
+}
+
+class TestController extends JController
+{
+ public function task1() {}
+
+ public function task2() {}
+
+ protected function task3() {}
+
+ private function _task4() {}
+
+}
+
+class TestTestController extends TestController
+{
+ public function task5() {}
+}
View
168 tests/suite/joomla/application/component/JControllerTest.php
@@ -1,12 +1,12 @@
<?php
/**
- * @version $Id: JControllerTest.php 20196 2011-01-09 02:40:25Z ian $
- * @copyright Copyright (C) 2005 - 2011 Open Source Matters. All rights reserved.
- * @license GNU General Public License version 2 or later; see LICENSE.txt
+ * @version $Id: JControllerTest.php 20196 2011-01-09 02:40:25Z ian $
+ * @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 JPATH_PLATFORM.'/joomla/application/component/controller.php';
-require_once JPATH_PLATFORM.'/joomla/environment/request.php';
+require_once JPATH_PLATFORM . '/joomla/application/component/controller.php';
+require_once JPATH_PLATFORM . '/joomla/environment/request.php';
/**
* Test class for JController.
@@ -20,11 +20,14 @@ class JControllerTest extends PHPUnit_Framework_TestCase
*/
protected function setUp()
{
- if (!defined('JPATH_COMPONENT')) {
- define('JPATH_COMPONENT', JPATH_BASE.'/components/com_foobar');
+ if (!defined('JPATH_COMPONENT'))
+ {
+ define('JPATH_COMPONENT', JPATH_BASE . '/components/com_foobar');
}
- include_once 'JControllerHelper.php';
+ include_once 'JControllerInspector.php';
+
+ $this->object = new JControllerInspector;
}
/**
@@ -50,7 +53,7 @@ public function test__construct()
'task5', 'task1', 'task2', 'display'
)
),
- 'Line:'.__LINE__.' The available tasks should be the public tasks in _all_ the derived classes after controller plus "display".'
+ 'Line:' . __LINE__ . ' The available tasks should be the public tasks in _all_ the derived classes after controller plus "display".'
);
}
@@ -62,18 +65,18 @@ public function test__construct()
public function testAddModelPath()
{
// Include JModel as this method is a proxy for JModel::addIncludePath
- require_once JPATH_PLATFORM.'/joomla/application/component/model.php';
+ require_once JPATH_PLATFORM . '/joomla/application/component/model.php';
- $path = JPATH_ROOT.'/addmodelpath';
+ $path = JPath::clean(JPATH_ROOT . '/addmodelpath');
JController::addModelPath($path);
// The default path is the class file folder/forms
- $valid = JPATH_PLATFORM.'/joomla/form/fields';
+ $valid = JPATH_PLATFORM . '/joomla/form/fields';
$this->assertThat(
in_array($path, JModel::addIncludePath()),
$this->isTrue(),
- 'Line:'.__LINE__.' The path should be added to the JModel paths.'
+ 'Line:' . __LINE__ . ' The path should be added to the JModel paths.'
);
}
@@ -89,26 +92,26 @@ public function testAddPath()
{
$controller = new JControllerInspector;
- $path = JPATH_ROOT.'//foobar';
+ $path = JPATH_ROOT . '//foobar';
$controller->addPath('test', $path);
$paths = $controller->getPaths();
$this->assertThat(
isset($paths['test']),
$this->isTrue(),
- 'Line:'.__LINE__.' The path type should be set.'
+ 'Line:' . __LINE__ . ' The path type should be set.'
);
$this->assertThat(
is_array($paths['test']),
$this->isTrue(),
- 'Line:'.__LINE__.' The path type should be an array.'
+ 'Line:' . __LINE__ . ' The path type should be an array.'
);
$this->assertThat(
- $paths['test'][0],
- $this->equalTo(JPATH_ROOT.DS.'foobar/'),
- 'Line:'.__LINE__.' The path type should be present, clean and with a trailing slash.'
+ str_replace(DIRECTORY_SEPARATOR, '/', $paths['test'][0]),
+ $this->equalTo(str_replace(DIRECTORY_SEPARATOR, '/', JPATH_ROOT . '/foobar/')),
+ 'Line:' . __LINE__ . ' The path type should be present, clean and with a trailing slash.'
);
}
@@ -119,26 +122,26 @@ public function testAddViewPath()
{
$controller = new JControllerInspector;
- $path = JPATH_ROOT.'/views';
+ $path = JPATH_ROOT . '/views';
$controller->addViewPath($path);
$paths = $controller->getPaths();
$this->assertThat(
isset($paths['view']),
$this->isTrue(),
- 'Line:'.__LINE__.' The path type should be set.'
+ 'Line:' . __LINE__ . ' The path type should be set.'
);
$this->assertThat(
is_array($paths['view']),
$this->isTrue(),
- 'Line:'.__LINE__.' The path type should be an array.'
+ 'Line:' . __LINE__ . ' The path type should be an array.'
);
$this->assertThat(
- $paths['view'][0],
- $this->equalTo(JPATH_ROOT.DS.'views/'),
- 'Line:'.__LINE__.' The path type should be present, clean and with a trailing slash.'
+ str_replace(DIRECTORY_SEPARATOR, '/', $paths['view'][0]),
+ $this->equalTo(str_replace(DIRECTORY_SEPARATOR, '/', JPATH_ROOT . '/views/')),
+ 'Line:' . __LINE__ . ' The path type should be present, clean and with a trailing slash.'
);
}
@@ -222,17 +225,39 @@ public function testGetModel()
*/
public function testGetName()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
+ $this->assertThat(
+ $this->object->getName(),
+ $this->equalTo('j')
+ );
+
+ $this->object->name = 'inspector';
+
+ $this->assertThat(
+ $this->object->getName(),
+ $this->equalTo('inspector')
+ );
}
/**
- * Test JController::getTask
+ * Test JController::getTask().
+ *
+ * @return void
+ *
+ * @since 11.3
*/
public function testGetTask()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
+ $this->assertThat(
+ $this->object->get('task'),
+ $this->equalTo(null)
+ );
+
+ $this->object->set('task', 'test');
+
+ $this->assertThat(
+ $this->object->get('task'),
+ $this->equalTo('test')
+ );
}
/**
@@ -249,7 +274,7 @@ public function testGetTasks()
'task1', 'task2', 'display'
)
),
- 'Line:'.__LINE__.' The available tasks should be the public tasks in the derived controller plus "display".'
+ 'Line:' . __LINE__ . ' The available tasks should be the public tasks in the derived controller plus "display".'
);
}
@@ -307,18 +332,22 @@ public function testSetMessage()
$controller->setMessage('Hello World');
$this->assertEquals($controller->message, 'Hello World',
- 'Line:'.__LINE__.' The message text does not equal with previuosly set one');
+ 'Line:' . __LINE__ . ' The message text does not equal with previuosly set one'
+ );
$this->assertEquals($controller->messageType, 'message',
- 'Line:'.__LINE__.' Default message type should be "message"');
+ 'Line:' . __LINE__ . ' Default message type should be "message"'
+ );
$controller->setMessage('Morning Universe', 'notice');
$this->assertEquals($controller->message, 'Morning Universe',
- 'Line:'.__LINE__.' The message text does not equal with previuosly set one');
+ 'Line:' . __LINE__ . ' The message text does not equal with previuosly set one'
+ );
$this->assertEquals($controller->messageType, 'notice',
- 'Line:'.__LINE__.' The message type does not equal with previuosly set one');
+ 'Line:' . __LINE__ . ' The message type does not equal with previuosly set one'
+ );
}
/**
@@ -343,18 +372,18 @@ public function testSetRedirect()
$this->assertEquals(
$controller->redirect,
'index.php?option=com_foobar',
- 'Line:'.__LINE__.' The redirect address does not equal with passed one'
+ 'Line:' . __LINE__ . ' The redirect address does not equal with passed one'
);
$this->assertNull(
$controller->message,
- 'Line:'.__LINE__.' The message is not set, so it should be null'
+ 'Line:' . __LINE__ . ' The message is not set, so it should be null'
);
$this->assertEquals(
$controller->messageType,
'message',
- 'Line:'.__LINE__.' Default message type should be "message"'
+ 'Line:' . __LINE__ . ' Default message type should be "message"'
);
// Set the URL and message
@@ -363,19 +392,19 @@ public function testSetRedirect()
$this->assertEquals(
$controller->redirect,
'index.php?option=com_foobar',
- 'Line:'.__LINE__.' The redirect address does not equal with passed one'
+ 'Line:' . __LINE__ . ' The redirect address does not equal with passed one'
);
$this->assertEquals(
$controller->message,
'Hello World',
- 'Line:'.__LINE__.' The message text does not equal with passed one'
+ 'Line:' . __LINE__ . ' The message text does not equal with passed one'
);
$this->assertEquals(
$controller->messageType,
'message',
- 'Line:'.__LINE__.' Default message type should be "message"'
+ 'Line:' . __LINE__ . ' Default message type should be "message"'
);
// URL, message and message type
@@ -384,18 +413,19 @@ public function testSetRedirect()
$this->assertEquals(
$controller->redirect,
'index.php?option=com_foobar',
- 'Line:'.__LINE__.' The redirect address does not equal with passed one'
+ 'Line:' . __LINE__ . ' The redirect address does not equal with passed one'
);
$this->assertEquals(
$controller->message,
'Morning Universe',
- 'Line:'.__LINE__.' The message text does not equal with passed one');
+ 'Line:' . __LINE__ . ' The message text does not equal with passed one'
+ );
$this->assertEquals(
$controller->messageType,
'notice',
- 'Line:'.__LINE__.' The message type does not equal with passed one'
+ 'Line:' . __LINE__ . ' The message type does not equal with passed one'
);
// With previously set message
@@ -406,19 +436,19 @@ public function testSetRedirect()
$this->assertEquals(
$controller->redirect,
'index.php?option=com_foobar',
- 'Line:'.__LINE__.' The redirect address does not equal with passed one'
+ 'Line:' . __LINE__ . ' The redirect address does not equal with passed one'
);
$this->assertEquals(
$controller->message,
'Hi all',
- 'Line:'.__LINE__.' The message text does not equal with previously set one'
+ 'Line:' . __LINE__ . ' The message text does not equal with previously set one'
);
$this->assertEquals(
$controller->messageType,
'message',
- 'Line:'.__LINE__.' Default message type should be "message"'
+ 'Line:' . __LINE__ . ' Default message type should be "message"'
);
// URL and message
@@ -428,19 +458,19 @@ public function testSetRedirect()
$this->assertEquals(
$controller->redirect,
'index.php?option=com_foobar',
- 'Line:'.__LINE__.' The redirect address does not equal with passed one'
+ 'Line:' . __LINE__ . ' The redirect address does not equal with passed one'
);
$this->assertEquals(
$controller->message,
'Bye all',
- 'Line:'.__LINE__.' The message text should be overridden'
+ 'Line:' . __LINE__ . ' The message text should be overridden'
);
$this->assertEquals(
$controller->messageType,
'message',
- 'Line:'.__LINE__.' Default message type should be "message"'
+ 'Line:' . __LINE__ . ' Default message type should be "message"'
);
// URL, message and message type
@@ -450,19 +480,19 @@ public function testSetRedirect()
$this->assertEquals(
$controller->redirect,
'index.php?option=com_foobar',
- 'Line:'.__LINE__.' The redirect address does not equal with passed one'
+ 'Line:' . __LINE__ . ' The redirect address does not equal with passed one'
);
$this->assertEquals(
$controller->message,
'Bye all',
- 'Line:'.__LINE__.' The message text should be overridden'
+ 'Line:' . __LINE__ . ' The message text should be overridden'
);
$this->assertEquals(
$controller->messageType,
'notice',
- 'Line:'.__LINE__.' The message type should be overridden'
+ 'Line:' . __LINE__ . ' The message type should be overridden'
);
// URL and message type
@@ -472,19 +502,19 @@ public function testSetRedirect()
$this->assertEquals(
$controller->redirect,
'index.php?option=com_foobar',
- 'Line:'.__LINE__.' The redirect address does not equal with passed one'
+ 'Line:' . __LINE__ . ' The redirect address does not equal with passed one'
);
$this->assertEquals(
$controller->message,
'Hi all',
- 'Line:'.__LINE__.' The message text should not be overridden'
+ 'Line:' . __LINE__ . ' The message text should not be overridden'
);
$this->assertEquals(
$controller->messageType,
'notice',
- 'Line:'.__LINE__.' The message type should be overridden'
+ 'Line:' . __LINE__ . ' The message type should be overridden'
);
// With previously set message and message type
@@ -495,19 +525,19 @@ public function testSetRedirect()
$this->assertEquals(
$controller->redirect,
'index.php?option=com_foobar',
- 'Line:'.__LINE__.' The redirect address does not equal with passed one'
+ 'Line:' . __LINE__ . ' The redirect address does not equal with passed one'
);
$this->assertEquals(
$controller->message,
'Hello folks',
- 'Line:'.__LINE__.' The message text does not equal with previously set one'
+ 'Line:' . __LINE__ . ' The message text does not equal with previously set one'
);
$this->assertEquals(
$controller->messageType,
'notice',
- 'Line:'.__LINE__.' The message type does not equal with previously set one'
+ 'Line:' . __LINE__ . ' The message type does not equal with previously set one'
);
// URL and message
@@ -517,19 +547,19 @@ public function testSetRedirect()
$this->assertEquals(
$controller->redirect,
'index.php?option=com_foobar',
- 'Line:'.__LINE__.' The redirect address does not equal with passed one'
+ 'Line:' . __LINE__ . ' The redirect address does not equal with passed one'
);
$this->assertEquals(
$controller->message,
'Bye, Folks',
- 'Line:'.__LINE__.' The message text should be overridden'
+ 'Line:' . __LINE__ . ' The message text should be overridden'
);
$this->assertEquals(
$controller->messageType,
'notice',
- 'Line:'.__LINE__.' The message type does not equal with previously set one'
+ 'Line:' . __LINE__ . ' The message type does not equal with previously set one'
);
// URL, message and message type
@@ -539,19 +569,19 @@ public function testSetRedirect()
$this->assertEquals(
$controller->redirect,
'index.php?option=com_foobar',
- 'Line:'.__LINE__.' The redirect address does not equal with passed one'
+ 'Line:' . __LINE__ . ' The redirect address does not equal with passed one'
);
$this->assertEquals(
$controller->message,
'Bye, folks',
- 'Line:'.__LINE__.' The message text should be overridden'
+ 'Line:' . __LINE__ . ' The message text should be overridden'
);
$this->assertEquals(
$controller->messageType,
'notice',
- 'Line:'.__LINE__.' The message type should be overridden'
+ 'Line:' . __LINE__ . ' The message type should be overridden'
);
// URL and message type
@@ -561,19 +591,19 @@ public function testSetRedirect()
$this->assertEquals(
$controller->redirect,
'index.php?option=com_foobar',
- 'Line:'.__LINE__.' The redirect address does not equal with passed one'
+ 'Line:' . __LINE__ . ' The redirect address does not equal with passed one'
);
$this->assertEquals(
$controller->message,
'Folks?',
- 'Line:'.__LINE__.' The message text should not be overridden'
+ 'Line:' . __LINE__ . ' The message text should not be overridden'
);
$this->assertEquals(
$controller->messageType,
'question',
- 'Line:'.__LINE__.' The message type should be overridden'
+ 'Line:' . __LINE__ . ' The message type should be overridden'
);
}
-}
Please sign in to comment.
Something went wrong with that request. Please try again.