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
b812f2f0
Commit
b812f2f0
authored
Jan 25, 2012
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding more view tests.
parent
99a2c520
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
74 additions
and
0 deletions
+74
-0
view.test.php
tests/cases/laravel/view.test.php
+73
-0
basic.php
tests/laravel/application/views/tests/basic.php
+1
-0
No files found.
tests/cases/laravel/view.test.php
View file @
b812f2f0
...
...
@@ -2,6 +2,16 @@
class
ViewTest
extends
PHPUnit_Framework_TestCase
{
/**
* Test the View::make method.
*
* @group laravel
*/
public
function
testMakeMethodReturnsAViewInstance
()
{
$this
->
assertInstanceOf
(
'Laravel\\View'
,
View
::
make
(
'home.index'
));
}
/**
* Test the View class constructor.
*
...
...
@@ -38,6 +48,42 @@ class ViewTest extends PHPUnit_Framework_TestCase {
$this
->
assertEquals
(
'Taylor'
,
$view
->
data
[
'name'
]);
}
/**
* Test the View::name method.
*
* @group laravel
*/
public
function
testNameMethodRegistersAViewName
()
{
View
::
name
(
'home.index'
,
'home'
);
$this
->
assertEquals
(
'home.index'
,
View
::
$names
[
'home'
]);
}
/**
* Test the View::shared method.
*
* @group laravel
*/
public
function
testSharedMethodAddsDataToSharedArray
()
{
View
::
share
(
'comment'
,
'Taylor'
);
$this
->
assertEquals
(
'Taylor'
,
View
::
$shared
[
'comment'
]);
}
/**
* Test the View::with method.
*
* @group laravel
*/
public
function
testViewDataCanBeSetUsingWithMethod
()
{
$view
=
View
::
make
(
'home.index'
)
->
with
(
'comment'
,
'Taylor'
);
$this
->
assertEquals
(
'Taylor'
,
$view
->
data
[
'comment'
]);
}
/**
* Test the View class constructor.
*
...
...
@@ -106,4 +152,31 @@ class ViewTest extends PHPUnit_Framework_TestCase {
$this
->
assertEquals
(
'Taylor'
,
$view
[
'comment'
]);
}
/**
* Test the View::nest method.
*
* @group laravel
*/
public
function
testNestMethodSetsViewInstanceInData
()
{
$view
=
View
::
make
(
'home.index'
)
->
nest
(
'partial'
,
'tests.basic'
);
$this
->
assertEquals
(
'tests.basic'
,
$view
->
data
[
'partial'
]
->
view
);
$this
->
assertInstanceOf
(
'Laravel\\View'
,
$view
->
data
[
'partial'
]);
}
/**
* Test that the registered data is passed to the view correctly.
*
* @group laravel
*/
public
function
testDataIsPassedToViewCorrectly
()
{
View
::
share
(
'name'
,
'Taylor'
);
$view
=
View
::
make
(
'tests.basic'
)
->
with
(
'age'
,
25
)
->
render
();
$this
->
assertEquals
(
'Taylor is 25'
,
$view
);
}
}
\ No newline at end of file
tests/laravel/application/views/tests/basic.php
0 → 100644
View file @
b812f2f0
<?php
echo
$name
;
?>
is
<?php
echo
$age
;
?>
\ No newline at end of file
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