Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yeray Santana Hualde
syncEnrollments
Commits
49b2d4ab
Commit
49b2d4ab
authored
Nov 06, 2012
by
Dayle Rees
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1423 from laravie/feature/html-testcase
Add unit testing coverage for Laravel\HTML
parents
d20add8f
56eca662
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
254 additions
and
5 deletions
+254
-5
html.php
laravel/html.php
+2
-0
form.test.php
laravel/tests/cases/form.test.php
+8
-4
html.test.php
laravel/tests/cases/html.test.php
+242
-0
session.test.php
laravel/tests/cases/session.test.php
+1
-1
url.test.php
laravel/tests/cases/url.test.php
+1
-0
No files found.
laravel/html.php
View file @
49b2d4ab
...
@@ -174,6 +174,8 @@ class HTML {
...
@@ -174,6 +174,8 @@ class HTML {
{
{
$url
=
URL
::
to_asset
(
$url
,
$https
);
$url
=
URL
::
to_asset
(
$url
,
$https
);
if
(
is_null
(
$title
))
$title
=
$url
;
return
'<a href="'
.
$url
.
'"'
.
static
::
attributes
(
$attributes
)
.
'>'
.
static
::
entities
(
$title
)
.
'</a>'
;
return
'<a href="'
.
$url
.
'"'
.
static
::
attributes
(
$attributes
)
.
'>'
.
static
::
entities
(
$title
)
.
'</a>'
;
}
}
...
...
laravel/tests/cases/form.test.php
View file @
49b2d4ab
<?php
<?php
class
TestForm
extends
PHPUnit_Framework_TestCase
{
class
FormTest
extends
PHPUnit_Framework_TestCase
{
/**
/**
* Setup the test environment.
* Setup the test environment.
...
@@ -9,12 +9,16 @@ class TestForm extends PHPUnit_Framework_TestCase {
...
@@ -9,12 +9,16 @@ class TestForm extends PHPUnit_Framework_TestCase {
{
{
URL
::
$base
=
null
;
URL
::
$base
=
null
;
Config
::
set
(
'application.url'
,
'http://localhost'
);
Config
::
set
(
'application.url'
,
'http://localhost'
);
Config
::
set
(
'application.index'
,
'index.php'
);
}
}
/**
/**
*
Tear down the test enviro
nment.
*
Destroy the test envior
nment.
*/
*/
public
function
tearDown
(){}
public
function
tearDown
()
{
Config
::
set
(
'application.url'
,
''
);
Config
::
set
(
'application.index'
,
'index.php'
);
}
/**
/**
* Test the compilation of opening a form
* Test the compilation of opening a form
...
...
laravel/tests/cases/html.test.php
0 → 100644
View file @
49b2d4ab
<?php
class
HtmlTest
extends
PHPUnit_Framework_TestCase
{
/**
* Setup the test environment
*/
public
function
setUp
()
{
URL
::
$base
=
null
;
Config
::
set
(
'application.url'
,
'http://localhost'
);
Config
::
set
(
'application.index'
,
'index.php'
);
Router
::
$names
=
array
();
Router
::
$routes
=
array
();
}
/**
* Destroy the test environment
*/
public
function
tearDown
()
{
Config
::
set
(
'application.url'
,
''
);
Config
::
set
(
'application.index'
,
'index.php'
);
Router
::
$names
=
array
();
Router
::
$routes
=
array
();
}
/**
* Test generating a link to JavaScript files
*
* @group laravel
*/
public
function
testGeneratingScript
()
{
$html1
=
HTML
::
script
(
'foo.js'
);
$html2
=
HTML
::
script
(
'http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js'
);
$html3
=
HTML
::
script
(
'foo.js'
,
array
(
'type'
=>
'text/javascript'
));
$this
->
assertEquals
(
'<script src="http://localhost/foo.js"></script>'
.
"
\n
"
,
$html1
);
$this
->
assertEquals
(
'<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>'
.
"
\n
"
,
$html2
);
$this
->
assertEquals
(
'<script src="http://localhost/foo.js" type="text/javascript"></script>'
.
"
\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
(
'<link href="http://localhost/foo.css" media="all" type="text/css" rel="stylesheet">'
.
"
\n
"
,
$html1
);
$this
->
assertEquals
(
'<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/js/bootstrap.min.js" media="all" type="text/css" rel="stylesheet">'
.
"
\n
"
,
$html2
);
$this
->
assertEquals
(
'<link href="http://localhost/foo.css" media="print" type="text/css" rel="stylesheet">'
.
"
\n
"
,
$html3
);
}
/**
* Test generating proper span
*
* @group laravel
*/
public
function
testGeneratingSpan
()
{
$html1
=
HTML
::
span
(
'foo'
);
$html2
=
HTML
::
span
(
'foo'
,
array
(
'class'
=>
'badge'
));
$this
->
assertEquals
(
'<span>foo</span>'
,
$html1
);
$this
->
assertEquals
(
'<span class="badge">foo</span>'
,
$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
(
'<a href="http://localhost/index.php/foo">http://localhost/index.php/foo</a>'
,
$html1
);
$this
->
assertEquals
(
'<a href="http://localhost/index.php/foo">Foobar</a>'
,
$html2
);
$this
->
assertEquals
(
'<a href="http://localhost/index.php/foo" class="btn">Foobar</a>'
,
$html3
);
$this
->
assertEquals
(
'<a href="http://google.com">Google</a>'
,
$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
(
'<a href="https://localhost/index.php/foo">https://localhost/index.php/foo</a>'
,
$html1
);
$this
->
assertEquals
(
'<a href="https://localhost/index.php/foo">Foobar</a>'
,
$html2
);
$this
->
assertEquals
(
'<a href="https://localhost/index.php/foo" class="btn">Foobar</a>'
,
$html3
);
$this
->
assertEquals
(
'<a href="http://google.com">Google</a>'
,
$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
(
'<a href="http://localhost/foo.css">http://localhost/foo.css</a>'
,
$html1
);
$this
->
assertEquals
(
'<a href="http://localhost/foo.css">Foobar</a>'
,
$html2
);
$this
->
assertEquals
(
'<a href="http://localhost/foo.css" class="btn">Foobar</a>'
,
$html3
);
$this
->
assertEquals
(
'<a href="http://google.com/images.jpg">Google</a>'
,
$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
(
'<a href="https://localhost/foo.css">https://localhost/foo.css</a>'
,
$html1
);
$this
->
assertEquals
(
'<a href="https://localhost/foo.css">Foobar</a>'
,
$html2
);
$this
->
assertEquals
(
'<a href="https://localhost/foo.css" class="btn">Foobar</a>'
,
$html3
);
$this
->
assertEquals
(
'<a href="http://google.com/images.jpg">Google</a>'
,
$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
(
'<a href="http://localhost/index.php/dashboard">http://localhost/index.php/dashboard</a>'
,
$html1
);
$this
->
assertEquals
(
'<a href="http://localhost/index.php/dashboard">Foobar</a>'
,
$html2
);
$this
->
assertEquals
(
'<a href="http://localhost/index.php/dashboard" class="btn">Foobar</a>'
,
$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
(
'<a href="http://localhost/index.php/foo/bar">http://localhost/index.php/foo/bar</a>'
,
$html1
);
$this
->
assertEquals
(
'<a href="http://localhost/index.php/foo/bar">Foobar</a>'
,
$html2
);
$this
->
assertEquals
(
'<a href="http://localhost/index.php/foo/bar" class="btn">Foobar</a>'
,
$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
(
'<ul><li>foo</li><li>foobar<ul><li>hello</li><li>hello world</li></ul></li></ul>'
,
$html1
);
$this
->
assertEquals
(
'<ul class="nav"><li>foo</li><li>foobar<ul><li>hello</li><li>hello world</li></ul></li></ul>'
,
$html2
);
$this
->
assertEquals
(
'<ol><li>foo</li><li>foobar<ol><li>hello</li><li>hello world</li></ol></li></ol>'
,
$html3
);
$this
->
assertEquals
(
'<ol class="nav"><li>foo</li><li>foobar<ol><li>hello</li><li>hello world</li></ol></li></ol>'
,
$html4
);
}
/**
* Test generating proper listing
*
* @group laravel
*/
public
function
testGeneratingDefinition
()
{
$definition
=
array
(
'foo'
=>
'foobar'
,
'hello'
=>
'hello world'
,
);
$html1
=
HTML
::
dl
(
$definition
);
$html2
=
HTML
::
dl
(
$definition
,
array
(
'class'
=>
'nav'
));
$this
->
assertEquals
(
'<dl><dt>foo</dt><dd>foobar</dd><dt>hello</dt><dd>hello world</dd></dl>'
,
$html1
);
$this
->
assertEquals
(
'<dl class="nav"><dt>foo</dt><dd>foobar</dd><dt>hello</dt><dd>hello world</dd></dl>'
,
$html2
);
}
/**
* Test generating proper image link
*
* @group laravel
*/
public
function
testGeneratingAssetLinkImage
()
{
$html1
=
HTML
::
image
(
'foo.jpg'
);
$html2
=
HTML
::
image
(
'foo.jpg'
,
'Foobar'
);
$html3
=
HTML
::
image
(
'foo.jpg'
,
'Foobar'
,
array
(
'class'
=>
'btn'
));
$html4
=
HTML
::
image
(
'http://google.com/images.jpg'
,
'Google'
);
$this
->
assertEquals
(
'<img src="http://localhost/foo.jpg" alt="">'
,
$html1
);
$this
->
assertEquals
(
'<img src="http://localhost/foo.jpg" alt="Foobar">'
,
$html2
);
$this
->
assertEquals
(
'<img src="http://localhost/foo.jpg" class="btn" alt="Foobar">'
,
$html3
);
$this
->
assertEquals
(
'<img src="http://google.com/images.jpg" alt="Google">'
,
$html4
);
}
}
\ No newline at end of file
laravel/tests/cases/session.test.php
View file @
49b2d4ab
laravel/tests/cases/url.test.php
View file @
49b2d4ab
...
@@ -15,6 +15,7 @@ class URLTest extends PHPUnit_Framework_TestCase {
...
@@ -15,6 +15,7 @@ class URLTest extends PHPUnit_Framework_TestCase {
Router
::
$uses
=
array
();
Router
::
$uses
=
array
();
Router
::
$fallback
=
array
();
Router
::
$fallback
=
array
();
Config
::
set
(
'application.url'
,
'http://localhost'
);
Config
::
set
(
'application.url'
,
'http://localhost'
);
Config
::
set
(
'application.index'
,
'index.php'
);
}
}
/**
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment