@@ 5-54 (lines=50) @@ | ||
2 | ||
3 | namespace Emarref\Jwt\Claim; |
|
4 | ||
5 | class ExpirationTest extends \PHPUnit_Framework_TestCase |
|
6 | { |
|
7 | private static $name = 'exp'; |
|
8 | private static $value = 1357002000; |
|
9 | ||
10 | /** |
|
11 | * @var Expiration |
|
12 | */ |
|
13 | private $claim; |
|
14 | ||
15 | public function setUp() |
|
16 | { |
|
17 | $this->claim = new Expiration(self::$value); |
|
18 | } |
|
19 | ||
20 | public function testGetName() |
|
21 | { |
|
22 | $this->assertSame(self::$name, $this->claim->getName()); |
|
23 | } |
|
24 | ||
25 | public function testGetValue() |
|
26 | { |
|
27 | $this->assertSame(self::$value, $this->claim->getValue()); |
|
28 | } |
|
29 | ||
30 | public function testTimestampValue() |
|
31 | { |
|
32 | $now = new \DateTime('now', new \DateTimeZone('UTC')); |
|
33 | ||
34 | $this->claim->setValue($now->getTimestamp()); |
|
35 | $this->assertSame($now->getTimestamp(), $this->claim->getValue()); |
|
36 | } |
|
37 | ||
38 | public function testDateTimeValue() |
|
39 | { |
|
40 | $now = new \DateTime('now', new \DateTimeZone('UTC')); |
|
41 | ||
42 | $this->claim->setValue($now); |
|
43 | $this->assertSame($now->getTimestamp(), $this->claim->getValue()); |
|
44 | } |
|
45 | ||
46 | public function testTimezone() |
|
47 | { |
|
48 | $akl = new \DateTime('2014-01-01 13:00:00', new \DateTimeZone('Pacific/Auckland')); |
|
49 | $utc = new \DateTime('2014-01-01 00:00:00', new \DateTimeZone('UTC')); |
|
50 | ||
51 | $this->claim->setValue($akl); |
|
52 | $this->assertSame($utc->getTimestamp(), $this->claim->getValue()); |
|
53 | } |
|
54 | } |
|
55 |
@@ 5-54 (lines=50) @@ | ||
2 | ||
3 | namespace Emarref\Jwt\Claim; |
|
4 | ||
5 | class IssuedAtTest extends \PHPUnit_Framework_TestCase |
|
6 | { |
|
7 | private static $name = 'iat'; |
|
8 | private static $value = 1357002000; |
|
9 | ||
10 | /** |
|
11 | * @var IssuedAt |
|
12 | */ |
|
13 | private $claim; |
|
14 | ||
15 | public function setUp() |
|
16 | { |
|
17 | $this->claim = new IssuedAt(self::$value); |
|
18 | } |
|
19 | ||
20 | public function testGetName() |
|
21 | { |
|
22 | $this->assertSame(self::$name, $this->claim->getName()); |
|
23 | } |
|
24 | ||
25 | public function testGetValue() |
|
26 | { |
|
27 | $this->assertSame(self::$value, $this->claim->getValue()); |
|
28 | } |
|
29 | ||
30 | public function testTimestampValue() |
|
31 | { |
|
32 | $now = new \DateTime('now', new \DateTimeZone('UTC')); |
|
33 | ||
34 | $this->claim->setValue($now->getTimestamp()); |
|
35 | $this->assertSame($now->getTimestamp(), $this->claim->getValue()); |
|
36 | } |
|
37 | ||
38 | public function testDateTimeValue() |
|
39 | { |
|
40 | $now = new \DateTime('now', new \DateTimeZone('UTC')); |
|
41 | ||
42 | $this->claim->setValue($now); |
|
43 | $this->assertSame($now->getTimestamp(), $this->claim->getValue()); |
|
44 | } |
|
45 | ||
46 | public function testTimezone() |
|
47 | { |
|
48 | $akl = new \DateTime('2014-01-01 13:00:00', new \DateTimeZone('Pacific/Auckland')); |
|
49 | $utc = new \DateTime('2014-01-01 00:00:00', new \DateTimeZone('UTC')); |
|
50 | ||
51 | $this->claim->setValue($akl); |
|
52 | $this->assertSame($utc->getTimestamp(), $this->claim->getValue()); |
|
53 | } |
|
54 | } |
|
55 |
@@ 5-54 (lines=50) @@ | ||
2 | ||
3 | namespace Emarref\Jwt\Claim; |
|
4 | ||
5 | class NotBeforeTest extends \PHPUnit_Framework_TestCase |
|
6 | { |
|
7 | private static $name = 'nbf'; |
|
8 | private static $value = 1357002000; |
|
9 | ||
10 | /** |
|
11 | * @var NotBefore |
|
12 | */ |
|
13 | private $claim; |
|
14 | ||
15 | public function setUp() |
|
16 | { |
|
17 | $this->claim = new NotBefore(self::$value); |
|
18 | } |
|
19 | ||
20 | public function testGetName() |
|
21 | { |
|
22 | $this->assertSame(self::$name, $this->claim->getName()); |
|
23 | } |
|
24 | ||
25 | public function testGetValue() |
|
26 | { |
|
27 | $this->assertSame(self::$value, $this->claim->getValue()); |
|
28 | } |
|
29 | ||
30 | public function testTimestampValue() |
|
31 | { |
|
32 | $now = new \DateTime('now', new \DateTimeZone('UTC')); |
|
33 | ||
34 | $this->claim->setValue($now->getTimestamp()); |
|
35 | $this->assertSame($now->getTimestamp(), $this->claim->getValue()); |
|
36 | } |
|
37 | ||
38 | public function testDateTimeValue() |
|
39 | { |
|
40 | $now = new \DateTime('now', new \DateTimeZone('UTC')); |
|
41 | ||
42 | $this->claim->setValue($now); |
|
43 | $this->assertSame($now->getTimestamp(), $this->claim->getValue()); |
|
44 | } |
|
45 | ||
46 | public function testTimezone() |
|
47 | { |
|
48 | $akl = new \DateTime('2014-01-01 13:00:00', new \DateTimeZone('Pacific/Auckland')); |
|
49 | $utc = new \DateTime('2014-01-01 00:00:00', new \DateTimeZone('UTC')); |
|
50 | ||
51 | $this->claim->setValue($akl); |
|
52 | $this->assertSame($utc->getTimestamp(), $this->claim->getValue()); |
|
53 | } |
|
54 | } |
|
55 |