<?php
/**
 * @copyright	Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.
 * @license	GNU General Public License version 2 or later; see LICENSE.txt
 * @package	JoomlaFramework
 */

/**
 * @package	JoomlaFramework - Support: joomlateam@complusoft.es
 */
require_once 'PHPUnit/Framework.php';

require_once JPATH_BASE . '/libraries/joomla/language/helper.php';
require_once JPATH_BASE . '/libraries/joomla/language/language.php';

/**
 * Test class for JLanguageHelper.
 * Generated by PHPUnit on 2009-10-27 at 15:18:36.
 */
class JLanguageHelperTest extends PHPUnit_Framework_TestCase
{
	/**
	 * @var JLanguageHelper
	 */
	protected $object;

	/**
	 * Sets up the fixture, for example, opens a network connection.
	 * This method is called before a test is executed.
	 */
	protected function setUp()
	{
		$this->object = new JLanguageHelper;
	}

	/**
	 * Tears down the fixture, for example, closes a network connection.
	 * This method is called after a test is executed.
	 */
	protected function tearDown()
	{
	}

    /**
     * @todo Implement testCreateLanguageList().
     */
    public function testCreateLanguageList()
    {
        // This method creates a list consisting of the name and value of language
        $actualLanguage = 'en-GB';
        $basePath = '../../administrator/';
        $caching = false;

        $option1 = array(
            'text' => 'English (United Kingdom)',
            'value' => 'en-GB',
            'selected' => 'selected="selected"'
        );
        $option2 = array(
            'text' => 'XXTestLang',
            'value' => 'xx-XX'
        );
        $listCompareEqual1 = array(
            0 => $option1,
            1 => $option2
        );

        $help = new JLanguageHelper('');
        $list = $help->createLanguageList($actualLanguage,$basePath,$caching);
        $this->assertThat(
           $listCompareEqual1,
           $this->equalTo($list)
        );

        $this->assertNotEquals(
                $listCompareEqual1[1]['text'],
                $list[0]['text']
        );
    }

    /**
     * @todo Implement testDetectLanguage()..
     */
    public function testDetectLanguage()
    {
        // This method returns the language that is active or which is by default
        $langCompareEqual = 'en-GB';
        $langCompareNotEqual = 'es-ES';
        $help = new JLanguageHelper();
        $lang = $help->detectLanguage(); // in this case, returns default language
		// Todo impossible to verify this test in console test  because joomla cannot detect browser language
/*        $this->assertEquals(
                $langCompareEqual,
                $lang
        );*/
        $this->assertNotEquals(
                $langCompareNotEqual,
                $lang
        );
    }
}
