コード例 #1
0
 private static function getNewEntity()
 {
     if (is_null(self::$curPartition) || self::$curPartition == count(self::$Partitions) - 1) {
         self::$curPartition = 0;
         self::$curRowKey = TableServiceFunctionalTestData::getNewKey();
     } else {
         self::$curPartition++;
     }
     $entity = new Entity();
     $entity->setPartitionKey(self::$Partitions[self::$curPartition]);
     $entity->setRowKey(self::$curRowKey);
     return $entity;
 }
 /**
  * @covers WindowsAzure\Table\TableRestProxy::deleteEntity
  */
 public function testDeleteEntityTableNull()
 {
     $table = TableServiceFunctionalTestData::$TEST_TABLE_NAMES[0];
     try {
         $this->restProxy->deleteEntity(null, TableServiceFunctionalTestData::getNewKey(), TableServiceFunctionalTestData::getNewKey());
         $this->fail('Expect null table name to throw');
     } catch (\InvalidArgumentException $e) {
         $this->assertEquals(sprintf(Resources::NULL_OR_EMPTY_MSG, 'table'), $e->getMessage(), 'Expect error message');
         $this->assertEquals(0, $e->getCode(), 'Expected error code');
     }
     $this->clearTable($table);
 }
コード例 #3
0
 /**
  * @covers WindowsAzure\Table\TableRestProxy::updateEntity
  */
 private function createTargetEntity($table, $initialEnt, $concurType, $mutatePivot)
 {
     $targetEnt = TableServiceFunctionalTestUtils::cloneEntity($initialEnt);
     // Update the entity/table state to get the requested concurrency type error.
     switch ($concurType) {
         case ConcurType::NoKeyMatch:
             // Mutate the keys to not match.
             $targetEnt->setRowKey(TableServiceFunctionalTestData::getNewKey());
             break;
         case ConcurType::KeyMatchNoEtag:
             $targetEnt->setEtag(null);
             break;
         case ConcurType::KeyMatchEtagMismatch:
             $newEtag = $this->restProxy->updateEntity($table, $initialEnt)->getEtag();
             $initialEnt->setEtag($newEtag);
             // Now the $targetEnt Etag will not match.
             $this->assertTrue($targetEnt->getEtag() != $initialEnt->getEtag(), 'targetEnt->Etag(\'' . $targetEnt->getEtag() . '\') !=  updated->Etag(\'' . $initialEnt->getEtag() . '\')');
             break;
         case ConcurType::KeyMatchEtagMatch:
             // Don't worry here.
             break;
     }
     // Mutate the properties.
     TableServiceFunctionalTestUtils::mutateEntity($targetEnt, $mutatePivot);
     return $targetEnt;
 }
コード例 #4
0
 static function mutateEntity($ent, $pivot)
 {
     if ($pivot == MutatePivot::CHANGE_VALUES) {
         self::mutateEntityChangeValues($ent);
     } else {
         if ($pivot == MutatePivot::ADD_PROPERTY) {
             $ent->addProperty('BOOLEAN' . TableServiceFunctionalTestData::getNewKey(), EdmType::BOOLEAN, true);
             $ent->addProperty('DATETIME' . TableServiceFunctionalTestData::getNewKey(), EdmType::DATETIME, Utilities::convertToDateTime('2012-01-26T18:26:19.0000473Z'));
             $ent->addProperty('DOUBLE' . TableServiceFunctionalTestData::getNewKey(), EdmType::DOUBLE, 12345678901);
             $ent->addProperty('GUID' . TableServiceFunctionalTestData::getNewKey(), EdmType::GUID, '90ab64d6-d3f8-49ec-b837-b8b5b6367b74');
             $ent->addProperty('INT32' . TableServiceFunctionalTestData::getNewKey(), EdmType::INT32, 23);
             $ent->addProperty('INT64' . TableServiceFunctionalTestData::getNewKey(), EdmType::INT64, '-1');
             $ent->addProperty('STRING' . TableServiceFunctionalTestData::getNewKey(), EdmType::STRING, 'this is a test!');
         } else {
             if ($pivot == MutatePivot::REMOVE_PROPERTY) {
                 $propToRemove = null;
                 foreach ($ent->getProperties() as $propName => $propValue) {
                     // Don't mess with the keys.
                     if ($propName == 'PartitionKey' || $propName == 'RowKey' || $propName == 'Timestamp') {
                         continue;
                     }
                     $propToRemove = $propName;
                     break;
                 }
                 $props = $ent->getProperties();
                 unset($props[$propToRemove]);
             } else {
                 if ($pivot == MutatePivot::NULL_PROPERTY) {
                     foreach ($ent->getProperties() as $propName => $propValue) {
                         // Don't mess with the keys.
                         if ($propName == 'PartitionKey' || $propName == 'RowKey' || $propName == 'Timestamp') {
                             continue;
                         }
                         $propValue->setValue(null);
                     }
                 }
             }
         }
     }
 }