summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2010-01-19 22:38:19 -0800
committerBharat Mediratta <bharat@menalto.com>2010-01-19 22:38:19 -0800
commit76da85a1a08cdf065bf186c81ea444d03d6f8935 (patch)
tree7068ce2265e54fb7af6abac7457309cfa900ef87
parenta774dc5447a1d90cd5c361e9196ab41fd91f92cf (diff)
Extend Gallery_Unit_Test_Case instead of Unit_Test_Case.
-rw-r--r--modules/akismet/tests/Akismet_Helper_Test.php2
-rw-r--r--modules/comment/tests/Comment_Event_Test.php2
-rw-r--r--modules/comment/tests/Comment_Helper_Test.php2
-rw-r--r--modules/comment/tests/Comment_Model_Test.php2
-rw-r--r--modules/digibug/tests/Digibug_Controller_Test.php2
-rw-r--r--modules/exif/tests/Exif_Test.php2
-rw-r--r--modules/gallery/tests/Access_Helper_Test.php2
-rw-r--r--modules/gallery/tests/Albums_Controller_Test.php2
-rw-r--r--modules/gallery/tests/Cache_Test.php2
-rw-r--r--modules/gallery/tests/Controller_Auth_Test.php2
-rw-r--r--modules/gallery/tests/Database_Test.php2
-rw-r--r--modules/gallery/tests/Dir_Helper_Test.php2
-rw-r--r--modules/gallery/tests/DrawForm_Test.php2
-rw-r--r--modules/gallery/tests/File_Structure_Test.php2
-rw-r--r--modules/gallery/tests/Gallery_I18n_Test.php2
-rw-r--r--modules/gallery/tests/Gallery_Installer_Test.php2
-rw-r--r--modules/gallery/tests/Html_Helper_Test.php2
-rw-r--r--modules/gallery/tests/Item_Helper_Test.php2
-rw-r--r--modules/gallery/tests/Item_Model_Test.php2
-rw-r--r--modules/gallery/tests/Locales_Helper_Test.php2
-rw-r--r--modules/gallery/tests/Menu_Test.php2
-rw-r--r--modules/gallery/tests/ORM_MPTT_Test.php2
-rw-r--r--modules/gallery/tests/Photos_Controller_Test.php2
-rw-r--r--modules/gallery/tests/SafeString_Test.php2
-rw-r--r--modules/gallery/tests/Sendmail_Test.php2
-rw-r--r--modules/gallery/tests/Url_Security_Test.php2
-rw-r--r--modules/gallery/tests/Var_Test.php2
-rw-r--r--modules/gallery/tests/Xss_Security_Test.php2
-rw-r--r--modules/gallery_unit_test/helpers/test.php11
-rw-r--r--modules/rest/tests/Rest_Controller_Test.php142
-rw-r--r--modules/tag/tests/Tag_Rest_Helper_Test.php2
-rw-r--r--modules/tag/tests/Tag_Test.php2
-rw-r--r--modules/user/tests/No_Direct_ORM_Access_Test.php2
-rw-r--r--modules/user/tests/User_Groups_Test.php2
-rw-r--r--modules/user/tests/User_Installer_Test.php2
35 files changed, 68 insertions, 151 deletions
diff --git a/modules/akismet/tests/Akismet_Helper_Test.php b/modules/akismet/tests/Akismet_Helper_Test.php
index b32e9a02..e185f280 100644
--- a/modules/akismet/tests/Akismet_Helper_Test.php
+++ b/modules/akismet/tests/Akismet_Helper_Test.php
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
-class Akismet_Helper_Test extends Unit_Test_Case {
+class Akismet_Helper_Test extends Gallery_Unit_Test_Case {
private $_comment;
public function setup() {
diff --git a/modules/comment/tests/Comment_Event_Test.php b/modules/comment/tests/Comment_Event_Test.php
index 5b7daef4..27272055 100644
--- a/modules/comment/tests/Comment_Event_Test.php
+++ b/modules/comment/tests/Comment_Event_Test.php
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
-class Comment_Event_Test extends Unit_Test_Case {
+class Comment_Event_Test extends Gallery_Unit_Test_Case {
public function deleting_an_item_deletes_its_comments_too_test() {
$album = test::random_album();
diff --git a/modules/comment/tests/Comment_Helper_Test.php b/modules/comment/tests/Comment_Helper_Test.php
index d780aba6..7ba024c7 100644
--- a/modules/comment/tests/Comment_Helper_Test.php
+++ b/modules/comment/tests/Comment_Helper_Test.php
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
-class Comment_Helper_Test extends Unit_Test_Case {
+class Comment_Helper_Test extends Gallery_Unit_Test_Case {
private $_ip_address;
private $_user_agent;
diff --git a/modules/comment/tests/Comment_Model_Test.php b/modules/comment/tests/Comment_Model_Test.php
index c98eb63c..f0449c05 100644
--- a/modules/comment/tests/Comment_Model_Test.php
+++ b/modules/comment/tests/Comment_Model_Test.php
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
-class Comment_Model_Test extends Unit_Test_Case {
+class Comment_Model_Test extends Gallery_Unit_Test_Case {
public function cant_view_comments_for_unviewable_items_test() {
$album = test::random_album();
diff --git a/modules/digibug/tests/Digibug_Controller_Test.php b/modules/digibug/tests/Digibug_Controller_Test.php
index 38dcd8e9..561dd3c9 100644
--- a/modules/digibug/tests/Digibug_Controller_Test.php
+++ b/modules/digibug/tests/Digibug_Controller_Test.php
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
-class Digibug_Controller_Test extends Unit_Test_Case {
+class Digibug_Controller_Test extends Gallery_Unit_Test_Case {
private $_server;
public function setup() {
diff --git a/modules/exif/tests/Exif_Test.php b/modules/exif/tests/Exif_Test.php
index 191bdb99..e4835b7f 100644
--- a/modules/exif/tests/Exif_Test.php
+++ b/modules/exif/tests/Exif_Test.php
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
-class Exif_Test extends Unit_Test_Case {
+class Exif_Test extends Gallery_Unit_Test_Case {
public function exif_extract_test() {
$photo = test::random_photo_unsaved()
->set_data_file(MODPATH . "exif/tests/data/image.jpg")
diff --git a/modules/gallery/tests/Access_Helper_Test.php b/modules/gallery/tests/Access_Helper_Test.php
index da72f12f..7ddd2875 100644
--- a/modules/gallery/tests/Access_Helper_Test.php
+++ b/modules/gallery/tests/Access_Helper_Test.php
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
-class Access_Helper_Test extends Unit_Test_Case {
+class Access_Helper_Test extends Gallery_Unit_Test_Case {
private $_group;
public function teardown() {
diff --git a/modules/gallery/tests/Albums_Controller_Test.php b/modules/gallery/tests/Albums_Controller_Test.php
index 26dc2571..76c9a628 100644
--- a/modules/gallery/tests/Albums_Controller_Test.php
+++ b/modules/gallery/tests/Albums_Controller_Test.php
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
-class Albums_Controller_Test extends Unit_Test_Case {
+class Albums_Controller_Test extends Gallery_Unit_Test_Case {
public function setup() {
$this->_save = array($_POST, $_SERVER);
}
diff --git a/modules/gallery/tests/Cache_Test.php b/modules/gallery/tests/Cache_Test.php
index d5bf37cc..1023568b 100644
--- a/modules/gallery/tests/Cache_Test.php
+++ b/modules/gallery/tests/Cache_Test.php
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
-class Cache_Test extends Unit_Test_Case {
+class Cache_Test extends Gallery_Unit_Test_Case {
private $_driver;
public function setup() {
db::build()->delete("caches")->execute();
diff --git a/modules/gallery/tests/Controller_Auth_Test.php b/modules/gallery/tests/Controller_Auth_Test.php
index 124d8b4c..c27196da 100644
--- a/modules/gallery/tests/Controller_Auth_Test.php
+++ b/modules/gallery/tests/Controller_Auth_Test.php
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
-class Controller_Auth_Test extends Unit_Test_Case {
+class Controller_Auth_Test extends Gallery_Unit_Test_Case {
public function find_missing_auth_test() {
$found = array();
$controllers = explode("\n", `git ls-files '*/*/controllers/*.php'`);
diff --git a/modules/gallery/tests/Database_Test.php b/modules/gallery/tests/Database_Test.php
index 6aa186e5..e58f73eb 100644
--- a/modules/gallery/tests/Database_Test.php
+++ b/modules/gallery/tests/Database_Test.php
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
-class Database_Test extends Unit_Test_Case {
+class Database_Test extends Gallery_Unit_Test_Case {
function setup() {
$config = Kohana_Config::instance();
$config->set("database.mock.connection.type", "mock");
diff --git a/modules/gallery/tests/Dir_Helper_Test.php b/modules/gallery/tests/Dir_Helper_Test.php
index 46bb871c..69241447 100644
--- a/modules/gallery/tests/Dir_Helper_Test.php
+++ b/modules/gallery/tests/Dir_Helper_Test.php
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
-class Dir_Helper_Test extends Unit_Test_Case {
+class Dir_Helper_Test extends Gallery_Unit_Test_Case {
public function remove_album_test() {
$dirname = (VARPATH . "albums/testdir");
mkdir($dirname, 0777, true);
diff --git a/modules/gallery/tests/DrawForm_Test.php b/modules/gallery/tests/DrawForm_Test.php
index da8a6b04..f7b727c0 100644
--- a/modules/gallery/tests/DrawForm_Test.php
+++ b/modules/gallery/tests/DrawForm_Test.php
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
-class DrawForm_Test extends Unit_Test_Case {
+class DrawForm_Test extends Gallery_Unit_Test_Case {
function no_group_test() {
$form = new Forge("test/controller", "", "post", array("id" => "g-test-group-form"));
$form->input("title")->label(t("Title"));
diff --git a/modules/gallery/tests/File_Structure_Test.php b/modules/gallery/tests/File_Structure_Test.php
index b5026188..bffdf361 100644
--- a/modules/gallery/tests/File_Structure_Test.php
+++ b/modules/gallery/tests/File_Structure_Test.php
@@ -19,7 +19,7 @@
*/
require_once(MODPATH . "gallery/tests/Gallery_Filters.php");
-class File_Structure_Test extends Unit_Test_Case {
+class File_Structure_Test extends Gallery_Unit_Test_Case {
public function no_trailing_closing_php_tag_test() {
$dir = new GalleryCodeFilterIterator(
new RecursiveIteratorIterator(new RecursiveDirectoryIterator(DOCROOT)));
diff --git a/modules/gallery/tests/Gallery_I18n_Test.php b/modules/gallery/tests/Gallery_I18n_Test.php
index 5d2fd994..f6e50d71 100644
--- a/modules/gallery/tests/Gallery_I18n_Test.php
+++ b/modules/gallery/tests/Gallery_I18n_Test.php
@@ -18,7 +18,7 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
-class Gallery_I18n_Test extends Unit_Test_Case {
+class Gallery_I18n_Test extends Gallery_Unit_Test_Case {
private $i18n;
public function setup() {
diff --git a/modules/gallery/tests/Gallery_Installer_Test.php b/modules/gallery/tests/Gallery_Installer_Test.php
index 74a07b1a..3db434bc 100644
--- a/modules/gallery/tests/Gallery_Installer_Test.php
+++ b/modules/gallery/tests/Gallery_Installer_Test.php
@@ -22,7 +22,7 @@
* This test case operates under the assumption that gallery_installer::install() is called by the
* test controller before it starts.
*/
-class Gallery_Installer_Test extends Unit_Test_Case {
+class Gallery_Installer_Test extends Gallery_Unit_Test_Case {
public function install_creates_dirs_test() {
$this->assert_true(file_exists(VARPATH . "albums"));
$this->assert_true(file_exists(VARPATH . "resizes"));
diff --git a/modules/gallery/tests/Html_Helper_Test.php b/modules/gallery/tests/Html_Helper_Test.php
index 1662b866..be318632 100644
--- a/modules/gallery/tests/Html_Helper_Test.php
+++ b/modules/gallery/tests/Html_Helper_Test.php
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
-class Html_Helper_Test extends Unit_Test_Case {
+class Html_Helper_Test extends Gallery_Unit_Test_Case {
public function clean_test() {
$safe_string = html::clean("hello <p >world</p>");
$this->assert_equal("hello &lt;p &gt;world&lt;/p&gt;",
diff --git a/modules/gallery/tests/Item_Helper_Test.php b/modules/gallery/tests/Item_Helper_Test.php
index b3896c7a..5fa8d6b1 100644
--- a/modules/gallery/tests/Item_Helper_Test.php
+++ b/modules/gallery/tests/Item_Helper_Test.php
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
-class Item_Helper_Test extends Unit_Test_Case {
+class Item_Helper_Test extends Gallery_Unit_Test_Case {
public function viewable_test() {
$album = test::random_album();
diff --git a/modules/gallery/tests/Item_Model_Test.php b/modules/gallery/tests/Item_Model_Test.php
index 284491a0..9ea74b16 100644
--- a/modules/gallery/tests/Item_Model_Test.php
+++ b/modules/gallery/tests/Item_Model_Test.php
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
-class Item_Model_Test extends Unit_Test_Case {
+class Item_Model_Test extends Gallery_Unit_Test_Case {
public function saving_sets_created_and_updated_dates_test() {
$item = test::random_photo();
$this->assert_true(!empty($item->created));
diff --git a/modules/gallery/tests/Locales_Helper_Test.php b/modules/gallery/tests/Locales_Helper_Test.php
index 4c03d8d4..a2680928 100644
--- a/modules/gallery/tests/Locales_Helper_Test.php
+++ b/modules/gallery/tests/Locales_Helper_Test.php
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
-class Locales_Helper_Test extends Unit_Test_Case {
+class Locales_Helper_Test extends Gallery_Unit_Test_Case {
static $installed_locales;
static $default_locale;
diff --git a/modules/gallery/tests/Menu_Test.php b/modules/gallery/tests/Menu_Test.php
index c91aee0b..643aa727 100644
--- a/modules/gallery/tests/Menu_Test.php
+++ b/modules/gallery/tests/Menu_Test.php
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
-class Menu_Test extends Unit_Test_Case {
+class Menu_Test extends Gallery_Unit_Test_Case {
public function find_menu_item_test() {
$menu = new Menu(true);
$menu
diff --git a/modules/gallery/tests/ORM_MPTT_Test.php b/modules/gallery/tests/ORM_MPTT_Test.php
index 30adf2a0..1ffe1c57 100644
--- a/modules/gallery/tests/ORM_MPTT_Test.php
+++ b/modules/gallery/tests/ORM_MPTT_Test.php
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
-class ORM_MPTT_Test extends Unit_Test_Case {
+class ORM_MPTT_Test extends Gallery_Unit_Test_Case {
public function add_to_parent_test() {
$album = test::random_album();
diff --git a/modules/gallery/tests/Photos_Controller_Test.php b/modules/gallery/tests/Photos_Controller_Test.php
index f548b40d..6012ed1c 100644
--- a/modules/gallery/tests/Photos_Controller_Test.php
+++ b/modules/gallery/tests/Photos_Controller_Test.php
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
-class Photos_Controller_Test extends Unit_Test_Case {
+class Photos_Controller_Test extends Gallery_Unit_Test_Case {
public function setup() {
$this->_save = array($_POST, $_SERVER);
$_SERVER["HTTP_REFERER"] = "HTTP_REFERER";
diff --git a/modules/gallery/tests/SafeString_Test.php b/modules/gallery/tests/SafeString_Test.php
index 2c07d934..7002a874 100644
--- a/modules/gallery/tests/SafeString_Test.php
+++ b/modules/gallery/tests/SafeString_Test.php
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
-class SafeString_Test extends Unit_Test_Case {
+class SafeString_Test extends Gallery_Unit_Test_Case {
public function toString_escapes_for_html_test() {
$safe_string = new SafeString("hello <p>world</p>");
$this->assert_equal("hello &lt;p&gt;world&lt;/p&gt;",
diff --git a/modules/gallery/tests/Sendmail_Test.php b/modules/gallery/tests/Sendmail_Test.php
index f3a8d897..bc57e434 100644
--- a/modules/gallery/tests/Sendmail_Test.php
+++ b/modules/gallery/tests/Sendmail_Test.php
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
-class Sendmail_Test extends Unit_Test_Case {
+class Sendmail_Test extends Gallery_Unit_Test_Case {
public function setup() {
Kohana_Config::instance()->set("sendmail.from", "from@gallery3.com");
}
diff --git a/modules/gallery/tests/Url_Security_Test.php b/modules/gallery/tests/Url_Security_Test.php
index de25880f..255b3909 100644
--- a/modules/gallery/tests/Url_Security_Test.php
+++ b/modules/gallery/tests/Url_Security_Test.php
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
-class Url_Security_Test extends Unit_Test_Case {
+class Url_Security_Test extends Gallery_Unit_Test_Case {
public function setup() {
$this->save = array(Router::$current_uri, Router::$complete_uri, $_GET);
}
diff --git a/modules/gallery/tests/Var_Test.php b/modules/gallery/tests/Var_Test.php
index 355d94a7..fb19da7a 100644
--- a/modules/gallery/tests/Var_Test.php
+++ b/modules/gallery/tests/Var_Test.php
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
-class Var_Test extends Unit_Test_Case {
+class Var_Test extends Gallery_Unit_Test_Case {
public function add_parameter_test() {
module::set_var("gallery", "Parameter", "original value");
$this->assert_equal("original value", module::get_var("gallery", "Parameter"));
diff --git a/modules/gallery/tests/Xss_Security_Test.php b/modules/gallery/tests/Xss_Security_Test.php
index b296d97c..a39a069d 100644
--- a/modules/gallery/tests/Xss_Security_Test.php
+++ b/modules/gallery/tests/Xss_Security_Test.php
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
-class Xss_Security_Test extends Unit_Test_Case {
+class Xss_Security_Test extends Gallery_Unit_Test_Case {
public function find_unescaped_variables_in_views_test() {
$found = array();
foreach (glob("*/*/views/*.php") as $view) {
diff --git a/modules/gallery_unit_test/helpers/test.php b/modules/gallery_unit_test/helpers/test.php
index 77948465..8e483c60 100644
--- a/modules/gallery_unit_test/helpers/test.php
+++ b/modules/gallery_unit_test/helpers/test.php
@@ -48,6 +48,11 @@ class test_Core {
return test::random_photo_unsaved($parent)->save();
}
+ static function random_user($password="password") {
+ $rand = "name_" . rand();
+ return identity::create_user($rand, $rand, $password, "$rand@rand.com");
+ }
+
static function random_name($item=null) {
$rand = "name_" . rand();
if ($item && $item->is_photo()) {
@@ -59,4 +64,10 @@ class test_Core {
static function starts_with($outer, $inner) {
return strpos($outer, $inner) === 0;
}
+
+ static function call_and_capture($callback) {
+ ob_start();
+ call_user_func($callback);
+ return ob_get_clean();
+ }
}
diff --git a/modules/rest/tests/Rest_Controller_Test.php b/modules/rest/tests/Rest_Controller_Test.php
index c881583c..ae5e6d48 100644
--- a/modules/rest/tests/Rest_Controller_Test.php
+++ b/modules/rest/tests/Rest_Controller_Test.php
@@ -17,108 +17,43 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
-class Rest_Controller_Test extends Unit_Test_Case {
+class Rest_Controller_Test extends Gallery_Unit_Test_Case {
public function setup() {
$this->_save = array($_GET, $_POST, $_SERVER);
}
- private function _create_user() {
- if (empty($this->_user)) {
- $this->_user = identity::create_user("access_test" . rand(), "Access Test", "password");
- $this->_key = ORM::factory("user_access_token");
- $this->_key->access_key = md5($this->_user->name . rand());
- $this->_key->user_id = $this->_user->id;
- $this->_key->save();
- identity::set_active_user($this->_user);
- }
- return array($this->_key->access_key, $this->_user);
- }
-
public function teardown() {
list($_GET, $_POST, $_SERVER) = $this->_save;
- if (!empty($this->_user)) {
- try {
- $this->_user->delete();
- } catch (Exception $e) { }
- }
- }
-
- private function _create_image($parent=null) {
- $filename = MODPATH . "gallery/tests/test.jpg";
- $image_name = "image_" . rand();
- if (empty($parent)) {
- $parent = ORM::factory("item", 1);
- }
- return photo::create($parent, $filename, "$image_name.jpg", $image_name);
- }
-
- public function rest_access_key_exists_test() {
- list ($access_key, $user) = $this->_create_user();
- $_SERVER["REQUEST_METHOD"] = "GET";
- $_GET["user"] = $user->name;;
- $_GET["password"] = "password";
-
- $this->assert_equal(
- json_encode(array("status" => "OK", "token" => $access_key)),
- $this->_call_controller());
}
- public function rest_access_key_generated_test() {
- list ($access_key, $user) = $this->_create_user();
- ORM::factory("user_access_token")
- ->where("access_key", $access_key)
- ->delete();
- $_SERVER["REQUEST_METHOD"] = "GET";
- $_GET["user"] = $user->name;
- $_GET["password"] = "password";
+ public function login_test() {
+ $user = test::random_user("password");
- $results = json_decode($this->_call_controller());
-
- $this->assert_equal("OK", $results->status);
- $this->assert_false(empty($results->token));
- }
+ // There's no access key at first
+ $this->assert_false(
+ ORM::factory("user_access_token")->where("user_id", "=", $user->id)->find()->loaded());
- public function rest_access_key_no_parameters_test() {
- $_SERVER["REQUEST_METHOD"] = "GET";
-
- try {
- $this->_call_controller();
- } catch (Rest_Exception $e) {
- $this->assert_equal(403, $e->getCode());
- $this->assert_equal("Forbidden", $e->getMessage());
- } catch (Exception $e) {
- $this->assert_false(true, $e->__toString());
- }
- }
+ $_POST["user"] = $user->name;
+ $_POST["password"] = "password";
- public function rest_access_key_user_not_found_test() {
- $_SERVER["REQUEST_METHOD"] = "POST";
- $_POST["request"] = json_encode(array("user" => "access_test2", "password" => "password"));
+ $response = test::call_and_capture(array(new Rest_Controller(), "index"));
+ $expected =
+ ORM::factory("user_access_token")->where("user_id", "=", $user->id)->find()->access_key;
- try {
- $this->_call_controller();
- } catch (Rest_Exception $e) {
- $this->assert_equal(403, $e->getCode());
- $this->assert_equal("Forbidden", $e->getMessage());
- } catch (Exception $e) {
- $this->assert_false(true, $e->__toString());
- }
+ // Now there is an access key, and it was returned
+ $this->assert_equal(json_encode($expected), $response);
}
- public function rest_access_key_invalid_password_test() {
- $_SERVER["REQUEST_METHOD"] = "POST";
+ public function login_failed_test() {
+ $user = test::random_user("password");
+ $_POST["user"] = $user->name;
+ $_POST["password"] = "WRONG PASSWORD";
- try {
- $this->_call_controller();
- } catch (Rest_Exception $e) {
- $this->assert_equal(403, $e->getCode());
- $this->assert_equal("Forbidden", $e->getMessage());
- } catch (Exception $e) {
- $this->assert_false(true, $e->__toString());
- }
+ // @todo check the http response code
+ $this->assert_equal(null, test::call_and_capture(array(new Rest_Controller(), "index")));
}
- public function rest_get_resource_no_request_key_test() {
+ public function rest_get_resource_no_request_key_test_() {
$_SERVER["REQUEST_METHOD"] = "GET";
$photo = $this->_create_image();
@@ -132,7 +67,7 @@ class Rest_Controller_Test extends Unit_Test_Case {
$this->_call_controller("rest", explode("/", $photo->relative_url())));
}
- public function rest_get_resource_invalid_key_test() {
+ public function rest_get_resource_invalid_key_test_() {
list ($access_key, $user) = $this->_create_user();
$_SERVER["HTTP_X_GALLERY_REQUEST_KEY"] = md5($access_key); // screw up the access key;
$_SERVER["REQUEST_METHOD"] = "GET";
@@ -147,7 +82,7 @@ class Rest_Controller_Test extends Unit_Test_Case {
}
}
- public function rest_get_resource_no_user_for_key_test() {
+ public function rest_get_resource_no_user_for_key_test_() {
list ($access_key, $user) = $this->_create_user();
$_SERVER["REQUEST_METHOD"] = "GET";
$_SERVER["HTTP_X_GALLERY_REQUEST_KEY"] = $access_key;
@@ -166,7 +101,7 @@ class Rest_Controller_Test extends Unit_Test_Case {
}
}
- public function rest_get_resource_no_handler_test() {
+ public function rest_get_resource_no_handler_test_() {
list ($access_key, $user) = $this->_create_user();
$_SERVER["REQUEST_METHOD"] = "GET";
$_SERVER["HTTP_X_GALLERY_REQUEST_KEY"] = $access_key;
@@ -183,7 +118,7 @@ class Rest_Controller_Test extends Unit_Test_Case {
}
}
- public function rest_get_resource_test() {
+ public function rest_get_resource_test_() {
list ($access_key, $user) = $this->_create_user();
$_SERVER["REQUEST_METHOD"] = "GET";
$_SERVER["HTTP_X_GALLERY_REQUEST_KEY"] = $access_key;
@@ -198,33 +133,4 @@ class Rest_Controller_Test extends Unit_Test_Case {
"internet_address" => $photo->slug))),
$this->_call_controller("rest", explode("/", $photo->relative_url())));
}
-
- private function _call_controller($method="access_key", $arg=null) {
- $controller = new Rest_Controller();
-
- ob_start();
- call_user_func_array(array($controller, $method), $arg);
- $results = ob_get_contents();
- ob_end_clean();
-
- return $results;
- }
-}
-
-class rest_rest {
- static $request = null;
-
- static function get($request) {
- self::$request = $request;
- $item = ORM::factory("item")
- ->where("relative_url_cache", "=", implode("/", $request->arguments))
- ->find();
- $response["path"] = $item->relative_url();
- $response["title"] = $item->title;
- $response["thumb_url"] = $item->thumb_url();
- $response["description"] = $item->description;
- $response["internet_address"] = $item->slug;
- return rest::reply(array($item->type => $response));
- }
-
}
diff --git a/modules/tag/tests/Tag_Rest_Helper_Test.php b/modules/tag/tests/Tag_Rest_Helper_Test.php
index 555539fd..c2d55ba4 100644
--- a/modules/tag/tests/Tag_Rest_Helper_Test.php
+++ b/modules/tag/tests/Tag_Rest_Helper_Test.php
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
-class Tag_Rest_Helper_Test extends Unit_Test_Case {
+class Tag_Rest_Helper_Test extends Gallery_Unit_Test_Case {
public function setup() {
try {
Database::instance()->query("TRUNCATE {tags}");
diff --git a/modules/tag/tests/Tag_Test.php b/modules/tag/tests/Tag_Test.php
index c96e7f2b..c3243145 100644
--- a/modules/tag/tests/Tag_Test.php
+++ b/modules/tag/tests/Tag_Test.php
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
-class Tag_Test extends Unit_Test_Case {
+class Tag_Test extends Gallery_Unit_Test_Case {
public function create_tag_test() {
$rand = rand();
$root = ORM::factory("item", 1);
diff --git a/modules/user/tests/No_Direct_ORM_Access_Test.php b/modules/user/tests/No_Direct_ORM_Access_Test.php
index 440321fa..c372258e 100644
--- a/modules/user/tests/No_Direct_ORM_Access_Test.php
+++ b/modules/user/tests/No_Direct_ORM_Access_Test.php
@@ -19,7 +19,7 @@
*/
require_once(MODPATH . "gallery/tests/Gallery_Filters.php");
-class No_Direct_ORM_Access_Test extends Unit_Test_Case {
+class No_Direct_ORM_Access_Test extends Gallery_Unit_Test_Case {
public function no_access_to_users_table_test() {
$dir = new UserModuleFilterIterator(
new PhpCodeFilterIterator(
diff --git a/modules/user/tests/User_Groups_Test.php b/modules/user/tests/User_Groups_Test.php
index 163b7d79..089ab9a6 100644
--- a/modules/user/tests/User_Groups_Test.php
+++ b/modules/user/tests/User_Groups_Test.php
@@ -18,7 +18,7 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
-class User_Groups_Test extends Unit_Test_Case {
+class User_Groups_Test extends Gallery_Unit_Test_Case {
public function teardown() {
try {
$group = ORM::factory("group")->where("name", "=", "user_groups_test")->find();
diff --git a/modules/user/tests/User_Installer_Test.php b/modules/user/tests/User_Installer_Test.php
index 12a10eda..b3c5960a 100644
--- a/modules/user/tests/User_Installer_Test.php
+++ b/modules/user/tests/User_Installer_Test.php
@@ -22,7 +22,7 @@
* This test case operates under the assumption that user_installer::install() is called by the
* test controller before it starts.
*/
-class User_Installer_Test extends Unit_Test_Case {
+class User_Installer_Test extends Gallery_Unit_Test_Case {
public function install_creates_admin_user_test() {
$user = ORM::factory("user", 1);
$this->assert_equal("guest", $user->name);