bug #15176 [Serializer] Fix ClassMetadata::sleep() (dunglas)

This PR was squashed before being merged into the 2.7 branch (closes #15176).

Discussion
----------

[Serializer] Fix ClassMetadata::sleep()

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

Fix a bug with the `sleep()` method. It is blocking under when using the APC metadata cache.

Commits
-------

2f42801 [Serializer] Fix ClassMetadata::sleep()
This commit is contained in:
Fabien Potencier 2015-07-08 08:12:51 +02:00
commit b2fddecde9
3 changed files with 28 additions and 1 deletions

View File

@ -110,7 +110,7 @@ class ClassMetadata implements ClassMetadataInterface
{
return array(
'name',
'attributes',
'attributesMetadata',
);
}
}

View File

@ -54,4 +54,14 @@ class AttributeMetadataTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(array('a', 'b', 'c'), $attributeMetadata1->getGroups());
}
public function testSerialize()
{
$attributeMetadata = new AttributeMetadata('attribute');
$attributeMetadata->addGroup('a');
$attributeMetadata->addGroup('b');
$serialized = serialize($attributeMetadata);
$this->assertEquals($attributeMetadata, unserialize($serialized));
}
}

View File

@ -62,4 +62,21 @@ class ClassMetadataTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(array('a1' => $ac1), $classMetadata2->getAttributesMetadata());
}
public function testSerialize()
{
$classMetadata = new ClassMetadata('a');
$a1 = $this->getMock('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface');
$a1->method('getName')->willReturn('b1');
$a2 = $this->getMock('Symfony\Component\Serializer\Mapping\AttributeMetadataInterface');
$a2->method('getName')->willReturn('b2');
$classMetadata->addAttributeMetadata($a1);
$classMetadata->addAttributeMetadata($a2);
$serialized = serialize($classMetadata);
$this->assertEquals($classMetadata, unserialize($serialized));
}
}