class ClassMetadataTest in Zircon Profile 8
Same name in this branch
- 8 vendor/symfony/validator/Tests/Mapping/ClassMetadataTest.php \Symfony\Component\Validator\Tests\Mapping\ClassMetadataTest
- 8 vendor/symfony/serializer/Tests/Mapping/ClassMetadataTest.php \Symfony\Component\Serializer\Tests\Mapping\ClassMetadataTest
Same name and namespace in other branches
- 8.0 vendor/symfony/serializer/Tests/Mapping/ClassMetadataTest.php \Symfony\Component\Serializer\Tests\Mapping\ClassMetadataTest
@author Kévin Dunglas <dunglas@gmail.com>
Hierarchy
- class \Symfony\Component\Serializer\Tests\Mapping\ClassMetadataTest extends \Symfony\Component\Serializer\Tests\Mapping\PHPUnit_Framework_TestCase
Expanded class hierarchy of ClassMetadataTest
File
- vendor/
symfony/ serializer/ Tests/ Mapping/ ClassMetadataTest.php, line 19
Namespace
Symfony\Component\Serializer\Tests\MappingView source
class ClassMetadataTest extends \PHPUnit_Framework_TestCase {
public function testInterface() {
$classMetadata = new ClassMetadata('name');
$this
->assertInstanceOf('Symfony\\Component\\Serializer\\Mapping\\ClassMetadataInterface', $classMetadata);
}
public function testAttributeMetadata() {
$classMetadata = new ClassMetadata('c');
$a1 = $this
->getMock('Symfony\\Component\\Serializer\\Mapping\\AttributeMetadataInterface');
$a1
->method('getName')
->willReturn('a1');
$a2 = $this
->getMock('Symfony\\Component\\Serializer\\Mapping\\AttributeMetadataInterface');
$a2
->method('getName')
->willReturn('a2');
$classMetadata
->addAttributeMetadata($a1);
$classMetadata
->addAttributeMetadata($a2);
$this
->assertEquals(array(
'a1' => $a1,
'a2' => $a2,
), $classMetadata
->getAttributesMetadata());
}
public function testMerge() {
$classMetadata1 = new ClassMetadata('c1');
$classMetadata2 = new ClassMetadata('c2');
$ac1 = $this
->getMock('Symfony\\Component\\Serializer\\Mapping\\AttributeMetadataInterface');
$ac1
->method('getName')
->willReturn('a1');
$ac1
->method('getGroups')
->willReturn(array(
'a',
'b',
));
$ac2 = $this
->getMock('Symfony\\Component\\Serializer\\Mapping\\AttributeMetadataInterface');
$ac2
->method('getName')
->willReturn('a1');
$ac2
->method('getGroups')
->willReturn(array(
'b',
'c',
));
$classMetadata1
->addAttributeMetadata($ac1);
$classMetadata2
->addAttributeMetadata($ac2);
$classMetadata1
->merge($classMetadata2);
$ac1
->method('getGroups')
->willReturn('a', 'b', 'c');
$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));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ClassMetadataTest:: |
public | function | ||
ClassMetadataTest:: |
public | function | ||
ClassMetadataTest:: |
public | function | ||
ClassMetadataTest:: |
public | function |