Exemplo n.º 1
0
 public function testGetHydratorForEntityGivenUnkownEntityAndNoDefaultHydratorDefinedShouldReturnFalse()
 {
     $entity = new TestAsset\Entity('foo', 'Foo Bar');
     $metadataMap = new MetadataMap();
     $metadataMap->setHydratorManager(new HydratorPluginManager(new ServiceManager()));
     $hydratorPluginManager = new HydratorPluginManager(new ServiceManager());
     $entityHydratorManager = new EntityHydratorManager($hydratorPluginManager, $metadataMap);
     $hydrator = $entityHydratorManager->getHydratorForEntity($entity);
     $this->assertFalse($hydrator);
 }
Exemplo n.º 2
0
 /**
  * @group 79
  */
 public function testInjectsLinksFromMetadataWhenCreatingCollection()
 {
     $set = new HalPluginTestAsset\Collection([(object) ['id' => 'foo', 'name' => 'foo'], (object) ['id' => 'bar', 'name' => 'bar'], (object) ['id' => 'baz', 'name' => 'baz']]);
     $metadata = new MetadataMap([HalPluginTestAsset\Collection::class => ['is_collection' => true, 'route_name' => 'hostname/contacts', 'entity_route_name' => 'hostname/embedded', 'links' => [['rel' => 'describedby', 'url' => 'http://example.com/api/help/collection']]]]);
     $metadata->setHydratorManager(new HydratorPluginManager(new ServiceManager()));
     $resourceFactory = $this->getResourceFactory($metadata);
     $collection = $resourceFactory->createCollectionFromMetadata($set, $metadata->get(HalPluginTestAsset\Collection::class));
     $this->assertInstanceof('ZF\\Hal\\Collection', $collection);
     $links = $collection->getLinks();
     $this->assertTrue($links->has('describedby'));
     $link = $links->get('describedby');
     $this->assertTrue($link->hasUrl());
     $this->assertEquals('http://example.com/api/help/collection', $link->getUrl());
 }
Exemplo n.º 3
0
 public function testCreateCollectionWithoutForcedSelfLinks()
 {
     $collection = ['foo' => 'bar'];
     $metadata = new MetadataMap(['ZF\\Hal\\Collection' => ['is_collection' => true, 'route_name' => 'hostname/contacts', 'entity_route_name' => 'hostname/embedded', 'links' => [], 'force_self_link' => false]]);
     $metadata->setHydratorManager(new Hydrator\HydratorPluginManager(new ServiceManager()));
     $this->plugin->setMetadataMap($metadata);
     $result = $this->plugin->createCollection($collection);
     $links = $result->getLinks();
     $this->assertFalse($links->has('self'));
 }