当前位置: 首页>>代码示例>>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;未经允许,请勿转载。