Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pquery
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Taddeüs Kroes
pquery
Commits
7394bf50
Commit
7394bf50
authored
13 years ago
by
Taddeus Kroes
Browse files
Options
Downloads
Patches
Plain Diff
Forgot to add tests file in previous commit...
parent
7f57b354
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/url.php
+73
-0
73 additions, 0 deletions
tests/url.php
with
73 additions
and
0 deletions
tests/url.php
0 → 100644
+
73
−
0
View file @
7394bf50
<?php
include_once
'config.php'
;
__p
::
require_plugins
(
'url'
);
class
pQueryUrlTest
extends
PHPUnit_Framework_TestCase
{
function
setUp
()
{
$this
->
url
=
_url
(
'foo/bar'
);
}
function
tearDown
()
{
__url
::
$handlers
=
array
();
}
function
test_constructor
()
{
$this
->
assertInstanceOf
(
'pQueryUrl'
,
$this
->
url
,
'constructor does not return pQueryUrl object'
);
}
function
test_parse_url
()
{
$this
->
assertEquals
(
'foo/bar'
,
_url
(
'/foo/bar'
)
->
url
);
$this
->
assertEquals
(
'foo/bar'
,
_url
(
'foo/bar/'
)
->
url
);
}
function
test_add_handler_callable
()
{
$handler
=
create_function
(
'$a'
,
'return true;'
);
__url
::
add_handler
(
'foo/.*'
,
$handler
);
$this
->
assertArrayHasKey
(
'%foo/.*%'
,
__url
::
$handlers
);
$this
->
assertEquals
(
$handler
,
__url
::
$handlers
[
'%foo/.*%'
]);
}
/**
* @expectedException pQueryException
*/
function
test_add_handler_not_callable
()
{
__url
::
add_handler
(
'foo/.*'
,
'bar'
);
}
/**
* @depends test_add_handler_callable
*/
function
test_add_handlers
()
{
$handler1
=
create_function
(
'$a'
,
'return true;'
);
$handler2
=
create_function
(
'$a'
,
'return false;'
);
__url
::
add_handlers
(
array
(
'foo/.*'
=>
$handler1
,
'bar/.*'
=>
$handler2
));
$this
->
assertArrayHasKey
(
'%foo/.*%'
,
__url
::
$handlers
);
$this
->
assertArrayHasKey
(
'%bar/.*%'
,
__url
::
$handlers
);
$this
->
assertEquals
(
$handler1
,
__url
::
$handlers
[
'%foo/.*%'
]);
$this
->
assertEquals
(
$handler2
,
__url
::
$handlers
[
'%bar/.*%'
]);
}
/**
* @depends test_add_handler_callable
*/
function
test_handler
()
{
$handler
=
create_function
(
'$a'
,
'return $a;'
);
__url
::
add_handler
(
'foo/(.*)'
,
$handler
);
$result
=
$this
->
url
->
handler
();
$this
->
assertEquals
(
'bar'
,
$result
);
}
/**
* @depends test_handler
* @expectedException pQueryException
*/
function
test_handler_error
()
{
$this
->
url
->
handler
();
}
}
?>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment