@@ -30,7 +30,7 @@ protected function setUp()
30
30
31
31
public function testCreateRedirectResponse ()
32
32
{
33
- $ utils = new HttpUtils ($ this ->getRouter ());
33
+ $ utils = new HttpUtils ($ this ->getUrlGenerator ());
34
34
35
35
// absolute path
36
36
$ response = $ utils ->createRedirectResponse ($ this ->getRequest (), '/foobar ' );
@@ -42,14 +42,14 @@ public function testCreateRedirectResponse()
42
42
$ this ->assertTrue ($ response ->isRedirect ('http://symfony.com/ ' ));
43
43
44
44
// route name
45
- $ utils = new HttpUtils ($ router = $ this ->getMockBuilder ('Symfony\Component\Routing\Router ' )-> disableOriginalConstructor ()-> getMock ( ));
46
- $ router
45
+ $ utils = new HttpUtils ($ urlGenerator = $ this ->getMock ('Symfony\Component\Routing\Generator\UrlGeneratorInterface ' ));
46
+ $ urlGenerator
47
47
->expects ($ this ->any ())
48
48
->method ('generate ' )
49
49
->with ('foobar ' , array (), true )
50
50
->will ($ this ->returnValue ('http://localhost/foo/bar ' ))
51
51
;
52
- $ router
52
+ $ urlGenerator
53
53
->expects ($ this ->any ())
54
54
->method ('getContext ' )
55
55
->will ($ this ->returnValue ($ this ->getMock ('Symfony\Component\Routing\RequestContext ' )))
@@ -60,7 +60,7 @@ public function testCreateRedirectResponse()
60
60
61
61
public function testCreateRequest ()
62
62
{
63
- $ utils = new HttpUtils ($ this ->getRouter ());
63
+ $ utils = new HttpUtils ($ this ->getUrlGenerator ());
64
64
65
65
// absolute path
66
66
$ request = $ this ->getRequest ();
@@ -72,13 +72,13 @@ public function testCreateRequest()
72
72
$ this ->assertEquals ('bar ' , $ subRequest ->server ->get ('Foo ' ));
73
73
74
74
// route name
75
- $ utils = new HttpUtils ($ router = $ this ->getMockBuilder ('Symfony\Component\Routing\Router ' )-> disableOriginalConstructor ()-> getMock ( ));
76
- $ router
75
+ $ utils = new HttpUtils ($ urlGenerator = $ this ->getMock ('Symfony\Component\Routing\Generator\UrlGeneratorInterface ' ));
76
+ $ urlGenerator
77
77
->expects ($ this ->once ())
78
78
->method ('generate ' )
79
79
->will ($ this ->returnValue ('/foo/bar ' ))
80
80
;
81
- $ router
81
+ $ urlGenerator
82
82
->expects ($ this ->any())
83
83
->method ('getContext ' )
84
84
->will ($ this ->returnValue ($ this ->getMock ('Symfony\Component\Routing\RequestContext ' )))
@@ -93,55 +93,55 @@ public function testCreateRequest()
93
93
94
94
public function testCheckRequestPath ()
95
95
{
96
- $ utils = new HttpUtils ($ this ->getRouter ());
96
+ $ utils = new HttpUtils ($ this ->getUrlGenerator ());
97
97
98
98
$ this ->assertTrue ($ utils ->checkRequestPath ($ this ->getRequest (), '/ ' ));
99
99
$ this ->assertFalse ($ utils ->checkRequestPath ($ this ->getRequest (), '/foo ' ));
100
100
101
- $ router = $ this ->getMock ('Symfony\Component\Routing\RouterInterface ' );
102
- $ router
101
+ $ urlMatcher = $ this ->getMock ('Symfony\Component\Routing\Matcher\UrlMatcherInterface ' );
102
+ $ urlMatcher
103
103
->expects ($ this ->any ())
104
104
->method ('match ' )
105
105
->will ($ this ->throwException (new ResourceNotFoundException ()))
106
106
;
107
- $ utils = new HttpUtils ($ router );
107
+ $ utils = new HttpUtils (null , $ urlMatcher );
108
108
$ this ->assertFalse ($ utils ->checkRequestPath ($ this ->getRequest (), 'foobar ' ));
109
109
110
- $ router = $ this ->getMock ('Symfony\Component\Routing\RouterInterface ' );
111
- $ router
110
+ $ urlMatcher = $ this ->getMock ('Symfony\Component\Routing\Matcher\UrlMatcherInterface ' );
111
+ $ urlMatcher
112
112
->expects ($ this ->any ())
113
113
->method ('match ' )
114
114
->will ($ this ->returnValue (array ('_route ' => 'foobar ' )))
115
115
;
116
- $ utils = new HttpUtils ($ router );
116
+ $ utils = new HttpUtils (null , $ urlMatcher );
117
117
$ this ->assertTrue ($ utils ->checkRequestPath ($ this ->getRequest ('/foo/bar ' ), 'foobar ' ));
118
118
}
119
119
120
120
/**
121
121
* @expectedException \RuntimeException
122
122
*/
123
- public function testCheckRequestPathWithRouterLoadingException ()
123
+ public function testCheckRequestPathWithUrlMatcherLoadingException ()
124
124
{
125
- $ router = $ this ->getMock ('Symfony\Component\Routing\RouterInterface ' );
126
- $ router
125
+ $ urlMatcher = $ this ->getMock ('Symfony\Component\Routing\Matcher\UrlMatcherInterface ' );
126
+ $ urlMatcher
127
127
->expects ($ this ->any ())
128
128
->method ('match ' )
129
129
->will ($ this ->throwException (new \RuntimeException ()))
130
130
;
131
- $ utils = new HttpUtils ($ router );
131
+ $ utils = new HttpUtils (null , $ urlMatcher );
132
132
$ utils ->checkRequestPath ($ this ->getRequest (), 'foobar ' );
133
133
}
134
134
135
- private function getRouter ()
135
+ private function getUrlGenerator ()
136
136
{
137
- $ router = $ this ->getMock ('Symfony\Component\Routing\RouterInterface ' );
138
- $ router
137
+ $ urlGenerator = $ this ->getMock ('Symfony\Component\Routing\Generator\UrlGeneratorInterface ' );
138
+ $ urlGenerator
139
139
->expects ($ this ->any ())
140
140
->method ('generate ' )
141
141
->will ($ this ->returnValue ('/foo/bar ' ))
142
142
;
143
143
144
- return $ router ;
144
+ return $ urlGenerator ;
145
145
}
146
146
147
147
private function getRequest ($ path = '/ ' )
0 commit comments