Skip to content

Commit de80142

Browse files
Merge branch '4.3' into 4.4
* 4.3: Use willReturn() instead of will(returnValue()).
2 parents e1db1d9 + 3e629bd commit de80142

18 files changed

+95
-95
lines changed

Tests/CacheWarmer/TemplateFinderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function testFindAllTemplates()
3737
$kernel
3838
->expects($this->once())
3939
->method('getBundles')
40-
->will($this->returnValue(['BaseBundle' => new BaseBundle()]))
40+
->willReturn(['BaseBundle' => new BaseBundle()])
4141
;
4242

4343
$parser = new TemplateFilenameParser();

Tests/CacheWarmer/TemplatePathsCacheWarmerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ public function testWarmUp()
7171
$this->templateFinder
7272
->expects($this->once())
7373
->method('findAllTemplates')
74-
->will($this->returnValue([$template]));
74+
->willReturn([$template]);
7575

7676
$this->fileLocator
7777
->expects($this->once())
7878
->method('locate')
7979
->with($template->getPath())
80-
->will($this->returnValue(\dirname($this->tmpDir).'/path/to/template.html.twig'));
80+
->willReturn(\dirname($this->tmpDir).'/path/to/template.html.twig');
8181

8282
$warmer = new TemplatePathsCacheWarmer($this->templateFinder, $this->templateLocator);
8383
$warmer->warmUp($this->tmpDir);
@@ -90,7 +90,7 @@ public function testWarmUpEmpty()
9090
$this->templateFinder
9191
->expects($this->once())
9292
->method('findAllTemplates')
93-
->will($this->returnValue([]));
93+
->willReturn([]);
9494

9595
$this->fileLocator
9696
->expects($this->never())

Tests/Command/RouterMatchCommandTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ private function getRouter()
6262
$router
6363
->expects($this->any())
6464
->method('getRouteCollection')
65-
->will($this->returnValue($routeCollection));
65+
->willReturn($routeCollection);
6666
$router
6767
->expects($this->any())
6868
->method('getContext')
69-
->will($this->returnValue($requestContext));
69+
->willReturn($requestContext);
7070

7171
return $router;
7272
}
@@ -77,9 +77,9 @@ private function getKernel()
7777
$container
7878
->expects($this->atLeastOnce())
7979
->method('has')
80-
->will($this->returnCallback(function ($id) {
80+
->willReturnCallback(function ($id) {
8181
return 'console.command_loader' !== $id;
82-
}))
82+
})
8383
;
8484
$container
8585
->expects($this->any())

Tests/Command/TranslationDebugCommandTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -154,26 +154,26 @@ private function createCommandTester($extractedMessages = [], $loadedMessages =
154154
$translator
155155
->expects($this->any())
156156
->method('getFallbackLocales')
157-
->will($this->returnValue(['en']));
157+
->willReturn(['en']);
158158

159159
$extractor = $this->getMockBuilder('Symfony\Component\Translation\Extractor\ExtractorInterface')->getMock();
160160
$extractor
161161
->expects($this->any())
162162
->method('extract')
163-
->will(
164-
$this->returnCallback(function ($path, $catalogue) use ($extractedMessages) {
163+
->willReturnCallback(
164+
function ($path, $catalogue) use ($extractedMessages) {
165165
$catalogue->add($extractedMessages);
166-
})
166+
}
167167
);
168168

169169
$loader = $this->getMockBuilder('Symfony\Component\Translation\Reader\TranslationReader')->getMock();
170170
$loader
171171
->expects($this->any())
172172
->method('read')
173-
->will(
174-
$this->returnCallback(function ($path, $catalogue) use ($loadedMessages) {
173+
->willReturnCallback(
174+
function ($path, $catalogue) use ($loadedMessages) {
175175
$catalogue->add($loadedMessages);
176-
})
176+
}
177177
);
178178

179179
if (null === $kernel) {
@@ -191,21 +191,21 @@ private function createCommandTester($extractedMessages = [], $loadedMessages =
191191
$kernel
192192
->expects($this->any())
193193
->method('getBundle')
194-
->will($this->returnValueMap($returnValues));
194+
->willReturnMap($returnValues);
195195
}
196196

197197
$kernel
198198
->expects($this->any())
199199
->method('getBundles')
200-
->will($this->returnValue([]));
200+
->willReturn([]);
201201

202202
$container = new Container();
203203
$container->setParameter('kernel.root_dir', $this->translationDir);
204204

205205
$kernel
206206
->expects($this->any())
207207
->method('getContainer')
208-
->will($this->returnValue($container));
208+
->willReturn($container);
209209

210210
$command = new TranslationDebugCommand($translator, $loader, $extractor, $this->translationDir.'/translations', $this->translationDir.'/templates', $transPaths, $viewsPaths);
211211

@@ -221,7 +221,7 @@ private function getBundle($path)
221221
$bundle
222222
->expects($this->any())
223223
->method('getPath')
224-
->will($this->returnValue($path))
224+
->willReturn($path)
225225
;
226226

227227
return $bundle;

Tests/Command/TranslationUpdateCommandTest.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -130,36 +130,36 @@ private function createCommandTester($extractedMessages = [], $loadedMessages =
130130
$translator
131131
->expects($this->any())
132132
->method('getFallbackLocales')
133-
->will($this->returnValue(['en']));
133+
->willReturn(['en']);
134134

135135
$extractor = $this->getMockBuilder('Symfony\Component\Translation\Extractor\ExtractorInterface')->getMock();
136136
$extractor
137137
->expects($this->any())
138138
->method('extract')
139-
->will(
140-
$this->returnCallback(function ($path, $catalogue) use ($extractedMessages) {
139+
->willReturnCallback(
140+
function ($path, $catalogue) use ($extractedMessages) {
141141
foreach ($extractedMessages as $domain => $messages) {
142142
$catalogue->add($messages, $domain);
143143
}
144-
})
144+
}
145145
);
146146

147147
$loader = $this->getMockBuilder('Symfony\Component\Translation\Reader\TranslationReader')->getMock();
148148
$loader
149149
->expects($this->any())
150150
->method('read')
151-
->will(
152-
$this->returnCallback(function ($path, $catalogue) use ($loadedMessages) {
151+
->willReturnCallback(
152+
function ($path, $catalogue) use ($loadedMessages) {
153153
$catalogue->add($loadedMessages);
154-
})
154+
}
155155
);
156156

157157
$writer = $this->getMockBuilder('Symfony\Component\Translation\Writer\TranslationWriter')->getMock();
158158
$writer
159159
->expects($this->any())
160160
->method('getFormats')
161-
->will(
162-
$this->returnValue(['xlf', 'yml', 'yaml'])
161+
->willReturn(
162+
['xlf', 'yml', 'yaml']
163163
);
164164

165165
if (null === $kernel) {
@@ -177,25 +177,25 @@ private function createCommandTester($extractedMessages = [], $loadedMessages =
177177
$kernel
178178
->expects($this->any())
179179
->method('getBundle')
180-
->will($this->returnValueMap($returnValues));
180+
->willReturnMap($returnValues);
181181
}
182182

183183
$kernel
184184
->expects($this->any())
185185
->method('getRootDir')
186-
->will($this->returnValue($this->translationDir));
186+
->willReturn($this->translationDir);
187187

188188
$kernel
189189
->expects($this->any())
190190
->method('getBundles')
191-
->will($this->returnValue([]));
191+
->willReturn([]);
192192

193193
$container = new Container();
194194
$container->setParameter('kernel.root_dir', $this->translationDir);
195195
$kernel
196196
->expects($this->any())
197197
->method('getContainer')
198-
->will($this->returnValue($container));
198+
->willReturn($container);
199199

200200
$command = new TranslationUpdateCommand($writer, $loader, $extractor, 'en', $this->translationDir.'/translations', $this->translationDir.'/templates', $transPaths, $viewsPaths);
201201

@@ -211,7 +211,7 @@ private function getBundle($path)
211211
$bundle
212212
->expects($this->any())
213213
->method('getPath')
214-
->will($this->returnValue($path))
214+
->willReturn($path)
215215
;
216216

217217
return $bundle;

Tests/Console/ApplicationTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ private function getKernel(array $bundles, $useDispatcher = false)
271271
->expects($this->atLeastOnce())
272272
->method('get')
273273
->with($this->equalTo('event_dispatcher'))
274-
->will($this->returnValue($dispatcher));
274+
->willReturn($dispatcher);
275275
}
276276

277277
$container
@@ -292,12 +292,12 @@ private function getKernel(array $bundles, $useDispatcher = false)
292292
$kernel
293293
->expects($this->any())
294294
->method('getBundles')
295-
->will($this->returnValue($bundles))
295+
->willReturn($bundles)
296296
;
297297
$kernel
298298
->expects($this->any())
299299
->method('getContainer')
300-
->will($this->returnValue($container))
300+
->willReturn($container)
301301
;
302302

303303
return $kernel;
@@ -309,9 +309,9 @@ private function createBundleMock(array $commands)
309309
$bundle
310310
->expects($this->once())
311311
->method('registerCommands')
312-
->will($this->returnCallback(function (Application $application) use ($commands) {
312+
->willReturnCallback(function (Application $application) use ($commands) {
313313
$application->addCommands($commands);
314-
}))
314+
})
315315
;
316316

317317
return $bundle;

Tests/Controller/ControllerNameParserTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,13 @@ private function createParser()
155155
$kernel
156156
->expects($this->any())
157157
->method('getBundle')
158-
->will($this->returnCallback(function ($bundle) use ($bundles) {
158+
->willReturnCallback(function ($bundle) use ($bundles) {
159159
if (!isset($bundles[$bundle])) {
160160
throw new \InvalidArgumentException(sprintf('Invalid bundle name "%s"', $bundle));
161161
}
162162

163163
return $bundles[$bundle];
164-
}))
164+
})
165165
;
166166

167167
$bundles = [
@@ -172,7 +172,7 @@ private function createParser()
172172
$kernel
173173
->expects($this->any())
174174
->method('getBundles')
175-
->will($this->returnValue($bundles))
175+
->willReturn($bundles)
176176
;
177177

178178
return new ControllerNameParser($kernel);
@@ -181,8 +181,8 @@ private function createParser()
181181
private function getBundle($namespace, $name)
182182
{
183183
$bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock();
184-
$bundle->expects($this->any())->method('getName')->will($this->returnValue($name));
185-
$bundle->expects($this->any())->method('getNamespace')->will($this->returnValue($namespace));
184+
$bundle->expects($this->any())->method('getName')->willReturn($name);
185+
$bundle->expects($this->any())->method('getNamespace')->willReturn($namespace);
186186

187187
return $bundle;
188188
}

Tests/Controller/ControllerResolverTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function testGetControllerWithBundleNotation()
6060
$parser->expects($this->once())
6161
->method('parse')
6262
->with($shortName)
63-
->will($this->returnValue('Symfony\Bundle\FrameworkBundle\Tests\Controller\ContainerAwareController::testAction'))
63+
->willReturn('Symfony\Bundle\FrameworkBundle\Tests\Controller\ContainerAwareController::testAction')
6464
;
6565

6666
$resolver = $this->createControllerResolver(null, null, $parser);

Tests/Controller/ControllerTraitTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ public function testForward()
4444
$requestStack->push($request);
4545

4646
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
47-
$kernel->expects($this->once())->method('handle')->will($this->returnCallback(function (Request $request) {
47+
$kernel->expects($this->once())->method('handle')->willReturnCallback(function (Request $request) {
4848
return new Response($request->getRequestFormat().'--'.$request->getLocale());
49-
}));
49+
});
5050

5151
$container = new Container();
5252
$container->set('request_stack', $requestStack);
@@ -111,7 +111,7 @@ private function getContainerWithTokenStorage($token = null)
111111
$tokenStorage
112112
->expects($this->once())
113113
->method('getToken')
114-
->will($this->returnValue($token));
114+
->willReturn($token);
115115

116116
$container = new Container();
117117
$container->set('security.token_storage', $tokenStorage);
@@ -138,7 +138,7 @@ public function testJsonWithSerializer()
138138
->expects($this->once())
139139
->method('serialize')
140140
->with([], 'json', ['json_encode_options' => JsonResponse::DEFAULT_ENCODING_OPTIONS])
141-
->will($this->returnValue('[]'));
141+
->willReturn('[]');
142142

143143
$container->set('serializer', $serializer);
144144

@@ -159,7 +159,7 @@ public function testJsonWithSerializerContextOverride()
159159
->expects($this->once())
160160
->method('serialize')
161161
->with([], 'json', ['json_encode_options' => 0, 'other' => 'context'])
162-
->will($this->returnValue('[]'));
162+
->willReturn('[]');
163163

164164
$container->set('serializer', $serializer);
165165

Tests/Controller/RedirectControllerTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function testRoute($permanent, $keepRequestMethod, $keepQueryParams, $ign
7474
->expects($this->once())
7575
->method('generate')
7676
->with($this->equalTo($route), $this->equalTo($expectedAttributes))
77-
->will($this->returnValue($url));
77+
->willReturn($url);
7878

7979
$controller = new RedirectController($router);
8080

@@ -247,7 +247,7 @@ public function testRedirectWithQuery()
247247
$request->query = new ParameterBag(['base' => 'zaza']);
248248
$request->attributes = new ParameterBag(['_route_params' => ['base2' => 'zaza']]);
249249
$urlGenerator = $this->getMockBuilder(UrlGeneratorInterface::class)->getMock();
250-
$urlGenerator->expects($this->once())->method('generate')->will($this->returnValue('/test?base=zaza&base2=zaza'))->with('/test', ['base' => 'zaza', 'base2' => 'zaza'], UrlGeneratorInterface::ABSOLUTE_URL);
250+
$urlGenerator->expects($this->once())->method('generate')->willReturn('/test?base=zaza&base2=zaza')->with('/test', ['base' => 'zaza', 'base2' => 'zaza'], UrlGeneratorInterface::ABSOLUTE_URL);
251251

252252
$controller = new RedirectController($urlGenerator);
253253
$this->assertRedirectUrl($controller->redirectAction($request, '/test', false, false, false, true), '/test?base=zaza&base2=zaza');
@@ -264,7 +264,7 @@ public function testRedirectWithQueryWithRouteParamsOveriding()
264264
$request->query = new ParameterBag(['base' => 'zaza']);
265265
$request->attributes = new ParameterBag(['_route_params' => ['base' => 'zouzou']]);
266266
$urlGenerator = $this->getMockBuilder(UrlGeneratorInterface::class)->getMock();
267-
$urlGenerator->expects($this->once())->method('generate')->will($this->returnValue('/test?base=zouzou'))->with('/test', ['base' => 'zouzou'], UrlGeneratorInterface::ABSOLUTE_URL);
267+
$urlGenerator->expects($this->once())->method('generate')->willReturn('/test?base=zouzou')->with('/test', ['base' => 'zouzou'], UrlGeneratorInterface::ABSOLUTE_URL);
268268

269269
$controller = new RedirectController($urlGenerator);
270270
$this->assertRedirectUrl($controller->redirectAction($request, '/test', false, false, false, true), '/test?base=zouzou');
@@ -276,23 +276,23 @@ private function createRequestObject($scheme, $host, $port, $baseUrl, $queryStri
276276
$request
277277
->expects($this->any())
278278
->method('getScheme')
279-
->will($this->returnValue($scheme));
279+
->willReturn($scheme);
280280
$request
281281
->expects($this->any())
282282
->method('getHost')
283-
->will($this->returnValue($host));
283+
->willReturn($host);
284284
$request
285285
->expects($this->any())
286286
->method('getPort')
287-
->will($this->returnValue($port));
287+
->willReturn($port);
288288
$request
289289
->expects($this->any())
290290
->method('getBaseUrl')
291-
->will($this->returnValue($baseUrl));
291+
->willReturn($baseUrl);
292292
$request
293293
->expects($this->any())
294294
->method('getQueryString')
295-
->will($this->returnValue($queryString));
295+
->willReturn($queryString);
296296

297297
return $request;
298298
}

0 commit comments

Comments
 (0)