コード例 #1
0
 /**
  * @covers WindowsAzure\Table\TableRestProxy::batch
  * @covers WindowsAzure\Table\TableRestProxy::insertEntity
  */
 private function batchPositiveOuter($firstConcurType, $seed)
 {
     // The random here is not to generate random values, but to
     // get a good mix of values in the table entities.
     mt_srand($seed);
     $concurTypes = ConcurType::values();
     $mutatePivots = MutatePivot::values();
     $opTypes = OpType::values();
     // Main loop.
     foreach ($opTypes as $firstOpType) {
         if (!is_null($this->expectConcurrencyFailure($firstOpType, $firstConcurType))) {
             // Want to know there is at least one part that does not fail.
             continue;
         }
         if (Configuration::isEmulated() && ($firstOpType == OpType::insertOrMergeEntity || $firstOpType == OpType::insertOrReplaceEntity)) {
             // Emulator does not support these operations.
             continue;
         }
         $simpleEntities = TableServiceFunctionalTestData::getSimpleEntities(6);
         $configs = array();
         $firstConfig = new BatchWorkerConfig();
         $firstConfig->concurType = $firstConcurType;
         $firstConfig->opType = $firstOpType;
         $firstConfig->ent = $simpleEntities[0];
         $firstConfig->mutatePivot = $mutatePivots[mt_rand(0, count($mutatePivots))];
         array_push($configs, $firstConfig);
         for ($i = 1; $i < count($simpleEntities); $i++) {
             $config = new BatchWorkerConfig();
             while (!is_null($this->expectConcurrencyFailure($config->opType, $config->concurType))) {
                 $config->concurType = $concurTypes[mt_rand(0, count($concurTypes))];
                 $config->opType = $opTypes[mt_rand(0, count($opTypes))];
                 if (Configuration::isEmulated()) {
                     if ($config->opType == OpType::insertOrMergeEntity) {
                         $config->opType = OpType::mergeEntity;
                     }
                     if ($config->opType == OpType::insertOrReplaceEntity) {
                         $config->opType = OpType::updateEntity;
                     }
                 }
             }
             $config->mutatePivot = $mutatePivots[mt_rand(0, count($mutatePivots) - 1)];
             $config->ent = $simpleEntities[$i];
             array_push($configs, $config);
         }
         for ($i = 0; $i <= 1; $i++) {
             $options = $i == 0 ? null : new TableServiceOptions();
             if (Configuration::isEmulated()) {
                 // The emulator has trouble with some batches.
                 for ($j = 0; $j < count($configs); $j++) {
                     $tmpconfigs = array();
                     $tmpconfigs[] = $configs[$j];
                     $this->batchWorker($tmpconfigs, $options);
                 }
             } else {
                 $this->batchWorker($configs, $options);
             }
         }
     }
 }