Backup of db before drupal security update
[yaffs-website] / vendor / symfony-cmf / routing / Tests / Candidates / CandidatesTest.php
1 <?php
2
3 /*
4  * This file is part of the Symfony CMF package.
5  *
6  * (c) 2011-2015 Symfony CMF
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\Cmf\Component\Routing\Tests\Candidates;
13
14 use Symfony\Cmf\Component\Routing\Candidates\Candidates;
15 use Symfony\Component\HttpFoundation\Request;
16
17 class CandidatesTest extends \PHPUnit_Framework_Testcase
18 {
19     /**
20      * Everything is a candidate.
21      */
22     public function testIsCandidate()
23     {
24         $candidates = new Candidates();
25         $this->assertTrue($candidates->isCandidate('/routes'));
26         $this->assertTrue($candidates->isCandidate('/routes/my/path'));
27     }
28
29     /**
30      * Nothing should be called on the query builder.
31      */
32     public function testRestrictQuery()
33     {
34         $candidates = new Candidates();
35         $candidates->restrictQuery(null);
36     }
37
38     public function testGetCandidates()
39     {
40         $request = Request::create('/my/path.html');
41
42         $candidates = new Candidates();
43         $paths = $candidates->getCandidates($request);
44
45         $this->assertEquals(
46             array(
47                 '/my/path.html',
48                 '/my/path',
49                 '/my',
50                 '/',
51             ),
52             $paths
53         );
54     }
55
56     public function testGetCandidatesLocales()
57     {
58         $candidates = new Candidates(array('de', 'fr'));
59
60         $request = Request::create('/fr/path.html');
61         $paths = $candidates->getCandidates($request);
62
63         $this->assertEquals(
64             array(
65                 '/fr/path.html',
66                 '/fr/path',
67                 '/fr',
68                 '/',
69                 '/path.html',
70                 '/path',
71             ),
72             $paths
73         );
74
75         $request = Request::create('/it/path.html');
76         $paths = $candidates->getCandidates($request);
77
78         $this->assertEquals(
79             array(
80                 '/it/path.html',
81                 '/it/path',
82                 '/it',
83                 '/',
84             ),
85             $paths
86         );
87     }
88
89     public function testGetCandidatesLimit()
90     {
91         $candidates = new Candidates(array(), 1);
92
93         $request = Request::create('/my/path/is/deep.html');
94
95         $paths = $candidates->getCandidates($request);
96
97         $this->assertEquals(
98             array(
99                 '/my/path/is/deep.html',
100                 '/my/path/is/deep',
101             ),
102             $paths
103         );
104     }
105 }