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
11fda10c
Commit
11fda10c
authored
Jan 21, 2013
by
Jérémy Romey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated Application register and mount methods to return Application
parent
ca7e2dc4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
0 deletions
+27
-0
src/Silex/Application.php
src/Silex/Application.php
+8
-0
tests/Silex/Tests/ApplicationTest.php
tests/Silex/Tests/ApplicationTest.php
+19
-0
No files found.
src/Silex/Application.php
View file @
11fda10c
...
...
@@ -154,6 +154,8 @@ class Application extends \Pimple implements HttpKernelInterface, TerminableInte
*
* @param ServiceProviderInterface $provider A ServiceProviderInterface instance
* @param array $values An array of values that customizes the provider
*
* @return Application
*/
public
function
register
(
ServiceProviderInterface
$provider
,
array
$values
=
array
())
{
...
...
@@ -164,6 +166,8 @@ class Application extends \Pimple implements HttpKernelInterface, TerminableInte
foreach
(
$values
as
$key
=>
$value
)
{
$this
[
$key
]
=
$value
;
}
return
$this
;
}
/**
...
...
@@ -428,6 +432,8 @@ class Application extends \Pimple implements HttpKernelInterface, TerminableInte
*
* @param string $prefix The route prefix
* @param ControllerCollection|ControllerProviderInterface $controllers A ControllerCollection or a ControllerProviderInterface instance
*
* @return Application
*/
public
function
mount
(
$prefix
,
$controllers
)
{
...
...
@@ -440,6 +446,8 @@ class Application extends \Pimple implements HttpKernelInterface, TerminableInte
}
$this
[
'routes'
]
->
addCollection
(
$controllers
->
flush
(
$prefix
),
$prefix
);
return
$this
;
}
/**
...
...
tests/Silex/Tests/ApplicationTest.php
View file @
11fda10c
...
...
@@ -12,6 +12,8 @@
namespace
Silex\Tests
;
use
Silex\Application
;
use
Silex\ControllerCollection
;
use
Silex\Route
;
use
Symfony\Component\HttpFoundation\Request
;
use
Symfony\Component\HttpKernel\Exception\HttpException
;
...
...
@@ -468,6 +470,23 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
$this
->
assertEquals
(
'foo /'
,
$app
->
handle
(
$mainRequest
)
->
getContent
());
}
public
function
testRegisterShouldReturnSelf
()
{
$app
=
new
Application
();
$provider
=
$this
->
getMock
(
'Silex\ServiceProviderInterface'
);
$this
->
assertSame
(
$app
,
$app
->
register
(
$provider
));
}
public
function
testMountShouldReturnSelf
()
{
$app
=
new
Application
();
$mounted
=
new
ControllerCollection
(
new
Route
());
$mounted
->
get
(
'/{name}'
,
function
(
$name
)
{
return
new
Response
(
$name
);
});
$this
->
assertSame
(
$app
,
$app
->
mount
(
'/hello'
,
$mounted
));
}
}
class
FooController
...
...
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