public function testGetProperty()
 {
     $propertyId = 'test-property_id';
     $property = $this->getMock('Omeka\\Entity\\Property');
     $adapter = $this->getMock('Omeka\\Api\\Adapter\\AbstractAdapter');
     $adapter->expects($this->once())->method('getRepresentation')->with($this->identicalTo($property));
     $apiAdapterManager = $this->getMock('Omeka\\Api\\Adapter\\Manager');
     $apiAdapterManager->expects($this->once())->method('get')->with($this->equalTo('properties'))->will($this->returnValue($adapter));
     $serviceLocator = $this->getServiceManager(['Omeka\\ApiAdapterManager' => $apiAdapterManager]);
     $value = $this->getMock('Omeka\\Entity\\Value');
     $value->expects($this->once())->method('getProperty')->will($this->returnValue($property));
     $valueRep = new ValueRepresentation($value, $serviceLocator);
     $this->assertNull($valueRep->property());
 }
 /**
  * Get all value representations of this resource.
  *
  * <code>
  * array(
  *   {term} => array(
  *     'property' => {PropertyRepresentation},
  *     'alternate_label' => {label},
  *     'alternate_comment' => {comment},
  *     'values' => array(
  *       {ValueRepresentation},
  *       {ValueRepresentation},
  *     ),
  *   ),
  * )
  * </code>
  *
  * @return array
  */
 public function values()
 {
     if (isset($this->values)) {
         return $this->values;
     }
     // Set the default template info.
     $templateInfo = ['dcterms:title' => [], 'dcterms:description' => []];
     $template = $this->resourceTemplate();
     if ($template) {
         // Set the custom template info.
         $templateInfo = [];
         foreach ($template->resourceTemplateProperties() as $templateProperty) {
             $term = $templateProperty->property()->term();
             $templateInfo[$term] = ['alternate_label' => $templateProperty->alternateLabel(), 'alternate_comment' => $templateProperty->alternateComment()];
         }
     }
     // Get this resource's values.
     $values = [];
     foreach ($this->resource->getValues() as $valueEntity) {
         $value = new ValueRepresentation($valueEntity, $this->getServiceLocator());
         if ('resource' === $value->type() && null === $value->valueResource()) {
             // Skip this resource value if the resource is not available
             // (most likely becuase it is private).
             continue;
         }
         $term = $value->property()->term();
         if (!isset($values[$term]['property'])) {
             $values[$term]['property'] = $value->property();
             $values[$term]['alternate_label'] = null;
             $values[$term]['alternate_comment'] = null;
         }
         $values[$term]['values'][] = $value;
     }
     // Order this resource's values according to the template order.
     $sortedValues = [];
     foreach ($values as $term => $valueInfo) {
         foreach ($templateInfo as $templateTerm => $templateAlternates) {
             if (array_key_exists($templateTerm, $values)) {
                 $sortedValues[$templateTerm] = array_merge($values[$templateTerm], $templateAlternates);
             }
         }
     }
     $this->values = $sortedValues + $values;
     return $this->values;
 }