summaryrefslogtreecommitdiff
path: root/modules/rest/tests
diff options
context:
space:
mode:
Diffstat (limited to 'modules/rest/tests')
-rw-r--r--modules/rest/tests/Rest_Controller_Test.php29
1 files changed, 18 insertions, 11 deletions
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";