Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
Silex
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
Silex
Commits
e18192f7
Commit
e18192f7
authored
Jan 03, 2013
by
Fabien Potencier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allowed to override application values via the constructor
parent
6f9cca8b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
5 deletions
+12
-5
src/Silex/Application.php
src/Silex/Application.php
+4
-2
tests/Silex/Tests/ApplicationTest.php
tests/Silex/Tests/ApplicationTest.php
+8
-3
No files found.
src/Silex/Application.php
View file @
e18192f7
...
@@ -60,8 +60,6 @@ class Application extends \Pimple implements HttpKernelInterface, TerminableInte
...
@@ -60,8 +60,6 @@ class Application extends \Pimple implements HttpKernelInterface, TerminableInte
*/
*/
public
function
__construct
(
array
$values
=
array
())
public
function
__construct
(
array
$values
=
array
())
{
{
parent
::
__construct
(
$values
);
$app
=
$this
;
$app
=
$this
;
$this
[
'logger'
]
=
null
;
$this
[
'logger'
]
=
null
;
...
@@ -143,6 +141,10 @@ class Application extends \Pimple implements HttpKernelInterface, TerminableInte
...
@@ -143,6 +141,10 @@ class Application extends \Pimple implements HttpKernelInterface, TerminableInte
$this
[
'debug'
]
=
false
;
$this
[
'debug'
]
=
false
;
$this
[
'charset'
]
=
'UTF-8'
;
$this
[
'charset'
]
=
'UTF-8'
;
$this
[
'locale'
]
=
'en'
;
$this
[
'locale'
]
=
'en'
;
foreach
(
$values
as
$key
=>
$value
)
{
$this
[
$key
]
=
$value
;
}
}
}
/**
/**
...
...
tests/Silex/Tests/ApplicationTest.php
View file @
e18192f7
...
@@ -48,12 +48,17 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
...
@@ -48,12 +48,17 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
$this
->
assertInstanceOf
(
'Silex\Controller'
,
$returnValue
);
$this
->
assertInstanceOf
(
'Silex\Controller'
,
$returnValue
);
}
}
public
function
testConstructorInjection
()
public
function
testConstructorInjection
()
{
{
$params
=
array
(
"param"
=>
"value"
);
// inject a custom parameter
$params
=
array
(
'param'
=>
'value'
);
$app
=
new
Application
(
$params
);
$app
=
new
Application
(
$params
);
$this
->
assertSame
(
$params
[
'param'
],
$app
[
'param'
]);
$this
->
assertSame
(
$params
[
'param'
],
$app
[
'param'
]);
// inject an existing parameter
$params
=
array
(
'locale'
=>
'value'
);
$app
=
new
Application
(
$params
);
$this
->
assertSame
(
$params
[
'locale'
],
$app
[
'locale'
]);
}
}
public
function
testGetRequest
()
public
function
testGetRequest
()
...
...
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