Skip to content

Commit d041e3b

Browse files
committed
Use willReturn() instead of will(returnValue()).
1 parent 23cf394 commit d041e3b

File tree

8 files changed

+26
-26
lines changed

8 files changed

+26
-26
lines changed

Test/ConstraintValidatorTestCase.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ protected function createContext()
109109
$validator->expects($this->any())
110110
->method('inContext')
111111
->with($context)
112-
->will($this->returnValue($contextualValidator));
112+
->willReturn($contextualValidator);
113113

114114
return $context;
115115
}
@@ -174,7 +174,7 @@ protected function expectValidateAt($i, $propertyPath, $value, $group)
174174
$validator->expects($this->at(2 * $i))
175175
->method('atPath')
176176
->with($propertyPath)
177-
->will($this->returnValue($validator));
177+
->willReturn($validator);
178178
$validator->expects($this->at(2 * $i + 1))
179179
->method('validate')
180180
->with($value, $this->logicalOr(null, [], $this->isInstanceOf('\Symfony\Component\Validator\Constraints\Valid')), $group);
@@ -186,7 +186,7 @@ protected function expectValidateValueAt($i, $propertyPath, $value, $constraints
186186
$contextualValidator->expects($this->at(2 * $i))
187187
->method('atPath')
188188
->with($propertyPath)
189-
->will($this->returnValue($contextualValidator));
189+
->willReturn($contextualValidator);
190190
$contextualValidator->expects($this->at(2 * $i + 1))
191191
->method('validate')
192192
->with($value, $constraints, $group);

Tests/Constraints/ExpressionValidatorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,11 @@ public function testExpressionLanguageUsage()
258258
$used = false;
259259

260260
$expressionLanguage->method('evaluate')
261-
->will($this->returnCallback(function () use (&$used) {
261+
->willReturnCallback(function () use (&$used) {
262262
$used = true;
263263

264264
return true;
265-
}));
265+
});
266266

267267
$validator = new ExpressionValidator(null, $expressionLanguage);
268268
$validator->initialize($this->createContext());

Tests/Constraints/FileValidatorTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -291,11 +291,11 @@ public function testValidMimeType()
291291
$file
292292
->expects($this->once())
293293
->method('getPathname')
294-
->will($this->returnValue($this->path));
294+
->willReturn($this->path);
295295
$file
296296
->expects($this->once())
297297
->method('getMimeType')
298-
->will($this->returnValue('image/jpg'));
298+
->willReturn('image/jpg');
299299

300300
$constraint = new File([
301301
'mimeTypes' => ['image/png', 'image/jpg'],
@@ -315,11 +315,11 @@ public function testValidWildcardMimeType()
315315
$file
316316
->expects($this->once())
317317
->method('getPathname')
318-
->will($this->returnValue($this->path));
318+
->willReturn($this->path);
319319
$file
320320
->expects($this->once())
321321
->method('getMimeType')
322-
->will($this->returnValue('image/jpg'));
322+
->willReturn('image/jpg');
323323

324324
$constraint = new File([
325325
'mimeTypes' => ['image/*'],
@@ -339,11 +339,11 @@ public function testInvalidMimeType()
339339
$file
340340
->expects($this->once())
341341
->method('getPathname')
342-
->will($this->returnValue($this->path));
342+
->willReturn($this->path);
343343
$file
344344
->expects($this->once())
345345
->method('getMimeType')
346-
->will($this->returnValue('application/pdf'));
346+
->willReturn('application/pdf');
347347

348348
$constraint = new File([
349349
'mimeTypes' => ['image/png', 'image/jpg'],
@@ -369,11 +369,11 @@ public function testInvalidWildcardMimeType()
369369
$file
370370
->expects($this->once())
371371
->method('getPathname')
372-
->will($this->returnValue($this->path));
372+
->willReturn($this->path);
373373
$file
374374
->expects($this->once())
375375
->method('getMimeType')
376-
->will($this->returnValue('application/pdf'));
376+
->willReturn('application/pdf');
377377

378378
$constraint = new File([
379379
'mimeTypes' => ['image/*', 'image/jpg'],

Tests/ContainerConstraintValidatorFactoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function testGetInstanceInvalidValidatorClass()
5454
$constraint
5555
->expects($this->once())
5656
->method('validatedBy')
57-
->will($this->returnValue('Fully\\Qualified\\ConstraintValidator\\Class\\Name'));
57+
->willReturn('Fully\\Qualified\\ConstraintValidator\\Class\\Name');
5858

5959
$factory = new ContainerConstraintValidatorFactory(new Container());
6060
$factory->getInstance($constraint);

Tests/Mapping/Cache/AbstractCacheTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function testWrite()
3131

3232
$meta->expects($this->once())
3333
->method('getClassName')
34-
->will($this->returnValue('Foo\\Bar'));
34+
->willReturn('Foo\\Bar');
3535

3636
$this->cache->write($meta);
3737

@@ -51,7 +51,7 @@ public function testHas()
5151

5252
$meta->expects($this->once())
5353
->method('getClassName')
54-
->will($this->returnValue('Foo\\Bar'));
54+
->willReturn('Foo\\Bar');
5555

5656
$this->assertFalse($this->cache->has('Foo\\Bar'), 'has() returns false when there is no entry');
5757

@@ -68,7 +68,7 @@ public function testRead()
6868

6969
$meta->expects($this->once())
7070
->method('getClassName')
71-
->will($this->returnValue('Foo\\Bar'));
71+
->willReturn('Foo\\Bar');
7272

7373
$this->assertFalse($this->cache->read('Foo\\Bar'), 'read() returns false when there is no entry');
7474

Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function testWriteMetadataToCache()
9797
[$this->equalTo(self::PARENT_CLASS)],
9898
[$this->equalTo(self::INTERFACE_A_CLASS)]
9999
)
100-
->will($this->returnValue(false));
100+
->willReturn(false);
101101
$cache->expects($this->exactly(2))
102102
->method('write')
103103
->withConsecutive(
@@ -172,12 +172,12 @@ public function testMetadataCacheWithRuntimeConstraint()
172172
$cache
173173
->expects($this->any())
174174
->method('write')
175-
->will($this->returnCallback(function ($metadata) { serialize($metadata); }))
175+
->willReturnCallback(function ($metadata) { serialize($metadata); })
176176
;
177177

178178
$cache->expects($this->any())
179179
->method('read')
180-
->will($this->returnValue(false));
180+
->willReturn(false);
181181

182182
$metadata = $factory->getMetadataFor(self::PARENT_CLASS);
183183
$metadata->addConstraint(new Callback(function () {}));

Tests/Mapping/Loader/LoaderChainTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ public function testReturnsTrueIfAnyLoaderReturnedTrue()
4646
$loader1 = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Loader\LoaderInterface')->getMock();
4747
$loader1->expects($this->any())
4848
->method('loadClassMetadata')
49-
->will($this->returnValue(true));
49+
->willReturn(true);
5050

5151
$loader2 = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Loader\LoaderInterface')->getMock();
5252
$loader2->expects($this->any())
5353
->method('loadClassMetadata')
54-
->will($this->returnValue(false));
54+
->willReturn(false);
5555

5656
$chain = new LoaderChain([
5757
$loader1,
@@ -68,12 +68,12 @@ public function testReturnsFalseIfNoLoaderReturnedTrue()
6868
$loader1 = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Loader\LoaderInterface')->getMock();
6969
$loader1->expects($this->any())
7070
->method('loadClassMetadata')
71-
->will($this->returnValue(false));
71+
->willReturn(false);
7272

7373
$loader2 = $this->getMockBuilder('Symfony\Component\Validator\Mapping\Loader\LoaderInterface')->getMock();
7474
$loader2->expects($this->any())
7575
->method('loadClassMetadata')
76-
->will($this->returnValue(false));
76+
->willReturn(false);
7777

7878
$chain = new LoaderChain([
7979
$loader1,

Tests/Validator/AbstractTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,9 +610,9 @@ public function testInitializeObjectsOnFirstValidation()
610610
$initializer1->expects($this->once())
611611
->method('initialize')
612612
->with($entity)
613-
->will($this->returnCallback(function ($object) {
613+
->willReturnCallback(function ($object) {
614614
$object->initialized = true;
615-
}));
615+
});
616616

617617
$initializer2->expects($this->once())
618618
->method('initialize')

0 commit comments

Comments
 (0)