Skip to content

Commit a305824

Browse files
committed
fixed obsolete getMock() usage
1 parent 7ae26ed commit a305824

File tree

42 files changed

+197
-206
lines changed

Some content is hidden

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

42 files changed

+197
-206
lines changed

src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/DoctrineChoiceLoaderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public function testLoadChoiceList()
117117
*/
118118
public function testLegacyLoadChoiceList()
119119
{
120-
$factory = $this->getMock('Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface');
120+
$factory = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface')->getMock();
121121
$loader = new DoctrineChoiceLoader(
122122
$factory,
123123
$this->om,

src/Symfony/Bridge/Doctrine/Tests/Form/EventListener/MergeDoctrineCollectionListenerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ protected function setUp()
3131
{
3232
$this->collection = new ArrayCollection(array('test'));
3333
$this->dispatcher = new EventDispatcher();
34-
$this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface');
34+
$this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock();
3535
$this->form = $this->getBuilder()
3636
->getForm();
3737
}

src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ private function getContainerWithTokenStorage($token = null)
132132

133133
public function testJson()
134134
{
135-
$container = $this->getMock(ContainerInterface::class);
135+
$container = $this->getMockBuilder(ContainerInterface::class)->getMock();
136136
$container
137137
->expects($this->once())
138138
->method('has')
@@ -149,14 +149,14 @@ public function testJson()
149149

150150
public function testJsonWithSerializer()
151151
{
152-
$container = $this->getMock(ContainerInterface::class);
152+
$container = $this->getMockBuilder(ContainerInterface::class)->getMock();
153153
$container
154154
->expects($this->once())
155155
->method('has')
156156
->with('serializer')
157157
->will($this->returnValue(true));
158158

159-
$serializer = $this->getMock(SerializerInterface::class);
159+
$serializer = $this->getMockBuilder(SerializerInterface::class)->getMock();
160160
$serializer
161161
->expects($this->once())
162162
->method('serialize')
@@ -179,14 +179,14 @@ public function testJsonWithSerializer()
179179

180180
public function testJsonWithSerializerContextOverride()
181181
{
182-
$container = $this->getMock(ContainerInterface::class);
182+
$container = $this->getMockBuilder(ContainerInterface::class)->getMock();
183183
$container
184184
->expects($this->once())
185185
->method('has')
186186
->with('serializer')
187187
->will($this->returnValue(true));
188188

189-
$serializer = $this->getMock(SerializerInterface::class);
189+
$serializer = $this->getMockBuilder(SerializerInterface::class)->getMock();
190190
$serializer
191191
->expects($this->once())
192192
->method('serialize')

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/ConfigCachePassTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function testThatCheckersAreProcessedInPriorityOrder()
2525
);
2626

2727
$definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
28-
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds', 'getDefinition', 'hasDefinition'))->getMock();
28+
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->getMock()->setMethods(array('findTaggedServiceIds', 'getDefinition', 'hasDefinition'))->getMock();
2929

3030
$container->expects($this->atLeastOnce())
3131
->method('findTaggedServiceIds')
@@ -50,7 +50,7 @@ public function testThatCheckersAreProcessedInPriorityOrder()
5050
public function testThatCheckersCanBeMissing()
5151
{
5252
$definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();
53-
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds'))->getMock();
53+
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->getMock()->setMethods(array('findTaggedServiceIds'))->getMock();
5454

5555
$container->expects($this->atLeastOnce())
5656
->method('findTaggedServiceIds')

src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function testGetUserNoTokenStorage()
3333

3434
public function testGetUserNoToken()
3535
{
36-
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
36+
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
3737
$this->container->set('security.token_storage', $tokenStorage);
3838
$this->assertNull($this->globals->getUser());
3939
}
@@ -43,8 +43,8 @@ public function testGetUserNoToken()
4343
*/
4444
public function testGetUser($user, $expectedUser)
4545
{
46-
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
47-
$token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
46+
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
47+
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
4848

4949
$this->container->set('security.token_storage', $tokenStorage);
5050

@@ -63,9 +63,9 @@ public function testGetUser($user, $expectedUser)
6363

6464
public function getUserProvider()
6565
{
66-
$user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
66+
$user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
6767
$std = new \stdClass();
68-
$token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
68+
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
6969

7070
return array(
7171
array($user, $user),

src/Symfony/Component/Console/Tests/ApplicationTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ public function testFindAlternativeNamespace()
454454

455455
public function testFindNamespaceDoesNotFailOnDeepSimilarNamespaces()
456456
{
457-
$application = $this->getMock('Symfony\Component\Console\Application', array('getNamespaces'));
457+
$application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(array('getNamespaces'))->getMock();
458458
$application->expects($this->once())
459459
->method('getNamespaces')
460460
->will($this->returnValue(array('foo:sublong', 'bar:sub')));
@@ -476,7 +476,7 @@ public function testFindWithDoubleColonInNameThrowsException()
476476

477477
public function testSetCatchExceptions()
478478
{
479-
$application = $this->getMock('Symfony\Component\Console\Application', array('getTerminalWidth'));
479+
$application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(array('getTerminalWidth'))->getMock();
480480
$application->setAutoExit(false);
481481
$application->expects($this->any())
482482
->method('getTerminalWidth')
@@ -514,7 +514,7 @@ public function testAutoExitSetting()
514514

515515
public function testRenderException()
516516
{
517-
$application = $this->getMock('Symfony\Component\Console\Application', array('getTerminalWidth'));
517+
$application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(array('getTerminalWidth'))->getMock();
518518
$application->setAutoExit(false);
519519
$application->expects($this->any())
520520
->method('getTerminalWidth')
@@ -546,7 +546,7 @@ public function testRenderException()
546546
$tester->run(array('command' => 'foo3:bar'), array('decorated' => true, 'capture_stderr_separately' => true));
547547
$this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception3decorated.txt', $tester->getErrorOutput(true), '->renderException() renders a pretty exceptions with previous exceptions');
548548

549-
$application = $this->getMock('Symfony\Component\Console\Application', array('getTerminalWidth'));
549+
$application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(array('getTerminalWidth'))->getMock();
550550
$application->setAutoExit(false);
551551
$application->expects($this->any())
552552
->method('getTerminalWidth')
@@ -559,7 +559,7 @@ public function testRenderException()
559559

560560
public function testRenderExceptionWithDoubleWidthCharacters()
561561
{
562-
$application = $this->getMock('Symfony\Component\Console\Application', array('getTerminalWidth'));
562+
$application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(array('getTerminalWidth'))->getMock();
563563
$application->setAutoExit(false);
564564
$application->expects($this->any())
565565
->method('getTerminalWidth')
@@ -575,7 +575,7 @@ public function testRenderExceptionWithDoubleWidthCharacters()
575575
$tester->run(array('command' => 'foo'), array('decorated' => true, 'capture_stderr_separately' => true));
576576
$this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception_doublewidth1decorated.txt', $tester->getErrorOutput(true), '->renderException() renders a pretty exceptions with previous exceptions');
577577

578-
$application = $this->getMock('Symfony\Component\Console\Application', array('getTerminalWidth'));
578+
$application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(array('getTerminalWidth'))->getMock();
579579
$application->setAutoExit(false);
580580
$application->expects($this->any())
581581
->method('getTerminalWidth')
@@ -709,7 +709,7 @@ public function testRunReturnsIntegerExitCode()
709709
{
710710
$exception = new \Exception('', 4);
711711

712-
$application = $this->getMock('Symfony\Component\Console\Application', array('doRun'));
712+
$application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(array('doRun'))->getMock();
713713
$application->setAutoExit(false);
714714
$application->expects($this->once())
715715
->method('doRun')
@@ -724,7 +724,7 @@ public function testRunReturnsExitCodeOneForExceptionCodeZero()
724724
{
725725
$exception = new \Exception('', 0);
726726

727-
$application = $this->getMock('Symfony\Component\Console\Application', array('doRun'));
727+
$application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(array('doRun'))->getMock();
728728
$application->setAutoExit(false);
729729
$application->expects($this->once())
730730
->method('doRun')

src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public function testDefaultLogger()
124124
try {
125125
$handler = ErrorHandler::register();
126126

127-
$logger = $this->getMock('Psr\Log\LoggerInterface');
127+
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
128128

129129
$handler->setDefaultLogger($logger, E_NOTICE);
130130
$handler->setDefaultLogger($logger, array(E_USER_NOTICE => LogLevel::CRITICAL));
@@ -198,7 +198,7 @@ public function testHandleError()
198198
restore_error_handler();
199199
restore_exception_handler();
200200

201-
$logger = $this->getMock('Psr\Log\LoggerInterface');
201+
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
202202

203203
$warnArgCheck = function ($logLevel, $message, $context) {
204204
$this->assertEquals('info', $logLevel);
@@ -222,7 +222,7 @@ public function testHandleError()
222222
restore_error_handler();
223223
restore_exception_handler();
224224

225-
$logger = $this->getMock('Psr\Log\LoggerInterface');
225+
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
226226

227227
$logArgCheck = function ($level, $message, $context) {
228228
$this->assertEquals('Undefined variable: undefVar', $message);
@@ -283,7 +283,7 @@ public function testHandleDeprecation()
283283
$this->assertArrayHasKey('stack', $context);
284284
};
285285

286-
$logger = $this->getMock('Psr\Log\LoggerInterface');
286+
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
287287
$logger
288288
->expects($this->once())
289289
->method('log')
@@ -302,7 +302,7 @@ public function testHandleException()
302302

303303
$exception = new \Exception('foo');
304304

305-
$logger = $this->getMock('Psr\Log\LoggerInterface');
305+
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
306306

307307
$logArgCheck = function ($level, $message, $context) {
308308
$this->assertEquals('Uncaught Exception: foo', $message);
@@ -342,7 +342,7 @@ public function testErrorStacking()
342342
$handler = ErrorHandler::register();
343343
$handler->screamAt(E_USER_WARNING);
344344

345-
$logger = $this->getMock('Psr\Log\LoggerInterface');
345+
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
346346

347347
$logger
348348
->expects($this->exactly(2))
@@ -400,7 +400,7 @@ public function testBootstrappingLogger()
400400

401401
$bootLogger->log($expectedLog[0], $expectedLog[1], $expectedLog[2]);
402402

403-
$mockLogger = $this->getMock('Psr\Log\LoggerInterface');
403+
$mockLogger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
404404
$mockLogger->expects($this->once())
405405
->method('log')
406406
->with(LogLevel::WARNING, 'Foo message', $expectedLog[2]);
@@ -420,7 +420,7 @@ public function testHandleFatalError()
420420
'line' => 123,
421421
);
422422

423-
$logger = $this->getMock('Psr\Log\LoggerInterface');
423+
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
424424

425425
$logArgCheck = function ($level, $message, $context) {
426426
$this->assertEquals('Fatal Parse Error: foo', $message);
@@ -471,7 +471,7 @@ public function testHandleFatalErrorOnHHVM()
471471
try {
472472
$handler = ErrorHandler::register();
473473

474-
$logger = $this->getMock('Psr\Log\LoggerInterface');
474+
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
475475
$logger
476476
->expects($this->once())
477477
->method('log')

src/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function testAddAListenerService()
2929
{
3030
$event = new Event();
3131

32-
$service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
32+
$service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock();
3333

3434
$service
3535
->expects($this->once())
@@ -50,7 +50,7 @@ public function testAddASubscriberService()
5050
{
5151
$event = new Event();
5252

53-
$service = $this->getMock('Symfony\Component\EventDispatcher\Tests\SubscriberService');
53+
$service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\SubscriberService')->getMock();
5454

5555
$service
5656
->expects($this->once())
@@ -85,7 +85,7 @@ public function testPreventDuplicateListenerService()
8585
{
8686
$event = new Event();
8787

88-
$service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
88+
$service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock();
8989

9090
$service
9191
->expects($this->once())
@@ -107,7 +107,7 @@ public function testHasListenersOnLazyLoad()
107107
{
108108
$event = new Event();
109109

110-
$service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
110+
$service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock();
111111

112112
$container = new Container();
113113
$container->set('service.listener', $service);
@@ -130,7 +130,7 @@ public function testHasListenersOnLazyLoad()
130130

131131
public function testGetListenersOnLazyLoad()
132132
{
133-
$service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
133+
$service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock();
134134

135135
$container = new Container();
136136
$container->set('service.listener', $service);
@@ -147,7 +147,7 @@ public function testGetListenersOnLazyLoad()
147147

148148
public function testRemoveAfterDispatch()
149149
{
150-
$service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
150+
$service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock();
151151

152152
$container = new Container();
153153
$container->set('service.listener', $service);
@@ -162,7 +162,7 @@ public function testRemoveAfterDispatch()
162162

163163
public function testRemoveBeforeDispatch()
164164
{
165-
$service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service');
165+
$service = $this->getMockBuilder('Symfony\Component\EventDispatcher\Tests\Service')->getMock();
166166

167167
$container = new Container();
168168
$container->set('service.listener', $service);

src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public function testGetCalledListenersNested()
120120

121121
public function testLogger()
122122
{
123-
$logger = $this->getMock('Psr\Log\LoggerInterface');
123+
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
124124

125125
$dispatcher = new EventDispatcher();
126126
$tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch(), $logger);
@@ -135,7 +135,7 @@ public function testLogger()
135135

136136
public function testLoggerWithStoppedEvent()
137137
{
138-
$logger = $this->getMock('Psr\Log\LoggerInterface');
138+
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
139139

140140
$dispatcher = new EventDispatcher();
141141
$tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch(), $logger);

src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ function ($object) { return $object->value; }
193193

194194
public function testCreateFromLoader()
195195
{
196-
$loader = $this->getMock('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface');
196+
$loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
197197

198198
$list = $this->factory->createListFromLoader($loader);
199199

@@ -202,7 +202,7 @@ public function testCreateFromLoader()
202202

203203
public function testCreateFromLoaderWithValues()
204204
{
205-
$loader = $this->getMock('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface');
205+
$loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
206206

207207
$value = function () {};
208208
$list = $this->factory->createListFromLoader($loader, $value);

0 commit comments

Comments
 (0)