diff options
author | Florian Pritz <bluewind@xinu.at> | 2018-05-18 23:06:40 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2018-05-18 23:10:31 +0200 |
commit | 11ea08df8d4784aad4836852180098c45b90c5a2 (patch) | |
tree | 390e3fc854aca566c51e303960bf113b8c18f8e7 /application/test/tests | |
parent | 9f8486c87cd81cdb888b8e518f0d3eb50b6abbb9 (diff) |
Add invitation key deletion
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/test/tests')
-rw-r--r-- | application/test/tests/test_service_user.php | 61 |
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"); + + } + +} + |