Skip to content

Commit 4fb67df

Browse files
committed
Use willReturn() instead of will(returnValue()).
1 parent 7ae54b4 commit 4fb67df

File tree

198 files changed

+1225
-1227
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

198 files changed

+1225
-1227
lines changed

.php_cs.dist

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ return PhpCsFixer\Config::create()
1818
'native_function_invocation' => ['include' => ['@compiler_optimized'], 'scope' => 'namespaced'],
1919
// Part of future @Symfony ruleset in PHP-CS-Fixer To be removed from the config file once upgrading
2020
'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
21-
// Part of @Symfony:risky in PHP-CS-Fixer 2.15.0. Incompatible with PHPUnit 4 that is required for Symfony 3.4
22-
'php_unit_mock_short_will_return' => false,
2321
])
2422
->setRiskyAllowed(true)
2523
->setFinder(

src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,20 +166,20 @@ private function createCollector($queries)
166166
->getMock();
167167
$connection->expects($this->any())
168168
->method('getDatabasePlatform')
169-
->will($this->returnValue(new MySqlPlatform()));
169+
->willReturn(new MySqlPlatform());
170170

171171
$registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock();
172172
$registry
173173
->expects($this->any())
174174
->method('getConnectionNames')
175-
->will($this->returnValue(['default' => 'doctrine.dbal.default_connection']));
175+
->willReturn(['default' => 'doctrine.dbal.default_connection']);
176176
$registry
177177
->expects($this->any())
178178
->method('getManagerNames')
179-
->will($this->returnValue(['default' => 'doctrine.orm.default_entity_manager']));
179+
->willReturn(['default' => 'doctrine.orm.default_entity_manager']);
180180
$registry->expects($this->any())
181181
->method('getConnection')
182-
->will($this->returnValue($connection));
182+
->willReturn($connection);
183183

184184
$logger = $this->getMockBuilder('Doctrine\DBAL\Logging\DebugStack')->getMock();
185185
$logger->queries = $queries;

src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ protected function setUp()
4444

4545
$this->extension->expects($this->any())
4646
->method('getObjectManagerElementName')
47-
->will($this->returnCallback(function ($name) {
47+
->willReturnCallback(function ($name) {
4848
return 'doctrine.orm.'.$name;
49-
}));
49+
});
5050
}
5151

5252
/**

src/Symfony/Bridge/Doctrine/Tests/ExpressionLanguage/DoctrineParserCacheTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function testFetch()
2626

2727
$doctrineCacheMock->expects($this->once())
2828
->method('fetch')
29-
->will($this->returnValue('bar'));
29+
->willReturn('bar');
3030

3131
$result = $parserCache->fetch('foo');
3232

@@ -41,7 +41,7 @@ public function testFetchUnexisting()
4141
$doctrineCacheMock
4242
->expects($this->once())
4343
->method('fetch')
44-
->will($this->returnValue(false));
44+
->willReturn(false);
4545

4646
$this->assertNull($parserCache->fetch(''));
4747
}

src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,47 +34,47 @@ public function requiredProvider()
3434
// Simple field, not nullable
3535
$classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock();
3636
$classMetadata->fieldMappings['field'] = true;
37-
$classMetadata->expects($this->once())->method('isNullable')->with('field')->will($this->returnValue(false));
37+
$classMetadata->expects($this->once())->method('isNullable')->with('field')->willReturn(false);
3838

3939
$return[] = [$classMetadata, new ValueGuess(true, Guess::HIGH_CONFIDENCE)];
4040

4141
// Simple field, nullable
4242
$classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock();
4343
$classMetadata->fieldMappings['field'] = true;
44-
$classMetadata->expects($this->once())->method('isNullable')->with('field')->will($this->returnValue(true));
44+
$classMetadata->expects($this->once())->method('isNullable')->with('field')->willReturn(true);
4545

4646
$return[] = [$classMetadata, new ValueGuess(false, Guess::MEDIUM_CONFIDENCE)];
4747

4848
// One-to-one, nullable (by default)
4949
$classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock();
50-
$classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(true));
50+
$classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->willReturn(true);
5151

5252
$mapping = ['joinColumns' => [[]]];
53-
$classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->will($this->returnValue($mapping));
53+
$classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->willReturn($mapping);
5454

5555
$return[] = [$classMetadata, new ValueGuess(false, Guess::HIGH_CONFIDENCE)];
5656

5757
// One-to-one, nullable (explicit)
5858
$classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock();
59-
$classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(true));
59+
$classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->willReturn(true);
6060

6161
$mapping = ['joinColumns' => [['nullable' => true]]];
62-
$classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->will($this->returnValue($mapping));
62+
$classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->willReturn($mapping);
6363

6464
$return[] = [$classMetadata, new ValueGuess(false, Guess::HIGH_CONFIDENCE)];
6565

6666
// One-to-one, not nullable
6767
$classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock();
68-
$classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(true));
68+
$classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->willReturn(true);
6969

7070
$mapping = ['joinColumns' => [['nullable' => false]]];
71-
$classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->will($this->returnValue($mapping));
71+
$classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->willReturn($mapping);
7272

7373
$return[] = [$classMetadata, new ValueGuess(true, Guess::HIGH_CONFIDENCE)];
7474

7575
// One-to-many, no clue
7676
$classMetadata = $this->getMockBuilder('Doctrine\ORM\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock();
77-
$classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(false));
77+
$classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->willReturn(false);
7878

7979
$return[] = [$classMetadata, null];
8080

@@ -84,10 +84,10 @@ public function requiredProvider()
8484
private function getGuesser(ClassMetadata $classMetadata)
8585
{
8686
$em = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')->getMock();
87-
$em->expects($this->once())->method('getClassMetaData')->with('TestEntity')->will($this->returnValue($classMetadata));
87+
$em->expects($this->once())->method('getClassMetaData')->with('TestEntity')->willReturn($classMetadata);
8888

8989
$registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock();
90-
$registry->expects($this->once())->method('getManagers')->will($this->returnValue([$em]));
90+
$registry->expects($this->once())->method('getManagers')->willReturn([$em]);
9191

9292
return new DoctrineOrmTypeGuesser($registry);
9393
}

src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ protected function getExtensions()
3838

3939
$manager->expects($this->any())
4040
->method('getManager')
41-
->will($this->returnValue($this->em));
41+
->willReturn($this->em);
4242

4343
$manager->expects($this->any())
4444
->method('getManagerForClass')
45-
->will($this->returnValue($this->em));
45+
->willReturn($this->em);
4646

4747
return [
4848
new CoreExtension(),

src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,7 +1087,7 @@ public function testGetManagerForClassIfNoEm()
10871087
$this->emRegistry->expects($this->once())
10881088
->method('getManagerForClass')
10891089
->with(self::SINGLE_IDENT_CLASS)
1090-
->will($this->returnValue($this->em));
1090+
->willReturn($this->em);
10911091

10921092
$this->factory->createNamed('name', static::TESTED_TYPE, null, [
10931093
'class' => self::SINGLE_IDENT_CLASS,
@@ -1237,7 +1237,7 @@ protected function createRegistryMock($name, $em)
12371237
$registry->expects($this->any())
12381238
->method('getManager')
12391239
->with($this->equalTo($name))
1240-
->will($this->returnValue($em));
1240+
->willReturn($em);
12411241

12421242
return $registry;
12431243
}

src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ private function getManager($em, $name = null)
188188
$manager->expects($this->any())
189189
->method('getManager')
190190
->with($this->equalTo($name))
191-
->will($this->returnValue($em));
191+
->willReturn($em);
192192

193193
return $manager;
194194
}

src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ protected function createRegistryMock(ObjectManager $em = null)
8282
$registry->expects($this->any())
8383
->method('getManager')
8484
->with($this->equalTo(self::EM_NAME))
85-
->will($this->returnValue($em));
85+
->willReturn($em);
8686

8787
return $registry;
8888
}
@@ -104,14 +104,14 @@ protected function createEntityManagerMock($repositoryMock)
104104
;
105105
$em->expects($this->any())
106106
->method('getRepository')
107-
->will($this->returnValue($repositoryMock))
107+
->willReturn($repositoryMock)
108108
;
109109

110110
$classMetadata = $this->getMockBuilder('Doctrine\Common\Persistence\Mapping\ClassMetadata')->getMock();
111111
$classMetadata
112112
->expects($this->any())
113113
->method('hasField')
114-
->will($this->returnValue(true))
114+
->willReturn(true)
115115
;
116116
$reflParser = $this->getMockBuilder('Doctrine\Common\Reflection\StaticReflectionParser')
117117
->disableOriginalConstructor()
@@ -125,12 +125,12 @@ protected function createEntityManagerMock($repositoryMock)
125125
$refl
126126
->expects($this->any())
127127
->method('getValue')
128-
->will($this->returnValue(true))
128+
->willReturn(true)
129129
;
130130
$classMetadata->reflFields = ['name' => $refl];
131131
$em->expects($this->any())
132132
->method('getClassMetadata')
133-
->will($this->returnValue($classMetadata))
133+
->willReturn($classMetadata)
134134
;
135135

136136
return $em;
@@ -366,7 +366,7 @@ public function testValidateUniquenessUsingCustomRepositoryMethod()
366366
$repository = $this->createRepositoryMock();
367367
$repository->expects($this->once())
368368
->method('findByCustom')
369-
->will($this->returnValue([]))
369+
->willReturn([])
370370
;
371371
$this->em = $this->createEntityManagerMock($repository);
372372
$this->registry = $this->createRegistryMock($this->em);
@@ -394,15 +394,15 @@ public function testValidateUniquenessWithUnrewoundArray()
394394
$repository = $this->createRepositoryMock();
395395
$repository->expects($this->once())
396396
->method('findByCustom')
397-
->will(
398-
$this->returnCallback(function () use ($entity) {
397+
->willReturnCallback(
398+
function () use ($entity) {
399399
$returnValue = [
400400
$entity,
401401
];
402402
next($returnValue);
403403

404404
return $returnValue;
405-
})
405+
}
406406
)
407407
;
408408
$this->em = $this->createEntityManagerMock($repository);
@@ -430,7 +430,7 @@ public function testValidateResultTypes($entity1, $result)
430430
$repository = $this->createRepositoryMock();
431431
$repository->expects($this->once())
432432
->method('findByCustom')
433-
->will($this->returnValue($result))
433+
->willReturn($result)
434434
;
435435
$this->em = $this->createEntityManagerMock($repository);
436436
$this->registry = $this->createRegistryMock($this->em);
@@ -564,7 +564,7 @@ public function testValidateUniquenessWithArrayValue()
564564

565565
$repository->expects($this->once())
566566
->method('findByCustom')
567-
->will($this->returnValue([$entity1]))
567+
->willReturn([$entity1])
568568
;
569569

570570
$this->em->persist($entity1);
@@ -635,7 +635,7 @@ public function testValidateUniquenessOnNullResult()
635635
$repository = $this->createRepositoryMock();
636636
$repository
637637
->method('find')
638-
->will($this->returnValue(null))
638+
->willReturn(null)
639639
;
640640

641641
$this->em = $this->createEntityManagerMock($repository);

src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function testVerbosityMapping($verbosity, $level, $isHandling, array $map
5050
$output
5151
->expects($this->atLeastOnce())
5252
->method('getVerbosity')
53-
->will($this->returnValue($verbosity))
53+
->willReturn($verbosity)
5454
;
5555
$handler = new ConsoleHandler($output, true, $map);
5656
$this->assertSame($isHandling, $handler->isHandling(['level' => $level]),
@@ -114,12 +114,12 @@ public function testVerbosityChanged()
114114
$output
115115
->expects($this->at(0))
116116
->method('getVerbosity')
117-
->will($this->returnValue(OutputInterface::VERBOSITY_QUIET))
117+
->willReturn(OutputInterface::VERBOSITY_QUIET)
118118
;
119119
$output
120120
->expects($this->at(1))
121121
->method('getVerbosity')
122-
->will($this->returnValue(OutputInterface::VERBOSITY_DEBUG))
122+
->willReturn(OutputInterface::VERBOSITY_DEBUG)
123123
;
124124
$handler = new ConsoleHandler($output);
125125
$this->assertFalse($handler->isHandling(['level' => Logger::NOTICE]),
@@ -144,7 +144,7 @@ public function testWritingAndFormatting()
144144
$output
145145
->expects($this->any())
146146
->method('getVerbosity')
147-
->will($this->returnValue(OutputInterface::VERBOSITY_DEBUG))
147+
->willReturn(OutputInterface::VERBOSITY_DEBUG)
148148
;
149149
$output
150150
->expects($this->once())

0 commit comments

Comments
 (0)