summaryrefslogtreecommitdiff
path: root/modules/gallery_unit_test
diff options
context:
space:
mode:
authorNathan Kinkade <nath@nkinka.de>2013-02-14 14:28:46 +0000
committerNathan Kinkade <nath@nkinka.de>2013-02-14 14:28:46 +0000
commit711651f727e093cc7357a6bbff6bd992fd6dfd80 (patch)
tree2dadc1c06acf1ab3d42d3ed5415568535db54416 /modules/gallery_unit_test
parent0047af90bf4db08b22838e6ded22a7fa70cee98a (diff)
parente5ed05004f005bdccdbf68e199ae2324ad97e895 (diff)
Merge branch 'master' of git://github.com/gallery/gallery3
Diffstat (limited to 'modules/gallery_unit_test')
-rw-r--r--modules/gallery_unit_test/controllers/gallery_unit_test.php4
-rw-r--r--modules/gallery_unit_test/helpers/MY_request.php2
-rw-r--r--modules/gallery_unit_test/helpers/test.php45
-rw-r--r--modules/gallery_unit_test/libraries/Gallery_Unit_Test_Case.php2
4 files changed, 48 insertions, 5 deletions
diff --git a/modules/gallery_unit_test/controllers/gallery_unit_test.php b/modules/gallery_unit_test/controllers/gallery_unit_test.php
index 19017a43..67d006b3 100644
--- a/modules/gallery_unit_test/controllers/gallery_unit_test.php
+++ b/modules/gallery_unit_test/controllers/gallery_unit_test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -108,7 +108,7 @@ class Gallery_Unit_Test_Controller extends Controller {
// Install the active modules
// Force gallery and user to be installed first to resolve dependencies.
- gallery_installer::install(true);
+ module::install("gallery");
module::load_modules();
module::install("user");
diff --git a/modules/gallery_unit_test/helpers/MY_request.php b/modules/gallery_unit_test/helpers/MY_request.php
index 657f69ef..28c222b8 100644
--- a/modules/gallery_unit_test/helpers/MY_request.php
+++ b/modules/gallery_unit_test/helpers/MY_request.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/gallery_unit_test/helpers/test.php b/modules/gallery_unit_test/helpers/test.php
index 7fba0eda..75cf9b33 100644
--- a/modules/gallery_unit_test/helpers/test.php
+++ b/modules/gallery_unit_test/helpers/test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -33,6 +33,21 @@ class test_Core {
return test::random_album_unsaved($parent)->save()->reload();
}
+ static function random_movie_unsaved($parent=null) {
+ $rand = test::random_string(6);
+ $photo = ORM::factory("item");
+ $photo->type = "movie";
+ $photo->parent_id = $parent ? $parent->id : 1;
+ $photo->set_data_file(MODPATH . "gallery/tests/test.flv");
+ $photo->name = "name_$rand.flv";
+ $photo->title = "title_$rand";
+ return $photo;
+ }
+
+ static function random_movie($parent=null) {
+ return test::random_movie_unsaved($parent)->save()->reload();
+ }
+
static function random_photo_unsaved($parent=null) {
$rand = test::random_string(6);
$photo = ORM::factory("item");
@@ -48,6 +63,34 @@ class test_Core {
return test::random_photo_unsaved($parent)->save()->reload();
}
+ // If a test compares photo file contents (i.e. file_get_contents), it's best to use this
+ // function to guarantee uniqueness.
+ static function random_unique_photo_unsaved($parent=null) {
+ $rand = test::random_string(6);
+ $photo = ORM::factory("item");
+ $photo->type = "photo";
+ $photo->parent_id = $parent ? $parent->id : 1;
+ if (function_exists("gd_info")) {
+ // Make image unique - color the black dot of test.jpg to the 6-digit hex code of rand.
+ $image = imagecreatefromjpeg(MODPATH . "gallery/tests/test.jpg");
+ imagefilter($image, IMG_FILTER_COLORIZE,
+ hexdec(substr($rand, 0, 2)), hexdec(substr($rand, 2, 2)), hexdec(substr($rand, 4, 2)));
+ imagejpeg($image, TMPPATH . "test_$rand.jpg");
+ imagedestroy($image);
+ $photo->set_data_file(TMPPATH . "test_$rand.jpg");
+ } else {
+ // Just use the black dot.
+ $photo->set_data_file(MODPATH . "gallery/tests/test.jpg");
+ }
+ $photo->name = "name_$rand.jpg";
+ $photo->title = "title_$rand";
+ return $photo;
+ }
+
+ static function random_unique_photo($parent=null) {
+ return test::random_unique_photo_unsaved($parent)->save()->reload();
+ }
+
static function random_user($password="password") {
$rand = "name_" . test::random_string(6);
return identity::create_user($rand, $rand, $password, "$rand@rand.com");
diff --git a/modules/gallery_unit_test/libraries/Gallery_Unit_Test_Case.php b/modules/gallery_unit_test/libraries/Gallery_Unit_Test_Case.php
index a79f2e42..4a1fcdd4 100644
--- a/modules/gallery_unit_test/libraries/Gallery_Unit_Test_Case.php
+++ b/modules/gallery_unit_test/libraries/Gallery_Unit_Test_Case.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2012 Bharat Mediratta
+ * Copyright (C) 2000-2013 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by