/**
  * @group 100
  */
 public function testRenderEntityPostEventIsTriggered()
 {
     $entity = ['id' => 1, 'foo' => 'bar'];
     $halEntity = new Entity($entity, 1);
     $triggered = false;
     $this->plugin->getEventManager()->attach('renderEntity.post', function ($e) use(&$triggered) {
         $triggered = true;
     });
     $this->plugin->renderEntity($halEntity);
     $this->assertTrue($triggered);
 }
Exemple #2
0
 /**
  * @expectedException \Zend\Mvc\Router\Exception\RuntimeException
  */
 public function testNotExistingRouteInMetadataLinks()
 {
     $object = new TestAsset\Entity('foo', 'Foo');
     $object->first_child = new TestAsset\EmbeddedEntity('bar', 'Bar');
     $entity = new Entity($object, 'foo');
     $self = new Link('self');
     $self->setRoute('hostname/resource', ['id' => 'foo']);
     $entity->getLinks()->add($self);
     $metadata = new MetadataMap(['ZFTest\\Hal\\Plugin\\TestAsset\\EmbeddedEntity' => ['hydrator' => 'Zend\\Hydrator\\ObjectProperty', 'route' => 'hostname/embedded', 'route_identifier_name' => 'id', 'entity_identifier_name' => 'id', 'links' => ['link' => ['rel' => 'link', 'route' => ['name' => 'non_existing_route']]]]]);
     $this->plugin->setMetadataMap($metadata);
     $this->plugin->renderEntity($entity);
 }
Exemple #3
0
    public function testSubsequentRenderEntityCalls()
    {
        $entity = $this->createNestedEntity();
        $metadataMap1 = $this->createNestedMetadataMap(0);
        $metadataMap2 = $this->createNestedMetadataMap(1);

        $this->plugin->setMetadataMap($metadataMap1);
        $result1 = $this->plugin->renderEntity($entity);

        $this->plugin->setMetadataMap($metadataMap2);
        $result2 = $this->plugin->renderEntity($entity);

        $this->assertNotEquals($result1, $result2);
    }