public function testCreateEntityWithoutForcedSelfLinks() { $object = new TestAsset\Entity('foo', 'Foo'); $metadata = new MetadataMap(['ZFTest\\Hal\\Plugin\\TestAsset\\Entity' => ['hydrator' => 'Zend\\Hydrator\\ObjectProperty', 'route_name' => 'hostname/resource', 'links' => [], 'force_self_link' => false]]); $this->plugin->setMetadataMap($metadata); $entity = $this->plugin->createEntity($object, 'hostname/resource', 'id'); $links = $entity->getLinks(); $this->assertFalse($links->has('self')); }
/** * @group 39 */ public function testCreateEntityPassesNullValueForIdentifierIfNotDiscovered() { $entity = array('foo' => 'bar'); $hal = $this->plugin->createEntity($entity, 'api.foo', 'foo_id'); $this->assertInstanceOf('ZF\Hal\Entity', $hal); $this->assertEquals($entity, $hal->entity); $this->assertNull($hal->id); $links = $hal->getLinks(); $this->assertTrue($links->has('self')); $link = $links->get('self'); $params = $link->getRouteParams(); $this->assertEquals(array(), $params); }