Пример #1
0
 public function it_can_get_output_with_meta_links()
 {
     $input = new LinkCollection();
     $link = Link::createSelf('http://yolo');
     $link->addMeta('jedi', 'yoda');
     $link->addMeta('sith', 'darth vader');
     $input->addLink($link);
     $this->beConstructedWith($input);
     $output = new \stdClass();
     $output->self = new \stdClass();
     $output->self->meta = new \stdClass();
     $output->self->meta->jedi = 'yoda';
     $output->self->meta->sith = 'darth vader';
     $output->self->href = 'http://yolo';
     $this->getOutput()->shouldObjectMatch($output);
 }
Пример #2
0
 public function it_can_output_link_collections_with_meta(Serializer $serializer)
 {
     $collection = new LinkCollection();
     $link = Link::createSelf('http://example.com/articles/1');
     $link->addMeta('jedi', 'yoda');
     $collection->addLink($link);
     $serializer->beConstructedWith([$collection]);
     $this->addMember($serializer);
     $this->getMembers()->shouldBeArray();
     $this->getMembers()->shouldContain($serializer);
     $serializer->getTopLevelName()->willReturn('links');
     $output = new \stdClass();
     $output->self = new \stdClass();
     $output->self->href = 'http://example.com/articles/1';
     $output->self->meta = new \stdClass();
     $output->self->meta->jedi = 'yoda';
     $serializer->getOutput()->willReturn($output);
     $this->getOutput()->shouldReturn('{"links":{"self":{"href":"http://example.com/articles/1","meta":{"jedi":"yoda"}}}}');
 }