Skip to content

Commit 727bf35

Browse files
committed
fixed obsolete getMock() usage
1 parent e4748cc commit 727bf35

File tree

7 files changed

+22
-22
lines changed

7 files changed

+22
-22
lines changed

Tests/Mapping/ClassMetadataTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ public function testAttributeMetadata()
2828
{
2929
$classMetadata = new ClassMetadata('c');
3030

31-
$a1 = $this->getMock('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface');
31+
$a1 = $this->getMockBuilder('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface')->getMock();
3232
$a1->method('getName')->willReturn('a1');
3333

34-
$a2 = $this->getMock('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface');
34+
$a2 = $this->getMockBuilder('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface')->getMock();
3535
$a2->method('getName')->willReturn('a2');
3636

3737
$classMetadata->addAttributeMetadata($a1);
@@ -45,11 +45,11 @@ public function testMerge()
4545
$classMetadata1 = new ClassMetadata('c1');
4646
$classMetadata2 = new ClassMetadata('c2');
4747

48-
$ac1 = $this->getMock('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface');
48+
$ac1 = $this->getMockBuilder('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface')->getMock();
4949
$ac1->method('getName')->willReturn('a1');
5050
$ac1->method('getGroups')->willReturn(array('a', 'b'));
5151

52-
$ac2 = $this->getMock('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface');
52+
$ac2 = $this->getMockBuilder('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface')->getMock();
5353
$ac2->method('getName')->willReturn('a1');
5454
$ac2->method('getGroups')->willReturn(array('b', 'c'));
5555

@@ -67,10 +67,10 @@ public function testSerialize()
6767
{
6868
$classMetadata = new ClassMetadata('a');
6969

70-
$a1 = $this->getMock('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface');
70+
$a1 = $this->getMockBuilder('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface')->getMock();
7171
$a1->method('getName')->willReturn('b1');
7272

73-
$a2 = $this->getMock('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface');
73+
$a2 = $this->getMockBuilder('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface')->getMock();
7474
$a2->method('getName')->willReturn('b2');
7575

7676
$classMetadata->addAttributeMetadata($a1);

Tests/Mapping/Factory/ClassMetadataFactoryTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function testHasMetadataFor()
4747

4848
public function testCacheExists()
4949
{
50-
$cache = $this->getMock('Doctrine\Common\Cache\Cache');
50+
$cache = $this->getMockBuilder('Doctrine\Common\Cache\Cache')->getMock();
5151
$cache
5252
->expects($this->once())
5353
->method('fetch')
@@ -60,7 +60,7 @@ public function testCacheExists()
6060

6161
public function testCacheNotExists()
6262
{
63-
$cache = $this->getMock('Doctrine\Common\Cache\Cache');
63+
$cache = $this->getMockBuilder('Doctrine\Common\Cache\Cache')->getMock();
6464
$cache
6565
->method('fetch')
6666
->will($this->returnValue(false))

Tests/Normalizer/AbstractNormalizerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ class AbstractNormalizerTest extends \PHPUnit_Framework_TestCase
2929

3030
protected function setUp()
3131
{
32-
$loader = $this->getMock('Symfony\Component\Serializer\Mapping\Loader\LoaderChain', array(), array(array()));
33-
$this->classMetadata = $this->getMock('Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory', array(), array($loader));
32+
$loader = $this->getMockBuilder('Symfony\Component\Serializer\Mapping\Loader\LoaderChain')->setConstructorArgs(array(array()))->getMock();
33+
$this->classMetadata = $this->getMockBuilder('Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory')->setConstructorArgs(array($loader))->getMock();
3434
$this->normalizer = new AbstractNormalizerDummy($this->classMetadata);
3535
}
3636

Tests/Normalizer/GetSetMethodNormalizerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class GetSetMethodNormalizerTest extends \PHPUnit_Framework_TestCase
3636

3737
protected function setUp()
3838
{
39-
$this->serializer = $this->getMock(__NAMESPACE__.'\SerializerNormalizer');
39+
$this->serializer = $this->getMockBuilder(__NAMESPACE__.'\SerializerNormalizer')->getMock();
4040
$this->normalizer = new GetSetMethodNormalizer();
4141
$this->normalizer->setSerializer($this->serializer);
4242
}
@@ -470,7 +470,7 @@ public function provideCallbacks()
470470
*/
471471
public function testUnableToNormalizeObjectAttribute()
472472
{
473-
$serializer = $this->getMock('Symfony\Component\Serializer\SerializerInterface');
473+
$serializer = $this->getMockBuilder('Symfony\Component\Serializer\SerializerInterface')->getMock();
474474
$this->normalizer->setSerializer($serializer);
475475

476476
$obj = new GetSetDummy();

Tests/Normalizer/ObjectNormalizerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class ObjectNormalizerTest extends \PHPUnit_Framework_TestCase
3939

4040
protected function setUp()
4141
{
42-
$this->serializer = $this->getMock(__NAMESPACE__.'\ObjectSerializerNormalizer');
42+
$this->serializer = $this->getMockBuilder(__NAMESPACE__.'\ObjectSerializerNormalizer')->getMock();
4343
$this->normalizer = new ObjectNormalizer();
4444
$this->normalizer->setSerializer($this->serializer);
4545
}
@@ -404,7 +404,7 @@ public function provideCallbacks()
404404
*/
405405
public function testUnableToNormalizeObjectAttribute()
406406
{
407-
$serializer = $this->getMock('Symfony\Component\Serializer\SerializerInterface');
407+
$serializer = $this->getMockBuilder('Symfony\Component\Serializer\SerializerInterface')->getMock();
408408
$this->normalizer->setSerializer($serializer);
409409

410410
$obj = new ObjectDummy();

Tests/Normalizer/PropertyNormalizerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class PropertyNormalizerTest extends \PHPUnit_Framework_TestCase
3535

3636
protected function setUp()
3737
{
38-
$this->serializer = $this->getMock('Symfony\Component\Serializer\SerializerInterface');
38+
$this->serializer = $this->getMockBuilder('Symfony\Component\Serializer\SerializerInterface')->getMock();
3939
$this->normalizer = new PropertyNormalizer();
4040
$this->normalizer->setSerializer($this->serializer);
4141
}
@@ -423,7 +423,7 @@ public function testDenormalizeShouldIgnoreStaticProperty()
423423
*/
424424
public function testUnableToNormalizeObjectAttribute()
425425
{
426-
$serializer = $this->getMock('Symfony\Component\Serializer\SerializerInterface');
426+
$serializer = $this->getMockBuilder('Symfony\Component\Serializer\SerializerInterface')->getMock();
427427
$this->normalizer->setSerializer($serializer);
428428

429429
$obj = new PropertyDummy();

Tests/SerializerTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function testInterface()
3838
*/
3939
public function testNormalizeNoMatch()
4040
{
41-
$serializer = new Serializer(array($this->getMock('Symfony\Component\Serializer\Normalizer\CustomNormalizer')));
41+
$serializer = new Serializer(array($this->getMockBuilder('Symfony\Component\Serializer\Normalizer\CustomNormalizer')->getMock()));
4242
$serializer->normalize(new \stdClass(), 'xml');
4343
}
4444

@@ -70,7 +70,7 @@ public function testNormalizeOnDenormalizer()
7070
*/
7171
public function testDenormalizeNoMatch()
7272
{
73-
$serializer = new Serializer(array($this->getMock('Symfony\Component\Serializer\Normalizer\CustomNormalizer')));
73+
$serializer = new Serializer(array($this->getMockBuilder('Symfony\Component\Serializer\Normalizer\CustomNormalizer')->getMock()));
7474
$serializer->denormalize('foo', 'stdClass');
7575
}
7676

@@ -95,14 +95,14 @@ public function testCustomNormalizerCanNormalizeCollectionsAndScalar()
9595

9696
public function testNormalizeWithSupportOnData()
9797
{
98-
$normalizer1 = $this->getMock('Symfony\Component\Serializer\Normalizer\NormalizerInterface');
98+
$normalizer1 = $this->getMockBuilder('Symfony\Component\Serializer\Normalizer\NormalizerInterface')->getMock();
9999
$normalizer1->method('supportsNormalization')
100100
->willReturnCallback(function ($data, $format) {
101101
return isset($data->test);
102102
});
103103
$normalizer1->method('normalize')->willReturn('test1');
104104

105-
$normalizer2 = $this->getMock('Symfony\Component\Serializer\Normalizer\NormalizerInterface');
105+
$normalizer2 = $this->getMockBuilder('Symfony\Component\Serializer\Normalizer\NormalizerInterface')->getMock();
106106
$normalizer2->method('supportsNormalization')
107107
->willReturn(true);
108108
$normalizer2->method('normalize')->willReturn('test2');
@@ -118,14 +118,14 @@ public function testNormalizeWithSupportOnData()
118118

119119
public function testDenormalizeWithSupportOnData()
120120
{
121-
$denormalizer1 = $this->getMock('Symfony\Component\Serializer\Normalizer\DenormalizerInterface');
121+
$denormalizer1 = $this->getMockBuilder('Symfony\Component\Serializer\Normalizer\DenormalizerInterface')->getMock();
122122
$denormalizer1->method('supportsDenormalization')
123123
->willReturnCallback(function ($data, $type, $format) {
124124
return isset($data['test1']);
125125
});
126126
$denormalizer1->method('denormalize')->willReturn('test1');
127127

128-
$denormalizer2 = $this->getMock('Symfony\Component\Serializer\Normalizer\DenormalizerInterface');
128+
$denormalizer2 = $this->getMockBuilder('Symfony\Component\Serializer\Normalizer\DenormalizerInterface')->getMock();
129129
$denormalizer2->method('supportsDenormalization')
130130
->willReturn(true);
131131
$denormalizer2->method('denormalize')->willReturn('test2');

0 commit comments

Comments
 (0)