summaryrefslogtreecommitdiff
path: root/modules/rest
diff options
context:
space:
mode:
Diffstat (limited to 'modules/rest')
-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
4 files changed, 24 insertions, 14 deletions
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";