Add URL::to_language and HTML::link_to_language localization helpers

Signed-off-by: Anahkiasen <ehtnam6@gmail.com>
This commit is contained in:
Anahkiasen
2012-10-26 22:32:52 +01:00
parent 205cc4869d
commit 89e3bf1fbd
5 changed files with 84 additions and 4 deletions

View File

@@ -105,6 +105,26 @@ class URLTest extends PHPUnit_Framework_TestCase {
$this->assertEquals('http://localhost/index.php/url/test/taylor/otwell', URL::to_route('url-test-2', array('taylor', 'otwell')));
}
/**
* Test the URL::to_language method.
*
* @group laravel
*/
public function testToLanguageMethodGeneratesURLsToDifferentLanguage()
{
URI::$uri = 'foo/bar';
Config::set('application.languages', array('sp', 'fr'));
Config::set('application.language', 'sp');
$this->assertEquals('http://localhost/index.php/fr/foo/bar', URL::to_language('fr'));
$this->assertEquals('http://localhost/index.php/fr/', URL::to_language('fr', true));
Config::set('application.index', '');
$this->assertEquals('http://localhost/fr/foo/bar', URL::to_language('fr'));
$this->assertEquals('http://localhost/sp/foo/bar', URL::to_language('en'));
}
/**
* Test language based URL generation.