1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright 2017 Facebook, Inc. |
4
|
|
|
* |
5
|
|
|
* You are hereby granted a non-exclusive, worldwide, royalty-free license to |
6
|
|
|
* use, copy, modify, and distribute this software in source code or binary |
7
|
|
|
* form for use in connection with the web services and APIs provided by |
8
|
|
|
* Facebook. |
9
|
|
|
* |
10
|
|
|
* As with any software that integrates with the Facebook platform, your use |
11
|
|
|
* of this software is subject to the Facebook Developer Principles and |
12
|
|
|
* Policies [http://developers.facebook.com/policy/]. This copyright notice |
13
|
|
|
* shall be included in all copies or substantial portions of the software. |
14
|
|
|
* |
15
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
16
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
17
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
18
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
19
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
20
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
21
|
|
|
* DEALINGS IN THE SOFTWARE. |
22
|
|
|
*/ |
23
|
|
|
namespace Facebook\Tests; |
24
|
|
|
|
25
|
|
|
use Facebook\Application; |
26
|
|
|
use Facebook\Authentication\AccessToken; |
27
|
|
|
use PHPUnit\Framework\TestCase; |
28
|
|
|
|
29
|
|
|
class ApplicationTest extends TestCase |
30
|
|
|
{ |
31
|
|
|
/** |
32
|
|
|
* @var Application |
33
|
|
|
*/ |
34
|
|
|
private $app; |
35
|
|
|
|
36
|
|
|
protected function setUp() |
37
|
|
|
{ |
38
|
|
|
$this->app = new Application('id', 'secret'); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function testGetId() |
42
|
|
|
{ |
43
|
|
|
$this->assertEquals('id', $this->app->getId()); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function testGetSecret() |
47
|
|
|
{ |
48
|
|
|
$this->assertEquals('secret', $this->app->getSecret()); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function testAnAppAccessTokenCanBeGenerated() |
52
|
|
|
{ |
53
|
|
|
$accessToken = $this->app->getAccessToken(); |
54
|
|
|
|
55
|
|
|
$this->assertInstanceOf(AccessToken::class, $accessToken); |
56
|
|
|
$this->assertEquals('id|secret', (string)$accessToken); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function testSerialization() |
60
|
|
|
{ |
61
|
|
|
$newApp = unserialize(serialize($this->app)); |
62
|
|
|
|
63
|
|
|
$this->assertInstanceOf(Application::class, $newApp); |
64
|
|
|
$this->assertEquals('id', $newApp->getId()); |
65
|
|
|
$this->assertEquals('secret', $newApp->getSecret()); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @expectedException \Facebook\Exception\SDKException |
70
|
|
|
*/ |
71
|
|
|
public function testOverflowIntegersWillThrow() |
72
|
|
|
{ |
73
|
|
|
new Application(PHP_INT_MAX + 1, "foo"); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
public function testUnserializedIdsWillBeString() |
77
|
|
|
{ |
78
|
|
|
$newApp = unserialize(serialize(new Application(1, "foo"))); |
79
|
|
|
|
80
|
|
|
$this->assertSame('1', $newApp->getId()); |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|