Ejemplo n.º 1
0
    public function testSerialization()
    {
        $form = new Form();
        $form->links[] = AtomLink::create('self', 'http://fsc.com/aform');
        $form->method = 'POST';
        $form->action = 'http://fsc.com/aresource';
        $this->assertSerializedXmlEquals('<form method="POST" action="http://fsc.com/aresource">
  <link rel="self" href="http://fsc.com/aform"/>
</form>', $form);
    }
Ejemplo n.º 2
0
 public function testCreate()
 {
     $rel = 'self';
     $href = 'http://fsc.com';
     $type = 'application/vnd.com.fsc+xml';
     $atomLink = AtomLink::create($rel, $href, $type);
     $atomLinkWithoutType = AtomLink::create($rel, $href);
     $this->assertInstanceOf('FSC\\RestBundle\\Model\\Representation\\AtomLink', $atomLink);
     $this->assertEquals($rel, $atomLink->rel);
     $this->assertEquals($href, $atomLink->href);
     $this->assertEquals($type, $atomLink->type);
     $this->assertInstanceOf('FSC\\RestBundle\\Model\\Representation\\AtomLink', $atomLinkWithoutType);
     $this->assertEquals($rel, $atomLinkWithoutType->rel);
     $this->assertEquals($href, $atomLinkWithoutType->href);
 }
Ejemplo n.º 3
0
    public function testSerialization()
    {
        $entity = new Entity();
        $entity->addLink(AtomLink::create('self', 'http://fsc.com/entity/1'));
        $entity->addLink(AtomLink::create('edit', 'http://fsc.com/entity/1/edit'));
        $entity->addLink(AtomLink::create('delete', 'http://fsc.com/entity/1/delete'));
        $entity->setAttribute('id', '1');
        $entity->setAttribute('happy', 'true');
        $entity->setAttribute('parentId', '34');
        $entity->setElement('name', 'Adrien');
        $entity->setElement('description', 'someDescriptionValue');
        $this->assertSerializedXmlEquals('<result id="1" happy="true" parentId="34">
  <link rel="self" href="http://fsc.com/entity/1"/>
  <link rel="edit" href="http://fsc.com/entity/1/edit"/>
  <link rel="delete" href="http://fsc.com/entity/1/delete"/>
  <name><![CDATA[Adrien]]></name>
  <description><![CDATA[someDescriptionValue]]></description>
</result>', $entity);
    }
Ejemplo n.º 4
0
    public function testSerialization()
    {
        $collection = new Collection();
        $collection->total = 20;
        $collection->page = 2;
        $collection->limit = 10;
        $collection->addLink(AtomLink::create('self', 'http://fsc.com/collection?page=2'));
        $collection->addLink(AtomLink::create('next', 'http://fsc.com/collection?page=3'));
        $collection->addLink(AtomLink::create('previous', 'http://fsc.com/collection?page=1'));
        $collection->addLink(AtomLink::create('first', 'http://fsc.com/collection?page=1'));
        $collection->addLink(AtomLink::create('last', 'http://fsc.com/collection?page=5'));
        $collection->addLink(AtomLink::create('new', 'http://fsc.com/collection/new'));
        $collection->results = array('foo', 'bar');
        $this->assertSerializedXmlEquals('<collection total="20" page="2" limit="10">
  <link rel="self" href="http://fsc.com/collection?page=2"/>
  <link rel="next" href="http://fsc.com/collection?page=3"/>
  <link rel="previous" href="http://fsc.com/collection?page=1"/>
  <link rel="first" href="http://fsc.com/collection?page=1"/>
  <link rel="last" href="http://fsc.com/collection?page=5"/>
  <link rel="new" href="http://fsc.com/collection/new"/>
  <entry><![CDATA[foo]]></entry>
  <entry><![CDATA[bar]]></entry>
</collection>', $collection);
    }
Ejemplo n.º 5
0
 public function create($rel, $href, $type = null)
 {
     return AtomLink::create($this->getRel($rel), $href, $type);
 }
Ejemplo n.º 6
0
 public function testSerializationWithNoType()
 {
     $atomLink = AtomLink::create('self', 'http://fsc.com');
     $this->assertSerializedXmlEquals('<link rel="self" href="http://fsc.com"/>', $atomLink);
 }