@@ -43,40 +43,40 @@ public function setUp()
43
43
$ this ->middleware = new AuthMicro ($ this ->app );
44
44
45
45
$ app = $ this ->app ;
46
-
47
- $ this ->app ->get ('/ ' , function () use ($ app ) {
46
+
47
+ $ this ->app ->get ('/ ' , function () use ($ app ) {
48
48
$ response = $ app ["response " ];
49
49
$ response ->setStatusCode (200 );
50
50
$ response ->setContentType ("application/json " );
51
51
$ response ->setContent (json_encode (['index get ' ]));
52
52
$ response ->send ();
53
53
});
54
54
55
- $ this ->app ->get ('/members ' , function () use ($ app ) {
55
+ $ this ->app ->get ('/members ' , function () use ($ app ) {
56
56
$ response = $ app ["response " ];
57
57
$ response ->setStatusCode (200 );
58
58
$ response ->setContentType ("application/json " );
59
59
$ response ->setContent (json_encode (['members get ' ]));
60
60
$ response ->send ();
61
61
});
62
62
63
- $ this ->app ->post ('/members ' , function () use ($ app ) {
63
+ $ this ->app ->post ('/members ' , function () use ($ app ) {
64
64
$ response = $ app ["response " ];
65
65
$ response ->setStatusCode (200 );
66
66
$ response ->setContentType ("application/json " );
67
67
$ response ->setContent (json_encode (['members post ' ]));
68
68
$ response ->send ();
69
69
});
70
70
71
- $ this ->app ->put ('/members ' , function () use ($ app ) {
71
+ $ this ->app ->put ('/members ' , function () use ($ app ) {
72
72
$ response = $ app ["response " ];
73
73
$ response ->setStatusCode (200 );
74
74
$ response ->setContentType ("application/json " );
75
75
$ response ->setContent (json_encode (['members put ' ]));
76
76
$ response ->send ();
77
77
});
78
78
79
- $ this ->app ->options ('/members ' , function () use ($ app ) {
79
+ $ this ->app ->options ('/members ' , function () use ($ app ) {
80
80
$ response = $ app ["response " ];
81
81
$ response ->setStatusCode (204 );
82
82
$ response ->setContentType ("application/json " );
@@ -90,11 +90,11 @@ public function testLookForTokenFail()
90
90
{
91
91
// override for testing
92
92
$ _SERVER ['REQUEST_URI ' ] = '/members ' ;
93
-
93
+
94
94
// call this on test methods instead
95
95
$ this ->app ->handle ('/members ' );
96
96
97
- $ this ->assertEquals (' 401 Unauthorized ' , $ this ->app ['response ' ]->getStatusCode ());
97
+ $ this ->assertEquals (401 , $ this ->app ['response ' ]->getStatusCode ());
98
98
$ this ->assertEquals ('["missing token"] ' , $ this ->app ['response ' ]->getContent ());
99
99
}
100
100
@@ -105,22 +105,22 @@ public function testIgnoreOptionMethod()
105
105
$ _SERVER ["REQUEST_METHOD " ] = "OPTIONS " ;
106
106
107
107
$ this ->middleware ->setIgnoreOptionsMethod ();
108
-
108
+
109
109
// call this on test methods instead
110
110
$ this ->app ->handle ('/members ' );
111
111
112
- $ this ->assertEquals (' 204 No Content ' , $ this ->app ['response ' ]->getStatusCode ());
112
+ $ this ->assertEquals (204 , $ this ->app ['response ' ]->getStatusCode ());
113
113
}
114
114
115
115
public function testIgnoreUri ()
116
116
{
117
117
$ _SERVER ['REQUEST_URI ' ] = '/members ' ;
118
118
$ _SERVER ["REQUEST_METHOD " ] = "PUT " ;
119
-
119
+
120
120
// call this on test methods instead
121
121
$ this ->app ->handle ('/members ' );
122
122
123
- $ this ->assertEquals (' 200 OK ' , $ this ->app ['response ' ]->getStatusCode ());
123
+ $ this ->assertEquals (200 , $ this ->app ['response ' ]->getStatusCode ());
124
124
$ this ->assertEquals ('["members put"] ' , $ this ->app ['response ' ]->getContent ());
125
125
}
126
126
@@ -133,12 +133,12 @@ public function testIgnoreUriWithToken()
133
133
134
134
$ jwt = JWT ::encode ($ payload , $ this ->config ['secretKey ' ]);
135
135
136
- $ _GET ['token ' ] = $ jwt ;
137
-
136
+ $ _GET ['_token ' ] = $ jwt ;
137
+
138
138
// call this on test methods instead
139
139
$ this ->app ->handle ('/members ' );
140
140
141
- $ this ->assertEquals (' 200 OK ' , $ this ->app ['response ' ]->getStatusCode ());
141
+ $ this ->assertEquals (200 , $ this ->app ['response ' ]->getStatusCode ());
142
142
$ this ->assertEquals ('["members put"] ' , $ this ->app ['response ' ]->getContent ());
143
143
$ this ->assertEquals ($ payload ['sub ' ], $ this ->app ['auth ' ]->id ());
144
144
}
@@ -153,12 +153,12 @@ public function testPassedExpiredToken()
153
153
$ payload ['exp ' ] = -20 ;
154
154
$ jwt = JWT ::encode ($ payload , $ this ->config ['secretKey ' ]);
155
155
156
- $ _GET ['token ' ] = $ jwt ;
157
-
156
+ $ _GET ['_token ' ] = $ jwt ;
157
+
158
158
// call this on test methods instead
159
159
$ this ->app ->handle ('/members ' );
160
160
161
- $ this ->assertEquals (' 401 Unauthorized ' , $ this ->app ['response ' ]->getStatusCode ());
161
+ $ this ->assertEquals (401 , $ this ->app ['response ' ]->getStatusCode ());
162
162
$ this ->assertEquals ('["Expired token"] ' , $ this ->app ['response ' ]->getContent ());
163
163
}
164
164
@@ -171,12 +171,12 @@ public function testPasssedValidToken()
171
171
// let's expired the token
172
172
$ jwt = JWT ::encode ($ payload , $ this ->config ['secretKey ' ]);
173
173
174
- $ _GET ['token ' ] = $ jwt ;
175
-
174
+ $ _GET ['_token ' ] = $ jwt ;
175
+
176
176
// call this on test methods instead
177
177
$ this ->app ->handle ('/members ' );
178
178
179
- $ this ->assertEquals (' 200 OK ' , $ this ->app ['response ' ]->getStatusCode ());
179
+ $ this ->assertEquals (200 , $ this ->app ['response ' ]->getStatusCode ());
180
180
$ this ->assertEquals ('["members post"] ' , $ this ->app ['response ' ]->getContent ());
181
181
182
182
// make sure data is correct
0 commit comments