@@ -56,4 +56,37 @@ public function testRevocableSession()
56
56
$ this ->setExpectedException ('Parse\ParseException ' , 'invalid session token ' );
57
57
ParseUser::become ($ sessionToken );
58
58
}
59
+
60
+ /**
61
+ * @group upgrade-to-revocable-session
62
+ */
63
+ public function testUpgradeToRevocableSession ()
64
+ {
65
+ $ user = new ParseUser ();
66
+ $ user ->setUsername ('revocable_username ' );
67
+ $ user ->setPassword ('revocable_password ' );
68
+ $ user ->signUp ();
69
+
70
+ $ session = ParseSession::getCurrentSession ();
71
+ $ this ->assertEquals ($ user ->getSessionToken (), $ session ->getSessionToken ());
72
+
73
+ // upgrade the current session (changes our session as well)
74
+ ParseSession::upgradeToRevocableSession ();
75
+
76
+ // verify that our session has changed, and our updated current user matches it
77
+ $ session = ParseSession::getCurrentSession ();
78
+ $ user = ParseUser::getCurrentUser ();
79
+ $ this ->assertEquals ($ user ->getSessionToken (), $ session ->getSessionToken ());
80
+ $ this ->assertTrue ($ session ->isCurrentSessionRevocable ());
81
+ }
82
+
83
+ /**
84
+ * @group upgrade-to-revocable-session
85
+ */
86
+ public function testBadUpgradeToRevocableSession ()
87
+ {
88
+ // upgrade the current session (changes our session as well)
89
+ $ this ->setExpectedException ('Parse\ParseException ' , 'No session to upgrade. ' );
90
+ ParseSession::upgradeToRevocableSession ();
91
+ }
59
92
}
0 commit comments