summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2010-01-02 14:31:59 -0800
committerTim Almdal <tnalmdal@shaw.ca>2010-01-02 14:31:59 -0800
commit28597ba53354537704899e7ad9eb39bbd5718b21 (patch)
tree45de0d70d0b80e98bdab62de5b05d5d66bc4bc5f /modules
parentbff7b393ec763c50f9fe66fef16150bcaa55dac3 (diff)
Correct file structure tests, Have the tests delete the userid they create so as not to impact other tests.
Diffstat (limited to 'modules')
-rw-r--r--modules/gallery/tests/Gallery_Rest_Helper_Test.php22
-rw-r--r--modules/rest/controllers/rest.php3
-rw-r--r--modules/rest/helpers/rest.php3
-rw-r--r--modules/rest/helpers/rest_event.php3
-rw-r--r--modules/rest/tests/Rest_Controller_Test.php29
-rw-r--r--modules/tag/tests/Tag_Rest_Helper_Test.php20
6 files changed, 52 insertions, 28 deletions
diff --git a/modules/gallery/tests/Gallery_Rest_Helper_Test.php b/modules/gallery/tests/Gallery_Rest_Helper_Test.php
index 4cd3f2a6..605a4f37 100644
--- a/modules/gallery/tests/Gallery_Rest_Helper_Test.php
+++ b/modules/gallery/tests/Gallery_Rest_Helper_Test.php
@@ -26,17 +26,25 @@ class Gallery_Rest_Helper_Test extends Unit_Test_Case {
public function teardown() {
list($_GET, $_POST, $_SERVER, $_FILES) = $this->_save;
identity::set_active_user($this->_saved_active_user);
+ if (!empty($this->_user)) {
+ try {
+ $this->_user->delete();
+ } catch (Exception $e) { }
+ }
}
private function _create_user() {
- $user = identity::create_user("access_test" . rand(), "Access Test", "password");
- $key = ORM::factory("user_access_token");
- $key->access_key = md5($user->name . rand());
- $key->user_id = $user->id;
- $key->save();
- identity::set_active_user($user);
- return $user;
+ if (empty($this->_user)) {
+ $this->_user = identity::create_user("access_test" . rand(), "Access Test", "password");
+ $key = ORM::factory("user_access_token");
+ $key->access_key = md5($this->_user->name . rand());
+ $key->user_id = $this->_user->id;
+ $key->save();
+ identity::set_active_user($this->_user);
+ }
+ return $this->_user;
}
+
private function _create_album($parent=null) {
$album_name = "album_" . rand();
if (empty($parent)) {
diff --git a/modules/rest/controllers/rest.php b/modules/rest/controllers/rest.php
index 446ec7cb..39ca4797 100644
--- a/modules/rest/controllers/rest.php
+++ b/modules/rest/controllers/rest.php
@@ -1,4 +1,5 @@
-<?php defined("SYSPATH") or die("No direct script access.");/**
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
diff --git a/modules/rest/helpers/rest.php b/modules/rest/helpers/rest.php
index 7e2445e4..00790e6b 100644
--- a/modules/rest/helpers/rest.php
+++ b/modules/rest/helpers/rest.php
@@ -1,4 +1,5 @@
-<?php defined("SYSPATH") or die("No direct script access.");/**
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
diff --git a/modules/rest/helpers/rest_event.php b/modules/rest/helpers/rest_event.php
index a06f43ea..00cea7eb 100644
--- a/modules/rest/helpers/rest_event.php
+++ b/modules/rest/helpers/rest_event.php
@@ -1,4 +1,5 @@
-<?php defined("SYSPATH") or die("No direct script access.");/**
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
diff --git a/modules/rest/tests/Rest_Controller_Test.php b/modules/rest/tests/Rest_Controller_Test.php
index 3e0c4063..83bd9db6 100644
--- a/modules/rest/tests/Rest_Controller_Test.php
+++ b/modules/rest/tests/Rest_Controller_Test.php
@@ -23,12 +23,24 @@ class Rest_Controller_Test extends Unit_Test_Case {
}
private function _create_user() {
- $user = identity::create_user("access_test" . rand(), "Access Test", "password");
- $key = ORM::factory("user_access_token");
- $key->access_key = md5($user->name . rand());
- $key->user_id = $user->id;
- $key->save();
- return array($key->access_key, $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) {
@@ -40,11 +52,6 @@ class Rest_Controller_Test extends Unit_Test_Case {
return photo::create($parent, $filename, "$image_name.jpg", $image_name);
}
-
- public function teardown() {
- list($_GET, $_POST, $_SERVER) = $this->_save;
- }
-
public function rest_access_key_exists_test() {
list ($access_key, $user) = $this->_create_user();
$_SERVER["REQUEST_METHOD"] = "GET";
diff --git a/modules/tag/tests/Tag_Rest_Helper_Test.php b/modules/tag/tests/Tag_Rest_Helper_Test.php
index ac64470c..055e5cec 100644
--- a/modules/tag/tests/Tag_Rest_Helper_Test.php
+++ b/modules/tag/tests/Tag_Rest_Helper_Test.php
@@ -31,18 +31,24 @@ class Tag_Rest_Helper_Test extends Unit_Test_Case {
Database::instance()->query("TRUNCATE {tags}");
Database::instance()->query("TRUNCATE {items_tags}");
+ if (!empty($this->_user)) {
+ $this->_user->delete();
+ }
} catch (Exception $e) { }
}
private function _create_user() {
- $user = identity::create_user("access_test" . rand(), "Access Test", "password");
- $key = ORM::factory("user_access_token");
- $key->access_key = md5($user->name . rand());
- $key->user_id = $user->id;
- $key->save();
- identity::set_active_user($user);
- return $user;
+ if (empty($this->_user)) {
+ $this->_user = identity::create_user("access_test" . rand(), "Access Test", "password");
+ $key = ORM::factory("user_access_token");
+ $key->access_key = md5($this->_user->name . rand());
+ $key->user_id = $this->_user->id;
+ $key->save();
+ identity::set_active_user($this->_user);
+ }
+ return $this->_user;
}
+
private function _create_album($tags=array(), $parent=null) {
$album_name = "album_" . rand();
if (empty($parent)) {