Fixing a double slash bug in URL generation with languages. add tests.
This commit is contained in:
parent
cfe5fa109a
commit
4e21cfce39
|
@ -84,6 +84,8 @@ public function testToAssetGeneratesURLWithoutFrontControllerInURL()
|
||||||
Request::foundation()->server->add(array('HTTPS' => 'on'));
|
Request::foundation()->server->add(array('HTTPS' => 'on'));
|
||||||
|
|
||||||
$this->assertEquals('https://localhost/image.jpg', URL::to_asset('image.jpg'));
|
$this->assertEquals('https://localhost/image.jpg', URL::to_asset('image.jpg'));
|
||||||
|
|
||||||
|
Request::foundation()->server->add(array('HTTPS' => 'off'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -103,4 +105,26 @@ public function testToRouteMethodGeneratesURLsToRoutes()
|
||||||
$this->assertEquals('http://localhost/index.php/url/test/taylor/otwell', URL::to_route('url-test-2', array('taylor', 'otwell')));
|
$this->assertEquals('http://localhost/index.php/url/test/taylor/otwell', URL::to_route('url-test-2', array('taylor', 'otwell')));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test language based URL generation.
|
||||||
|
*
|
||||||
|
* @group laravel
|
||||||
|
*/
|
||||||
|
public function testUrlsGeneratedWithLanguages()
|
||||||
|
{
|
||||||
|
Config::set('application.languages', array('sp', 'fr'));
|
||||||
|
Config::set('application.language', 'sp');
|
||||||
|
$this->assertEquals('http://localhost/index.php/sp/foo', URL::to('foo'));
|
||||||
|
$this->assertEquals('http://localhost/foo.jpg', URL::to_asset('foo.jpg'));
|
||||||
|
|
||||||
|
Config::set('application.index', '');
|
||||||
|
$this->assertEquals('http://localhost/sp/foo', URL::to('foo'));
|
||||||
|
|
||||||
|
Config::set('application.index', 'index.php');
|
||||||
|
Config::set('application.language', 'en');
|
||||||
|
$this->assertEquals('http://localhost/index.php/foo', URL::to('foo'));
|
||||||
|
Config::set('application.languages', array());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -114,9 +114,14 @@ public static function to($url = '', $https = null, $asset = false, $locale = tr
|
||||||
$root .= '/'.Config::get('application.index');
|
$root .= '/'.Config::get('application.index');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! $asset and $locale and count(Config::get('application.languages')) > 0)
|
$languages = Config::get('application.languages');
|
||||||
|
|
||||||
|
if ( ! $asset and $locale and count($languages) > 0)
|
||||||
{
|
{
|
||||||
$root .= '/'.Config::get('application.language');
|
if (in_array($default = Config::get('application.language'), $languages))
|
||||||
|
{
|
||||||
|
$root = rtrim($root, '/').'/'.$default;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Since SSL is not often used while developing the application, we allow the
|
// Since SSL is not often used while developing the application, we allow the
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
<phpunit colors="true"
|
||||||
|
bootstrap="/Users/taylor/Code/Laravel/framework/laravel/tests/phpunit.php"
|
||||||
|
backupGlobals="false">
|
||||||
|
<testsuites>
|
||||||
|
<testsuite name="Test Suite">
|
||||||
|
<directory suffix=".test.php">/Users/taylor/Code/Laravel/framework/laravel/tests/cases</directory>
|
||||||
|
</testsuite>
|
||||||
|
</testsuites>
|
||||||
|
</phpunit>
|
Loading…
Reference in New Issue