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
974ff302
Commit
974ff302
authored
Jan 25, 2012
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding some view tests and fixing a few bugs.
parent
c9eb7bdf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
10 deletions
+67
-10
session.php
laravel/session.php
+5
-5
view.php
laravel/view.php
+9
-5
view.test.php
tests/cases/laravel/view.test.php
+53
-0
No files found.
laravel/session.php
View file @
974ff302
<?php
namespace
Laravel
;
<?php
namespace
Laravel
;
if
(
Config
::
get
(
'application.key'
)
===
''
)
{
throw
new
\Exception
(
"An application key is required to use sessions."
);
}
class
Session
{
class
Session
{
/**
/**
...
@@ -29,6 +24,11 @@ class Session {
...
@@ -29,6 +24,11 @@ class Session {
*/
*/
public
static
function
start
(
$driver
)
public
static
function
start
(
$driver
)
{
{
if
(
Config
::
get
(
'application.key'
)
===
''
)
{
throw
new
\Exception
(
"An application key is required to use sessions."
);
}
static
::
$instance
=
new
Session\Payload
(
static
::
factory
(
$driver
));
static
::
$instance
=
new
Session\Payload
(
static
::
factory
(
$driver
));
}
}
...
...
laravel/view.php
View file @
974ff302
...
@@ -21,7 +21,7 @@ class View implements ArrayAccess {
...
@@ -21,7 +21,7 @@ class View implements ArrayAccess {
*
*
* @var string
* @var string
*/
*/
p
rotected
$path
;
p
ublic
$path
;
/**
/**
* All of the shared view data.
* All of the shared view data.
...
@@ -68,12 +68,16 @@ class View implements ArrayAccess {
...
@@ -68,12 +68,16 @@ class View implements ArrayAccess {
// This makes error display in the view extremely convenient, since the
// This makes error display in the view extremely convenient, since the
// developer can always assume they have a message container instance
// developer can always assume they have a message container instance
// available to them in the view.
// available to them in the view.
if
(
Config
::
get
(
'session.driver'
)
!==
''
and
Session
::
started
()
and
!
isset
(
$this
[
'errors'
]))
if
(
!
isset
(
$this
->
data
[
'errors'
]))
{
{
$this
->
data
[
'errors'
]
=
Session
::
get
(
'errors'
,
function
(
)
if
(
Session
::
started
()
and
Session
::
has
(
'errors'
)
)
{
{
return
new
Messages
;
$this
->
data
[
'errors'
]
=
Session
::
get
(
'errors'
);
});
}
else
{
$this
->
data
[
'errors'
]
=
new
Messages
;
}
}
}
}
}
...
...
tests/cases/laravel/view.test.php
0 → 100644
View file @
974ff302
<?php
class
ViewTest
extends
PHPUnit_Framework_TestCase
{
/**
* Test the View class constructor.
*
* @group laravel
*/
public
function
testViewNameIsSetByConstrutor
()
{
$view
=
new
View
(
'home.index'
);
$this
->
assertEquals
(
'home.index'
,
$view
->
view
);
}
/**
* Test the View class constructor.
*
* @group laravel
*/
public
function
testViewIsCreatedWithCorrectPath
()
{
$view
=
new
View
(
'home.index'
);
$this
->
assertEquals
(
APP_PATH
.
'views/home/index.php'
,
$view
->
path
);
}
/**
* Test the View class constructor.
*
* @group laravel
*/
public
function
testDataIsSetOnViewByConstructor
()
{
$view
=
new
View
(
'home.index'
,
array
(
'name'
=>
'Taylor'
));
$this
->
assertEquals
(
'Taylor'
,
$view
->
data
[
'name'
]);
}
/**
* Test the View class constructor.
*
* @group laravel
*/
public
function
testEmptyMessageContainerSetOnViewWhenNoErrorsInSession
()
{
$view
=
new
View
(
'home.index'
);
$this
->
assertInstanceOf
(
'Laravel\\Messages'
,
$view
->
data
[
'errors'
]);
}
}
\ 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