Skip to content

Commit 4334855

Browse files
dunglasfabpot
authored andcommitted
[Serializer] Fix ClassMetadata::sleep()
1 parent e419e3f commit 4334855

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

Mapping/ClassMetadata.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function __sleep()
110110
{
111111
return array(
112112
'name',
113-
'attributes',
113+
'attributesMetadata',
114114
);
115115
}
116116
}

Tests/Mapping/AttributeMetadataTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,14 @@ public function testMerge()
5454

5555
$this->assertEquals(array('a', 'b', 'c'), $attributeMetadata1->getGroups());
5656
}
57+
58+
public function testSerialize()
59+
{
60+
$attributeMetadata = new AttributeMetadata('attribute');
61+
$attributeMetadata->addGroup('a');
62+
$attributeMetadata->addGroup('b');
63+
64+
$serialized = serialize($attributeMetadata);
65+
$this->assertEquals($attributeMetadata, unserialize($serialized));
66+
}
5767
}

Tests/Mapping/ClassMetadataTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,21 @@ public function testMerge()
6262

6363
$this->assertEquals(array('a1' => $ac1), $classMetadata2->getAttributesMetadata());
6464
}
65+
66+
public function testSerialize()
67+
{
68+
$classMetadata = new ClassMetadata('a');
69+
70+
$a1 = $this->getMock('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface');
71+
$a1->method('getName')->willReturn('b1');
72+
73+
$a2 = $this->getMock('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface');
74+
$a2->method('getName')->willReturn('b2');
75+
76+
$classMetadata->addAttributeMetadata($a1);
77+
$classMetadata->addAttributeMetadata($a2);
78+
79+
$serialized = serialize($classMetadata);
80+
$this->assertEquals($classMetadata, unserialize($serialized));
81+
}
6582
}

0 commit comments

Comments
 (0)