summaryrefslogtreecommitdiffstats
path: root/application/test
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2018-05-18 23:06:40 +0200
committerFlorian Pritz <bluewind@xinu.at>2018-05-18 23:10:31 +0200
commit11ea08df8d4784aad4836852180098c45b90c5a2 (patch)
tree390e3fc854aca566c51e303960bf113b8c18f8e7 /application/test
parent9f8486c87cd81cdb888b8e518f0d3eb50b6abbb9 (diff)
Add invitation key deletion
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/test')
-rw-r--r--application/test/tests/test_service_user.php61
1 files changed, 61 insertions, 0 deletions
diff --git a/application/test/tests/test_service_user.php b/application/test/tests/test_service_user.php
new file mode 100644
index 000000000..4cbbdfac0
--- /dev/null
+++ b/application/test/tests/test_service_user.php
@@ -0,0 +1,61 @@
+<?php
+/*
+ * Copyright 2018 Florian "Bluewind" Pritz <bluewind@server-speed.net>
+ *
+ * Licensed under AGPLv3
+ * (see COPYING for full license text)
+ *
+ */
+
+namespace test\tests;
+
+class test_service_user extends \test\Test {
+
+ public function __construct() {
+ parent::__construct();
+ }
+
+ public function init() {
+ }
+
+ public function cleanup() {
+ }
+
+ public function test_invitation_key_delete() {
+ $CI =& get_instance();
+
+ $userid = 1;
+
+ $result = $CI->db->select('user, key, action')->from('actions')->get()->result_array();
+ $this->t->is_deeply([], $result, "database contains no actions");
+
+ $key = \service\user::create_invitation_key($userid);
+
+ $result = $CI->db->select('user, key, action')->from('actions')->get()->result_array();
+ $this->t->is_deeply([['user' => "".$userid, 'key' => $key, 'action' => 'invitation']], $result, "database contains new key");
+
+ \service\user::delete_invitation_key($userid+1, $key);
+ $result = $CI->db->select('user, key, action')->from('actions')->get()->result_array();
+ $this->t->is_deeply([['user' => "".$userid, 'key' => $key, 'action' => 'invitation']], $result, "database contains new key after incorrect deletion");
+
+ \service\user::delete_invitation_key($userid+1, "foobar-");
+ $result = $CI->db->select('user, key, action')->from('actions')->get()->result_array();
+ $this->t->is_deeply([['user' => "".$userid, 'key' => $key, 'action' => 'invitation']], $result, "database contains new key after incorrect deletion");
+
+ \service\user::delete_invitation_key($userid+1, "");
+ $result = $CI->db->select('user, key, action')->from('actions')->get()->result_array();
+ $this->t->is_deeply([['user' => "".$userid, 'key' => $key, 'action' => 'invitation']], $result, "database contains new key after incorrect deletion");
+
+ \service\user::delete_invitation_key($userid, "");
+ $result = $CI->db->select('user, key, action')->from('actions')->get()->result_array();
+ $this->t->is_deeply([['user' => "".$userid, 'key' => $key, 'action' => 'invitation']], $result, "database contains new key");
+
+ \service\user::delete_invitation_key($userid, $key);
+
+ $result = $CI->db->select('user, key, action')->from('actions')->get()->result_array();
+ $this->t->is_deeply([], $result, "key has been deleted");
+
+ }
+
+}
+