Permalink
Browse files

Fixing unit tests after re-organization.

  • Loading branch information...
1 parent 2c7f109 commit 65ceccc773aaff82846e45f773276769bb3c0b02 @LouisLandry LouisLandry committed Apr 3, 2012
Showing with 48 additions and 152 deletions.
  1. +2 −1 build.xml
  2. +12 −2 libraries/joomla/access/access.php
  3. +1 −13 libraries/joomla/database/driver/mysqli.php
  4. +1 −13 libraries/joomla/database/driver/sqlsrv.php
  5. +1 −1 libraries/joomla/filesystem/folder.php
  6. +1 −1 libraries/joomla/form/form.php
  7. +1 −2 libraries/joomla/log/log.php
  8. +1 −1 libraries/joomla/object/object.php
  9. +2 −2 libraries/joomla/registry/format.php
  10. +10 −1 libraries/joomla/session/session.php
  11. +1 −1 libraries/joomla/session/storage.php
  12. +0 −3 libraries/joomla/utilities/date.php
  13. 0 libraries/{joomla/form/fields → legacy/form/field}/category.php
  14. +1 −1 libraries/{joomla/form/fields → legacy/form/field}/componentlayout.php
  15. 0 libraries/{joomla/form/fields → legacy/form/field}/menu.php
  16. +1 −1 libraries/{joomla/form/fields → legacy/form/field}/modulelayout.php
  17. +0 −26 tests/core/case/database.php
  18. +0 −2 tests/suites/legacy/component/JComponentHelperTest.php
  19. +0 −2 tests/suites/legacy/controller/JControllerAdminTest.php
  20. +0 −1 tests/suites/legacy/controller/JControllerFormTest.php
  21. +0 −4 tests/suites/legacy/controller/JControllerTest.php
  22. +3 −14 tests/suites/{unit/joomla/form/fields → legacy/form/field}/JFormFieldCategoryTest.php
  23. +3 −14 tests/suites/{unit/joomla/form/fields → legacy/form/field}/JFormFieldComponentLayoutTest.php
  24. +3 −14 tests/suites/{unit/joomla/form/fields → legacy/form/field}/JFormFieldModuleLayoutTest.php
  25. +0 −2 tests/suites/legacy/model/JModelAdminTest.php
  26. +0 −2 tests/suites/legacy/model/JModelFormTest.php
  27. +0 −2 tests/suites/legacy/model/JModelItemTest.php
  28. +0 −2 tests/suites/legacy/model/JModelListTest.php
  29. +0 −2 tests/suites/legacy/model/JModelTest.php
  30. +0 −2 tests/suites/legacy/module/JModuleHelperTest.php
  31. +0 −1 tests/suites/legacy/view/JViewTest.php
  32. +2 −19 tests/suites/unit/joomla/document/opensearch/JDocumentOpensearchTest.php
  33. +2 −0 tests/suites/unit/joomla/html/html/JHtmlFormTest.php
View
3 build.xml
@@ -24,7 +24,8 @@
<target name="phpunit-legacy" description="Run legacy tests using PHPUnit and generates junit.legacy.xml and clover.legacy.xml">
<exec executable="phpunit">
- <arg value="-c legacy.xml.dist" />
+ <arg value="-c" />
+ <arg value="legacy.xml.dist" />
</exec>
</target>
View
14 libraries/joomla/access/access.php
@@ -282,10 +282,20 @@ public static function getGroupsByUser($userId, $recursive = true)
if (!isset(self::$groupsByUser[$storeId]))
{
+ // TODO: Uncouple this from JComponentHelper and allow for a configuration setting or value injection.
+ if (class_exists('JComponentHelper'))
+ {
+ $guestUsergroup = JComponentHelper::getParams('com_users')->get('guest_usergroup', 1);
+ }
+ else
+ {
+ $guestUsergroup = 1;
+ }
+
// Guest user (if only the actually assigned group is requested)
if (empty($userId) && !$recursive)
{
- $result = array(JComponentHelper::getParams('com_users')->get('guest_usergroup', 1));
+ $result = array($guestUsergroup);
}
// Registered user and guest if all groups are requested
else
@@ -298,7 +308,7 @@ public static function getGroupsByUser($userId, $recursive = true)
if (empty($userId))
{
$query->from('#__usergroups AS a');
- $query->where('a.id = ' . (int) JComponentHelper::getParams('com_users')->get('guest_usergroup', 1));
+ $query->where('a.id = ' . (int) $guestUsergroup);
}
else
{
View
14 libraries/joomla/database/driver/mysqli.php
@@ -94,19 +94,7 @@ public function connect()
// Make sure the MySQLi extension for PHP is installed and enabled.
if (!function_exists('mysqli_connect'))
{
-
- // Legacy error handling switch based on the JError::$legacy switch.
- // @deprecated 12.1
- if (JError::$legacy)
- {
- $this->errorNum = 1;
- $this->errorMsg = JText::_('JLIB_DATABASE_ERROR_ADAPTER_MYSQLI');
- return;
- }
- else
- {
- throw new RuntimeException('The MySQL adapter mysqli is not available');
- }
+ throw new RuntimeException('The MySQL adapter mysqli is not available');
}
$this->connection = @mysqli_connect(
View
14 libraries/joomla/database/driver/sqlsrv.php
@@ -739,19 +739,7 @@ public function select($database)
if (!sqlsrv_query($this->connection, 'USE ' . $database, null, array('scrollable' => SQLSRV_CURSOR_STATIC)))
{
-
- // Legacy error handling switch based on the JError::$legacy switch.
- // @deprecated 12.1
- if (JError::$legacy)
- {
- $this->errorNum = 3;
- $this->errorMsg = JText::_('JLIB_DATABASE_ERROR_DATABASE_CONNECT');
- return false;
- }
- else
- {
- throw new RuntimeException('Could not connect to database');
- }
+ throw new RuntimeException('Could not connect to database');
}
return true;
View
2 libraries/joomla/filesystem/folder.php
@@ -29,7 +29,7 @@
* @param string $force Force copy.
* @param boolean $use_streams Optionally force folder/file overwrites.
*
- * @return mixed JError object on failure or boolean True on success.
+ * @return boolean True on success.
*
* @since 11.1
* @throws RuntimeException
View
2 libraries/joomla/form/form.php
@@ -249,7 +249,7 @@ public function filter($data, $group = null)
/**
* Return all errors, if any.
*
- * @return array Array of error messages or JException objects.
+ * @return array Array of error messages or RuntimeException objects.
*
* @since 11.1
*/
View
3 libraries/joomla/log/log.php
@@ -172,8 +172,7 @@ public static function add($entry, $priority = self::INFO, $category = '', $date
}
/**
- * Method to set the way the JError will handle different error levels.
- * Use this if you want to override the default settings.
+ * Add a logger to the JLog instance. Loggers route log entries to the correct files/systems to be logged.
*
* @param array $options The object configuration array.
* @param integer $priorities Message priority
View
2 libraries/joomla/object/object.php
@@ -22,7 +22,7 @@
class JObject
{
/**
- * An array of error messages or JExceptions objects.
+ * An array of error messages or Exception objects.
*
* @var array
* @since 11.1
View
4 libraries/joomla/registry/format.php
@@ -33,7 +33,7 @@
* @return JRegistryFormat Registry format handler
*
* @since 11.1
- * @throws JException
+ * @throws InvalidArgumentException
*/
public static function getInstance($type)
{
@@ -54,7 +54,7 @@ public static function getInstance($type)
}
else
{
- throw new JException(JText::_('JLIB_REGISTRY_EXCEPTION_LOAD_FORMAT_CLASS'), 500, E_ERROR);
+ throw new InvalidArgumentException('Unable to load format class.', 500);
}
}
View
11 libraries/joomla/session/session.php
@@ -248,7 +248,16 @@ public static function getFormToken($forceNew = false)
{
$user = JFactory::getUser();
$session = JFactory::getSession();
- $hash = JApplication::getHash($user->get('id', 0) . $session->getToken($forceNew));
+
+ // TODO: Decouple from legacy JApplication class.
+ if (is_callable(array('JApplication', 'getHash')))
+ {
+ $hash = JApplication::getHash($user->get('id', 0) . $session->getToken($forceNew));
+ }
+ else
+ {
+ $hash = md5(JFactory::getApplication()->get('secret') . $user->get('id', 0) . $session->getToken($forceNew));
+ }
return $hash;
}
View
2 libraries/joomla/session/storage.php
@@ -65,7 +65,7 @@ public static function getInstance($name = 'none', $options = array())
}
else
{
- // No call to JError::raiseError here, as it tries to close the non-existing session
+ // No attempt to die gracefully here, as it tries to close the non-existing session
jexit('Unable to load session storage class: ' . $name);
}
}
View
3 libraries/joomla/utilities/date.php
@@ -77,8 +77,6 @@ class JDate extends DateTime
* @param mixed $tz Time zone to be used for the date. Might be a string or a DateTimeZone object.
*
* @since 11.1
- *
- * @throws JException
*/
public function __construct($date = 'now', $tz = null)
{
@@ -212,7 +210,6 @@ public function __toString()
* @return JDate
*
* @since 11.3
- * @throws JException
*/
public static function getInstance($date = 'now', $tz = null)
{
View
0 libraries/joomla/form/fields/category.php → libraries/legacy/form/field/category.php
File renamed without changes.
View
2 ...es/joomla/form/fields/componentlayout.php → ...ies/legacy/form/field/componentlayout.php
@@ -20,7 +20,7 @@
* @subpackage Form
* @since 11.1
*/
-class JFormFieldComponentLayout extends JFormField
+class JFormFieldComponentlayout extends JFormField
{
/**
* The form field type.
View
0 libraries/joomla/form/fields/menu.php → libraries/legacy/form/field/menu.php
File renamed without changes.
View
2 ...aries/joomla/form/fields/modulelayout.php → libraries/legacy/form/field/modulelayout.php
@@ -19,7 +19,7 @@
* @subpackage Form
* @since 11.1
*/
-class JFormFieldModuleLayout extends JFormField
+class JFormFieldModulelayout extends JFormField
{
/**
* The form field type.
View
26 tests/core/case/database.php
@@ -488,30 +488,4 @@ protected function setUp()
parent::setUp();
}
-
- /**
- * Overrides the parent tearDown method.
- *
- * @return void
- *
- * @see PHPUnit_Framework_TestCase::tearDown()
- * @since 11.1
- */
- protected function tearDown()
- {
- if (is_array($this->expectedErrors) && !empty($this->expectedErrors))
- {
- $this->fail('An expected error was not raised.');
- }
-
- // Handle optional usage of JError until removed.
- if (class_exists('JError'))
- {
- JError::setErrorHandling(E_NOTICE, 'ignore');
- JError::setErrorHandling(E_WARNING, 'ignore');
- JError::setErrorHandling(E_ERROR, 'ignore');
- }
-
- parent::tearDown();
- }
}
View
2 tests/suites/legacy/component/JComponentHelperTest.php
@@ -5,8 +5,6 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
-require_once JPATH_PLATFORM . '/joomla/application/component/helper.php';
-
/**
* Test class for JComponentHelper.
*/
View
2 tests/suites/legacy/controller/JControllerAdminTest.php
@@ -7,8 +7,6 @@
* @license GNU General Public License version 2 or later; see LICENSE
*/
-include_once JPATH_PLATFORM . '/joomla/application/component/controlleradmin.php';
-
/**
* Test class for JControllerAdmin.
* Generated by PHPUnit on 2011-10-26 at 19:37:59.
View
1 tests/suites/legacy/controller/JControllerFormTest.php
@@ -5,7 +5,6 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
-require_once JPATH_PLATFORM . '/joomla/application/component/controllerform.php';
require_once __DIR__ . '/stubs/controllerform.php';
/**
View
4 tests/suites/legacy/controller/JControllerTest.php
@@ -5,7 +5,6 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
-require_once JPATH_PLATFORM . '/joomla/application/component/controller.php';
require_once __DIR__ . '/stubs/controller.php';
/**
@@ -43,9 +42,6 @@ protected function setUp()
*/
public function testAddModelPath()
{
- // Include JModel as this method is a proxy for JModel::addIncludePath
- require_once JPATH_PLATFORM . '/joomla/application/component/model.php';
-
$path = JPath::clean(JPATH_ROOT . '/addmodelpath');
JController::addModelPath($path);
View
17 ...la/form/fields/JFormFieldCategoryTest.php → ...acy/form/field/JFormFieldCategoryTest.php
@@ -7,6 +7,8 @@
* @license GNU General Public License version 2 or later; see LICENSE
*/
+require_once JPATH_TESTS . '/suites/unit/joomla/form/inspectors.php';
+
/**
* Test class for JFormFieldCategory.
*
@@ -17,19 +19,6 @@
class JFormFieldCategoryTest extends TestCaseDatabase
{
/**
- * Sets up dependencies for the test.
- *
- * @return void
- *
- * @since 11.1
- */
- protected function setUp()
- {
- require_once JPATH_PLATFORM . '/joomla/form/fields/category.php';
- include_once dirname(__DIR__) . '/inspectors.php';
- }
-
- /**
* Gets the data set to be loaded into the database during setup
*
* @return xml dataset
@@ -38,7 +27,7 @@ protected function setUp()
*/
protected function getDataSet()
{
- return $this->createXMLDataSet(__DIR__ . '/testfiles/JFormField.xml');
+ return $this->createXMLDataSet(JPATH_TESTS . '/suites/unit/joomla/form/fields/testfiles/JFormField.xml');
}
/**
View
17 .../fields/JFormFieldComponentLayoutTest.php → ...m/field/JFormFieldComponentLayoutTest.php
@@ -7,6 +7,8 @@
* @license GNU General Public License version 2 or later; see LICENSE
*/
+require_once JPATH_TESTS . '/suites/unit/joomla/form/inspectors.php';
+
/**
* Test class for JFormFieldComponentLayout.
*
@@ -17,19 +19,6 @@
class JFormFieldComponentLayoutTest extends TestCase
{
/**
- * Sets up dependencies for the test.
- *
- * @return void
- *
- * @since 11.1
- */
- protected function setUp()
- {
- require_once JPATH_PLATFORM . '/joomla/form/fields/componentlayout.php';
- include_once dirname(__DIR__) . '/inspectors.php';
- }
-
- /**
* Test the getInput method.
*
* @return void
@@ -46,7 +35,7 @@ public function testGetInput()
'Line:'.__LINE__.' XML string should load successfully.'
);
- $field = new JFormFieldComponentLayout($form);
+ $field = new JFormFieldComponentlayout($form);
$this->assertThat(
$field->setup($form->getXml()->field, 'value'),
View
17 ...orm/fields/JFormFieldModuleLayoutTest.php → ...form/field/JFormFieldModuleLayoutTest.php
@@ -7,6 +7,8 @@
* @license GNU General Public License version 2 or later; see LICENSE
*/
+require_once JPATH_TESTS . '/suites/unit/joomla/form/inspectors.php';
+
/**
* Test class for JFormFieldModuleLayout.
*
@@ -16,19 +18,6 @@
class JFormFieldModuleLayoutTest extends TestCase
{
/**
- * Sets up dependencies for the test.
- *
- * @return void
- *
- * @since 11.1
- */
- protected function setUp()
- {
- require_once JPATH_PLATFORM . '/joomla/form/fields/modulelayout.php';
- include_once dirname(__DIR__) . '/inspectors.php';
- }
-
- /**
* Test the getInput method.
*
* @return void
@@ -45,7 +34,7 @@ public function testGetInput()
'Line:'.__LINE__.' XML string should load successfully.'
);
- $field = new JFormFieldModuleLayout($form);
+ $field = new JFormFieldModulelayout($form);
$this->assertThat(
$field->setup($form->getXml()->field, 'value'),
View
2 tests/suites/legacy/model/JModelAdminTest.php
@@ -5,8 +5,6 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
-require_once JPATH_PLATFORM . '/joomla/application/component/modeladmin.php';
-
/**
* Test class for JModelList.
*/
View
2 tests/suites/legacy/model/JModelFormTest.php
@@ -5,8 +5,6 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
-require_once JPATH_PLATFORM . '/joomla/application/component/modelform.php';
-
/**
* Test class for JModelForm.
*/
View
2 tests/suites/legacy/model/JModelItemTest.php
@@ -5,8 +5,6 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
-require_once JPATH_PLATFORM . '/joomla/application/component/modelitem.php';
-
/**
* Test class for JModelItem.
*/
View
2 tests/suites/legacy/model/JModelListTest.php
@@ -5,8 +5,6 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
-require_once JPATH_PLATFORM . '/joomla/application/component/modellist.php';
-
/**
* Test class for JModelList.
*/
View
2 tests/suites/legacy/model/JModelTest.php
@@ -5,8 +5,6 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
-require_once JPATH_PLATFORM . '/joomla/application/component/model.php';
-
/**
* Test class for JModel.
*/
View
2 tests/suites/legacy/module/JModuleHelperTest.php
@@ -7,8 +7,6 @@
* @license GNU General Public License version 2 or later; see LICENSE
*/
-require_once JPATH_PLATFORM . '/joomla/application/module/helper.php';
-
/**
* Test class for JModuleHelper.
* Generated by PHPUnit on 2009-10-08 at 21:24:07.
View
1 tests/suites/legacy/view/JViewTest.php
@@ -5,7 +5,6 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
-require_once JPATH_PLATFORM . '/joomla/application/component/view.php';
require_once JPATH_PLATFORM . '/joomla/environment/uri.php';
/**
View
21 tests/suites/unit/joomla/document/opensearch/JDocumentOpensearchTest.php
@@ -33,25 +33,8 @@ protected function setUp()
$_SERVER['HTTP_HOST'] = 'localhost';
$_SERVER['SCRIPT_NAME'] = '';
- JFactory::$application = $this->getMock(
- 'JApplication',
- array(
- 'get',
- 'getCfg',
- 'getRouter',
- 'getTemplate',
- ),
- array(
- array(
- 'session' => false
- )
- )
- );
-
- JFactory::$config = $this->getMock(
- 'JConfig',
- array('get')
- );
+ JFactory::$application = $this->getMockApplication();
+ JFactory::$config = $this->getMockConfig();
$this->object = new JDocumentOpensearch;
}
View
2 tests/suites/unit/joomla/html/html/JHtmlFormTest.php
@@ -58,6 +58,8 @@ protected function tearDown()
*/
public function testToken()
{
+ JFactory::$application = $this->getMockWeb();
+
$token = JSession::getFormToken();
$this->assertThat(

0 comments on commit 65ceccc

Please sign in to comment.