Skip to content
This repository has been archived by the owner on Nov 26, 2017. It is now read-only.

JHtmlBatch tweak and unit tests #242

Merged
merged 11 commits into from Aug 23, 2011
7 changes: 3 additions & 4 deletions libraries/joomla/html/html/batch.php
Expand Up @@ -48,13 +48,12 @@ public static function access()
* Displays a batch widget for moving or copying items.
*
* @param string $extension The extension that owns the category.
* @param string $published The published state of categories to be shown in the list.
*
* @return string The necessary HTML for the widget.
*
* @since 11.1
*/
public static function item($extension, $published)
public static function item($extension)
{
// Create the copy/move options.
$options = array(JHtml::_('select.option', 'c', JText::_('JLIB_HTML_BATCH_COPY')),
Expand All @@ -64,8 +63,8 @@ public static function item($extension, $published)
$lines = array('<label id="batch-choose-action-lbl" for="batch-choose-action">', JText::_('JLIB_HTML_BATCH_MENU_LABEL'), '</label>',
'<fieldset id="batch-choose-action" class="combo">', '<select name="batch[category_id]" class="inputbox" id="batch-category-id">',
'<option value="">' . JText::_('JSELECT') . '</option>',
JHtml::_('select.options', JHtml::_('category.options', $extension, array('published' => (int) $published))), '</select>',
JHTML::_('select.radiolist', $options, 'batch[move_copy]', '', 'value', 'text', 'm'), '</fieldset>');
JHtml::_('select.options', JHtml::_('category.options', $extension)), '</select>',
JHtml::_('select.radiolist', $options, 'batch[move_copy]', '', 'value', 'text', 'm'), '</fieldset>');

return implode("\n", $lines);
}
Expand Down
27 changes: 27 additions & 0 deletions tests/suite/joomla/access/JAccessTest.xml
Expand Up @@ -323,6 +323,33 @@
<value>0</value>
<value></value>
</row>
<row>
<value>2</value>
<value>0</value>
<value>1</value>
<value>0</value>
<value>0</value>
<value>1</value>
<value></value>
<value>com_content</value>
<value>Uncategorised</value>
<value>uncategorised-content</value>
<value></value>
<value>1</value>
<value>0</value>
<value>0000-00-00 00:00:00</value>
<value>1</value>
<value>{}</value>
<value></value>
<value></value>
<value></value>
<value>0</value>
<value>2009-10-18 16:07:09</value>
<value>0</value>
<value>0000-00-00 00:00:00</value>
<value>0</value>
<value></value>
</row>
</table>
<table name="jos_content">
<column>id</column>
Expand Down
69 changes: 69 additions & 0 deletions tests/suite/joomla/html/html/JHtmlBatchTest.php
@@ -0,0 +1,69 @@
<?php
/**
* @package Joomla.UnitTest
* @subpackage HTML
*
* @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/

require_once JPATH_PLATFORM.'/joomla/html/html/batch.php';

/**
* Test class for JHtmlBatch.
*
* @since 11.3
*/
class JHtmlBatchTest extends JoomlaDatabaseTestCase
{
/**
* @var JHtmlBatch
* @since 11.3
*/
protected $object;

/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
parent::setUp();
}

/**
* Gets the data set to be loaded into the database during setup
*
* @return xml dataset
*
* @since 11.3
*/
protected function getDataSet()
{
return $this->createXMLDataSet(dirname(__FILE__).'/testfiles/JHtmlBatchTest.xml');
}

/**
* Tests the JHtmlBatch::access method.
*/
public function testAccess()
{
$this->assertThat(
JHtmlBatch::access(),
$this->StringContains('<option value="1">Public</option>')
);
}

/**
* Tests the JHtmlBatch::item method.
*
* @param string $extension
*/
public function testItem()
{
$this->assertThat(
JHtmlBatch::item('com_content'),
$this->StringContains('<option value="2">Uncategorised</option>')
);
}
}