public function runOnce() { XSDEditor::$shouldTransform = false; $this->schemaArray = Config::schemaArray(); $this->schema = $this->generateXSD($this->schemaArray); $this->testXML = $this->generateTestXML($this->schemaArray); $numOfActions = rand(1, 4); for ($i = 1; $i <= $numOfActions; $i++) { $this->randomizeAction(); } $this->transSchema = $this->generateXSD($this->schemaArray); $this->metadataTransformed(); }
/** * * @param array $schemaArray * @param string $elementId * @return array */ public static function changeListValues($schemaArray) { $indexArr = array(); foreach ($schemaArray as $index => $schemaElement) { if ($schemaElement instanceof MetadataListField) { $indexArr[] = $index; } } if (!count($indexArr)) { return $schemaArray; } $indexToChange = $indexArr[rand(0, count($indexArr) - 1)]; $elementToChange = $schemaArray[$indexToChange]; /* @var $elementToChange MetadataListField */ $option = rand(0, 2); switch ($option) { case 0: $randIndex = rand(0, count($elementToChange->valueList) - 1); array_splice($elementToChange->valueList, $randIndex, 0, uniqid('res_')); echo " Adding list value fieldIdx={$indexToChange} fieldId={$elementToChange->id} valIdx={$randIndex}\n"; break; case 1: $randIndex = rand(0, count($elementToChange->valueList) - 1); array_splice($elementToChange->valueList, $randIndex, 1); echo " Removing list value fieldIdx={$indexToChange} fieldId={$elementToChange->id} valIdx={$randIndex}\n"; self::$shouldTransform = true; break; case 2: $elementToChange->valueList = Config::getNewListVals(); echo " Replacing list values fieldIdx={$indexToChange} fieldId={$elementToChange->id}\n"; self::$shouldTransform = true; break; } return $schemaArray; }