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());
     }
 }
 public function testEntity()
 {
     $entity = new EntityElement('bar');
     $entity->addProperty(new Property('a', 'b', 'c'));
     $property = new EntityProperty(new String('foo'), new EntityType($entity), new String('zoo'));
     $xml = simplexml_load_string($this->serializer->serialize($property, "xml"));
     $this->assertEquals('property', $xml->getName());
     $this->assertEquals('entity', $xml['type']);
     $this->assertEquals('foo', $xml['name']);
     $this->assertEquals('zoo', $xml['title']);
     $this->assertEquals('bar', $xml['entityname']);
     $this->assertEquals(1, $xml->children()->count());
     foreach ($xml->children() as $child) {
         $this->assertEquals('entity', $child->getName());
         $this->assertEquals('bar', $child['name']);
         $this->assertEquals(1, $child->properties->count());
     }
 }
Exemplo n.º 3
0
 /**
  * Set internal pointer to entity
  *
  * @see currentEntity()
  * @param \Bpi\RestMediaTypeBundle\Element\Entity $entity
  */
 public function setCursorOnEntity(Entity $entity)
 {
     if ($entity->isOwner($this)) {
         $this->current_entity = $entity;
     }
 }
Exemplo n.º 4
0
 public function testHasProperty()
 {
     $entity = new Entity('foo');
     $entity->addProperty(new Property('a', 'b', 'c'));
     $this->assertTrue($entity->hasProperty('b'));
 }