/
TimerTest.php
59 lines (48 loc) · 1.36 KB
/
TimerTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
namespace Aura\Auth\Session;
use Aura\Auth\Status;
class TimerTest extends \PHPUnit_Framework_TestCase
{
protected $timer;
protected function setUp()
{
$this->timer = new Timer(1440, 14400);
}
public function testHasExpired()
{
$this->assertFalse($this->timer->hasExpired(time()));
$this->assertTrue($this->timer->hasExpired(time() - 14441));
}
public function testHasIdled()
{
$this->assertFalse($this->timer->hasIdled(time()));
$this->assertTrue($this->timer->hasIdled(time() - 1441));
}
public function testGetTimeoutStatus()
{
$actual = $this->timer->getTimeoutStatus(
time() - 14441,
time()
);
$this->assertSame(Status::EXPIRED, $actual);
$actual = $this->timer->getTimeoutStatus(
time() - 1442,
time() - 1441
);
$this->assertSame(Status::IDLE, $actual);
$this->assertNull($this->timer->getTimeoutStatus(
time(),
time()
));
}
public function testSetIdleTtl_bad()
{
$this->setExpectedException('Aura\Auth\Exception');
$this->timer->setIdleTtl(1441);
}
public function testSetExpireTtl_bad()
{
$this->setExpectedException('Aura\Auth\Exception');
$this->timer->setExpireTtl(14441);
}
}