Completed
Pull Request — master (#594)
by Andreas
03:19
created

FacebookAppTest::testUnserializedIdsWillBeString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 6
rs 9.4285
c 1
b 0
f 1
1
<?php
2
/**
3
 * Copyright 2016 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
 */
24
namespace Facebook\Tests;
25
26
use Facebook\FacebookApp;
27
28
class FacebookAppTest extends \PHPUnit_Framework_TestCase
29
{
30
    /**
31
     * @var FacebookApp
32
     */
33
    private $app;
34
35
    protected function setUp()
36
    {
37
        $this->app = new FacebookApp('id', 'secret');
38
    }
39
40
    public function testGetId()
41
    {
42
        $this->assertEquals('id', $this->app->getId());
43
    }
44
45
    public function testGetSecret()
46
    {
47
        $this->assertEquals('secret', $this->app->getSecret());
48
    }
49
50
    public function testAnAppAccessTokenCanBeGenerated()
51
    {
52
        $accessToken = $this->app->getAccessToken();
53
54
        $this->assertInstanceOf('Facebook\Authentication\AccessToken', $accessToken);
55
        $this->assertEquals('id|secret', (string)$accessToken);
56
    }
57
58
    public function testSerialization()
59
    {
60
        $newApp = unserialize(serialize($this->app));
61
62
        $this->assertInstanceOf('Facebook\FacebookApp', $newApp);
63
        $this->assertEquals('id', $newApp->getId());
64
        $this->assertEquals('secret', $newApp->getSecret());
65
    }
66
67
    /**
68
     * @expectedException \Facebook\Exceptions\FacebookSDKException
69
     */
70
    public function testOverflowIntegersWillThrow()
71
    {
72
        new FacebookApp(PHP_INT_MAX + 1, "foo");
73
    }
74
75
    public function testUnserializedIdsWillBeString()
76
    {
77
        $newApp = unserialize(serialize(new FacebookApp(1, "foo")));
78
79
        $this->assertSame('1', $newApp->getId());
80
    }
81
}
82