File tree Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ use \Mockery as m ;
4
+ use LucaDegasperi \OAuth2Server \Commands \ExpiredTokensCommand ;
5
+ use Symfony \Component \Console \Tester \CommandTester ;
6
+
7
+ class ExpiredTokensCommandTest extends TestCase
8
+ {
9
+ public function getSession ()
10
+ {
11
+ return m::mock ('LucaDegasperi\OAuth2Server\Repositories\SessionManagementInterface ' );
12
+ }
13
+
14
+ public function getCommand ($ session )
15
+ {
16
+ return new ExpiredTokensCommand ($ session );
17
+ }
18
+
19
+ public function testFiresWithDeleteOption ()
20
+ {
21
+ $ session = $ this ->getSession ();
22
+ $ session ->shouldReceive ('deleteExpired ' )->once ()->andReturn (5 );
23
+ $ comm = $ this ->getCommand ($ session );
24
+
25
+ $ tester = new CommandTester ($ comm );
26
+
27
+ $ tester ->execute (array ('--delete ' => true ));
28
+
29
+ $ this ->assertEquals ("5 expired OAuth tokens were deleted \n" , $ tester ->getDisplay ());
30
+ }
31
+
32
+ public function testDoesntFireWithoutDeleteOption ()
33
+ {
34
+ $ session = $ this ->getSession ();
35
+
36
+ $ comm = $ this ->getCommand ($ session );
37
+
38
+ $ tester = new CommandTester ($ comm );
39
+
40
+ $ tester ->execute (array ('--delete ' => false ));
41
+
42
+ $ this ->assertEquals (
43
+ "use the --delete option to trigger the delete of the expired tokens \n" ,
44
+ $ tester ->getDisplay ()
45
+ );
46
+ }
47
+
48
+ public function tearDown ()
49
+ {
50
+ m::close ();
51
+ }
52
+ }
You can’t perform that action at this time.
0 commit comments