Exemple #1
0
 /**
  * @param null|Entity  $entity
  * @param string|array $include List of keys to include in the output record
  * @param array        $record
  *
  * @return array
  */
 protected static function parseEntityToRecord($entity, $include = ApiOptions::FIELDS_ALL, $record = [])
 {
     if (!empty($entity)) {
         if (empty($include)) {
             $record[static::PARTITION_KEY] = $entity->getPartitionKey();
             $record[static::ROW_KEY] = $entity->getRowKey();
         } elseif (ApiOptions::FIELDS_ALL == $include) {
             // return all properties
             /** @var Property[] $properties */
             $properties = $entity->getProperties();
             foreach ($properties as $key => $property) {
                 $record[$key] = $property->getValue();
             }
         } else {
             if (!is_array($include)) {
                 $include = array_map('trim', explode(',', trim($include, ',')));
             }
             foreach ($include as $key) {
                 $record[$key] = $entity->getPropertyValue($key);
             }
         }
     }
     return $record;
 }
 /**
  * @covers WindowsAzure\Table\Models\Entity::setRowKey
  * @covers WindowsAzure\Table\Models\Entity::getRowKey
  */
 public function testSetRowKey()
 {
     // Setup
     $entity = new Entity();
     $expected = '1234';
     // Test
     $entity->setRowKey($expected);
     // Assert
     $this->assertEquals($expected, $entity->getRowKey());
 }