Skip to content

Commit 0e8b95a

Browse files
Merge branch '3.4' into 4.2
* 3.4: Use willReturn() instead of will(returnValue()).
2 parents 32cc317 + d041e3b commit 0e8b95a

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
@@ -110,7 +110,7 @@ protected function createContext()
110110
$validator->expects($this->any())
111111
->method('inContext')
112112
->with($context)
113-
->will($this->returnValue($contextualValidator));
113+
->willReturn($contextualValidator);
114114

115115
return $context;
116116
}
@@ -175,7 +175,7 @@ protected function expectValidateAt($i, $propertyPath, $value, $group)
175175
$validator->expects($this->at(2 * $i))
176176
->method('atPath')
177177
->with($propertyPath)
178-
->will($this->returnValue($validator));
178+
->willReturn($validator);
179179
$validator->expects($this->at(2 * $i + 1))
180180
->method('validate')
181181
->with($value, $this->logicalOr(null, [], $this->isInstanceOf('\Symfony\Component\Validator\Constraints\Valid')), $group);
@@ -187,7 +187,7 @@ protected function expectValidateValueAt($i, $propertyPath, $value, $constraints
187187
$contextualValidator->expects($this->at(2 * $i))
188188
->method('atPath')
189189
->with($propertyPath)
190-
->will($this->returnValue($contextualValidator));
190+
->willReturn($contextualValidator);
191191
$contextualValidator->expects($this->at(2 * $i + 1))
192192
->method('validate')
193193
->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
@@ -294,11 +294,11 @@ public function testValidMimeType()
294294
$file
295295
->expects($this->once())
296296
->method('getPathname')
297-
->will($this->returnValue($this->path));
297+
->willReturn($this->path);
298298
$file
299299
->expects($this->once())
300300
->method('getMimeType')
301-
->will($this->returnValue('image/jpg'));
301+
->willReturn('image/jpg');
302302

303303
$constraint = new File([
304304
'mimeTypes' => ['image/png', 'image/jpg'],
@@ -318,11 +318,11 @@ public function testValidWildcardMimeType()
318318
$file
319319
->expects($this->once())
320320
->method('getPathname')
321-
->will($this->returnValue($this->path));
321+
->willReturn($this->path);
322322
$file
323323
->expects($this->once())
324324
->method('getMimeType')
325-
->will($this->returnValue('image/jpg'));
325+
->willReturn('image/jpg');
326326

327327
$constraint = new File([
328328
'mimeTypes' => ['image/*'],
@@ -342,11 +342,11 @@ public function testInvalidMimeType()
342342
$file
343343
->expects($this->once())
344344
->method('getPathname')
345-
->will($this->returnValue($this->path));
345+
->willReturn($this->path);
346346
$file
347347
->expects($this->once())
348348
->method('getMimeType')
349-
->will($this->returnValue('application/pdf'));
349+
->willReturn('application/pdf');
350350

351351
$constraint = new File([
352352
'mimeTypes' => ['image/png', 'image/jpg'],
@@ -373,11 +373,11 @@ public function testInvalidWildcardMimeType()
373373
$file
374374
->expects($this->once())
375375
->method('getPathname')
376-
->will($this->returnValue($this->path));
376+
->willReturn($this->path);
377377
$file
378378
->expects($this->once())
379379
->method('getMimeType')
380-
->will($this->returnValue('application/pdf'));
380+
->willReturn('application/pdf');
381381

382382
$constraint = new File([
383383
'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)