當前位置: 首頁>>代碼示例>>PHP>>正文


PHP test::random_name方法代碼示例

本文整理匯總了PHP中test::random_name方法的典型用法代碼示例。如果您正苦於以下問題:PHP test::random_name方法的具體用法?PHP test::random_name怎麽用?PHP test::random_name使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在test的用法示例。


在下文中一共展示了test::random_name方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: generate_album_cover_from_png_test

 public function generate_album_cover_from_png_test()
 {
     $input_file = MODPATH . "gallery/tests/test.jpg";
     $output_file = TMPPATH . test::random_name() . ".png";
     gallery_graphics::resize($input_file, $output_file, null, null);
     $album = test::random_album();
     $photo = test::random_photo_unsaved($album);
     $photo->set_data_file($output_file);
     $photo->name = "album_cover_from_png.png";
     $photo->save();
     $album->reload();
     // Check that the image was correctly resized and converted to jpg
     $this->assert_equal(array(200, 150, "image/jpeg", "jpg"), photo::get_file_metadata($album->thumb_path()));
     // Check that the items table got updated
     $this->assert_equal(array(200, 150), array($album->thumb_width, $album->thumb_height));
     // Check that the image is not marked dirty
     $this->assert_equal(0, $album->thumb_dirty);
 }
開發者ID:HarriLu,項目名稱:gallery3,代碼行數:18,代碼來源:Graphics_Helper_Test.php

示例2: resize_bad_jpg_test

 public function resize_bad_jpg_test()
 {
     // Input is a garbled jpg, output is jpg autofit to 300x300
     $input_file = TMPPATH . test::random_name() . ".jpg";
     $output_file = TMPPATH . test::random_name() . ".jpg";
     $options = array("width" => 300, "height" => 300, "master" => Image::AUTO);
     file_put_contents($input_file, test::lorem_ipsum(200));
     // Should get passed to Image library and throw an exception
     try {
         gallery_graphics::resize($input_file, $output_file, $options, null);
         $this->assert_true(false, "Shouldn't get here");
     } catch (Exception $e) {
         // pass
     }
 }
開發者ID:HarriLu,項目名稱:gallery3,代碼行數:15,代碼來源:Gallery_Graphics_Helper_Test.php

示例3: item_rename_wont_accept_slash_test

 public function item_rename_wont_accept_slash_test()
 {
     $item = test::random_photo();
     try {
         $item->name = test::random_name() . "/";
         $item->save();
     } catch (ORM_Validation_Exception $e) {
         $this->assert_equal(array("name" => "no_slashes"), $e->validation->errors());
         return;
     }
     $this->assert_true(false, "Shouldn't get here");
 }
開發者ID:Joe7,項目名稱:gallery3,代碼行數:12,代碼來源:Item_Model_Test.php

示例4: add_watermark_reject_illegal_file_with_legal_extension_test

 public function add_watermark_reject_illegal_file_with_legal_extension_test()
 {
     // Source is a php file, watermark path has extension jpg
     $name = test::random_name();
     $source_path = MODPATH . "watermark/tests/Admin_Watermarks_Controller_Test.php";
     $watermark_path = TMPPATH . "uploadfile-123-{$name}.jpg";
     copy($source_path, $watermark_path);
     // Setup and run Admin_Watermarks_Controller::add
     $controller = new Admin_Watermarks_Controller();
     $_POST["file"] = $watermark_path;
     $_POST["csrf"] = access::csrf_token();
     ob_start();
     $controller->add();
     $results = ob_get_clean();
     // Delete all files marked using system::delete_later (from gallery_event::gallery_shutdown)
     system::delete_marked_files();
     // Add should *not* be successful, and watermark should be deleted
     $this->assert_equal("", $results);
     $this->assert_false(file_exists($watermark_path));
     $this->assert_false(file_exists(VARPATH . "modules/watermark/{$name}.php"));
     $this->assert_false(file_exists(VARPATH . "modules/watermark/{$name}.jpg"));
 }
開發者ID:HarriLu,項目名稱:gallery3,代碼行數:22,代碼來源:Admin_Watermarks_Controller_Test.php

示例5: legal_extension_that_does_match_gets_used_test

 public function legal_extension_that_does_match_gets_used_test()
 {
     foreach (array("jpg", "JPG", "Jpg", "jpeg") as $extension) {
         $photo = test::random_photo_unsaved(item::root());
         $photo->name = test::random_name() . ".{$extension}";
         $photo->save();
         // Should get renamed with the correct jpg extension of the data file.
         $this->assert_equal($extension, pathinfo($photo->name, PATHINFO_EXTENSION));
     }
 }
開發者ID:HarriLu,項目名稱:gallery3,代碼行數:10,代碼來源:Item_Model_Test.php


注:本文中的test::random_name方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。