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
f11cb433
Commit
f11cb433
authored
Mar 27, 2011
by
Fabien Potencier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
renamed setRouteName() to bind()
parent
be04c437
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
14 deletions
+14
-14
src/Silex/Controller.php
src/Silex/Controller.php
+2
-2
tests/Silex/Tests/ControllerCollectionTest.php
tests/Silex/Tests/ControllerCollectionTest.php
+4
-4
tests/Silex/Tests/ControllerTest.php
tests/Silex/Tests/ControllerTest.php
+5
-5
tests/Silex/Tests/FunctionalTest.php
tests/Silex/Tests/FunctionalTest.php
+3
-3
No files found.
src/Silex/Controller.php
View file @
f11cb433
...
@@ -33,7 +33,7 @@ class Controller
...
@@ -33,7 +33,7 @@ class Controller
public
function
__construct
(
Route
$route
)
public
function
__construct
(
Route
$route
)
{
{
$this
->
route
=
$route
;
$this
->
route
=
$route
;
$this
->
setRouteName
(
$this
->
defaultRouteName
());
$this
->
bind
(
$this
->
defaultRouteName
());
}
}
/**
/**
...
@@ -57,7 +57,7 @@ class Controller
...
@@ -57,7 +57,7 @@ class Controller
*
*
* @param string $routeName
* @param string $routeName
*/
*/
public
function
setRouteName
(
$routeName
)
public
function
bind
(
$routeName
)
{
{
if
(
$this
->
isFrozen
)
{
if
(
$this
->
isFrozen
)
{
throw
new
ControllerFrozenException
(
sprintf
(
'Calling %s on frozen %s instance.'
,
__METHOD__
,
__CLASS__
));
throw
new
ControllerFrozenException
(
sprintf
(
'Calling %s on frozen %s instance.'
,
__METHOD__
,
__CLASS__
));
...
...
tests/Silex/Tests/ControllerCollectionTest.php
View file @
f11cb433
...
@@ -54,23 +54,23 @@ class ControllerCollectionTest extends \PHPUnit_Framework_TestCase
...
@@ -54,23 +54,23 @@ class ControllerCollectionTest extends \PHPUnit_Framework_TestCase
$controllers
=
new
ControllerCollection
(
$routes
);
$controllers
=
new
ControllerCollection
(
$routes
);
$fooController
=
new
Controller
(
new
Route
(
'/foo'
));
$fooController
=
new
Controller
(
new
Route
(
'/foo'
));
$fooController
->
setRouteName
(
'foo'
);
$fooController
->
bind
(
'foo'
);
$controllers
->
add
(
$fooController
);
$controllers
->
add
(
$fooController
);
$barController
=
new
Controller
(
new
Route
(
'/bar'
));
$barController
=
new
Controller
(
new
Route
(
'/bar'
));
$barController
->
setRouteName
(
'bar'
);
$barController
->
bind
(
'bar'
);
$controllers
->
add
(
$barController
);
$controllers
->
add
(
$barController
);
$controllers
->
flush
();
$controllers
->
flush
();
try
{
try
{
$fooController
->
setRouteName
(
'foo2'
);
$fooController
->
bind
(
'foo2'
);
$this
->
fail
();
$this
->
fail
();
}
catch
(
ControllerFrozenException
$e
)
{
}
catch
(
ControllerFrozenException
$e
)
{
}
}
try
{
try
{
$barController
->
setRouteName
(
'bar2'
);
$barController
->
bind
(
'bar2'
);
$this
->
fail
();
$this
->
fail
();
}
catch
(
ControllerFrozenException
$e
)
{
}
catch
(
ControllerFrozenException
$e
)
{
}
}
...
...
tests/Silex/Tests/ControllerTest.php
View file @
f11cb433
...
@@ -21,21 +21,21 @@ use Symfony\Component\Routing\Route;
...
@@ -21,21 +21,21 @@ use Symfony\Component\Routing\Route;
*/
*/
class
ControllerTest
extends
\PHPUnit_Framework_TestCase
class
ControllerTest
extends
\PHPUnit_Framework_TestCase
{
{
public
function
test
SetRouteName
()
public
function
test
Bind
()
{
{
$controller
=
new
Controller
(
new
Route
(
'/foo'
));
$controller
=
new
Controller
(
new
Route
(
'/foo'
));
$controller
->
setRouteName
(
'foo'
);
$controller
->
bind
(
'foo'
);
$this
->
assertEquals
(
'foo'
,
$controller
->
getRouteName
());
$this
->
assertEquals
(
'foo'
,
$controller
->
getRouteName
());
}
}
/**
/**
* @expectedException Silex\Exception\ControllerFrozenException
* @expectedException Silex\Exception\ControllerFrozenException
*/
*/
public
function
test
SetRouteName
OnFrozenControllerShouldThrowException
()
public
function
test
Bind
OnFrozenControllerShouldThrowException
()
{
{
$controller
=
new
Controller
(
new
Route
(
'/foo'
));
$controller
=
new
Controller
(
new
Route
(
'/foo'
));
$controller
->
setRouteName
(
'foo'
);
$controller
->
bind
(
'foo'
);
$controller
->
freeze
();
$controller
->
freeze
();
$controller
->
setRouteName
(
'bar'
);
$controller
->
bind
(
'bar'
);
}
}
}
}
tests/Silex/Tests/FunctionalTest.php
View file @
f11cb433
...
@@ -20,19 +20,19 @@ use Silex\Application;
...
@@ -20,19 +20,19 @@ use Silex\Application;
*/
*/
class
FunctionalTest
extends
\PHPUnit_Framework_TestCase
class
FunctionalTest
extends
\PHPUnit_Framework_TestCase
{
{
public
function
test
SetRouteName
()
public
function
test
Bind
()
{
{
$application
=
new
Application
();
$application
=
new
Application
();
$application
->
get
(
'/'
,
function
()
{
$application
->
get
(
'/'
,
function
()
{
return
'hello'
;
return
'hello'
;
})
})
->
setRouteName
(
'homepage'
);
->
bind
(
'homepage'
);
$application
->
get
(
'/foo'
,
function
()
{
$application
->
get
(
'/foo'
,
function
()
{
return
'foo'
;
return
'foo'
;
})
})
->
setRouteName
(
'foo_abc'
);
->
bind
(
'foo_abc'
);
$application
->
flush
();
$application
->
flush
();
$routes
=
$application
[
'routes'
];
$routes
=
$application
[
'routes'
];
...
...
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