|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace WrDX\Facebook\Tests; |
|
4
|
|
|
|
|
5
|
|
|
use WrDX\Facebook\FacebookCakeSessionPersistentDataHandler; |
|
6
|
|
|
|
|
7
|
|
|
class FacebookCakeSessionPersistentDataHandlerTest extends \PHPUnit_Framework_TestCase { |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* @expectedException \Facebook\Exceptions\FacebookSDKException |
|
11
|
|
|
*/ |
|
12
|
|
|
public function testInactiveSessionsWillThrowFacebooksdkxception() { |
|
13
|
|
|
$CakeSession = $this |
|
14
|
|
|
->getMockBuilder('CakeSession') |
|
15
|
|
|
->setMethods(['start']) |
|
16
|
|
|
->getMock(); |
|
17
|
|
|
|
|
18
|
|
|
$CakeSession |
|
19
|
|
|
->expects($this->once()) |
|
20
|
|
|
->method('start') |
|
21
|
|
|
->will($this->returnValue(false)); |
|
22
|
|
|
|
|
23
|
|
|
new FacebookCakeSessionPersistentDataHandler($CakeSession); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
public function testCanSetAValue() { |
|
27
|
|
|
|
|
28
|
|
|
$CakeSession = $this |
|
29
|
|
|
->getMockBuilder('CakeSession') |
|
30
|
|
|
->setMethods(['write']) |
|
31
|
|
|
->getMock(); |
|
32
|
|
|
|
|
33
|
|
|
$CakeSession |
|
34
|
|
|
->expects($this->once()) |
|
35
|
|
|
->method('write') |
|
36
|
|
|
->will($this->returnValue(true)); |
|
37
|
|
|
|
|
38
|
|
|
$handler = new FacebookCakeSessionPersistentDataHandler($CakeSession, $enableSessionCheck = false, 'Test'); |
|
39
|
|
|
$value = $handler->set('foo', 'bar'); |
|
40
|
|
|
$this->assertTrue($value); |
|
41
|
|
|
|
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
public function testCanGetAValue() { |
|
45
|
|
|
|
|
46
|
|
|
$CakeSession = $this |
|
47
|
|
|
->getMockBuilder('CakeSession') |
|
48
|
|
|
->setMethods(['read']) |
|
49
|
|
|
->getMock(); |
|
50
|
|
|
|
|
51
|
|
|
$CakeSession |
|
52
|
|
|
->expects($this->once()) |
|
53
|
|
|
->method('read') |
|
54
|
|
|
->will($this->returnValue('baz')); |
|
55
|
|
|
|
|
56
|
|
|
$handler = new FacebookCakeSessionPersistentDataHandler($CakeSession, $enableSessionCheck = false, 'Test'); |
|
57
|
|
|
$value = $handler->get('faz'); |
|
58
|
|
|
$this->assertEquals('baz', $value); |
|
59
|
|
|
|
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
public function testGettingAValueThatDoesntExistWillReturnNull() { |
|
63
|
|
|
$CakeSession = $this |
|
64
|
|
|
->getMockBuilder('CakeSession') |
|
65
|
|
|
->setMethods(['read']) |
|
66
|
|
|
->getMock(); |
|
67
|
|
|
|
|
68
|
|
|
$CakeSession |
|
69
|
|
|
->expects($this->once()) |
|
70
|
|
|
->method('read') |
|
71
|
|
|
->will($this->returnValue(null)); |
|
72
|
|
|
|
|
73
|
|
|
$handler = new FacebookCakeSessionPersistentDataHandler($CakeSession, $enableSessionCheck = false); |
|
74
|
|
|
$value = $handler->get('does_not_exist'); |
|
75
|
|
|
$this->assertNull($value); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
|