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
d6e21a41
Commit
d6e21a41
authored
Jan 27, 2012
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding routing tests.
parent
f93532d2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
71 additions
and
0 deletions
+71
-0
routing.test.php
tests/cases/laravel/routing.test.php
+71
-0
No files found.
tests/cases/laravel/routing.test.php
0 → 100644
View file @
d6e21a41
<?php
use
Laravel\Routing\Router
;
class
RoutingTest
extends
PHPUnit_Framework_TestCase
{
/**
* Destroy the testing environment.
*/
public
function
tearDown
()
{
Router
::
$names
=
array
();
Router
::
$routes
=
array
();
}
/**
* Test the basic routing mechanism.
*
* @group laravel
*/
public
function
testBasicRouteCanBeRouted
()
{
Router
::
register
(
'GET /'
,
function
()
{});
Router
::
register
(
'GET /home'
,
function
()
{});
$this
->
assertEquals
(
'GET /'
,
Router
::
route
(
'GET'
,
'/'
)
->
key
);
$this
->
assertEquals
(
'GET /home'
,
Router
::
route
(
'GET'
,
'/home'
)
->
key
);
}
/**
* Test that the router can handle basic wildcards.
*
* @group laravel
*/
public
function
testWildcardRoutesCanBeRouted
()
{
Router
::
register
(
'GET /user/(:num)'
,
function
()
{});
Router
::
register
(
'GET /profile/(:any)/(:num)'
,
function
()
{});
$this
->
assertNull
(
Router
::
route
(
'GET'
,
'user/1.5'
));
$this
->
assertNull
(
Router
::
route
(
'GET'
,
'user/taylor'
));
$this
->
assertEquals
(
'GET /user/(:num)'
,
Router
::
route
(
'GET'
,
'user/1'
)
->
key
);
$this
->
assertNull
(
Router
::
route
(
'GET'
,
'profile/1/otwell'
));
$this
->
assertNull
(
Router
::
route
(
'POST'
,
'profile/taylor/1'
));
$this
->
assertNull
(
Router
::
route
(
'GET'
,
'profile/taylor/otwell'
));
$this
->
assertNull
(
Router
::
route
(
'GET'
,
'profile/taylor/1/otwell'
));
$this
->
assertEquals
(
'GET /profile/(:any)/(:num)'
,
Router
::
route
(
'GET'
,
'profile/taylor/1'
)
->
key
);
}
/**
* Test that optional wildcards can be routed.
*
* @group laravel
*/
public
function
testOptionalWildcardsCanBeRouted
()
{
Router
::
register
(
'GET /user/(:num?)'
,
function
()
{});
Router
::
register
(
'GET /profile/(:any)/(:any?)'
,
function
()
{});
$this
->
assertNull
(
Router
::
route
(
'GET'
,
'user/taylor'
));
$this
->
assertEquals
(
'GET /user/(:num?)'
,
Router
::
route
(
'GET'
,
'user'
)
->
key
);
$this
->
assertEquals
(
'GET /user/(:num?)'
,
Router
::
route
(
'GET'
,
'user/1'
)
->
key
);
$this
->
assertNull
(
Router
::
route
(
'GET'
,
'profile/taylor/otwell/test'
));
$this
->
assertEquals
(
'GET /profile/(:any)/(:any?)'
,
Router
::
route
(
'GET'
,
'profile/taylor'
)
->
key
);
$this
->
assertEquals
(
'GET /profile/(:any)/(:any?)'
,
Router
::
route
(
'GET'
,
'profile/taylor/25'
)
->
key
);
$this
->
assertEquals
(
'GET /profile/(:any)/(:any?)'
,
Router
::
route
(
'GET'
,
'profile/taylor/otwell'
)
->
key
);
}
}
\ 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