diff --git a/laravel/html.php b/laravel/html.php index 211e4022..33d91dd6 100644 --- a/laravel/html.php +++ b/laravel/html.php @@ -173,6 +173,8 @@ class HTML { public static function link_to_asset($url, $title = null, $attributes = array(), $https = null) { $url = URL::to_asset($url, $https); + + if (is_null($title)) $title = $url; return ''.static::entities($title).''; } diff --git a/laravel/tests/cases/form.test.php b/laravel/tests/cases/form.test.php index e812ad2d..5f6f7fa3 100644 --- a/laravel/tests/cases/form.test.php +++ b/laravel/tests/cases/form.test.php @@ -1,6 +1,6 @@ 'text/javascript')); + + $this->assertEquals(''."\n", $html1); + $this->assertEquals(''."\n", $html2); + $this->assertEquals(''."\n", $html3); + } + + /** + * Test generating a link to CSS files + * + * @group laravel + */ + public function testGeneratingStyle() + { + $html1 = HTML::style('foo.css'); + $html2 = HTML::style('http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/js/bootstrap.min.js'); + $html3 = HTML::style('foo.css', array('media' => 'print')); + + $this->assertEquals(''."\n", $html1); + $this->assertEquals(''."\n", $html2); + $this->assertEquals(''."\n", $html3); + } + + /** + * Test generating proper span + * + * @group laravel + */ + public function testGeneratingSpan() + { + $html1 = HTML::span('foo'); + $html2 = HTML::span('foo', array('class' => 'badge')); + + $this->assertEquals('foo', $html1); + $this->assertEquals('foo', $html2); + } + + /** + * Test generating proper link + * + * @group laravel + */ + public function testGeneratingLink() + { + $html1 = HTML::link('foo'); + $html2 = HTML::link('foo', 'Foobar'); + $html3 = HTML::link('foo', 'Foobar', array('class' => 'btn')); + $html4 = HTML::link('http://google.com', 'Google'); + + $this->assertEquals('http://localhost/index.php/foo', $html1); + $this->assertEquals('Foobar', $html2); + $this->assertEquals('Foobar', $html3); + $this->assertEquals('Google', $html4); + } + + /** + * Test generating proper link to secure + * + * @group laravel + */ + public function testGeneratingLinkToSecure() + { + $html1 = HTML::link_to_secure('foo'); + $html2 = HTML::link_to_secure('foo', 'Foobar'); + $html3 = HTML::link_to_secure('foo', 'Foobar', array('class' => 'btn')); + $html4 = HTML::link_to_secure('http://google.com', 'Google'); + + $this->assertEquals('https://localhost/index.php/foo', $html1); + $this->assertEquals('Foobar', $html2); + $this->assertEquals('Foobar', $html3); + $this->assertEquals('Google', $html4); + } + + /** + * Test generating proper link to asset + * + * @group laravel + */ + public function testGeneratingAssetLink() + { + $html1 = HTML::link_to_asset('foo.css'); + $html2 = HTML::link_to_asset('foo.css', 'Foobar'); + $html3 = HTML::link_to_asset('foo.css', 'Foobar', array('class' => 'btn')); + $html4 = HTML::link_to_asset('http://google.com/images.jpg', 'Google'); + + $this->assertEquals('http://localhost/foo.css', $html1); + $this->assertEquals('Foobar', $html2); + $this->assertEquals('Foobar', $html3); + $this->assertEquals('Google', $html4); + } + + /** + * Test generating proper link to secure asset + * + * @group laravel + */ + public function testGeneratingAssetLinkToSecure() + { + $html1 = HTML::link_to_secure_asset('foo.css'); + $html2 = HTML::link_to_secure_asset('foo.css', 'Foobar'); + $html3 = HTML::link_to_secure_asset('foo.css', 'Foobar', array('class' => 'btn')); + $html4 = HTML::link_to_secure_asset('http://google.com/images.jpg', 'Google'); + + $this->assertEquals('https://localhost/foo.css', $html1); + $this->assertEquals('Foobar', $html2); + $this->assertEquals('Foobar', $html3); + $this->assertEquals('Google', $html4); + } + + /** + * Test generating proper link to route + * + * @group laravel + */ + public function testGeneratingLinkToRoute() + { + Route::get('dashboard', array('as' => 'foo')); + + $html1 = HTML::link_to_route('foo'); + $html2 = HTML::link_to_route('foo', 'Foobar'); + $html3 = HTML::link_to_route('foo', 'Foobar', array(), array('class' => 'btn')); + + $this->assertEquals('http://localhost/index.php/dashboard', $html1); + $this->assertEquals('Foobar', $html2); + $this->assertEquals('Foobar', $html3); + } + + /** + * Test generating proper link to action + * + * @group laravel + */ + public function testGeneratingLinkToAction() + { + $html1 = HTML::link_to_action('foo@bar'); + $html2 = HTML::link_to_action('foo@bar', 'Foobar'); + $html3 = HTML::link_to_action('foo@bar', 'Foobar', array(), array('class' => 'btn')); + + $this->assertEquals('http://localhost/index.php/foo/bar', $html1); + $this->assertEquals('Foobar', $html2); + $this->assertEquals('Foobar', $html3); + } + + /** + * Test generating proper listing + * + * @group laravel + */ + public function testGeneratingListing() + { + $list = array( + 'foo', + 'foobar' => array( + 'hello', + 'hello world', + ), + ); + + $html1 = HTML::ul($list); + $html2 = HTML::ul($list, array('class' => 'nav')); + $html3 = HTML::ol($list); + $html4 = HTML::ol($list, array('class' => 'nav')); + + $this->assertEquals('
', $html1);
+ $this->assertEquals('
', $html2);
+ $this->assertEquals('
', $html3);
+ $this->assertEquals('
', $html4);
+ }
+}
\ No newline at end of file
diff --git a/laravel/tests/cases/session.test.php b/laravel/tests/cases/session.test.php
index f93ce9b1..b310870c 100644
--- a/laravel/tests/cases/session.test.php
+++ b/laravel/tests/cases/session.test.php
@@ -281,7 +281,7 @@ class SessionTest extends PHPUnit_Framework_TestCase {
->with($this->equalTo($expect), $this->equalTo($config), $this->equalTo(true));
$payload->save();
-
+
$this->assertEquals($session['data'][':new:'], $payload->session['data'][':old:']);
}
diff --git a/laravel/tests/cases/url.test.php b/laravel/tests/cases/url.test.php
index 603265ab..3bf37b40 100644
--- a/laravel/tests/cases/url.test.php
+++ b/laravel/tests/cases/url.test.php
@@ -15,6 +15,7 @@ class URLTest extends PHPUnit_Framework_TestCase {
Router::$uses = array();
Router::$fallback = array();
Config::set('application.url', 'http://localhost');
+ Config::set('application.index', 'index.php');
}
/**