Skip to content

Commit 6e2e2de

Browse files
committed
Use willReturn() instead of will(returnValue()).
1 parent 11145f3 commit 6e2e2de

20 files changed

+107
-107
lines changed

Tests/CacheWarmer/TemplateFinderTest.php

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

4040
$parser = new TemplateFilenameParser();

Tests/CacheWarmer/TemplatePathsCacheWarmerTest.php

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

7373
$this->fileLocator
7474
->expects($this->once())
7575
->method('locate')
7676
->with($template->getPath())
77-
->will($this->returnValue(\dirname($this->tmpDir).'/path/to/template.html.twig'));
77+
->willReturn(\dirname($this->tmpDir).'/path/to/template.html.twig');
7878

7979
$warmer = new TemplatePathsCacheWarmer($this->templateFinder, $this->templateLocator);
8080
$warmer->warmUp($this->tmpDir);
@@ -87,7 +87,7 @@ public function testWarmUpEmpty()
8787
$this->templateFinder
8888
->expects($this->once())
8989
->method('findAllTemplates')
90-
->will($this->returnValue([]));
90+
->willReturn([]);
9191

9292
$this->fileLocator
9393
->expects($this->never())

Tests/Command/RouterDebugCommandTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ private function getRouter()
8282
$router
8383
->expects($this->any())
8484
->method('getRouteCollection')
85-
->will($this->returnValue($routeCollection));
85+
->willReturn($routeCollection);
8686

8787
return $router;
8888
}
@@ -93,13 +93,13 @@ private function getKernel()
9393
$container
9494
->expects($this->atLeastOnce())
9595
->method('has')
96-
->will($this->returnCallback(function ($id) {
96+
->willReturnCallback(function ($id) {
9797
if ('console.command_loader' === $id) {
9898
return false;
9999
}
100100

101101
return true;
102-
}))
102+
})
103103
;
104104
$container
105105
->expects($this->any())

Tests/Command/RouterMatchCommandTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ private function getRouter()
8080
$router
8181
->expects($this->any())
8282
->method('getRouteCollection')
83-
->will($this->returnValue($routeCollection));
83+
->willReturn($routeCollection);
8484
$router
8585
->expects($this->any())
8686
->method('getContext')
87-
->will($this->returnValue($requestContext));
87+
->willReturn($requestContext);
8888

8989
return $router;
9090
}
@@ -95,9 +95,9 @@ private function getKernel()
9595
$container
9696
->expects($this->atLeastOnce())
9797
->method('has')
98-
->will($this->returnCallback(function ($id) {
98+
->willReturnCallback(function ($id) {
9999
return 'console.command_loader' !== $id;
100-
}))
100+
})
101101
;
102102
$container
103103
->expects($this->any())

Tests/Command/TranslationDebugCommandTest.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -136,26 +136,26 @@ private function createCommandTester($extractedMessages = [], $loadedMessages =
136136
$translator
137137
->expects($this->any())
138138
->method('getFallbackLocales')
139-
->will($this->returnValue(['en']));
139+
->willReturn(['en']);
140140

141141
$extractor = $this->getMockBuilder('Symfony\Component\Translation\Extractor\ExtractorInterface')->getMock();
142142
$extractor
143143
->expects($this->any())
144144
->method('extract')
145-
->will(
146-
$this->returnCallback(function ($path, $catalogue) use ($extractedMessages) {
145+
->willReturnCallback(
146+
function ($path, $catalogue) use ($extractedMessages) {
147147
$catalogue->add($extractedMessages);
148-
})
148+
}
149149
);
150150

151151
$loader = $this->getMockBuilder('Symfony\Component\Translation\Reader\TranslationReader')->getMock();
152152
$loader
153153
->expects($this->any())
154154
->method('read')
155-
->will(
156-
$this->returnCallback(function ($path, $catalogue) use ($loadedMessages) {
155+
->willReturnCallback(
156+
function ($path, $catalogue) use ($loadedMessages) {
157157
$catalogue->add($loadedMessages);
158-
})
158+
}
159159
);
160160

161161
if (null === $kernel) {
@@ -173,23 +173,23 @@ private function createCommandTester($extractedMessages = [], $loadedMessages =
173173
$kernel
174174
->expects($this->any())
175175
->method('getBundle')
176-
->will($this->returnValueMap($returnValues));
176+
->willReturnMap($returnValues);
177177
}
178178

179179
$kernel
180180
->expects($this->any())
181181
->method('getRootDir')
182-
->will($this->returnValue($this->translationDir));
182+
->willReturn($this->translationDir);
183183

184184
$kernel
185185
->expects($this->any())
186186
->method('getBundles')
187-
->will($this->returnValue([]));
187+
->willReturn([]);
188188

189189
$kernel
190190
->expects($this->any())
191191
->method('getContainer')
192-
->will($this->returnValue($this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock()));
192+
->willReturn($this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock());
193193

194194
$command = new TranslationDebugCommand($translator, $loader, $extractor, $this->translationDir.'/translations', $this->translationDir.'/templates');
195195

@@ -214,23 +214,23 @@ public function testLegacyDebugCommand()
214214
$kernel
215215
->expects($this->any())
216216
->method('getBundles')
217-
->will($this->returnValue([]));
217+
->willReturn([]);
218218

219219
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
220220
$container
221221
->expects($this->any())
222222
->method('get')
223-
->will($this->returnValueMap([
223+
->willReturnMap([
224224
['translation.extractor', 1, $extractor],
225225
['translation.reader', 1, $loader],
226226
['translator', 1, $translator],
227227
['kernel', 1, $kernel],
228-
]));
228+
]);
229229

230230
$kernel
231231
->expects($this->any())
232232
->method('getContainer')
233-
->will($this->returnValue($container));
233+
->willReturn($container);
234234

235235
$command = new TranslationDebugCommand();
236236
$command->setContainer($container);
@@ -250,7 +250,7 @@ private function getBundle($path)
250250
$bundle
251251
->expects($this->any())
252252
->method('getPath')
253-
->will($this->returnValue($path))
253+
->willReturn($path)
254254
;
255255

256256
return $bundle;

Tests/Command/TranslationUpdateCommandTest.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -114,36 +114,36 @@ private function createCommandTester($extractedMessages = [], $loadedMessages =
114114
$translator
115115
->expects($this->any())
116116
->method('getFallbackLocales')
117-
->will($this->returnValue(['en']));
117+
->willReturn(['en']);
118118

119119
$extractor = $this->getMockBuilder('Symfony\Component\Translation\Extractor\ExtractorInterface')->getMock();
120120
$extractor
121121
->expects($this->any())
122122
->method('extract')
123-
->will(
124-
$this->returnCallback(function ($path, $catalogue) use ($extractedMessages) {
123+
->willReturnCallback(
124+
function ($path, $catalogue) use ($extractedMessages) {
125125
foreach ($extractedMessages as $domain => $messages) {
126126
$catalogue->add($messages, $domain);
127127
}
128-
})
128+
}
129129
);
130130

131131
$loader = $this->getMockBuilder('Symfony\Component\Translation\Reader\TranslationReader')->getMock();
132132
$loader
133133
->expects($this->any())
134134
->method('read')
135-
->will(
136-
$this->returnCallback(function ($path, $catalogue) use ($loadedMessages) {
135+
->willReturnCallback(
136+
function ($path, $catalogue) use ($loadedMessages) {
137137
$catalogue->add($loadedMessages);
138-
})
138+
}
139139
);
140140

141141
$writer = $this->getMockBuilder('Symfony\Component\Translation\Writer\TranslationWriter')->getMock();
142142
$writer
143143
->expects($this->any())
144144
->method('getFormats')
145-
->will(
146-
$this->returnValue(['xlf', 'yml', 'yaml'])
145+
->willReturn(
146+
['xlf', 'yml', 'yaml']
147147
);
148148

149149
if (null === $kernel) {
@@ -161,23 +161,23 @@ private function createCommandTester($extractedMessages = [], $loadedMessages =
161161
$kernel
162162
->expects($this->any())
163163
->method('getBundle')
164-
->will($this->returnValueMap($returnValues));
164+
->willReturnMap($returnValues);
165165
}
166166

167167
$kernel
168168
->expects($this->any())
169169
->method('getRootDir')
170-
->will($this->returnValue($this->translationDir));
170+
->willReturn($this->translationDir);
171171

172172
$kernel
173173
->expects($this->any())
174174
->method('getBundles')
175-
->will($this->returnValue([]));
175+
->willReturn([]);
176176

177177
$kernel
178178
->expects($this->any())
179179
->method('getContainer')
180-
->will($this->returnValue($this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock()));
180+
->willReturn($this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock());
181181

182182
$command = new TranslationUpdateCommand($writer, $loader, $extractor, 'en', $this->translationDir.'/translations', $this->translationDir.'/templates');
183183

@@ -203,24 +203,24 @@ public function testLegacyUpdateCommand()
203203
$kernel
204204
->expects($this->any())
205205
->method('getBundles')
206-
->will($this->returnValue([]));
206+
->willReturn([]);
207207

208208
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
209209
$container
210210
->expects($this->any())
211211
->method('get')
212-
->will($this->returnValueMap([
212+
->willReturnMap([
213213
['translation.extractor', 1, $extractor],
214214
['translation.reader', 1, $loader],
215215
['translation.writer', 1, $writer],
216216
['translator', 1, $translator],
217217
['kernel', 1, $kernel],
218-
]));
218+
]);
219219

220220
$kernel
221221
->expects($this->any())
222222
->method('getContainer')
223-
->will($this->returnValue($container));
223+
->willReturn($container);
224224

225225
$command = new TranslationUpdateCommand();
226226
$command->setContainer($container);
@@ -240,7 +240,7 @@ private function getBundle($path)
240240
$bundle
241241
->expects($this->any())
242242
->method('getPath')
243-
->will($this->returnValue($path))
243+
->willReturn($path)
244244
;
245245

246246
return $bundle;

Tests/Console/ApplicationTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ private function getKernel(array $bundles, $useDispatcher = false)
206206
->expects($this->atLeastOnce())
207207
->method('get')
208208
->with($this->equalTo('event_dispatcher'))
209-
->will($this->returnValue($dispatcher));
209+
->willReturn($dispatcher);
210210
}
211211

212212
$container
@@ -226,12 +226,12 @@ private function getKernel(array $bundles, $useDispatcher = false)
226226
$kernel
227227
->expects($this->any())
228228
->method('getBundles')
229-
->will($this->returnValue($bundles))
229+
->willReturn($bundles)
230230
;
231231
$kernel
232232
->expects($this->any())
233233
->method('getContainer')
234-
->will($this->returnValue($container))
234+
->willReturn($container)
235235
;
236236

237237
return $kernel;
@@ -243,9 +243,9 @@ private function createBundleMock(array $commands)
243243
$bundle
244244
->expects($this->once())
245245
->method('registerCommands')
246-
->will($this->returnCallback(function (Application $application) use ($commands) {
246+
->willReturnCallback(function (Application $application) use ($commands) {
247247
$application->addCommands($commands);
248-
}))
248+
})
249249
;
250250

251251
return $bundle;

Tests/Controller/ControllerNameParserTest.php

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

164164
return $bundles[$bundle];
165-
}))
165+
})
166166
;
167167

168168
$bundles = [
@@ -175,7 +175,7 @@ private function createParser()
175175
$kernel
176176
->expects($this->any())
177177
->method('getBundles')
178-
->will($this->returnValue($bundles))
178+
->willReturn($bundles)
179179
;
180180

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

190190
return $bundle;
191191
}

Tests/Controller/ControllerResolverTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function testGetControllerWithBundleNotation()
5555
$parser->expects($this->once())
5656
->method('parse')
5757
->with($shortName)
58-
->will($this->returnValue('Symfony\Bundle\FrameworkBundle\Tests\Controller\ContainerAwareController::testAction'))
58+
->willReturn('Symfony\Bundle\FrameworkBundle\Tests\Controller\ContainerAwareController::testAction')
5959
;
6060

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

0 commit comments

Comments
 (0)