diff options
author | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2013-08-03 19:26:54 +0200 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2013-08-03 19:26:54 +0200 |
commit | 4f5b44bd3bd490309eb2ba7b44df4769816ba729 (patch) | |
tree | 6cefe170dfe0a5a361cb1e2d1fc4d580a3316d02 /vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/TraceableUrlMatcherTest.php | |
parent | 2b840e0cfb63a453bea67a98541f3df9c273c5f5 (diff) | |
download | wallabag-4f5b44bd3bd490309eb2ba7b44df4769816ba729.tar.gz wallabag-4f5b44bd3bd490309eb2ba7b44df4769816ba729.tar.zst wallabag-4f5b44bd3bd490309eb2ba7b44df4769816ba729.zip |
twig implementation
Diffstat (limited to 'vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/TraceableUrlMatcherTest.php')
-rw-r--r-- | vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/TraceableUrlMatcherTest.php | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/TraceableUrlMatcherTest.php b/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/TraceableUrlMatcherTest.php new file mode 100644 index 00000000..86d8d954 --- /dev/null +++ b/vendor/symfony/routing/Symfony/Component/Routing/Tests/Matcher/TraceableUrlMatcherTest.php | |||
@@ -0,0 +1,66 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Routing\Tests\Matcher; | ||
13 | |||
14 | use Symfony\Component\Routing\Route; | ||
15 | use Symfony\Component\Routing\RouteCollection; | ||
16 | use Symfony\Component\Routing\RequestContext; | ||
17 | use Symfony\Component\Routing\Matcher\TraceableUrlMatcher; | ||
18 | |||
19 | class TraceableUrlMatcherTest extends \PHPUnit_Framework_TestCase | ||
20 | { | ||
21 | public function test() | ||
22 | { | ||
23 | $coll = new RouteCollection(); | ||
24 | $coll->add('foo', new Route('/foo', array(), array('_method' => 'POST'))); | ||
25 | $coll->add('bar', new Route('/bar/{id}', array(), array('id' => '\d+'))); | ||
26 | $coll->add('bar1', new Route('/bar/{name}', array(), array('id' => '\w+', '_method' => 'POST'))); | ||
27 | $coll->add('bar2', new Route('/foo', array(), array(), array(), 'baz')); | ||
28 | $coll->add('bar3', new Route('/foo1', array(), array(), array(), 'baz')); | ||
29 | |||
30 | $context = new RequestContext(); | ||
31 | $context->setHost('baz'); | ||
32 | |||
33 | $matcher = new TraceableUrlMatcher($coll, $context); | ||
34 | $traces = $matcher->getTraces('/babar'); | ||
35 | $this->assertEquals(array(0, 0, 0, 0, 0), $this->getLevels($traces)); | ||
36 | |||
37 | $traces = $matcher->getTraces('/foo'); | ||
38 | $this->assertEquals(array(1, 0, 0, 2), $this->getLevels($traces)); | ||
39 | |||
40 | $traces = $matcher->getTraces('/bar/12'); | ||
41 | $this->assertEquals(array(0, 2), $this->getLevels($traces)); | ||
42 | |||
43 | $traces = $matcher->getTraces('/bar/dd'); | ||
44 | $this->assertEquals(array(0, 1, 1, 0, 0), $this->getLevels($traces)); | ||
45 | |||
46 | $traces = $matcher->getTraces('/foo1'); | ||
47 | $this->assertEquals(array(0, 0, 0, 0, 2), $this->getLevels($traces)); | ||
48 | |||
49 | $context->setMethod('POST'); | ||
50 | $traces = $matcher->getTraces('/foo'); | ||
51 | $this->assertEquals(array(2), $this->getLevels($traces)); | ||
52 | |||
53 | $traces = $matcher->getTraces('/bar/dd'); | ||
54 | $this->assertEquals(array(0, 1, 2), $this->getLevels($traces)); | ||
55 | } | ||
56 | |||
57 | public function getLevels($traces) | ||
58 | { | ||
59 | $levels = array(); | ||
60 | foreach ($traces as $trace) { | ||
61 | $levels[] = $trace['level']; | ||
62 | } | ||
63 | |||
64 | return $levels; | ||
65 | } | ||
66 | } | ||