1+ <?php 
2+ 
3+ /* 
4+  * This file is part of the Symfony framework. 
5+  * 
6+  * (c) Fabien Potencier <fabien@symfony.com> 
7+  * 
8+  * This source file is subject to the MIT license that is bundled 
9+  * with this source code in the file LICENSE. 
10+  */ 
11+ 
12+ namespace  Symfony \Bundle \FrameworkBundle \Tests \Routing ;
13+ 
14+ use  Symfony \Bundle \FrameworkBundle \Routing \Router ;
15+ use  Symfony \Component \Routing \Route ;
16+ use  Symfony \Component \Routing \RouteCollection ;
17+ use  Symfony \Bundle \FrameworkBundle \Routing \RedirectableUrlMatcher ;
18+ use  Symfony \Component \Routing \RequestContext ;
19+ 
20+ class  RedirectableUrlMatcherTest extends  \PHPUnit_Framework_TestCase
21+ {
22+  public  function  testRedirectWhenNoSlash ()
23+  {
24+  $ collnew  RouteCollection ();
25+  $ colladd ('foo ' , new  Route ('/foo/ ' ));
26+ 
27+  $ matchernew  RedirectableUrlMatcher ($ coll$ contextnew  RequestContext ());
28+ 
29+  $ this assertEquals (array (
30+  '_controller '  => 'Symfony\Bundle\FrameworkBundle\Controller\RedirectController::urlRedirectAction ' ,
31+  'path '  => '/foo/ ' ,
32+  'permanent '  => true ,
33+  'scheme '  => null ,
34+  'httpPort '  => $ contextgetHttpPort (),
35+  'httpsPort '  => $ contextgetHttpsPort (),
36+  '_route '  => null ,
37+  ),
38+  $ matchermatch ('/foo ' )
39+  );
40+  }
41+ 
42+  public  function  testSchemeRedirect ()
43+  {
44+  $ collnew  RouteCollection ();
45+  $ colladd ('foo ' , new  Route ('/foo ' , array (), array ('_scheme '  => 'https ' )));
46+ 
47+  $ matchernew  RedirectableUrlMatcher ($ coll$ contextnew  RequestContext ());
48+ 
49+  $ this assertEquals (array (
50+  '_controller '  => 'Symfony\Bundle\FrameworkBundle\Controller\RedirectController::urlRedirectAction ' ,
51+  'path '  => '/foo ' ,
52+  'permanent '  => true ,
53+  'scheme '  => 'https ' ,
54+  'httpPort '  => $ contextgetHttpPort (),
55+  'httpsPort '  => $ contextgetHttpsPort (),
56+  '_route '  => 'foo ' ,
57+  ),
58+  $ matchermatch ('/foo ' )
59+  );
60+  }
61+ }
0 commit comments