Browse Source

added url tests.

Taylor Otwell 13 years ago
parent
commit
4c2209e331
1 changed files with 49 additions and 0 deletions
  1. 49 0
      tests/Cases/UrlTest.php

+ 49 - 0
tests/Cases/UrlTest.php

@@ -0,0 +1,49 @@
+<?php use Laravel\URL, Laravel\Config;
+
+class UrlTest extends PHPUnit_Framework_TestCase {
+
+	public function test_simple_url()
+	{
+		$this->assertEquals(URL::to(''), 'http://localhost/index.php/');
+		$this->assertEquals(URL::to('something'), 'http://localhost/index.php/something');
+	}
+
+	public function test_simple_url_without_index()
+	{
+		Config::set('application.index', '');
+
+		$this->assertEquals(Url::to(''), 'http://localhost/');
+		$this->assertEquals(Url::to('something'), 'http://localhost/something');
+
+		Config::set('application.index', 'index.php');
+	}
+
+	public function test_asset_url()
+	{
+		$this->assertEquals(URL::to_asset('img/test.jpg'), 'http://localhost/img/test.jpg');
+
+		Config::set('application.index', '');
+
+		$this->assertEquals(URL::to_asset('img/test.jpg'), 'http://localhost/img/test.jpg');
+
+		Config::set('application.index', 'index.php');
+	}
+
+	public function test_secure_url()
+	{
+		$this->assertEquals(URL::to_secure('something'), 'https://localhost/index.php/something');
+
+		Config::set('application.ssl', false);
+
+		$this->assertEquals(URL::to_secure('something'), 'http://localhost/index.php/something');
+
+		Config::set('application.ssl', true);
+	}
+
+	public function test_slug()
+	{
+		$this->assertEquals(URL::slug('My favorite blog!!'), 'my-favorite-blog');
+		$this->assertEquals(URL::slug('My favorite blog!!', '_'), 'my_favorite_blog');
+	}
+
+}