Completed
Push — master ( 4c45e0...1a7b7a )
by Дмитрий
02:22
created

MeetupTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 3
eloc 21
dl 0
loc 49
rs 10
c 3
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testParsingTokenFailsWithInvalidBody() 0 10 1
A getProviderClassName() 0 3 1
A testParsingToken() 0 22 1
1
<?php
2
/**
3
 * SocialConnect project
4
 * @author: Andreas Heigl https://github.com/heiglandreas <[email protected]>
5
 */
6
7
namespace Test\OAuth2\Provider;
8
9
use SocialConnect\Common\Http\Client\ClientInterface;
10
use SocialConnect\OAuth2\AccessToken;
11
use SocialConnect\OAuth2\Provider\Meetup;
12
use SocialConnect\Provider\Consumer;
13
use SocialConnect\Provider\Session\SessionInterface;
14
15
class MeetupTest extends AbstractProviderTestCase
16
{
17
    /**
18
     * {@inheritdoc}
19
     */
20
    protected function getProviderClassName()
21
    {
22
        return \SocialConnect\OAuth2\Provider\Meetup::class;
23
    }
24
25
    /** @covers \SocialConnect\OAuth2\Provider\Meetup::parseToken */
26
    public function testParsingToken()
27
    {
28
        $expires = time() + 200;
29
        $body = json_encode([
30
            'access_token' => 'foo',
31
            'user_id'      => 'bar',
32
            'expires'      => $expires,
33
        ]);
34
35
        $meetup = new Meetup(
36
            self::createMock(ClientInterface::class),
0 ignored issues
show
Bug Best Practice introduced by
The method PHPUnit\Framework\TestCase::createMock() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

36
            self::/** @scrutinizer ignore-call */ 
37
                  createMock(ClientInterface::class),
Loading history...
37
            self::createMock(SessionInterface::class),
38
            self::createMock(Consumer::class),
39
            []
40
        );
41
42
        $token = $meetup->parseToken($body);
43
44
        self::assertInstanceOf(AccessToken::class, $token);
45
        self::assertAttributeEquals('foo', 'token', $token);
46
        self::assertAttributeEquals($expires, 'expires', $token);
47
        self::assertAttributeEquals('bar', 'uid', $token);
48
    }
49
50
    /**
51
     * @expectedException \SocialConnect\Provider\Exception\InvalidAccessToken
52
     * @covers \SocialConnect\OAuth2\Provider\Meetup::parseToken
53
     */
54
    public function testParsingTokenFailsWithInvalidBody()
55
    {
56
        $meetup = new Meetup(
57
            self::createMock(ClientInterface::class),
0 ignored issues
show
Bug Best Practice introduced by
The method PHPUnit\Framework\TestCase::createMock() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

57
            self::/** @scrutinizer ignore-call */ 
58
                  createMock(ClientInterface::class),
Loading history...
58
            self::createMock(SessionInterface::class),
59
            self::createMock(Consumer::class),
60
            []
61
        );
62
63
        $meetup->parseToken(json_encode(false));
64
    }
65
}
66