<?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
 */

require_once 'PHPUnit/Framework.php';
require_once JPATH_BASE.'/libraries/joomla/language/language.php';
require_once JPATH_BASE.'/libraries/joomla/utilities/string.php';

/**
 * Test class for JLanguage.
 * Generated by PHPUnit on 2009-10-27 at 15:18:20.
 */
class JLanguageTest extends PHPUnit_Framework_TestCase
{
	/**
	 * @var JLanguage
	 */
	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 JLanguage;

		include_once 'inspectors.php';
	}

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

	/**
	 * Test the JLanguage::parse method
	 */
	public function testParse()
	{
		$lang = new JLanguageInspector('', true);

		$strings = $lang->parse(dirname(__FILE__).'/_ini/bad.ini');

		$errors = $lang->getProperty('errorfiles');
		$this->assertThat(
			count($errors),
			$this->equalTo(1),
			'Line: '.__LINE__.' bad ini file should have one error.'
		);

		// Slice the error string.
		$parts = explode('line(s)', array_pop($errors));

		$this->assertThat(
			trim($parts[1]),
			$this->equalTo('4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15'),
			'Line: '.__LINE__.' bad ini file should have several lines marked.'
		);
	}

    /**
     * @todo Implement testGetInstance().
     */
    public function testGetInstance()
    {
		// This method returns the language in use
		// English is the default language
		$langEqual		= 'en-GB';
		$langNotEqual	= 'es-ES';

		$lang = new JLanguage('');

		$listEqual = $lang->getInstance($langEqual);
		$this->assertObjectHasAttribute(
			'metadata', $listEqual
		);

		$this->assertObjectNotHasAttribute(
			'name', $listEqual
		);

		$this->assertTrue(
			$listEqual->exists($langEqual)
		);

		$this->assertFalse(
			$listEqual->exists($langNotEqual)
		);

		$listNotEqual = $lang->getInstance($langNotEqual);
		$this->assertObjectHasAttribute(
			'metadata', $listNotEqual
		);

		$this->assertObjectNotHasAttribute(
			'name', $listNotEqual
		);

		$this->assertTrue(
			$listNotEqual->exists($langEqual)
		);
    }

    /**
     * @todo Implement testGetTransliterator().
     */
    public function testGetTransliterator()
    {
		$lang = new JLanguage('');

		// The first time you run the method returns NULL
		// Only if there is an setTransliterator, this test is wrong
		$this->assertNull(
			$lang->getTransliterator()
		);
    }

    /**
     * @todo Implement testSetTransliterator().
     */
    public function testSetTransliterator()
    {
		$function1	= 'phpinfo';
		$function2	= 'print';
		$lang		= new JLanguage('');

		// The first time, set y get returns NULL
		$this->assertNull(
			$lang->getTransliterator()
		);

		// set -> $funtion1: set returns NULL and get returns $function1
		$this->assertNull(
			$lang->setTransliterator($function1)
		);

		$get = $lang->getTransliterator();
		$this->assertEquals(
			$function1,
			$get,
			'Line: '.__LINE__
		);

		$this->assertNotEquals(
			$function2,
			$get,
			'Line: '.__LINE__
		);

		// set -> $function2: set returns $function1 and get retuns $function2
		$set = $lang->setTransliterator($function2);
		$this->assertEquals(
			$function1,
			$set,
			'Line: '.__LINE__
		);

		$this->assertNotEquals(
			$function2,
			$set,
			'Line: '.__LINE__
		);

		$this->assertEquals(
			$function2,
			$lang->getTransliterator(),
			'Line: '.__LINE__
		);

		$this->assertNotEquals(
			$function1,
			$lang->getTransliterator(),
			'Line: '.__LINE__
		);
    }

    /**
     * @todo Implement testgetPluralSuffixesCallback().
     */
    public function testgetPluralSuffixesCallback()
    {
		$lang = new JLanguage('');

		$this->assertTrue(
			is_callable($lang->getPluralSuffixesCallback())
		);
    }

    /**
     * @todo Implement testSetPluralSufficesCallback().
     */
    public function testSetPluralSufficesCallback()
    {
		$function1	= 'phpinfo';
		$function2	= 'print';
		$lang		= new JLanguage('');

		$this->assertTrue(
			is_callable($lang->getPluralSuffixesCallback())
		);

		$this->assertTrue(
			is_callable($lang->setPluralSufficesCallback($function1))
		);

		$get = $lang->getPluralSuffixesCallback();
		$this->assertEquals(
			$function1,
			$get,
			'Line: '.__LINE__
		);

		$this->assertNotEquals(
			$function2,
			$get,
			'Line: '.__LINE__
		);

		// set -> $function2: set returns $function1 and get retuns $function2
		$set = $lang->setPluralSufficesCallback($function2);
		$this->assertEquals(
			$function1,
			$set,
			'Line: '.__LINE__
		);

		$this->assertNotEquals(
			$function2,
			$set,
			'Line: '.__LINE__
		);

		$this->assertEquals(
			$function2,
			$lang->getPluralSuffixesCallback(),
			'Line: '.__LINE__
		);

		$this->assertNotEquals(
			$function1,
			$lang->getPluralSuffixesCallback(),
			'Line: '.__LINE__
		);
    }

   /**
     * @todo Implement testGetIgnoredSearchWords().
     */
    public function testGetIgnoredSearchWords()
    {
		$lang = new JLanguage('');

		$this->assertEquals(
			array('and', 'in', 'on'),
			$lang->getIgnoredSearchWords(),
			'Line: '.__LINE__
		);
    }

    /**
     * @todo Implement testGetIgnoredSearchWordsCallback().
     */
    public function testGetIgnoredSearchWordsCallback()
    {
		$lang = new JLanguage('');

		$this->assertTrue(
			is_callable($lang->getIgnoredSearchWordsCallback())
		);
    }

    /**
     * @todo Implement testSetIgnoredSearchWordsCallback().
     */
    public function testSetIgnoredSearchWordsCallback()
    {
		$function1 = 'phpinfo';
		$function2 = 'print';
		$lang = new JLanguage('');

		$this->assertTrue(
			is_callable($lang->getIgnoredSearchWordsCallback())
		);

		// set -> $funtion1: set returns NULL and get returns $function1
		$this->assertTrue(
			is_callable($lang->setIgnoredSearchWordsCallback($function1))
		);

		$get = $lang->getIgnoredSearchWordsCallback();
		$this->assertEquals(
			$function1,
			$get,
			'Line: '.__LINE__
		);

		$this->assertNotEquals(
			$function2,
			$get,
			'Line: '.__LINE__
		);

		// set -> $function2: set returns $function1 and get retuns $function2
		$set = $lang->setIgnoredSearchWordsCallback($function2);
		$this->assertEquals(
			$function1,
			$set,
			'Line: '.__LINE__
		);

		$this->assertNotEquals(
			$function2,
			$set,
			'Line: '.__LINE__
		);

		$this->assertEquals(
			$function2,
			$lang->getIgnoredSearchWordsCallback(),
			'Line: '.__LINE__
		);

		$this->assertNotEquals(
			$function1,
			$lang->getIgnoredSearchWordsCallback(),
			'Line: '.__LINE__
		);
    }

   /**
     * @todo Implement testGetLowerLimitSearchWord().
     */
    public function testGetLowerLimitSearchWord()
    {
		$lang = new JLanguage('');

		$this->assertEquals(
			3,
			$lang->getLowerLimitSearchWord(),
			'Line: '.__LINE__
		);
    }

    /**
     * @todo Implement testGetLowerLimitSearchWordCallback().
     */
    public function testGetLowerLimitSearchWordCallback()
    {
		$lang = new JLanguage('');

		$this->assertTrue(
			is_callable($lang->getLowerLimitSearchWordCallback())
		);
    }

    /**
     * @todo Implement testSetLowerLimitSearchWordCallback().
     */
    public function testSetLowerLimitSearchWordCallback()
    {
		$function1	= 'phpinfo';
		$function2	= 'print';
		$lang		= new JLanguage('');

		$this->assertTrue(
			is_callable($lang->getLowerLimitSearchWordCallback())
		);

		// set -> $funtion1: set returns NULL and get returns $function1
		$this->assertTrue(
			is_callable($lang->setLowerLimitSearchWordCallback($function1))
		);

		$get = $lang->getLowerLimitSearchWordCallback();
		$this->assertEquals(
			$function1,
			$get,
			'Line: '.__LINE__
		);

		$this->assertNotEquals(
			$function2,
			$get,
			'Line: '.__LINE__
		);

		// set -> $function2: set returns $function1 and get retuns $function2
		$set = $lang->setLowerLimitSearchWordCallback($function2);
		$this->assertEquals(
			$function1,
			$set,
			'Line: '.__LINE__
		);

		$this->assertNotEquals(
			$function2,
			$set,
			'Line: '.__LINE__
		);

		$this->assertEquals(
			$function2,
			$lang->getLowerLimitSearchWordCallback(),
			'Line: '.__LINE__
		);

		$this->assertNotEquals(
			$function1,
			$lang->getLowerLimitSearchWordCallback(),
			'Line: '.__LINE__
		);
    }

   /**
     * @todo Implement testGetUpperLimitSearchWord().
     */
    public function testGetUpperLimitSearchWord()
    {
		$lang = new JLanguage('');

		$this->assertEquals(
			20,
			$lang->getUpperLimitSearchWord(),
			'Line: '.__LINE__
		);
    }

    /**
     * @todo Implement testGetUpperLimitSearchWordCallback().
     */
    public function testGetUpperLimitSearchWordCallback()
    {
		$lang = new JLanguage('');

		$this->assertTrue(
			is_callable($lang->getUpperLimitSearchWordCallback())
		);
    }

    /**
     * @todo Implement testSetUpperLimitSearchWordCallback().
     */
    public function testSetUpperLimitSearchWordCallback()
    {
		$function1	= 'phpinfo';
		$function2	= 'print';
		$lang		= new JLanguage('');

		$this->assertTrue(
			is_callable($lang->getUpperLimitSearchWordCallback())
		);

		// set -> $funtion1: set returns NULL and get returns $function1
		$this->assertTrue(
			is_callable($lang->setUpperLimitSearchWordCallback($function1))
		);

		$get = $lang->getUpperLimitSearchWordCallback();
		$this->assertEquals(
			$function1,
			$get,
			'Line: '.__LINE__
		);

		$this->assertNotEquals(
			$function2,
			$get,
			'Line: '.__LINE__
		);

		// set -> $function2: set returns $function1 and get retuns $function2
		$set = $lang->setUpperLimitSearchWordCallback($function2);
		$this->assertEquals(
			$function1,
			$set,
			'Line: '.__LINE__
		);

		$this->assertNotEquals(
			$function2,
			$set,
			'Line: '.__LINE__
		);

		$this->assertEquals(
			$function2,
			$lang->getUpperLimitSearchWordCallback(),
			'Line: '.__LINE__
		);

		$this->assertNotEquals(
			$function1,
			$lang->getUpperLimitSearchWordCallback(),
			'Line: '.__LINE__
		);
    }

   /**
     * @todo Implement testGetSearchDisplayedCharactersNumber().
     */
    public function testGetSearchDisplayedCharactersNumber()
    {
		$lang = new JLanguage('');

		$this->assertEquals(
			200,
			$lang->getSearchDisplayedCharactersNumber(),
			'Line: '.__LINE__
		);
    }

    /**
     * @todo Implement testGetSearchDisplayedCharactersNumberCallback().
     */
    public function testGetSearchDisplayedCharactersNumberCallback()
    {
		$lang = new JLanguage('');

		$this->assertTrue(
			is_callable($lang->getSearchDisplayedCharactersNumberCallback())
		);
    }

    /**
     * @todo Implement testSetSearchDisplayedCharactersNumberCallback().
     */
    public function testSetSearchDisplayedCharactersNumberCallback()
    {
		$function1	= 'phpinfo';
		$function2	= 'print';
		$lang		= new JLanguage('');

		$this->assertTrue(
			is_callable($lang->getSearchDisplayedCharactersNumberCallback())
		);

		// set -> $funtion1: set returns NULL and get returns $function1
		$this->assertTrue(
			is_callable($lang->setSearchDisplayedCharactersNumberCallback($function1))
		);

		$get = $lang->getSearchDisplayedCharactersNumberCallback();
		$this->assertEquals(
			$function1,
			$get,
			'Line: '.__LINE__
		);

		$this->assertNotEquals(
			$function2,
			$get,
			'Line: '.__LINE__
		);

		// set -> $function2: set returns $function1 and get retuns $function2
		$set = $lang->setSearchDisplayedCharactersNumberCallback($function2);
		$this->assertEquals(
			$function1,
			$set,
			'Line: '.__LINE__
		);

		$this->assertNotEquals(
			$function2,
			$set,
			'Line: '.__LINE__
		);

		$this->assertEquals(
			$function2,
			$lang->getSearchDisplayedCharactersNumberCallback(),
			'Line: '.__LINE__
		);

		$this->assertNotEquals(
			$function1,
			$lang->getSearchDisplayedCharactersNumberCallback(),
			'Line: '.__LINE__
		);
    }

    /**
     * @todo Implement testExists().
     */
    public function testExists()
    {
		// This method checks the existence of a language in a directory
		$l1 = 'en-GB';
		$l2 = 'es-ES';
		$basePath = '../../administrator/';
		$lang = new JLanguage('');

		// In this case, returns TRUE with en-GB
		$this->assertTrue(
			$lang->exists($l1,$basePath)
		);

		$this->assertFalse(
			$lang->exists($l2,$basePath)
		);
    }

    /**
     * @todo Implement testLoad().
     */
    public function testLoad()
    {
		// This method loads an extension language
		$extension1 = 'com_admin';
		$extension2 = 'com_sobi2';
		$basePath = '../../administrator/';
		$l1 = 'en-GB';
		$l2 = 'es-ES';
		$reloaded1 = false;
		$reloaded2 = true;
		$lang = new JLanguage('');

		// com_admin (exist), OK
		$this->assertTrue(
			$lang->load($extension1,$basePath,$l1,$reloaded1)
		);

		$this->assertTrue(
			$lang->load($extension1,$basePath,$l2,$reloaded1)
		);

		// com_sobi2 (not exist), KO
		$this->assertFalse(
			$lang->load($extension2,$basePath,$l1,$reloaded1)
		);

		$this->assertFalse(
			$lang->load($extension2,$basePath,$l2,$reloaded1)
		);

		// com_admin (exist), OK
		$this->assertTrue(
			$lang->load($extension1,$basePath,$l1,$reloaded2)
		);

		$this->assertTrue(
			$lang->load($extension1,$basePath,$l2,$reloaded2)
		);

		// com_sobi2 (not exist), KO
		$this->assertFalse(
			$lang->load($extension2,$basePath,$l1,$reloaded2)
		);

		$this->assertFalse(
			$lang->load($extension2,$basePath,$l2,$reloaded2)
		);
    }

    /**
     * @todo Implement testLoadLanguage().
     */
    public function testLoadLanguage()
    {
		// protected method
    }

    /**
     * @todo Implement testGet().
     */
    public function testGet()
    {
		// This method get a matadata language property
		$property1	= '';
		$property2	= 'noExist';
		$property3	= 'tag';
		$property4	= 'name';
		$default	= null;
		$lang		= new JLanguage('');

		// If not property or does not exist, returns null
		$this->assertNull(
			$lang->get($property1,$default)
		);

		$this->assertNull(
			$lang->get($property2,$default)
		);

		// property = tag, returns en-GB (default language)
		$this->assertEquals(
			'en-GB',
			$lang->get($property3,$default),
			'Line: '.__LINE__
		);

		$this->assertNotEquals(
			'es-ES',
			$lang->get($property3,$default),
			'Line: '.__LINE__
		);

		// property = name, returns English (United Kingdom) (default language)
		$this->assertEquals(
			'English (United Kingdom)',
			$lang->get($property4,$default),
			'Line: '.__LINE__
		);

		$this->assertNotEquals(
			'Spanish (Spain)',
			$lang->get($property4,$default),
			'Line: '.__LINE__
		);
    }

    /**
     * @todo Implement testGetCallerInfo().
     */
    public function testGetCallerInfo()
    {
		// protected
    }

    /**
     * @todo Implement testGetName().
     */
    public function testGetName()
    {
		// This method get language name
		$lang = new JLanguage('');

		// In this case, returns English (United Kingdom) (default language)
		// - same operation of get method with name property
		$this->assertEquals(
			'English (United Kingdom)',
			$lang->getName(),
			'Line: '.__LINE__
		);

		$this->assertNotEquals(
			'Spanish (Spain)',
			$lang->getName(),
			'Line: '.__LINE__
		);
    }

    /**
     * @todo Implement testGetPaths().
     */
    public function testGetPaths()
    {
		$extension1 = '';
		$extension2 = 'com_sobi2';
		$extension3 = 'joomla';
		$lang = new JLanguage('');

		// without extension, retuns NULL
		$this->assertNull(
			$lang->getPaths($extension1)
		);

		// extension doesn't exist, returns NULL
		$this->assertNull(
			$lang->getPaths($extension2)
		);

		// extension = joomla, returns array with language path
		$this->assertNotNull(
			$lang->getPaths($extension3)
		);

		// No call parameter, returns array with language path
		$this->assertNotNull(
			$lang->getPaths()
		);
    }

    /**
     * @todo Implement testGetTag().
     */
    public function testGetTag()
    {
		// This method get language tag
		$lang = new JLanguage('');

		// In this case, returns en-GB (default language)
		// - same operation of get method with tag property
		$this->assertEquals(
			'en-GB',
			$lang->getTag(),
			'Line: '.__LINE__
		);

		$this->assertNotEquals(
			'es-ES',
			$lang->getTag(),
			'Line: '.__LINE__
		);
    }

    /**
     * @todo Implement testIsRTL().
     */
    public function testIsRTL()
    {
		// This method get language RTL
		$lang = new JLanguage('');

		// In this case, returns 0 (default language)
		// - same operation of get method with RTL property
		$this->assertEquals(
			'0',
			$lang->isRTL(),
			'Line: '.__LINE__
		);

		$this->assertNotEquals(
			'1',
			$lang->isRTL(),
			'Line: '.__LINE__
		);
    }

    /**
     * @todo Implement testGetOrphans().
     */
    public function testGetOrphans()
    {
		$orphansCompareEqual = array();
		$lang = new JLanguage('');

		// returns an empty array
		$this->assertEquals(
			$orphansCompareEqual,
			$lang->getOrphans(),
			'Line: '.__LINE__
		);
    }

    /**
     * @todo Implement testGetUsed().
     */
    public function testGetUsed()
    {
		$usedCompareEqual = array();
		$lang = new JLanguage('');

		// returns an empty array
		$this->assertEquals(
			$usedCompareEqual,
			$lang->getUsed(),
			'Line: '.__LINE__
		);
    }

    /**
     * @todo Implement testHasKey().
     */
    public function testHasKey()
    {
		$string1 = 'com_admin.key';
		$lang = new JLanguage('');

		// HasKey doesn't exist, returns FALSE
		$this->assertFalse(
			$lang->hasKey($string1)
		);
    }

    /**
     * @todo Implement testGetMetadata().
     */
    public function testGetMetadata()
    {
		// This method get language metadata
		$l1 = 'en-GB';
		$l2 = 'es-ES';

		// In this case, returns array with default language
		// - same operation of get method with metadata property
		$option1 = array(
		    'name' => 'English (United Kingdom)',
		    'tag' => 'en-GB',
		    'rtl' => 0,
		    'locale' => 'en_GB.utf8, en_GB.UTF-8, en_GB, eng_GB, en, english, english-uk, uk, gbr, britain, england, great britain, uk, united kingdom, united-kingdom',
		    'firstDay' => 0
		);
		$option2 = array(
		    'name' => 'XXTestLang',
		    'tag' => 'xx-XX',
		    'rtl' => 0,
		    'locale' => 'en_GB.utf8, en_GB.UTF-8, en_GB, eng_GB, en, english, english-uk, uk, gbr, britain, england, great britain, uk, united kingdom, united-kingdom',
		    'firstDay' => 0
		);

		$lang = new JLanguage('');

		// language exists, returns array with values
		$this->assertThat(
		   $option1,
		   $this->equalTo($lang->getMetadata($l1)),
			'Line: '.__LINE__
		);

		// language doesn't exist, retun NULL
		$this->assertNull(
			$lang->getMetadata($l2)
		);
    }

    /**
     * @todo Implement testGetKnownLanguages().
     */
    public function testGetKnownLanguages()
    {
		// This method returns a list of known languages
		$basePath = '../../administrator/';

		$option1 = array(
		    'name' => 'English (United Kingdom)',
		    'tag' => 'en-GB',
		    'rtl' => 0,
		    'locale' => 'en_GB.utf8, en_GB.UTF-8, en_GB, eng_GB, en, english, english-uk, uk, gbr, britain, england, great britain, uk, united kingdom, united-kingdom',
		    'firstDay' => 0
		);
		$option2 = array(
		    'name' => 'XXTestLang',
		    'tag' => 'xx-XX',
		    'rtl' => 0,
		    'locale' => 'en_GB.utf8, en_GB.UTF-8, en_GB, eng_GB, en, english, english-uk, uk, gbr, britain, england, great britain, uk, united kingdom, united-kingdom',
		    'firstDay' => 0
		);
		$listCompareEqual1 = array(
		    'en-GB' => $option1,
		    'xx-XX' => $option2
		);

		$lang = new JLanguage('');

		// for administrator directory, returns know languages (default)
		$list = $lang->getKnownLanguages($basePath);
		$this->assertThat(
		   $listCompareEqual1,
		   $this->equalTo($list),
			'Line: '.__LINE__
		);

		$this->assertNotEquals(
			$listCompareEqual1['xx-XX']['name'],
			$list['en-GB']['name'],
			'Line: '.__LINE__
		);
    }

    /**
     * @todo Implement testGetLanguagePath().
     */
    public function testGetLanguagePath()
    {
		$basePath	= 'languages';
		$language1	= null;
		$language2	= 'en-GB';
		$lang		= new JLanguage('');

		// $language = null, returns language directory
		$this->assertEquals(
			'languages/language',
			$lang->getLanguagePath($basePath, $language1),
			'Line: '.__LINE__
		);

		$this->assertNotEquals(
			'languages/language',
			$lang->getLanguagePath($basePath, $language2),
			'Line: '.__LINE__
		);

		// $language = value (en-GB, for example), returns en-GB language directory
		$this->assertEquals(
			'languages/language/en-GB',
			$lang->getLanguagePath($basePath, $language2),
			'Line: '.__LINE__
		);

		$this->assertNotEquals(
			'languages/language/en-GB',
			$lang->getLanguagePath($basePath, $language1),
			'Line: '.__LINE__
		);
    }

    /**
     * @todo Implement testSetLanguage().
     */
    public function testSetLanguage()
    {
		$l1 = 'en-GB';
		$l2 = 'es-ES';
		$lang = new JLanguage('');

		// set l2, return en-GB (default language)
		$l = $lang->setLanguage($l2);
		$this->assertEquals(
			'en-GB',
			$l,
			'Line: '.__LINE__
		);

		$this->assertNotEquals(
			'es-ES',
			$l,
			'Line: '.__LINE__
		);

		// set l1, retuns l2
		$l = $lang->setLanguage($l1);
		$this->assertEquals(
			'es-ES',
			$l,
			'Line: '.__LINE__
		);

		$this->assertNotEquals(
			'en-GB',
			$l,
			'Line: '.__LINE__
		);
    }

    /**
     * @todo Implement testParseLanguageFiles().
     */
    public function testParseLanguageFiles()
    {
		$dir = '../../language/';

		$option = array(
		    'name' => 'English (United Kingdom)',
		    'tag' => 'en-GB',
		    'rtl' => 0,
		    'locale' => 'en_GB.utf8, en_GB.UTF-8, en_GB, eng_GB, en, english, english-uk, uk, gbr, britain, england, great britain, uk, united kingdom, united-kingdom',
		    'firstDay' => 0
		);
		$language = array(
		    'en-GB' => $option
		);

		$lang = new JLanguage('');
		// First time, retuns en-GB array (default language)
		$this->assertThat(
		   $language,
		   $this->equalTo(array_intersect_key($lang->parseLanguageFiles($dir),array('en-GB'=>'en-GB'))),
			'Line: '.__LINE__
		);
		// If we add es-ES directory, returns infinite loop. Is that correct?
    }

    /**
     * @todo Implement testParseXMLLanguageFiles().
     */
    public function testParseXMLLanguageFiles()
    {
		$dir1 = null;
		$dir2 = '../../language/';
		$dir3 = '../../administrator';

		$option = array(
		    'name' => 'English (United Kingdom)',
		    'tag' => 'en-GB',
		    'rtl' => 0,
		    'locale' => 'en_GB.utf8, en_GB.UTF-8, en_GB, eng_GB, en, english, english-uk, uk, gbr, britain, england, great britain, uk, united kingdom, united-kingdom',
		    'firstDay' => 0
		);
		$language = array(
		    'en-GB' => $option
		);
		$empty = array();

		$lang = new JLanguage('');

		// si dir es null, devuelve null
		$this->assertNull(
			$lang->parseXMLLanguageFiles($dir1)
		);

		// si no encuentra fichero xml, devuelve array vacío
		$this->assertThat(
			$empty,
			$this->equalTo($lang->parseXMLLanguageFiles($dir2)),
			'Line: '.__LINE__
		);

		// si se encuentra fichero xml, devuelve array de en-GB (que es el que hay por defecto)
		/*$this->assertThat(
		   $language,
		   $this->equalTo($lang->parseXMLLanguageFiles($dir))
		);*/
    }

    /**
     * @todo Implement testParseXMLLanguageFile().
     */
    public function testParseXMLLanguageFile()
    {
		$path1 = 'file.xml';
		$path2 = '../../language/';
		$path3 = '../../administrator';

		$option = array(
		    'name' => 'English (United Kingdom)',
		    'tag' => 'en-GB',
		    'rtl' => 0,
		    'locale' => 'en_GB.utf8, en_GB.UTF-8, en_GB, eng_GB, en, english, english-uk, uk, gbr, britain, england, great britain, uk, united kingdom, united-kingdom',
		    'firstDay' => 0
		);
		$language = array(
		    'en-GB' => $option
		);
		$empty = array();

		$lang = new JLanguage('');

		//var_dump($lang->parseXMLLanguageFile($path2));
		// si no se carga el XML, devuelve null
		//$this->assertNull($lang->parseXMLLanguageFile($path1));
		// si no encuentra fichero xml, devuelve array vacío
		/*$this->assertThat(
		   $empty,
		   $this->equalTo($lang->parseXMLLanguageFile($dir2))
		);*/
    }
}
