/**
  * @covers WindowsAzure\Table\Models\EdmType::serializeValue
  */
 public function testSerializeValueWithDate()
 {
     // Setup
     $type = EdmType::DATETIME;
     $value = new \DateTime();
     $expected = Utilities::convertToEdmDateTime($value);
     // Test
     $actual = EdmType::serializeValue($type, $value);
     // Assert
     $this->assertEquals($expected, $actual);
 }
示例#2
0
 /**
  * Serializes EDM value into proper value to be used in query.
  * 
  * @param string $type  The EDM type.
  * @param mix    $value The EDM value.
  * 
  * @return string
  * 
  * @throws \InvalidArgumentException 
  */
 public static function serializeQueryValue($type, $value)
 {
     switch ($type) {
         case EdmType::DATETIME:
             $edmDate = Utilities::convertToEdmDateTime($value);
             return 'datetime\'' . $edmDate . '\'';
         case EdmType::BINARY:
             return 'X\'' . implode('', unpack("H*", $value)) . '\'';
         case EdmType::BOOLEAN:
             return $value ? 'true' : 'false';
         case EdmType::DOUBLE:
         case EdmType::INT32:
             return $value;
         case EdmType::INT64:
             return $value . 'L';
         case EdmType::GUID:
             return 'guid\'' . $value . '\'';
         case null:
         case EdmType::STRING:
             // NULL also is treated as EdmType::STRING
             return '\'' . str_replace('\'', '\'\'', $value) . '\'';
         default:
             throw new \InvalidArgumentException();
     }
 }
 /**
  * @covers WindowsAzure\Common\Internal\Utilities::convertToEdmDateTime
  */
 public function testConvertToEdmDateTime()
 {
     // Test
     $actual = Utilities::convertToEdmDateTime(new \DateTime());
     // Assert
     $this->assertNotNull($actual);
 }
示例#4
0
 /**
  * Converts this current object to XML representation.
  * 
  * @return array.
  */
 public function toArray()
 {
     $array = array();
     $array['Start'] = Utilities::convertToEdmDateTime($this->_start);
     $array['Expiry'] = Utilities::convertToEdmDateTime($this->_expiry);
     $array['Permission'] = $this->_permission;
     return $array;
 }
 public static function tmptostring($value)
 {
     if (is_null($value)) {
         return 'null';
     } else {
         if (is_bool($value)) {
             return $value == true ? 'true' : 'false';
         } else {
             if ($value instanceof \DateTime) {
                 return Utilities::convertToEdmDateTime($value);
             } else {
                 if ($value instanceof Entity) {
                     return self::entityToString($value);
                 } else {
                     if (is_array($value)) {
                         return self::entityPropsToString($value);
                     } else {
                         if ($value instanceof Filter) {
                             return TableServiceFunctionalTestUtils::filtertoString($value);
                         } else {
                             return $value;
                         }
                     }
                 }
             }
         }
     }
 }