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
dace3d50
Commit
dace3d50
authored
Nov 05, 2012
by
crynobone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add additional tests
Signed-off-by:
crynobone
<
crynobone@gmail.com
>
parent
915becdb
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
19 deletions
+28
-19
blade.test.php
laravel/tests/cases/blade.test.php
+28
-19
No files found.
laravel/tests/cases/blade.test.php
View file @
dace3d50
...
@@ -41,24 +41,28 @@ class BladeTest extends PHPUnit_Framework_TestCase {
...
@@ -41,24 +41,28 @@ class BladeTest extends PHPUnit_Framework_TestCase {
{
{
$blade1
=
"@if (true)
\n
foo
\n
@endif"
;
$blade1
=
"@if (true)
\n
foo
\n
@endif"
;
$blade2
=
"@if (count("
.
'$something'
.
") > 0)
\n
foo
\n
@endif"
;
$blade2
=
"@if (count("
.
'$something'
.
") > 0)
\n
foo
\n
@endif"
;
$blade3
=
"@if (true)
\n
foo
\n
@elseif (false)
\n
bar
\n
@endif"
;
$blade3
=
"@if (true)
\n
foo
\n
@elseif (false)
\n
bar
\n
@else
\n
foobar
\n
@endif"
;
$blade4
=
"@if (true)
\n
foo
\n
@else
\n
bar
\n
@endif"
;
$blade4
=
"@if (true)
\n
foo
\n
@elseif (false)
\n
bar
\n
@endif"
;
$blade5
=
"@unless (count("
.
'$something'
.
") > 0)
\n
foobar
\n
@endunless"
;
$blade5
=
"@if (true)
\n
foo
\n
@else
\n
bar
\n
@endif"
;
$blade6
=
"@for (Foo::all() as "
.
'$foo'
.
")
\n
foo
\n
@endfor"
;
$blade6
=
"@unless (count("
.
'$something'
.
") > 0)
\n
foobar
\n
@endunless"
;
$blade7
=
"@foreach (Foo::all() as "
.
'$foo'
.
")
\n
foo
\n
@endforeach"
;
$blade7
=
"@for (Foo::all() as "
.
'$foo'
.
")
\n
foo
\n
@endfor"
;
$blade8
=
"@forelse (Foo::all() as "
.
'$foo'
.
")
\n
foo
\n
@empty
\n
bar
\n
@endforelse"
;
$blade8
=
"@foreach (Foo::all() as "
.
'$foo'
.
")
\n
foo
\n
@endforeach"
;
$blade9
=
"@while (true)
\n
foo
\n
@endwhile"
;
$blade9
=
"@forelse (Foo::all() as "
.
'$foo'
.
")
\n
foo
\n
@empty
\n
bar
\n
@endforelse"
;
$blade10
=
"@while (true)
\n
foo
\n
@endwhile"
;
$blade11
=
"@while (Foo::bar())
\n
foo
\n
@endwhile"
;
$this
->
assertEquals
(
"<?php if (true): ?>
\n
foo
\n
<?php endif; ?>"
,
Blade
::
compile_string
(
$blade1
));
$this
->
assertEquals
(
"<?php if (true): ?>
\n
foo
\n
<?php endif; ?>"
,
Blade
::
compile_string
(
$blade1
));
$this
->
assertEquals
(
"<?php if (count("
.
'$something'
.
") > 0): ?>
\n
foo
\n
<?php endif; ?>"
,
Blade
::
compile_string
(
$blade2
));
$this
->
assertEquals
(
"<?php if (count("
.
'$something'
.
") > 0): ?>
\n
foo
\n
<?php endif; ?>"
,
Blade
::
compile_string
(
$blade2
));
$this
->
assertEquals
(
"<?php if (true): ?>
\n
foo
\n
<?php elseif (false): ?>
\n
bar
\n
<?php endif; ?>"
,
Blade
::
compile_string
(
$blade3
));
$this
->
assertEquals
(
"<?php if (true): ?>
\n
foo
\n
<?php elseif (false): ?>
\n
bar
\n
<?php else: ?>
\n
foobar
\n
<?php endif; ?>"
,
Blade
::
compile_string
(
$blade3
));
$this
->
assertEquals
(
"<?php if (true): ?>
\n
foo
\n
<?php else: ?>
\n
bar
\n
<?php endif; ?>"
,
Blade
::
compile_string
(
$blade4
));
$this
->
assertEquals
(
"<?php if (true): ?>
\n
foo
\n
<?php elseif (false): ?>
\n
bar
\n
<?php endif; ?>"
,
Blade
::
compile_string
(
$blade4
));
$this
->
assertEquals
(
"<?php if ( ! ( (count("
.
'$something'
.
") > 0))): ?>
\n
foobar
\n
<?php endif; ?>"
,
Blade
::
compile_string
(
$blade5
));
$this
->
assertEquals
(
"<?php if (true): ?>
\n
foo
\n
<?php else: ?>
\n
bar
\n
<?php endif; ?>"
,
Blade
::
compile_string
(
$blade5
));
$this
->
assertEquals
(
"<?php for (Foo::all() as "
.
'$foo'
.
"): ?>
\n
foo
\n
<?php endfor; ?>"
,
Blade
::
compile_string
(
$blade6
));
$this
->
assertEquals
(
"<?php if ( ! ( (count("
.
'$something'
.
") > 0))): ?>
\n
foobar
\n
<?php endif; ?>"
,
Blade
::
compile_string
(
$blade6
));
$this
->
assertEquals
(
"<?php foreach (Foo::all() as "
.
'$foo'
.
"): ?>
\n
foo
\n
<?php endforeach; ?>"
,
Blade
::
compile_string
(
$blade7
));
$this
->
assertEquals
(
"<?php for (Foo::all() as "
.
'$foo'
.
"): ?>
\n
foo
\n
<?php endfor; ?>"
,
Blade
::
compile_string
(
$blade7
));
$this
->
assertEquals
(
"<?php if (count(Foo::all()) > 0): ?><?php foreach (Foo::all() as "
.
'$foo'
.
"): ?>
\n
foo
\n
<?php endforeach; ?><?php else: ?>
\n
bar
\n
<?php endif; ?>"
,
Blade
::
compile_string
(
$blade8
));
$this
->
assertEquals
(
"<?php foreach (Foo::all() as "
.
'$foo'
.
"): ?>
\n
foo
\n
<?php endforeach; ?>"
,
Blade
::
compile_string
(
$blade8
));
$this
->
assertEquals
(
"<?php while (true): ?>
\n
foo
\n
<?php endwhile; ?>"
,
Blade
::
compile_string
(
$blade9
));
$this
->
assertEquals
(
"<?php if (count(Foo::all()) > 0): ?><?php foreach (Foo::all() as "
.
'$foo'
.
"): ?>
\n
foo
\n
<?php endforeach; ?><?php else: ?>
\n
bar
\n
<?php endif; ?>"
,
Blade
::
compile_string
(
$blade9
));
$this
->
assertEquals
(
"<?php while (true): ?>
\n
foo
\n
<?php endwhile; ?>"
,
Blade
::
compile_string
(
$blade10
));
$this
->
assertEquals
(
"<?php while (Foo::bar()): ?>
\n
foo
\n
<?php endwhile; ?>"
,
Blade
::
compile_string
(
$blade11
));
}
}
/**
/**
...
@@ -92,9 +96,11 @@ class BladeTest extends PHPUnit_Framework_TestCase {
...
@@ -92,9 +96,11 @@ class BladeTest extends PHPUnit_Framework_TestCase {
*/
*/
public
function
testIncludesAreCompiledCorrectly
()
public
function
testIncludesAreCompiledCorrectly
()
{
{
$blade
=
"@include('user.profile')"
;
$blade1
=
"@include('user.profile')"
;
$blade2
=
"@include(Config::get('application.default_view', 'user.profile'))"
;
$this
->
assertEquals
(
"<?php echo view('user.profile')->with(get_defined_vars())->render(); ?>"
,
Blade
::
compile_string
(
$blade
));
$this
->
assertEquals
(
"<?php echo view('user.profile')->with(get_defined_vars())->render(); ?>"
,
Blade
::
compile_string
(
$blade1
));
$this
->
assertEquals
(
"<?php echo view(Config::get('application.default_view', 'user.profile'))->with(get_defined_vars())->render(); ?>"
,
Blade
::
compile_string
(
$blade2
));
}
}
/**
/**
...
@@ -104,9 +110,12 @@ class BladeTest extends PHPUnit_Framework_TestCase {
...
@@ -104,9 +110,12 @@ class BladeTest extends PHPUnit_Framework_TestCase {
*/
*/
public
function
testRendersAreCompiledCorrectly
()
public
function
testRendersAreCompiledCorrectly
()
{
{
$blade
=
"@render('user.profile')"
;
$blade1
=
"@render('user.profile')"
;
$blade2
=
"@render(Config::get('application.default_view', 'user.profile'))"
;
$this
->
assertEquals
(
"<?php echo render('user.profile'); ?>"
,
Blade
::
compile_string
(
$blade1
));
$this
->
assertEquals
(
"<?php echo render(Config::get('application.default_view', 'user.profile')); ?>"
,
Blade
::
compile_string
(
$blade2
));
$this
->
assertEquals
(
"<?php echo render('user.profile'); ?>"
,
Blade
::
compile_string
(
$blade
));
}
}
}
}
\ 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