File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -148,6 +148,34 @@ public function testRsaSha256Signer()
148148 );
149149 }
150150
151+ public function testDefaultTimestampFormatter ()
152+ {
153+ $ time = Carbon::now ()->addMinutes (10 );
154+ $ token = JWT ::expiresAt ($ time )->getToken ();
155+
156+ $ parts = array_map ('base64_decode ' , explode ('. ' , $ token ->toString ()));
157+
158+ $ this ->assertEquals (
159+ $ time ->format ('U.u ' ),
160+ json_decode ($ parts [1 ])->exp
161+ );
162+ }
163+
164+ public function testUnixTimestampFormatter ()
165+ {
166+ config (['jwt.chained_formatter ' => ChainedFormatter::withUnixTimestampDates ()]);
167+
168+ $ time = Carbon::now ()->addMinutes (10 );
169+ $ token = JWT ::expiresAt ($ time )->getToken ();
170+
171+ $ parts = array_map ('base64_decode ' , explode ('. ' , $ token ->toString ()));
172+
173+ $ this ->assertEquals (
174+ $ time ->format ('U ' ),
175+ json_decode ($ parts [1 ])->exp
176+ );
177+ }
178+
151179 public function testQuickGet ()
152180 {
153181 $ jwt = JWT ::get ('test-id ' , ['foo ' => 'bar ' ], 1800 );
@@ -168,3 +196,4 @@ public function testQuickGet()
168196 );
169197 }
170198}
199+
You can’t perform that action at this time.
0 commit comments