本文整理汇总了PHP中test::random_photo_unsaved方法的典型用法代码示例。如果您正苦于以下问题:PHP test::random_photo_unsaved方法的具体用法?PHP test::random_photo_unsaved怎么用?PHP test::random_photo_unsaved使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类test
的用法示例。
在下文中一共展示了test::random_photo_unsaved方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_children_like_test
public function get_children_like_test()
{
$album1 = test::random_album();
$photo1 = test::random_photo($album1);
$photo2 = test::random_photo_unsaved($album1);
$photo2->name = "foo.jpg";
$photo2->save();
$album1->reload();
$request->url = rest::url("item", $album1);
$request->params->name = "foo";
$this->assert_equal_array(array("url" => rest::url("item", $album1), "entity" => $album1->as_array(), "members" => array(rest::url("item", $photo2)), "relationships" => array("tags" => array("url" => rest::url("item_tags", $album1), "members" => array()))), item_rest::get($request));
}
示例2: 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);
}
示例3: illegal_extension_test
public function illegal_extension_test()
{
foreach (array("test.php", "test.PHP", "test.php5", "test.php4", "test.pl") as $name) {
try {
$photo = test::random_photo_unsaved(item::root());
$photo->name = $name;
$photo->save();
} catch (ORM_Validation_Exception $e) {
$this->assert_equal(array("name" => "illegal_data_file_extension"), $e->validation->errors());
continue;
}
$this->assert_true(false, "Shouldn't get here");
}
}
示例4: find_by_relative_url_test
public function find_by_relative_url_test()
{
$level1 = test::random_album();
$level2 = test::random_album($level1);
$level3 = test::random_photo_unsaved($level2);
$level3->slug = "same";
$level3->save()->reload();
$level2b = test::random_album($level1);
$level3b = test::random_photo_unsaved($level2b);
$level3b->slug = "same";
$level3b->save()->reload();
// Item in album
$this->assert_same($level3->id, item::find_by_relative_url("{$level1->slug}/{$level2->slug}/{$level3->slug}")->id);
// Album, ends without a slash
$this->assert_same($level2->id, item::find_by_relative_url("{$level1->slug}/{$level2->slug}")->id);
// Return root if "" is passed
$this->assert_same(item::root()->id, item::find_by_relative_url("")->id);
// Verify that we don't get confused by the part slugs, using the fallback code.
db::build()->update("items")->set(array("relative_url_cache" => null))->where("id", "IN", array($level3->id, $level3b->id))->execute();
$this->assert_same($level3->id, item::find_by_relative_url("{$level1->slug}/{$level2->slug}/{$level3->slug}")->id);
$this->assert_same($level3b->id, item::find_by_relative_url("{$level1->slug}/{$level2b->slug}/{$level3b->slug}")->id);
// Verify that we don't get false positives
$this->assert_false(item::find_by_relative_url("foo/bar/baz")->loaded());
// Verify that the fallback code works
$this->assert_same($level3b->id, item::find_by_relative_url("{$level1->slug}/{$level2b->slug}/{$level3b->slug}")->id);
}
示例5: random_photo
static function random_photo($parent = null)
{
return test::random_photo_unsaved($parent)->save()->reload();
}
示例6: exif_extract_test
public function exif_extract_test()
{
$photo = test::random_photo_unsaved()->set_data_file(MODPATH . "exif/tests/data/image.jpg")->save();
$expected = array(array("caption" => "Camera Maker", "value" => "Pentax Corporation"), array("caption" => "Camera Model", "value" => "PENTAX K10D"), array("caption" => "Aperture", "value" => "f/2.8"), array("caption" => "Color Space", "value" => "Uncalibrated"), array("caption" => "Exposure Value", "value" => "4294.67 EV"), array("caption" => "Exposure Program", "value" => "Program"), array("caption" => "Exposure Time", "value" => "1/60 sec"), array("caption" => "Flash", "value" => "No Flash"), array("caption" => "Focal Length", "value" => "50 mm"), array("caption" => "ISO", "value" => "6553700"), array("caption" => "Metering Mode", "value" => "Multi-Segment"), array("caption" => "Date/Time", "value" => "2008:03:17 17:41:25"), array("caption" => "Copyright", "value" => "(C) 2008 - T. Almdal"), array("caption" => "Orientation", "value" => "1: Normal (0 deg)"), array("caption" => "Resolution Unit", "value" => "Inch"), array("caption" => "X Resolution", "value" => "240 dots per ResolutionUnit"), array("caption" => "Y Resolution", "value" => "240 dots per ResolutionUnit"), array("caption" => "Brightness Value", "value" => "0"), array("caption" => "Scene Type", "value" => "0"), array("caption" => "Subject Distance", "value" => "0"));
$this->assert_equal($expected, exif::get($photo));
}
示例7: legal_extension_that_doesnt_match_gets_fixed_test
public function legal_extension_that_doesnt_match_gets_fixed_test()
{
foreach (array("test.png", "test.mp4", "test.GIF") as $name) {
$photo = test::random_photo_unsaved(item::root());
$photo->name = $name;
$photo->save();
// Should get renamed with the correct jpg extension of the data file.
$this->assert_equal("jpg", pathinfo($photo->name, PATHINFO_EXTENSION));
}
}
示例8: move_photo_fails_conflicting_target_test
public function move_photo_fails_conflicting_target_test()
{
$photo1 = test::random_photo();
$album = test::random_album();
$photo2 = test::random_photo_unsaved($album);
$photo2->name = $photo1->name;
$photo2->save();
// $photo1 and $photo2 have the same name, so if we move $photo1 into the root they should
// conflict.
try {
$photo2->parent_id = item::root()->id;
$photo2->save();
} catch (Exception $e) {
// pass
$this->assert_equal(array("name" => "conflict", "slug" => "conflict"), $e->validation->errors());
return;
}
$this->assert_true(false, "Shouldn't get here");
}
示例9: move_conflicts_result_in_a_rename_test
public function move_conflicts_result_in_a_rename_test()
{
$rand = rand();
$photo1 = test::random_photo_unsaved(item::root());
$photo1->name = "{$rand}.jpg";
$photo1->slug = (string) $rand;
$photo1->save();
$src_album = test::random_album();
$photo2 = test::random_photo_unsaved($src_album);
$photo2->name = "{$rand}.jpg";
$photo2->slug = (string) $rand;
$photo2->save();
item::move($photo2, item::root());
$this->assert_same(item::root()->id, $photo2->parent_id);
$this->assert_not_same("{$rand}.jpg", $photo2->name);
$this->assert_not_same($rand, $photo2->slug);
}