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
cb3fd7d5
Commit
cb3fd7d5
authored
Jun 30, 2012
by
l3l0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed in phpunit.xml.dist and added testsfor lazy url matcher
parent
4b6c46ee
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
114 additions
and
0 deletions
+114
-0
phpunit.xml.dist
phpunit.xml.dist
+5
-0
tests/Silex/Tests/LazyUrlMatcherTest.php
tests/Silex/Tests/LazyUrlMatcherTest.php
+109
-0
No files found.
phpunit.xml.dist
View file @
cb3fd7d5
...
...
@@ -16,4 +16,9 @@
<directory>
./tests/Silex/
</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>
./src
</directory>
</whitelist>
</filter>
</phpunit>
tests/Silex/Tests/LazyUrlMatcherTest.php
0 → 100644
View file @
cb3fd7d5
<?php
/*
* This file is part of the Silex framework.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace
Silex\Tests
;
use
Silex\LazyUrlMatcher
;
/**
* LazyUrlMatcher test cases.
*
* @author Leszek Prabucki <leszek.prabucki@gmail.com>
*/
class
LazyUrlMatcherTest
extends
\PHPUnit_Framework_TestCase
{
/**
* @covers Silex\LazyUrlMatcher::getUrlMatcher
*/
public
function
testUserMatcherIsCreatedLazily
()
{
$callCounter
=
0
;
$urlMatcher
=
$this
->
getMock
(
'Symfony\Component\Routing\Matcher\UrlMatcherInterface'
);
$matcher
=
new
LazyUrlMatcher
(
function
()
use
(
$urlMatcher
,
&
$callCounter
)
{
$callCounter
++
;
return
$urlMatcher
;
});
$this
->
assertEquals
(
0
,
$callCounter
);
$matcher
->
match
(
'path'
);
$this
->
assertEquals
(
1
,
$callCounter
);
}
/**
* @expectedException LogicException
* @expectedExceptionMessage Factory supplied to LazyUrlMatcher must return implementation of UrlMatcherInterface.
*/
public
function
testThatCanInjectUrlMatcherOnly
()
{
$matcher
=
new
LazyUrlMatcher
(
function
()
{
return
'someMatcher'
;
});
$matcher
->
match
(
'path'
);
}
/**
* @covers Silex\LazyUrlMatcher::match
*/
public
function
testMatchIsProxy
()
{
$urlMatcher
=
$this
->
getMock
(
'Symfony\Component\Routing\Matcher\UrlMatcherInterface'
);
$urlMatcher
->
expects
(
$this
->
once
())
->
method
(
'match'
)
->
with
(
'path'
)
->
will
(
$this
->
returnValue
(
'matcherReturnValue'
));
$matcher
=
new
LazyUrlMatcher
(
function
()
use
(
$urlMatcher
)
{
return
$urlMatcher
;
});
$result
=
$matcher
->
match
(
'path'
);
$this
->
assertEquals
(
'matcherReturnValue'
,
$result
);
}
/**
* @covers Silex\LazyUrlMatcher::setContext
*/
public
function
testSetContextIsProxy
()
{
$context
=
$this
->
getMock
(
'Symfony\Component\Routing\RequestContext'
);
$urlMatcher
=
$this
->
getMock
(
'Symfony\Component\Routing\Matcher\UrlMatcherInterface'
);
$urlMatcher
->
expects
(
$this
->
once
())
->
method
(
'setContext'
)
->
with
(
$context
);
$matcher
=
new
LazyUrlMatcher
(
function
()
use
(
$urlMatcher
)
{
return
$urlMatcher
;
});
$result
=
$matcher
->
setContext
(
$context
);
}
/**
* @covers Silex\LazyUrlMatcher::getContext
*/
public
function
testGetContextIsProxy
()
{
$context
=
$this
->
getMock
(
'Symfony\Component\Routing\RequestContext'
);
$urlMatcher
=
$this
->
getMock
(
'Symfony\Component\Routing\Matcher\UrlMatcherInterface'
);
$urlMatcher
->
expects
(
$this
->
once
())
->
method
(
'getContext'
)
->
will
(
$this
->
returnValue
(
$context
));
$matcher
=
new
LazyUrlMatcher
(
function
()
use
(
$urlMatcher
)
{
return
$urlMatcher
;
});
$resultContext
=
$matcher
->
getContext
();
$this
->
assertSame
(
$resultContext
,
$context
);
}
}
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