Exemplo n.º 1
0
 /**
  * @group 95
  */
 public function testPassingFalseReuseParamsOptionShouldOmitMatchedParametersInGeneratedProperty()
 {
     $serverUrlHelper = $this->getMock('Zend\\View\\Helper\\ServerUrl');
     $urlHelper = new UrlHelper();
     $propertyExtractor = new PropertyExtractor($serverUrlHelper, $urlHelper);
     $match = $this->matchUrl('/resource/foo', $urlHelper);
     $this->assertEquals('foo', $match->getParam('id', false));
     $property = Property::factory(['key' => 'resource', 'route' => ['name' => 'hostname/resource', 'options' => ['reuse_matched_params' => false]]]);
     $result = $propertyExtractor->extract($property);
     $this->assertInternalType('string', $result);
     $this->assertEquals('http://localhost.localdomain/resource', $result);
 }
 public function testPropertyCollectionWithTwoPropertiesForSameRelationShouldReturnArrayWithOneKeyAggregatingProperties()
 {
     $propertyCollection = new PropertyCollection();
     $propertyCollection->add(Property::factory(['key' => 'foo', 'url' => 'http://example.com/foo']));
     $propertyCollection->add(Property::factory(['key' => 'foo', 'url' => 'http://example.com/bar']));
     $propertyCollection->add(Property::factory(['key' => 'baz', 'url' => 'http://example.com/baz']));
     $result = $this->propertyCollectionExtractor->extract($propertyCollection);
     $this->assertInternalType('array', $result);
     $this->assertCount(2, $result);
     $this->assertInternalType('array', $result['foo']);
     $this->assertCount(2, $result['foo']);
 }
Exemplo n.º 3
0
 /**
  * Inject any properties found in the metadata into the resource's property collection
  *
  * @param  Metadata $metadata
  * @param  PropertyCollection $properties
  */
 public function marshalMetadataProperties(Metadata $metadata, PropertyCollection $properties)
 {
     foreach ($metadata->getProperties() as $propertyData) {
         $property = Property::factory($propertyData);
         $properties->add($property);
     }
 }
Exemplo n.º 4
0
 /**
  * @group 79
  */
 public function testFactoryCanGeneratePropertyWithRouteInformation()
 {
     $rel = 'describedby';
     $route = 'api/docs';
     $params = ['version' => '1.1'];
     $options = ['query' => 'version=1.1'];
     $property = Property::factory(['key' => $rel, 'route' => ['name' => $route, 'params' => $params, 'options' => $options]]);
     $this->assertInstanceOf('ZF\\JsonLD\\Property\\Property', $property);
     $this->assertEquals('describedby', $property->getKeyword());
     $this->assertEquals($route, $property->getRoute());
     $this->assertEquals($params, $property->getRouteParams());
     $this->assertEquals($options, $property->getRouteOptions());
 }