Пример #1
0
 public function createCustomName($ext)
 {
     // get the generate class
     $oGen = new Generate();
     # create a new custom name
     $newName = $oGen->randomString(20);
     self::getUser_directory();
     # the new file name with the extension and full path appended to it
     $fileName_and_path = UPLOAD_STORE_FOLDER . $newName . "." . $ext;
     # the new name with only the extension appended to it
     $fileName = $newName . "." . $ext;
     # check if the file already exist if exists call this function again
     if (file_exists($fileName_and_path)) {
         createCustomName($ext);
     } else {
         return $result = array('fileName' => $fileName, 'newName' => $newName);
     }
 }
 public function testGetUpperCaseLowerCaseLengthOfEight()
 {
     $string = Generate::randomString('uppercase', 8);
     $this->assertEquals(8, strlen($string));
     $this->assertEquals(1, preg_match('/^[a-zA-Z]/', $string));
 }
 /**
  * Generates a random string and sets the property name
  */
 public function main()
 {
     $string = Generate::randomString($this->getStringType(), $this->getLength());
     $this->project->log(sprintf('Generated Random String: %s, Placing Under User Property: %s', $string, $this->getName()), Project::MSG_INFO);
     $this->project->setUserProperty($this->getName(), $string);
 }