@@ -23,6 +23,17 @@ class UserBasicTest extends
23
23
public function setUp ()
24
24
{
25
25
$ this ->connection = getConnection ();
26
+ $ this ->userHandler = new UserHandler ($ this ->connection );
27
+
28
+ try {
29
+ $ this ->userHandler ->removeUser ('testUser1 ' );
30
+ } catch (\Exception $ e ) {
31
+ }
32
+
33
+ try {
34
+ $ this ->userHandler ->removeUser ('testUser42 ' );
35
+ } catch (\Exception $ e ) {
36
+ }
26
37
}
27
38
28
39
@@ -31,8 +42,6 @@ public function setUp()
31
42
*/
32
43
public function testGrantPermission ()
33
44
{
34
- $ this ->userHandler = new UserHandler ($ this ->connection );
35
-
36
45
$ result = $ this ->userHandler ->addUser ('testUser42 ' , 'testPasswd ' , true );
37
46
static ::assertTrue ($ result );
38
47
@@ -65,8 +74,6 @@ public function testGrantPermission()
65
74
*/
66
75
public function testGrantAndRevokePermissions ()
67
76
{
68
- $ this ->userHandler = new UserHandler ($ this ->connection );
69
-
70
77
$ result = $ this ->userHandler ->addUser ('testUser42 ' , 'testPasswd ' , true );
71
78
static ::assertTrue ($ result );
72
79
@@ -95,13 +102,10 @@ public function testGrantAndRevokePermissions()
95
102
96
103
97
104
/**
98
- * Test if Document and DocumentHandler instances can be initialized
105
+ * Test if a user can be added, replaced, updated and removed
99
106
*/
100
107
public function testAddReplaceUpdateGetAndDeleteUserWithNullValues ()
101
108
{
102
- $ this ->userHandler = new UserHandler ($ this ->connection );
103
-
104
-
105
109
$ result = $ this ->userHandler ->addUser ('testUser1 ' , null , null , null );
106
110
static ::assertTrue ($ result );
107
111
@@ -116,6 +120,14 @@ public function testAddReplaceUpdateGetAndDeleteUserWithNullValues()
116
120
117
121
$ this ->userHandler ->removeUser ('testUser1 ' );
118
122
static ::assertTrue ($ result );
123
+
124
+ try {
125
+ $ this ->userHandler ->get ('testUser1 ' );
126
+ } catch (\Exception $ e ) {
127
+ // Just give us the $e
128
+ static ::assertEquals (404 , $ e ->getCode (), 'Should get 404, instead got: ' . $ e ->getCode ());
129
+ }
130
+ static ::assertInstanceOf (ServerException::class, $ e , 'should have gotten an exception ' );
119
131
}
120
132
121
133
@@ -124,8 +136,6 @@ public function testAddReplaceUpdateGetAndDeleteUserWithNullValues()
124
136
*/
125
137
public function testAddReplaceUpdateGetAndDeleteUserWithNonNullValues ()
126
138
{
127
- $ this ->userHandler = new UserHandler ($ this ->connection );
128
-
129
139
$ result = $ this ->userHandler ->addUser ('testUser1 ' , 'testPass1 ' , true , ['level ' => 1 ]);
130
140
static ::assertTrue ($ result );
131
141
@@ -174,8 +184,6 @@ public function testAddReplaceUpdateGetAndDeleteUserWithNonNullValues()
174
184
// test functions on non-existent user
175
185
public function testFunctionsOnNonExistentUser ()
176
186
{
177
- $ this ->userHandler = new UserHandler ($ this ->connection );
178
-
179
187
$ e = null ;
180
188
try {
181
189
$ this ->userHandler ->removeUser ('testUser1 ' );
0 commit comments