コード例 #1
0
 public function testMultipleEntities()
 {
     $entity = new EntityElement('bar');
     $entity2 = new EntityElement('bar');
     $property = new EntityProperty(new String('foo'), new EntityType(array($entity, $entity2)), new String('zoo'));
     $unserialized = simplexml_load_string($this->serializer->serialize($property, "xml"));
     $this->assertEquals('property', $unserialized->getName());
     $this->assertEquals('entity', $unserialized['type']);
     $this->assertEquals('foo', $unserialized['name']);
     $this->assertEquals('zoo', $unserialized['title']);
     $this->assertEquals('bar', $unserialized['entityname']);
     $this->assertEquals(2, $unserialized->children()->count());
     foreach ($unserialized->children() as $child) {
         $this->assertEquals('entity', $child->getName());
         $this->assertEquals('bar', $child['name']);
     }
 }
コード例 #2
0
 public function testHasLink()
 {
     $collection = new Collection('bar');
     $collection->addLink(new Link('foo', 'bar', 'zoo'));
     $xml = simplexml_load_string($this->serializer->serialize($collection, "xml"));
     $this->assertEquals(1, count($xml->links));
     foreach ($xml->links->children() as $link) {
         $this->assertEquals('link', $link->getName());
     }
     $entity = new Entity('bar');
     $entity->addLink(new Link('foo', 'bar', 'zoo'));
     $xml = simplexml_load_string($this->serializer->serialize($entity, "xml"));
     $this->assertEquals(1, count($xml->links));
     foreach ($xml->links->children() as $link) {
         $this->assertEquals('link', $link->getName());
     }
 }