diff options
author | Bharat Mediratta <bharat@menalto.com> | 2010-01-17 20:06:28 -0800 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2010-01-17 20:06:28 -0800 |
commit | dd5f08b703754b88f10234db94c44f153e4f37ca (patch) | |
tree | 6e1a10da3cbd0175229d8a3518ee1812c57781ad /modules/gallery_unit_test/helpers | |
parent | c0d01425528a979634b514250347f5bab25cf9a0 (diff) |
Create xxx_unsaved() versions for the case where you want to tinker with the item before it gets saved.
Diffstat (limited to 'modules/gallery_unit_test/helpers')
-rw-r--r-- | modules/gallery_unit_test/helpers/test.php | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/modules/gallery_unit_test/helpers/test.php b/modules/gallery_unit_test/helpers/test.php index 6dfa3cf0..5368539f 100644 --- a/modules/gallery_unit_test/helpers/test.php +++ b/modules/gallery_unit_test/helpers/test.php @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class test_Core { - static function random_album($parent=null) { + static function random_album_unsaved($parent=null) { $rand = rand(); $album = ORM::factory("item"); @@ -26,10 +26,14 @@ class test_Core { $album->parent_id = $parent ? $parent->id : 1; $album->name = "name_$rand"; $album->title = "title_$rand"; - return $album->save(); + return $album; } - static function random_photo($parent=null) { + static function random_album($parent=null) { + return test::random_album_unsaved($parent)->save(); + } + + static function random_photo_unsaved($parent=null) { $rand = rand(); $photo = ORM::factory("item"); $photo->type = "photo"; @@ -37,6 +41,10 @@ class test_Core { $photo->set_data_file(MODPATH . "gallery/tests/test.jpg"); $photo->name = "name_$rand.jpg"; $photo->title = "title_$rand"; - return $photo->save(); + return $photo; + } + + static function random_photo($parent=null) { + return test::random_photo_unsaved($parent)->save(); } } |