Skip to content

Commit 1f0159c

Browse files
Merge branch '4.2' into 4.3
* 4.2: Use willReturn() instead of will(returnValue()).
2 parents e6cc85f + b7d6c99 commit 1f0159c

7 files changed

+31
-31
lines changed

Tests/Loader/AnnotationClassLoaderTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,12 +233,12 @@ public function testInvokableClassMultipleRouteLoad()
233233
$reader
234234
->expects($this->exactly(1))
235235
->method('getClassAnnotations')
236-
->will($this->returnValue([new RouteAnnotation($classRouteData1), new RouteAnnotation($classRouteData2)]))
236+
->willReturn([new RouteAnnotation($classRouteData1), new RouteAnnotation($classRouteData2)])
237237
;
238238
$reader
239239
->expects($this->once())
240240
->method('getMethodAnnotations')
241-
->will($this->returnValue([]))
241+
->willReturn([])
242242
;
243243
$loader = new class($reader) extends AnnotationClassLoader {
244244
protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, $annot)
@@ -319,7 +319,7 @@ public function testDefaultRouteName()
319319
$reader
320320
->expects($this->once())
321321
->method('getMethodAnnotations')
322-
->will($this->returnValue([new RouteAnnotation($methodRouteData)]))
322+
->willReturn([new RouteAnnotation($methodRouteData)])
323323
;
324324

325325
$loader = new class($reader) extends AnnotationClassLoader {

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
@@ -56,7 +56,7 @@ public function testLoadVariadic()
5656
$route = new Route(['path' => '/path/to/{id}']);
5757
$this->reader->expects($this->once())->method('getClassAnnotation');
5858
$this->reader->expects($this->once())->method('getMethodAnnotations')
59-
->will($this->returnValue([$route]));
59+
->willReturn([$route]);
6060

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

Tests/Loader/ObjectRouteLoaderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public function testExceptionOnMethodNotReturningCollection()
118118
->getMock();
119119
$service->expects($this->once())
120120
->method('loadRoutes')
121-
->will($this->returnValue('NOT_A_COLLECTION'));
121+
->willReturn('NOT_A_COLLECTION');
122122

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

Tests/Matcher/RedirectableUrlMatcherTest.php

Lines changed: 9 additions & 9 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

@@ -33,7 +33,7 @@ public function testExtraTrailingSlash()
3333
$coll->add('foo', new Route('/foo'));
3434

3535
$matcher = $this->getUrlMatcher($coll);
36-
$matcher->expects($this->once())->method('redirect')->will($this->returnValue([]));
36+
$matcher->expects($this->once())->method('redirect')->willReturn([]);
3737
$matcher->match('/foo/');
3838
}
3939

@@ -61,7 +61,7 @@ public function testSchemeRedirectRedirectsToFirstScheme()
6161
->expects($this->once())
6262
->method('redirect')
6363
->with('/foo', 'foo', 'ftp')
64-
->will($this->returnValue(['_route' => 'foo']))
64+
->willReturn(['_route' => 'foo'])
6565
;
6666
$matcher->match('/foo');
6767
}
@@ -88,7 +88,7 @@ public function testSchemeRedirectWithParams()
8888
->expects($this->once())
8989
->method('redirect')
9090
->with('/foo/baz', 'foo', 'https')
91-
->will($this->returnValue(['redirect' => 'value']))
91+
->willReturn(['redirect' => 'value'])
9292
;
9393
$this->assertEquals(['_route' => 'foo', 'bar' => 'baz', 'redirect' => 'value'], $matcher->match('/foo/baz'));
9494
}
@@ -103,7 +103,7 @@ public function testSchemeRedirectForRoot()
103103
->expects($this->once())
104104
->method('redirect')
105105
->with('/', 'foo', 'https')
106-
->will($this->returnValue(['redirect' => 'value']));
106+
->willReturn(['redirect' => 'value']);
107107
$this->assertEquals(['_route' => 'foo', 'redirect' => 'value'], $matcher->match('/'));
108108
}
109109

@@ -117,7 +117,7 @@ public function testSlashRedirectWithParams()
117117
->expects($this->once())
118118
->method('redirect')
119119
->with('/foo/baz/', 'foo', null)
120-
->will($this->returnValue(['redirect' => 'value']))
120+
->willReturn(['redirect' => 'value'])
121121
;
122122
$this->assertEquals(['_route' => 'foo', 'bar' => 'baz', 'redirect' => 'value'], $matcher->match('/foo/baz'));
123123
}
@@ -148,15 +148,15 @@ public function testFallbackPage()
148148
$coll->add('bar', new Route('/{name}'));
149149

150150
$matcher = $this->getUrlMatcher($coll);
151-
$matcher->expects($this->once())->method('redirect')->with('/foo/', 'foo')->will($this->returnValue(['_route' => 'foo']));
151+
$matcher->expects($this->once())->method('redirect')->with('/foo/', 'foo')->willReturn(['_route' => 'foo']);
152152
$this->assertSame(['_route' => 'foo'], $matcher->match('/foo'));
153153

154154
$coll = new RouteCollection();
155155
$coll->add('foo', new Route('/foo'));
156156
$coll->add('bar', new Route('/{name}/'));
157157

158158
$matcher = $this->getUrlMatcher($coll);
159-
$matcher->expects($this->once())->method('redirect')->with('/foo', 'foo')->will($this->returnValue(['_route' => 'foo']));
159+
$matcher->expects($this->once())->method('redirect')->with('/foo', 'foo')->willReturn(['_route' => 'foo']);
160160
$this->assertSame(['_route' => 'foo'], $matcher->match('/foo/'));
161161
}
162162

@@ -166,7 +166,7 @@ public function testMissingTrailingSlashAndScheme()
166166
$coll->add('foo', (new Route('/foo/'))->setSchemes(['https']));
167167

168168
$matcher = $this->getUrlMatcher($coll);
169-
$matcher->expects($this->once())->method('redirect')->with('/foo/', 'foo', 'https')->will($this->returnValue([]));
169+
$matcher->expects($this->once())->method('redirect')->with('/foo/', 'foo', 'https')->willReturn([]);
170170
$matcher->match('/foo');
171171
}
172172

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
}
@@ -99,7 +99,7 @@ public function testMatcherIsCreatedIfCacheIsNotConfigured()
9999

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

104104
$this->assertInstanceOf('Symfony\\Component\\Routing\\Matcher\\UrlMatcher', $this->router->getMatcher());
105105
}
@@ -110,7 +110,7 @@ public function testGeneratorIsCreatedIfCacheIsNotConfigured()
110110

111111
$this->loader->expects($this->once())
112112
->method('load')->with('routing.yml', null)
113-
->will($this->returnValue(new RouteCollection()));
113+
->willReturn(new RouteCollection());
114114

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

0 commit comments

Comments
 (0)