本文整理汇总了PHP中test::random_photo方法的典型用法代码示例。如果您正苦于以下问题:PHP test::random_photo方法的具体用法?PHP test::random_photo怎么用?PHP test::random_photo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类test
的用法示例。
在下文中一共展示了test::random_photo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: move_leaves_empty_album_with_no_album_cover_test
public function move_leaves_empty_album_with_no_album_cover_test()
{
$src_album = test::random_album();
$photo = test::random_photo($src_album);
item::move($photo, item::root());
$src_album->reload();
$this->assert_false($src_album->album_cover_item_id);
}
示例2: get_children_type_test
public function get_children_type_test()
{
$album1 = test::random_album();
$photo1 = test::random_photo($album1);
$album2 = test::random_album($album1);
$album1->reload();
$request->url = rest::url("item", $album1);
$request->params->type = "album";
$this->assert_equal_array(array("url" => rest::url("item", $album1), "entity" => $album1->as_array(), "members" => array(rest::url("item", $album2)), "relationships" => array("tags" => array("url" => rest::url("item_tags", $album1), "members" => array()))), item_rest::get($request));
}
示例3: build_breadcrumbs_for_item_test
public function build_breadcrumbs_for_item_test()
{
$album = test::random_album();
$item = test::random_photo($album);
$expected = array();
$expected[] = Breadcrumb::instance(item::root()->title, item::root()->url("show={$album->id}"))->set_first();
$expected[] = Breadcrumb::instance($album->title, $album->url("show={$item->id}"));
$expected[] = Breadcrumb::instance($item->title, $item->url())->set_last();
$this->assert_equal($expected, Breadcrumb::array_from_item_parents($item));
}
示例4: _get_proxy
private function _get_proxy()
{
$album = test::random_album();
$photo = test::random_photo($album);
access::deny(identity::everybody(), "view_full", $album);
access::deny(identity::registered_users(), "view_full", $album);
$proxy = ORM::factory("digibug_proxy");
$proxy->uuid = random::hash();
$proxy->item_id = $photo->id;
return $proxy->save();
}
示例5: viewable_test
public function viewable_test()
{
$album = test::random_album();
$item = test::random_photo($album);
$album->reload();
identity::set_active_user(identity::guest());
// We can see the item when permissions are granted
access::allow(identity::everybody(), "view", $album);
$this->assert_equal(1, ORM::factory("item")->viewable()->where("id", "=", $item->id)->count_all());
// We can't see the item when permissions are denied
access::deny(identity::everybody(), "view", $album);
$this->assert_equal(0, ORM::factory("item")->viewable()->where("id", "=", $item->id)->count_all());
}
示例6: change_photo_no_csrf_fails_test
public function change_photo_no_csrf_fails_test()
{
$controller = new Photos_Controller();
$photo = test::random_photo();
$_POST["name"] = "new name.jpg";
$_POST["title"] = "new title";
$_POST["description"] = "new description";
$_POST["slug"] = "new slug";
access::allow(identity::everybody(), "edit", item::root());
try {
$controller->update($photo);
$this->assert_true(false, "This should fail");
} catch (Exception $e) {
// pass
$this->assert_same("@todo FORBIDDEN", $e->getMessage());
}
}
示例7: get_ancestors_test
public function get_ancestors_test()
{
$album1 = test::random_album();
$photo1 = test::random_photo($album1);
$album2 = test::random_album($album1);
$photo2 = test::random_photo($album2);
$album1->reload();
$album2->reload();
$root = ORM::factory("item", 1);
$restful_root = array("url" => rest::url("item", $root), "entity" => $root->as_restful_array(), "relationships" => rest::relationships("item", $root));
$restful_root["members"] = array();
foreach ($root->children() as $child) {
$restful_root["members"][] = rest::url("item", $child);
}
$request = new stdClass();
$request->params = new stdClass();
$request->params->ancestors_for = rest::url("item", $photo2);
$this->assert_equal_array(array($restful_root, array("url" => rest::url("item", $album1), "entity" => $album1->as_restful_array(), "relationships" => array("comments" => array("url" => rest::url("item_comments", $album1)), "tags" => array("url" => rest::url("item_tags", $album1), "members" => array())), "members" => array(rest::url("item", $photo1), rest::url("item", $album2))), array("url" => rest::url("item", $album2), "entity" => $album2->as_restful_array(), "relationships" => array("comments" => array("url" => rest::url("item_comments", $album2)), "tags" => array("url" => rest::url("item_tags", $album2), "members" => array())), "members" => array(rest::url("item", $photo2))), array("url" => rest::url("item", $photo2), "entity" => $photo2->as_restful_array(), "relationships" => array("comments" => array("url" => rest::url("item_comments", $photo2)), "tags" => array("url" => rest::url("item_tags", $photo2), "members" => array())))), items_rest::get($request));
}
示例8: as_restful_array_test
public function as_restful_array_test()
{
$album = test::random_album();
$photo = test::random_photo($album);
$album->reload();
$result = $album->as_restful_array();
$this->assert_same(rest::url("item", item::root()), $result["parent"]);
$this->assert_same(rest::url("item", $photo), $result["album_cover"]);
$this->assert_true(!array_key_exists("parent_id", $result));
$this->assert_true(!array_key_exists("album_cover_item_id", $result));
}
示例9: urls_test
public function urls_test()
{
$photo = test::random_photo();
$this->assert_true(preg_match("|http://./var/resizes/name_\\w+\\.jpg\\?m=\\d+|", $photo->resize_url()), $photo->resize_url() . " is malformed");
$this->assert_true(preg_match("|http://./var/thumbs/name_\\w+\\.jpg\\?m=\\d+|", $photo->thumb_url()), $photo->thumb_url() . " is malformed");
$this->assert_true(preg_match("|http://./var/albums/name_\\w+\\.jpg\\?m=\\d+|", $photo->file_url()), $photo->file_url() . " is malformed");
// Albums have special thumbnails. Empty album has cachebuster of 0 since it has no thumbnail
$album = test::random_album();
$this->assert_true(preg_match("|http://./var/thumbs/name_\\w+/\\.album\\.jpg\\?m=0|", $album->thumb_url()), $album->thumb_url() . " is malformed");
$photo = test::random_photo($album);
$this->assert_true(preg_match("|http://./var/thumbs/name_\\w+/\\.album\\.jpg\\?m=\\d+|", $album->thumb_url()), $album->thumb_url() . " is malformed");
}
示例10: moved_items_inherit_new_permissions_test
public function moved_items_inherit_new_permissions_test()
{
identity::set_active_user(identity::lookup_user_by_name("admin"));
$public_album = test::random_album();
$public_photo = test::random_photo($public_album);
access::allow(identity::everybody(), "view", $public_album);
access::allow(identity::everybody(), "edit", $public_album);
item::root()->reload();
// Account for MPTT changes
$private_album = test::random_album();
access::deny(identity::everybody(), "view", $private_album);
access::deny(identity::everybody(), "edit", $private_album);
$private_photo = test::random_photo($private_album);
// Make sure that we now have a public photo and private photo.
$this->assert_true(access::group_can(identity::everybody(), "view", $public_photo));
$this->assert_false(access::group_can(identity::everybody(), "view", $private_photo));
// Swap the photos
item::move($public_photo, $private_album);
$private_album->reload();
// Reload to get new MPTT pointers and cached perms.
$public_album->reload();
$private_photo->reload();
$public_photo->reload();
item::move($private_photo, $public_album);
$private_album->reload();
// Reload to get new MPTT pointers and cached perms.
$public_album->reload();
$private_photo->reload();
$public_photo->reload();
// Make sure that the public_photo is now private, and the private_photo is now public.
$this->assert_false(access::group_can(identity::everybody(), "view", $public_photo));
$this->assert_false(access::group_can(identity::everybody(), "edit", $public_photo));
$this->assert_true(access::group_can(identity::everybody(), "view", $private_photo));
$this->assert_true(access::group_can(identity::everybody(), "edit", $private_photo));
}
示例11: cant_rename_to_illegal_extension_test
public function cant_rename_to_illegal_extension_test()
{
foreach (array("test.php.test", "test.php", "test.PHP", "test.php5", "test.php4", "test.pl") as $name) {
try {
$photo = test::random_photo(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");
}
}
示例12: delete_cover_photo_picks_new_album_cover_test
public function delete_cover_photo_picks_new_album_cover_test()
{
$parent = test::random_album();
$album = test::random_album($parent);
$photo1 = test::random_photo($album);
// At this point, $photo1 is the album cover. We verify this in
// Item_Model_Test::first_photo_becomes_album_cover
$photo2 = test::random_photo($album);
$photo1->delete();
$album->reload();
$parent->reload();
$this->assert_same($photo2->id, $album->album_cover_item_id);
$this->assert_same($photo2->id, $parent->album_cover_item_id);
}
示例13: get_file_metadata_test
public function get_file_metadata_test()
{
$photo = test::random_photo();
$this->assert_equal(array(1024, 768, "image/jpeg", "jpg"), photo::get_file_metadata($photo->file_path()));
}
示例14: resequence_child_weights_test
public function resequence_child_weights_test()
{
$album = test::random_album_unsaved();
$album->sort_column = "id";
$album->save();
$photo1 = test::random_photo($album);
$photo2 = test::random_photo($album);
$this->assert_true($photo2->weight > $photo1->weight);
$album->reload();
$album->sort_order = "DESC";
$album->save();
item::resequence_child_weights($album);
$this->assert_equal(2, $photo1->reload()->weight);
$this->assert_equal(1, $photo2->reload()->weight);
}
示例15: missing_file_test
public function missing_file_test()
{
$photo = test::random_photo();
$_SERVER["REQUEST_URI"] = url::file("var/albums/{$photo->name}");
unlink($photo->file_path());
$controller = new File_Proxy_Controller();
try {
$controller->__call("", array());
$this->assert_true(false);
} catch (Kohana_404_Exception $e) {
$this->assert_same(7, $e->test_fail_code);
}
}