Skip to content

Commit d884d55

Browse files
committed
Use willReturn() instead of will(returnValue()).
1 parent 3458f90 commit d884d55

7 files changed

+37
-37
lines changed

Tests/Loader/AnnotationClassLoaderTest.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public function testLoad($className, $routeData = [], $methodArgs = [])
119119
$this->reader
120120
->expects($this->once())
121121
->method('getMethodAnnotations')
122-
->will($this->returnValue([$this->getAnnotatedRoute($routeData)]))
122+
->willReturn([$this->getAnnotatedRoute($routeData)])
123123
;
124124

125125
$routeCollection = $this->loader->load($className);
@@ -165,12 +165,12 @@ public function testClassRouteLoad()
165165
$this->reader
166166
->expects($this->once())
167167
->method('getClassAnnotation')
168-
->will($this->returnValue($this->getAnnotatedRoute($classRouteData)))
168+
->willReturn($this->getAnnotatedRoute($classRouteData))
169169
;
170170
$this->reader
171171
->expects($this->once())
172172
->method('getMethodAnnotations')
173-
->will($this->returnValue([$this->getAnnotatedRoute($methodRouteData)]))
173+
->willReturn([$this->getAnnotatedRoute($methodRouteData)])
174174
;
175175

176176
$routeCollection = $this->loader->load('Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BarClass');
@@ -193,12 +193,12 @@ public function testInvokableClassRouteLoadWithMethodAnnotation()
193193
$this->reader
194194
->expects($this->exactly(1))
195195
->method('getClassAnnotations')
196-
->will($this->returnValue([$this->getAnnotatedRoute($classRouteData)]))
196+
->willReturn([$this->getAnnotatedRoute($classRouteData)])
197197
;
198198
$this->reader
199199
->expects($this->once())
200200
->method('getMethodAnnotations')
201-
->will($this->returnValue([]))
201+
->willReturn([])
202202
;
203203

204204
$routeCollection = $this->loader->load('Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BazClass');
@@ -221,19 +221,19 @@ public function testInvokableClassRouteLoadWithClassAnnotation()
221221
$this->reader
222222
->expects($this->exactly(1))
223223
->method('getClassAnnotation')
224-
->will($this->returnValue($this->getAnnotatedRoute($classRouteData)))
224+
->willReturn($this->getAnnotatedRoute($classRouteData))
225225
;
226226

227227
$this->reader
228228
->expects($this->exactly(1))
229229
->method('getClassAnnotations')
230-
->will($this->returnValue([$this->getAnnotatedRoute($classRouteData)]))
230+
->willReturn([$this->getAnnotatedRoute($classRouteData)])
231231
;
232232

233233
$this->reader
234234
->expects($this->once())
235235
->method('getMethodAnnotations')
236-
->will($this->returnValue([]))
236+
->willReturn([])
237237
;
238238

239239
$routeCollection = $this->loader->load('Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BazClass');
@@ -263,12 +263,12 @@ public function testInvokableClassMultipleRouteLoad()
263263
$this->reader
264264
->expects($this->exactly(1))
265265
->method('getClassAnnotations')
266-
->will($this->returnValue([$this->getAnnotatedRoute($classRouteData1), $this->getAnnotatedRoute($classRouteData2)]))
266+
->willReturn([$this->getAnnotatedRoute($classRouteData1), $this->getAnnotatedRoute($classRouteData2)])
267267
;
268268
$this->reader
269269
->expects($this->once())
270270
->method('getMethodAnnotations')
271-
->will($this->returnValue([]))
271+
->willReturn([])
272272
;
273273

274274
$routeCollection = $this->loader->load('Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BazClass');
@@ -304,12 +304,12 @@ public function testInvokableClassWithMethodRouteLoad()
304304
$this->reader
305305
->expects($this->once())
306306
->method('getClassAnnotation')
307-
->will($this->returnValue($this->getAnnotatedRoute($classRouteData)))
307+
->willReturn($this->getAnnotatedRoute($classRouteData))
308308
;
309309
$this->reader
310310
->expects($this->once())
311311
->method('getMethodAnnotations')
312-
->will($this->returnValue([$this->getAnnotatedRoute($methodRouteData)]))
312+
->willReturn([$this->getAnnotatedRoute($methodRouteData)])
313313
;
314314

315315
$routeCollection = $this->loader->load('Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BazClass');
@@ -336,7 +336,7 @@ public function testDefaultRouteName()
336336
$this->reader
337337
->expects($this->once())
338338
->method('getMethodAnnotations')
339-
->will($this->returnValue([$this->getAnnotatedRoute($methodRouteData)]))
339+
->willReturn([$this->getAnnotatedRoute($methodRouteData)])
340340
;
341341

342342
$routeCollection = $this->loader->load('Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\EncodingClass');

Tests/Loader/AnnotationDirectoryLoaderTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ public function testLoad()
3434
$this->reader
3535
->expects($this->any())
3636
->method('getMethodAnnotations')
37-
->will($this->returnValue([]))
37+
->willReturn([])
3838
;
3939

4040
$this->reader
4141
->expects($this->any())
4242
->method('getClassAnnotations')
43-
->will($this->returnValue([]))
43+
->willReturn([])
4444
;
4545

4646
$this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses');
@@ -58,13 +58,13 @@ public function testLoadIgnoresHiddenDirectories()
5858
$this->reader
5959
->expects($this->any())
6060
->method('getMethodAnnotations')
61-
->will($this->returnValue([]))
61+
->willReturn([])
6262
;
6363

6464
$this->reader
6565
->expects($this->any())
6666
->method('getClassAnnotations')
67-
->will($this->returnValue([]))
67+
->willReturn([])
6868
;
6969

7070
$this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses');
@@ -93,7 +93,7 @@ public function testLoadFileIfLocatedResourceIsFile()
9393
$this->reader
9494
->expects($this->any())
9595
->method('getMethodAnnotations')
96-
->will($this->returnValue([]))
96+
->willReturn([])
9797
;
9898

9999
$this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses/FooClass.php');

Tests/Loader/AnnotationFileLoaderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function testLoadVariadic()
6262
$route = new Route(['path' => '/path/to/{id}']);
6363
$this->reader->expects($this->once())->method('getClassAnnotation');
6464
$this->reader->expects($this->once())->method('getMethodAnnotations')
65-
->will($this->returnValue([$route]));
65+
->willReturn([$route]);
6666

6767
$this->loader->load(__DIR__.'/../Fixtures/OtherAnnotatedClasses/VariadicClass.php');
6868
}

Tests/Loader/ObjectRouteLoaderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function testExceptionOnMethodNotReturningCollection()
8989
->getMock();
9090
$service->expects($this->once())
9191
->method('loadRoutes')
92-
->will($this->returnValue('NOT_A_COLLECTION'));
92+
->willReturn('NOT_A_COLLECTION');
9393

9494
$loader = new ObjectRouteLoaderForTest();
9595
$loader->loaderMap = ['my_service' => $service];

Tests/Matcher/RedirectableUrlMatcherTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function testMissingTrailingSlash()
2323
$coll->add('foo', new Route('/foo/'));
2424

2525
$matcher = $this->getUrlMatcher($coll);
26-
$matcher->expects($this->once())->method('redirect')->will($this->returnValue([]));
26+
$matcher->expects($this->once())->method('redirect')->willReturn([]);
2727
$matcher->match('/foo');
2828
}
2929

@@ -51,7 +51,7 @@ public function testSchemeRedirectRedirectsToFirstScheme()
5151
->expects($this->once())
5252
->method('redirect')
5353
->with('/foo', 'foo', 'ftp')
54-
->will($this->returnValue(['_route' => 'foo']))
54+
->willReturn(['_route' => 'foo'])
5555
;
5656
$matcher->match('/foo');
5757
}
@@ -78,7 +78,7 @@ public function testSchemeRedirectWithParams()
7878
->expects($this->once())
7979
->method('redirect')
8080
->with('/foo/baz', 'foo', 'https')
81-
->will($this->returnValue(['redirect' => 'value']))
81+
->willReturn(['redirect' => 'value'])
8282
;
8383
$this->assertEquals(['_route' => 'foo', 'bar' => 'baz', 'redirect' => 'value'], $matcher->match('/foo/baz'));
8484
}
@@ -93,7 +93,7 @@ public function testSlashRedirectWithParams()
9393
->expects($this->once())
9494
->method('redirect')
9595
->with('/foo/baz/', 'foo', null)
96-
->will($this->returnValue(['redirect' => 'value']))
96+
->willReturn(['redirect' => 'value'])
9797
;
9898
$this->assertEquals(['_route' => 'foo', 'bar' => 'baz', 'redirect' => 'value'], $matcher->match('/foo/baz'));
9999
}
@@ -124,7 +124,7 @@ public function testFallbackPage()
124124
$coll->add('bar', new Route('/{name}'));
125125

126126
$matcher = $this->getUrlMatcher($coll);
127-
$matcher->expects($this->once())->method('redirect')->with('/foo/')->will($this->returnValue(['_route' => 'foo']));
127+
$matcher->expects($this->once())->method('redirect')->with('/foo/')->willReturn(['_route' => 'foo']);
128128
$this->assertSame(['_route' => 'foo'], $matcher->match('/foo'));
129129
}
130130

Tests/RouteCollectionBuilderTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function testImport()
2828
$resolver->expects($this->once())
2929
->method('resolve')
3030
->with('admin_routing.yml', 'yaml')
31-
->will($this->returnValue($resolvedLoader));
31+
->willReturn($resolvedLoader);
3232

3333
$originalRoute = new Route('/foo/path');
3434
$expectedCollection = new RouteCollection();
@@ -39,12 +39,12 @@ public function testImport()
3939
->expects($this->once())
4040
->method('load')
4141
->with('admin_routing.yml', 'yaml')
42-
->will($this->returnValue($expectedCollection));
42+
->willReturn($expectedCollection);
4343

4444
$loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
4545
$loader->expects($this->any())
4646
->method('getResolver')
47-
->will($this->returnValue($resolver));
47+
->willReturn($resolver);
4848

4949
// import the file!
5050
$routes = new RouteCollectionBuilder($loader);
@@ -107,11 +107,11 @@ public function testFlushOrdering()
107107
// make this loader able to do the import - keeps mocking simple
108108
$loader->expects($this->any())
109109
->method('supports')
110-
->will($this->returnValue(true));
110+
->willReturn(true);
111111
$loader
112112
->expects($this->once())
113113
->method('load')
114-
->will($this->returnValue($importedCollection));
114+
->willReturn($importedCollection);
115115

116116
$routes = new RouteCollectionBuilder($loader);
117117

@@ -296,11 +296,11 @@ public function testFlushSetsPrefixedWithMultipleLevels()
296296
// make this loader able to do the import - keeps mocking simple
297297
$loader->expects($this->any())
298298
->method('supports')
299-
->will($this->returnValue(true));
299+
->willReturn(true);
300300
$loader
301301
->expects($this->any())
302302
->method('load')
303-
->will($this->returnValue($importedCollection));
303+
->willReturn($importedCollection);
304304
// import this from the /admin route builder
305305
$adminRoutes->import('admin.yml', '/imported');
306306

@@ -347,11 +347,11 @@ public function testAddsThePrefixOnlyOnceWhenLoadingMultipleCollections()
347347
$loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
348348
$loader->expects($this->any())
349349
->method('supports')
350-
->will($this->returnValue(true));
350+
->willReturn(true);
351351
$loader
352352
->expects($this->any())
353353
->method('load')
354-
->will($this->returnValue([$firstCollection, $secondCollection]));
354+
->willReturn([$firstCollection, $secondCollection]);
355355

356356
$routeCollectionBuilder = new RouteCollectionBuilder($loader);
357357
$routeCollectionBuilder->import('/directory/recurse/*', '/other/', 'glob');

Tests/RouterTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function testThatRouteCollectionIsLoaded()
8888

8989
$this->loader->expects($this->once())
9090
->method('load')->with('routing.yml', 'ResourceType')
91-
->will($this->returnValue($routeCollection));
91+
->willReturn($routeCollection);
9292

9393
$this->assertSame($routeCollection, $this->router->getRouteCollection());
9494
}
@@ -102,7 +102,7 @@ public function testMatcherIsCreatedIfCacheIsNotConfigured($option)
102102

103103
$this->loader->expects($this->once())
104104
->method('load')->with('routing.yml', null)
105-
->will($this->returnValue(new RouteCollection()));
105+
->willReturn(new RouteCollection());
106106

107107
$this->assertInstanceOf('Symfony\\Component\\Routing\\Matcher\\UrlMatcher', $this->router->getMatcher());
108108
}
@@ -124,7 +124,7 @@ public function testGeneratorIsCreatedIfCacheIsNotConfigured($option)
124124

125125
$this->loader->expects($this->once())
126126
->method('load')->with('routing.yml', null)
127-
->will($this->returnValue(new RouteCollection()));
127+
->willReturn(new RouteCollection());
128128

129129
$this->assertInstanceOf('Symfony\\Component\\Routing\\Generator\\UrlGenerator', $this->router->getGenerator());
130130
}

0 commit comments

Comments
 (0)