TwitterAccountTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 49
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testSetAccessToken() 0 15 1
A testGetAccessToken() 0 11 1
A testIsAuthorised() 0 18 1
1
<?php
2
3
class TwitterAccountTest extends SapphireTest
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
{
5
    public function testSetAccessToken()
6
    {
7
        /**
8
         * Should serialize the token and set it on the TwitterAccount.
9
         */
10
        $token = ['token' => 'abc', 'secret' => '123'];
11
12
        $twitterAccount = new TwitterAccount();
13
14
        $this->assertEquals(null, $twitterAccount->getField('AccessToken'));
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<TwitterAccountTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
15
16
        $twitterAccount->setAccessToken($token);
17
18
        $this->assertInternalType('string', $twitterAccount->getField('AccessToken'));
0 ignored issues
show
Bug introduced by
The method assertInternalType() does not seem to exist on object<TwitterAccountTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
19
    }
20
21
    public function testGetAccessToken()
22
    {
23
        /**
24
         * Should return the unserialized token on TwitterAccount.
25
         */
26
        $twitterAccount = new TwitterAccount([
27
            'AccessToken' => serialize(['token' => 'abc', 'secret' => '123']),
28
        ]);
29
30
        $this->assertInternalType('array', $twitterAccount->getAccessToken());
0 ignored issues
show
Bug introduced by
The method assertInternalType() does not seem to exist on object<TwitterAccountTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
31
    }
32
33
    public function testIsAuthorised()
34
    {
35
        /**
36
         * Should fail if an access token is not set.
37
         */
38
        $twitterAccount = new TwitterAccount();
39
40
        $this->assertFalse($twitterAccount->isAuthorised());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<TwitterAccountTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
41
42
        /**
43
         * Should pass if an access token is set.
44
         */
45
        $twitterAccount = new TwitterAccount([
46
            'AccessToken' => serialize(['token' => 'abc', 'secret' => '123']),
47
        ]);
48
49
        $this->assertTrue($twitterAccount->isAuthorised());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<TwitterAccountTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
50
    }
51
}
52