Passed
Pull Request — master (#1144)
by
unknown
01:41
created

ApplicationTest::testUnserializedIdsWillBeString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
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
     * TODO Delete as with types this is automatically coerced to string
70
     * @expectedException \Facebook\Exception\SDKException
71
     */
72
    /*public function testOverflowIntegersWillThrow()
0 ignored issues
show
Unused Code Comprehensibility introduced by
55% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
73
    {
74
        new Application(PHP_INT_MAX + 1, "foo");
75
    }
76
77
    public function testUnserializedIdsWillBeString()
78
    {
79
        $newApp = unserialize(serialize(new Application(1, "foo")));
80
81
        $this->assertSame('1', $newApp->getId());
82
    }*/
83
}
84