Skip to content

Commit 456ff5d

Browse files
committed
fixed obsolete getMock() usage
1 parent 527413c commit 456ff5d

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

+216
-236
lines changed

Tests/AbstractFormTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ protected function setUp()
3737
// We need an actual dispatcher to use the deprecated
3838
// bindRequest() method
3939
$this->dispatcher = new EventDispatcher();
40-
$this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface');
40+
$this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock();
4141
$this->form = $this->createForm();
4242
}
4343

@@ -73,8 +73,8 @@ protected function getBuilder($name = 'name', EventDispatcherInterface $dispatch
7373
*/
7474
protected function getMockForm($name = 'name')
7575
{
76-
$form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
77-
$config = $this->getMock('Symfony\Component\Form\FormConfigInterface');
76+
$form = $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock();
77+
$config = $this->getMockBuilder('Symfony\Component\Form\FormConfigInterface')->getMock();
7878

7979
$form->expects($this->any())
8080
->method('getName')
@@ -91,22 +91,22 @@ protected function getMockForm($name = 'name')
9191
*/
9292
protected function getDataMapper()
9393
{
94-
return $this->getMock('Symfony\Component\Form\DataMapperInterface');
94+
return $this->getMockBuilder('Symfony\Component\Form\DataMapperInterface')->getMock();
9595
}
9696

9797
/**
9898
* @return \PHPUnit_Framework_MockObject_MockObject
9999
*/
100100
protected function getDataTransformer()
101101
{
102-
return $this->getMock('Symfony\Component\Form\DataTransformerInterface');
102+
return $this->getMockBuilder('Symfony\Component\Form\DataTransformerInterface')->getMock();
103103
}
104104

105105
/**
106106
* @return \PHPUnit_Framework_MockObject_MockObject
107107
*/
108108
protected function getFormValidator()
109109
{
110-
return $this->getMock('Symfony\Component\Form\FormValidatorInterface');
110+
return $this->getMockBuilder('Symfony\Component\Form\FormValidatorInterface')->getMock();
111111
}
112112
}

Tests/AbstractLayoutTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ protected function setUp()
2828

2929
\Locale::setDefault('en');
3030

31-
$this->csrfTokenManager = $this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface');
31+
$this->csrfTokenManager = $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock();
3232

3333
parent::setUp();
3434
}

Tests/AbstractRequestHandlerTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@ abstract class AbstractRequestHandlerTest extends \PHPUnit_Framework_TestCase
3737

3838
protected function setUp()
3939
{
40-
$this->serverParams = $this->getMock(
41-
'Symfony\Component\Form\Util\ServerParams',
42-
array('getNormalizedIniPostMaxSize', 'getContentLength')
43-
);
40+
$this->serverParams = $this->getMockBuilder('Symfony\Component\Form\Util\ServerParams')->setMethods(array('getNormalizedIniPostMaxSize', 'getContentLength'))->getMock();
4441
$this->requestHandler = $this->getRequestHandler();
4542
$this->factory = Forms::createFormFactoryBuilder()->getFormFactory();
4643
$this->request = null;
@@ -363,15 +360,15 @@ abstract protected function getMockFile($suffix = '');
363360

364361
protected function getMockForm($name, $method = null, $compound = true)
365362
{
366-
$config = $this->getMock('Symfony\Component\Form\FormConfigInterface');
363+
$config = $this->getMockBuilder('Symfony\Component\Form\FormConfigInterface')->getMock();
367364
$config->expects($this->any())
368365
->method('getMethod')
369366
->will($this->returnValue($method));
370367
$config->expects($this->any())
371368
->method('getCompound')
372369
->will($this->returnValue($compound));
373370

374-
$form = $this->getMock('Symfony\Component\Form\Test\FormInterface');
371+
$form = $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock();
375372
$form->expects($this->any())
376373
->method('getName')
377374
->will($this->returnValue($name));

Tests/ButtonTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ class ButtonTest extends \PHPUnit_Framework_TestCase
2525

2626
protected function setUp()
2727
{
28-
$this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
29-
$this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface');
28+
$this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
29+
$this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock();
3030
}
3131

3232
/**

Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class CachingFactoryDecoratorTest extends \PHPUnit_Framework_TestCase
3030

3131
protected function setUp()
3232
{
33-
$this->decoratedFactory = $this->getMock('Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface');
33+
$this->decoratedFactory = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface')->getMock();
3434
$this->factory = new CachingFactoryDecorator($this->decoratedFactory);
3535
}
3636

@@ -295,7 +295,7 @@ public function testCreateFromFlippedChoicesDifferentValueClosure()
295295

296296
public function testCreateFromLoaderSameLoader()
297297
{
298-
$loader = $this->getMock('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface');
298+
$loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
299299
$list = new \stdClass();
300300

301301
$this->decoratedFactory->expects($this->once())
@@ -309,8 +309,8 @@ public function testCreateFromLoaderSameLoader()
309309

310310
public function testCreateFromLoaderDifferentLoader()
311311
{
312-
$loader1 = $this->getMock('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface');
313-
$loader2 = $this->getMock('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface');
312+
$loader1 = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
313+
$loader2 = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
314314
$list1 = new \stdClass();
315315
$list2 = new \stdClass();
316316

@@ -329,7 +329,7 @@ public function testCreateFromLoaderDifferentLoader()
329329

330330
public function testCreateFromLoaderSameValueClosure()
331331
{
332-
$loader = $this->getMock('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface');
332+
$loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
333333
$list = new \stdClass();
334334
$closure = function () {};
335335

@@ -344,7 +344,7 @@ public function testCreateFromLoaderSameValueClosure()
344344

345345
public function testCreateFromLoaderDifferentValueClosure()
346346
{
347-
$loader = $this->getMock('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface');
347+
$loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
348348
$list1 = new \stdClass();
349349
$list2 = new \stdClass();
350350
$closure1 = function () {};
@@ -366,7 +366,7 @@ public function testCreateFromLoaderDifferentValueClosure()
366366
public function testCreateViewSamePreferredChoices()
367367
{
368368
$preferred = array('a');
369-
$list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
369+
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
370370
$view = new \stdClass();
371371

372372
$this->decoratedFactory->expects($this->once())
@@ -382,7 +382,7 @@ public function testCreateViewDifferentPreferredChoices()
382382
{
383383
$preferred1 = array('a');
384384
$preferred2 = array('b');
385-
$list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
385+
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
386386
$view1 = new \stdClass();
387387
$view2 = new \stdClass();
388388

@@ -402,7 +402,7 @@ public function testCreateViewDifferentPreferredChoices()
402402
public function testCreateViewSamePreferredChoicesClosure()
403403
{
404404
$preferred = function () {};
405-
$list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
405+
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
406406
$view = new \stdClass();
407407

408408
$this->decoratedFactory->expects($this->once())
@@ -418,7 +418,7 @@ public function testCreateViewDifferentPreferredChoicesClosure()
418418
{
419419
$preferred1 = function () {};
420420
$preferred2 = function () {};
421-
$list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
421+
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
422422
$view1 = new \stdClass();
423423
$view2 = new \stdClass();
424424

@@ -438,7 +438,7 @@ public function testCreateViewDifferentPreferredChoicesClosure()
438438
public function testCreateViewSameLabelClosure()
439439
{
440440
$labels = function () {};
441-
$list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
441+
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
442442
$view = new \stdClass();
443443

444444
$this->decoratedFactory->expects($this->once())
@@ -454,7 +454,7 @@ public function testCreateViewDifferentLabelClosure()
454454
{
455455
$labels1 = function () {};
456456
$labels2 = function () {};
457-
$list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
457+
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
458458
$view1 = new \stdClass();
459459
$view2 = new \stdClass();
460460

@@ -474,7 +474,7 @@ public function testCreateViewDifferentLabelClosure()
474474
public function testCreateViewSameIndexClosure()
475475
{
476476
$index = function () {};
477-
$list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
477+
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
478478
$view = new \stdClass();
479479

480480
$this->decoratedFactory->expects($this->once())
@@ -490,7 +490,7 @@ public function testCreateViewDifferentIndexClosure()
490490
{
491491
$index1 = function () {};
492492
$index2 = function () {};
493-
$list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
493+
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
494494
$view1 = new \stdClass();
495495
$view2 = new \stdClass();
496496

@@ -510,7 +510,7 @@ public function testCreateViewDifferentIndexClosure()
510510
public function testCreateViewSameGroupByClosure()
511511
{
512512
$groupBy = function () {};
513-
$list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
513+
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
514514
$view = new \stdClass();
515515

516516
$this->decoratedFactory->expects($this->once())
@@ -526,7 +526,7 @@ public function testCreateViewDifferentGroupByClosure()
526526
{
527527
$groupBy1 = function () {};
528528
$groupBy2 = function () {};
529-
$list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
529+
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
530530
$view1 = new \stdClass();
531531
$view2 = new \stdClass();
532532

@@ -546,7 +546,7 @@ public function testCreateViewDifferentGroupByClosure()
546546
public function testCreateViewSameAttributes()
547547
{
548548
$attr = array('class' => 'foobar');
549-
$list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
549+
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
550550
$view = new \stdClass();
551551

552552
$this->decoratedFactory->expects($this->once())
@@ -562,7 +562,7 @@ public function testCreateViewDifferentAttributes()
562562
{
563563
$attr1 = array('class' => 'foobar1');
564564
$attr2 = array('class' => 'foobar2');
565-
$list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
565+
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
566566
$view1 = new \stdClass();
567567
$view2 = new \stdClass();
568568

@@ -582,7 +582,7 @@ public function testCreateViewDifferentAttributes()
582582
public function testCreateViewSameAttributesClosure()
583583
{
584584
$attr = function () {};
585-
$list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
585+
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
586586
$view = new \stdClass();
587587

588588
$this->decoratedFactory->expects($this->once())
@@ -598,7 +598,7 @@ public function testCreateViewDifferentAttributesClosure()
598598
{
599599
$attr1 = function () {};
600600
$attr2 = function () {};
601-
$list = $this->getMock('Symfony\Component\Form\ChoiceList\ChoiceListInterface');
601+
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
602602
$view1 = new \stdClass();
603603
$view2 = new \stdClass();
604604

Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ function ($choice) {
332332

333333
public function testCreateFromLoader()
334334
{
335-
$loader = $this->getMock('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface');
335+
$loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
336336

337337
$list = $this->factory->createListFromLoader($loader);
338338

@@ -341,7 +341,7 @@ public function testCreateFromLoader()
341341

342342
public function testCreateFromLoaderWithValues()
343343
{
344-
$loader = $this->getMock('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface');
344+
$loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
345345

346346
$value = function () {};
347347
$list = $this->factory->createListFromLoader($loader, $value);
@@ -771,7 +771,7 @@ public function testCreateViewForFlatLegacyChoiceList()
771771
$preferred = array(new LegacyChoiceView('x', 'x', 'Preferred'));
772772
$other = array(new LegacyChoiceView('y', 'y', 'Other'));
773773

774-
$list = $this->getMock('Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface');
774+
$list = $this->getMockBuilder('Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface')->getMock();
775775

776776
$list->expects($this->once())
777777
->method('getPreferredViews')
@@ -798,7 +798,7 @@ public function testCreateViewForNestedLegacyChoiceList()
798798
new LegacyChoiceView('z', 'z', 'Other one'),
799799
);
800800

801-
$list = $this->getMock('Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface');
801+
$list = $this->getMockBuilder('Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface')->getMock();
802802

803803
$list->expects($this->once())
804804
->method('getPreferredViews')

0 commit comments

Comments
 (0)