User Rating: 5 / 5

    Star ActiveStar ActiveStar ActiveStar ActiveStar Active

    If you are developing Joomla 3.x components you should familiar with this code:

    JHtmlSidebar::addFilter(
    	JText::_('JOPTION_SELECT_PUBLISHED'),
    	'filter_published',
    	JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), "value", "text", $this->state->get('filter.state'), true)
    );

    This code will create a drop down list to filter the items based on their state. This JHtmlJGrid is defined on /joomlapath/libraries/cms/html/jgrid.php and you can see the available options on jgrid.publishedOptions function. Here are the complete list:

    $options[] = JHtml::_('select.option', '1', 'JPUBLISHED');
    $options[] = JHtml::_('select.option', '0', 'JUNPUBLISHED');
    $options[] = JHtml::_('select.option', '2', 'JARCHIVED');
    $options[] = JHtml::_('select.option', '-2', 'JTRASHED');
    $options[] = JHtml::_('select.option', '*', 'JALL'); 

    So if you want to show only some options on the filter drop down list you can use the following code: 

    //show Trash and All option only
    $options        = array();        
    $options[]      = JHtml::_('select.option', '-2', 'JTRASHED');
    $options[]      = JHtml::_('select.option', '*', 'JALL');
    JHtmlSidebar::addFilter(
    	JText::_('JOPTION_SELECT_PUBLISHED'),
    	'filter_published',
    	JHtml::_('select.options', $options, "value", "text", $this->state->get('filter.state'), true)
    );

     

    User Rating: 2 / 5

    Star ActiveStar ActiveStar InactiveStar InactiveStar Inactive

    In the last tutorial we have created a unit test for the back end or administrator part of Joomla component and in this tutorial we will create a unit test for the front end or public part of Joomla component. In this tutorial we will use Joomla 3.2.x and Joomla article component (com_content) for experiment. So let's start

    1. Create a Test folder

    Create a new folder called Tests on /joomlapath/components/com_content folder. This folder will contain all test files for com_content component.

    2. Create phpunit configuration file

    Create a new file called phpunit.xml in Tests folder. We will use the following configurations for this experiment: 

    <phpunit bootstrap="bootstrap.php"
        colors="true"
        convertErrorsToExceptions="true"
        convertNoticesToExceptions="true"
        convertWarningsToExceptions="true"
        processIsolation="false"
        stopOnFailure="false"
        syntaxCheck="false"
        verbose="true">
    </phpunit>
    

    Please publish modules in offcanvas position.