Ejemplo n.º 1
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]]);
     $this->plugin->setMetadataMap($metadata);
     $result = $this->plugin->createCollection($collection);
     $links = $result->getLinks();
     $this->assertFalse($links->has('self'));
 }
Ejemplo n.º 2
0
    /**
     * @param $collection
     * @param $metadataMap
     * @param $expectedResult
     * @param $exception
     *
     * @dataProvider renderCollectionWithMaxDepthProvider
     */
    public function testRenderCollectionWithMaxDepth($collection, $metadataMap, $expectedResult, $exception = null)
    {
        $this->plugin->setMetadataMap($metadataMap);

        if ($exception) {
            $this->setExpectedException($exception['class'], $exception['message']);
        }

        if (is_callable($collection)) {
            $collection = $collection();
        }

        $halCollection = $this->plugin->createCollection($collection);
        $result = $this->plugin->renderCollection($halCollection);

        $this->assertEquals($expectedResult, $result);
    }