Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ec0474d

Browse filesBrowse files
committed
Updating tests
1 parent 0e96e86 commit ec0474d
Copy full SHA for ec0474d

File tree

9 files changed

+30
-46
lines changed
Filter options

9 files changed

+30
-46
lines changed

‎src/Symfony/Component/Serializer/Mapping/AttributeMetadata.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Mapping/AttributeMetadata.php
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ public function setType($type)
294294
/**
295295
* {@inheritdoc}
296296
*/
297-
public function merge(self $attributeMetadata)
297+
public function merge(AttributeMetadataInterface $attributeMetadata)
298298
{
299299
foreach ($attributeMetadata->getGroups() as $group) {
300300
$this->addGroup($group);
@@ -305,7 +305,7 @@ public function merge(self $attributeMetadata)
305305
$this->methodsAccessor = $attributeMetadata->getMethodsAccessor();
306306
}
307307
if (null === $this->methodsMutator) {
308-
$this->methodsMutator = $attributeMetadata->getMethodsAccessor();
308+
$this->methodsMutator = $attributeMetadata->getMethodsMutator();
309309
}
310310
if (null === $this->exclude) {
311311
$this->exclude = $attributeMetadata->getExclude();
@@ -336,8 +336,8 @@ public function __sleep()
336336
{
337337
return array(
338338
'name',
339-
'accessorGetter',
340-
'accessorSetter',
339+
'methodsAccessor',
340+
'methodsMutator',
341341
'exclude',
342342
'expose',
343343
'groups',

‎src/Symfony/Component/Serializer/Normalizer/MetadataAwareNormalizer.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Normalizer/MetadataAwareNormalizer.php
+8-6Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,14 @@ protected function isAllowedAttribute($classOrObject, $attribute, $format = null
127127
$classMetadata = $this->classMetadataFactory->getMetadataFor($classOrObject);
128128
$attributeMetadata = $classMetadata->getAttributesMetadata();
129129

130-
if (true === $attributeMetadata[$attribute]->getExclude()) {
131-
return false;
132-
}
130+
if (isset($attributeMetadata[$attribute])) {
131+
if (true === $attributeMetadata[$attribute]->getExclude()) {
132+
return false;
133+
}
133134

134-
if (true === $attributeMetadata[$attribute]->getExpose()) {
135-
return true;
135+
if (true === $attributeMetadata[$attribute]->getExpose()) {
136+
return true;
137+
}
136138
}
137139

138140
if (ExclusionPolicy::ALL === $classMetadata->getExclusionPolicy()) {
@@ -216,7 +218,7 @@ protected function prepareForDenormalization($data/*, string $class*/)
216218
$validSerializedKeys = array();
217219
foreach ($attributeMetadata as $attributeName => $metadata) {
218220
$attributeReadOnly = $metadata->getReadOnly();
219-
if (true === $attributeReadOnly || false !== $attributeReadOnly) {
221+
if (true === $attributeReadOnly) {
220222
// This is not a valid key
221223
continue;
222224
}

‎src/Symfony/Component/Serializer/Tests/Annotation/AccessorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Tests/Annotation/AccessorTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function testInvalidGetterParameter()
5252

5353
public function testAccessorParameters()
5454
{
55-
$accessor = new Methods(array('setter' => 'Foo', 'getter' => 'Bar'));
55+
$accessor = new Methods(array('mutator' => 'Foo', 'accessor' => 'Bar'));
5656
$this->assertEquals('Bar', $accessor->getAccessor());
5757
$this->assertEquals('Foo', $accessor->getMutator());
5858
}

‎src/Symfony/Component/Serializer/Tests/Annotation/ExcludeTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Tests/Annotation/ExcludeTest.php
-8Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,6 @@
1818
*/
1919
class ExcludeTest extends \PHPUnit\Framework\TestCase
2020
{
21-
/**
22-
* @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException
23-
*/
24-
public function testInvalidParameter()
25-
{
26-
new Exclude(array('value' => 'Foobar'));
27-
}
28-
2921
public function testExclude()
3022
{
3123
$exclude = new Exclude();

‎src/Symfony/Component/Serializer/Tests/Annotation/ExposeTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Tests/Annotation/ExposeTest.php
-8Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,6 @@
1818
*/
1919
class ExposeTest extends \PHPUnit\Framework\TestCase
2020
{
21-
/**
22-
* @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException
23-
*/
24-
public function testInvalidParameter()
25-
{
26-
new Expose(array('value' => 'Foobar'));
27-
}
28-
2921
public function testExpose()
3022
{
3123
$expose = new Expose();

‎src/Symfony/Component/Serializer/Tests/Fixtures/AccessorDummy.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Tests/Fixtures/AccessorDummy.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
class AccessorDummy
88
{
99
/**
10-
* @Serializer\Accessor(getter="getModel", setter="setModel")
10+
* @Serializer\Methods(accessor="getModel", mutator="setModel")
1111
*/
1212
public $model = 'defaultValue';
1313

‎src/Symfony/Component/Serializer/Tests/Fixtures/CompositionDummy.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Tests/Fixtures/CompositionDummy.php
+5-3Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ public function __construct($withValues = false)
2424
}
2525
}
2626

27-
/**
28-
* @return Car
29-
*/
3027
public function getChild()
3128
{
3229
return $this->child;
3330
}
31+
32+
public function setChild(CompositionChildDummy $child)
33+
{
34+
$this->child = $child;
35+
}
3436
}

‎src/Symfony/Component/Serializer/Tests/Fixtures/ReadOnlyClassDummy.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Tests/Fixtures/ReadOnlyClassDummy.php
-6Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,10 @@
1010
*/
1111
class ReadOnlyClassDummy
1212
{
13-
/**
14-
* @Serializer\ReadOnly(false)
15-
*/
1613
public $model;
1714

1815
public $size;
1916

20-
/**
21-
* @Serializer\ReadOnly()
22-
*/
2317
public $color;
2418

2519
public function __construct($withValues = false)

‎src/Symfony/Component/Serializer/Tests/Normalizer/MetadataAwareNormalizerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Tests/Normalizer/MetadataAwareNormalizerTest.php
+11-9Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
namespace Symfony\Component\Serializer\Tests\Normalizer;
1313

1414
use Doctrine\Common\Annotations\AnnotationReader;
15+
use PHPUnit\Framework\TestCase;
16+
use Symfony\Component\PropertyInfo\Extractor\SerializerExtractor;
1517
use Symfony\Component\Serializer\Mapping\Loader\BetterAnnotationLoader;
1618
use Symfony\Component\Serializer\NameConverter\CamelCaseToSnakeCaseNameConverter;
1719
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
@@ -38,7 +40,7 @@
3840
/**
3941
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
4042
*/
41-
class MetadataAwareNormalizerTest extends \PHPUnit_Framework_TestCase
43+
class MetadataAwareNormalizerTest extends TestCase
4244
{
4345
/**
4446
* @var MetadataAwareNormalizer
@@ -51,9 +53,9 @@ class MetadataAwareNormalizerTest extends \PHPUnit_Framework_TestCase
5153

5254
protected function setUp()
5355
{
54-
$this->serializer = $this->getMock(__NAMESPACE__.'\MetadataObjectSerializerNormalizer');
56+
$this->serializer = $this->getMockBuilder(__NAMESPACE__.'\MetadataObjectSerializerNormalizer')->getMock();
5557
$classMetadataFactory = new ClassMetadataFactory(new BetterAnnotationLoader(new AnnotationReader()));
56-
$this->normalizer = new MetadataAwareNormalizer($classMetadataFactory, null, null, null, new MetadataAwarePropertyTypeExtractor($classMetadataFactory));
58+
$this->normalizer = new MetadataAwareNormalizer($classMetadataFactory, null, new MetadataAwarePropertyTypeExtractor($classMetadataFactory));
5759
$this->normalizer->setSerializer($this->serializer);
5860
}
5961

@@ -91,7 +93,7 @@ public function testCompositionDenormalize()
9193
$serializer = new MicroSerializer($this->normalizer);
9294
$this->normalizer->setSerializer($serializer);
9395

94-
$data = json_decode('{"name":"Foobar","child":{"super_model":"val_model","car_size":"val_size","color":"val_color"}}', true);
96+
$data = json_decode('{"name":"Foobar","child":{"super_model":"val_model","carSize":"val_size","color":"val_color"}}', true);
9597
$obj = $this->normalizer->denormalize($data, CompositionDummy::class);
9698

9799
$this->assertEquals('Foobar', $obj->name);
@@ -287,7 +289,7 @@ public function testReadOnlyDenormalizeClass()
287289
$data = ['model' => 'model_value', 'size' => 'size_value', 'color' => 'color_value'];
288290
$obj = $this->normalizer->denormalize($data, ReadOnlyClassDummy::class);
289291

290-
$this->assertEquals('model_value', $obj->model);
292+
$this->assertEquals(null, $obj->model);
291293
$this->assertEquals(null, $obj->size);
292294
$this->assertEquals(null, $obj->color);
293295
}
@@ -303,9 +305,9 @@ public function testSerializedNameNormalize()
303305

304306
public function testSerializedNameDenormalize()
305307
{
306-
$serializer = $this->getMock(__NAMESPACE__.'\MetadataObjectSerializerNormalizer');
308+
$serializer = $this->getMockBuilder(__NAMESPACE__.'\MetadataObjectSerializerNormalizer')->getMock();
307309
$classMetadataFactory = new ClassMetadataFactory(new BetterAnnotationLoader(new AnnotationReader()));
308-
$normalizer = new MetadataAwareNormalizer($classMetadataFactory, new CamelCaseToSnakeCaseNameConverter(), null, null, new MetadataAwarePropertyTypeExtractor($classMetadataFactory));
310+
$normalizer = new MetadataAwareNormalizer($classMetadataFactory, new CamelCaseToSnakeCaseNameConverter(), new MetadataAwarePropertyTypeExtractor($classMetadataFactory));
309311
$normalizer->setSerializer($serializer);
310312

311313
$data = ['super_model' => 'model_val', 'car_size' => 'size_val', 'color' => 'color_val'];
@@ -321,9 +323,9 @@ public function testSerializedNameDenormalize()
321323
*/
322324
public function testSerializedNameDenormalizeWhenIgnoringSerializedName()
323325
{
324-
$serializer = $this->getMock(__NAMESPACE__.'\MetadataObjectSerializerNormalizer');
326+
$serializer = $this->getMockBuilder(__NAMESPACE__.'\MetadataObjectSerializerNormalizer')->getMock();
325327
$classMetadataFactory = new ClassMetadataFactory(new BetterAnnotationLoader(new AnnotationReader()));
326-
$normalizer = new MetadataAwareNormalizer($classMetadataFactory, new CamelCaseToSnakeCaseNameConverter(), null, null, new MetadataAwarePropertyTypeExtractor($classMetadataFactory));
328+
$normalizer = new MetadataAwareNormalizer($classMetadataFactory, new CamelCaseToSnakeCaseNameConverter(), new MetadataAwarePropertyTypeExtractor($classMetadataFactory));
327329
$normalizer->setSerializer($serializer);
328330

329331
$data = ['model' => 'model_val', 'carSize' => 'size_val', 'color' => 'color_val'];

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.