Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Rotua Panjaitan
yii2
Commits
154c2777
Commit
154c2777
authored
Jun 21, 2014
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3995 from njasm/master
Added more unit tests to widgets\Breadcrumbs and increased coverage to 100%
parents
1b12ddee
6974e84f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
4 deletions
+23
-4
BreadcrumbsTest.php
tests/unit/framework/widgets/BreadcrumbsTest.php
+23
-4
No files found.
tests/unit/framework/widgets/BreadcrumbsTest.php
View file @
154c2777
...
...
@@ -13,16 +13,35 @@ use yii\widgets\Breadcrumbs;
class
BreadcrumbsTest
extends
\yiiunit\TestCase
{
private
$breadcrumbs
;
private
$app
;
public
function
setUp
()
{
$this
->
app
=
$this
->
mockApplication
();
Yii
::
setAlias
(
'@testWeb'
,
'/'
);
Yii
::
setAlias
(
'@testWebRoot'
,
'@yiiunit/data/web'
);
// dirty way to have Request object not throwing exception when running testHomeLinkNull()
$_SERVER
[
'SCRIPT_FILENAME'
]
=
"index.php"
;
$_SERVER
[
'SCRIPT_NAME'
]
=
"index.php"
;
$this
->
mockApplication
([],
'yii\web\Application'
);
$this
->
breadcrumbs
=
new
Breadcrumbs
();
}
public
function
testHomeLinkNull
()
{
$this
->
breadcrumbs
->
homeLink
=
null
;
$this
->
breadcrumbs
->
links
=
[
'label'
=>
'My Home Page'
,
'url'
=>
'http://my.example.com/yii2/link/page'
];
$expectedHtml
=
"<ul class=
\"
breadcrumb
\"
><li><a href=
\"
./index.php
\"
>Home</a></li>
\n
"
.
"<li class=
\"
active
\"
>My Home Page</li>
\n
"
.
"<li class=
\"
active
\"
>http://my.example.com/yii2/link/page</li>
\n
"
.
"</ul>"
;
ob_start
();
$this
->
breadcrumbs
->
run
();
$actualHtml
=
ob_get_contents
();
ob_end_clean
();
$this
->
assertEquals
(
$expectedHtml
,
$actualHtml
);
}
public
function
testEmptyLinks
()
{
$this
->
assertNull
(
$this
->
breadcrumbs
->
run
());
...
...
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