From dd5f08b703754b88f10234db94c44f153e4f37ca Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 17 Jan 2010 20:06:28 -0800 Subject: Create xxx_unsaved() versions for the case where you want to tinker with the item before it gets saved. --- modules/gallery_unit_test/helpers/test.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'modules/gallery_unit_test') 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(); } } -- cgit v1.2.3