Skip to content

Commit 0a80685

Browse files
author
Luca Degasperi
committed
Increasing test coverage
1 parent fc37daf commit 0a80685

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

tests/ExpiredTokensCommandTest.php

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
}

0 commit comments

Comments
 (0)