testNamedFieldWithValidData()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 17
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 23
rs 9.7
1
<?php
2
3
namespace Austomos\OAuth2\Client\Test\Provider;
4
5
use Austomos\OAuth2\Client\Provider\ChasterAppResourceOwner;
6
use PHPUnit\Framework\TestCase;
7
8
class ChasterAppResourceOwnerTest extends TestCase
9
{
10
    /** @noinspection PhpUndefinedFieldInspection */
11
    public function testNamedFieldWithValidData(): void
12
    {
13
        $profile = new ChasterAppResourceOwner([
14
            '_id' => 'mock_id',
15
            'username' => 'mock_username',
16
            'email' => 'mock_email',
17
            'mock' => 'mock_value'
18
        ]);
19
        $this->assertEquals('mock_id', $profile->getId());
20
        $this->assertEquals('mock_id', $profile->toArray()['_id']);
21
        $this->assertEquals('mock_id', $profile->_id);
0 ignored issues
show
Bug Best Practice introduced by
The property _id does not exist on Austomos\OAuth2\Client\P...ChasterAppResourceOwner. Since you implemented __get, consider adding a @property annotation.
Loading history...
22
23
        $this->assertEquals('mock_username', $profile->getUsername());
24
        $this->assertEquals('mock_username', $profile->toArray()['username']);
25
        $this->assertEquals('mock_username', $profile->username);
0 ignored issues
show
Bug Best Practice introduced by
The property username does not exist on Austomos\OAuth2\Client\P...ChasterAppResourceOwner. Since you implemented __get, consider adding a @property annotation.
Loading history...
26
27
        $this->assertEquals('mock_email', $profile->getEmail());
28
        $this->assertEquals('mock_email', $profile->toArray()['email']);
29
        $this->assertEquals('mock_email', $profile->email);
0 ignored issues
show
Bug Best Practice introduced by
The property email does not exist on Austomos\OAuth2\Client\P...ChasterAppResourceOwner. Since you implemented __get, consider adding a @property annotation.
Loading history...
30
31
        $this->assertEquals('mock_value', $profile->toArray()['mock']);
32
        $this->assertEquals('mock_value', $profile->mock);
0 ignored issues
show
Bug Best Practice introduced by
The property mock does not exist on Austomos\OAuth2\Client\P...ChasterAppResourceOwner. Since you implemented __get, consider adding a @property annotation.
Loading history...
33
        $this->assertEquals(null, $profile->invalidMock);
0 ignored issues
show
Bug Best Practice introduced by
The property invalidMock does not exist on Austomos\OAuth2\Client\P...ChasterAppResourceOwner. Since you implemented __get, consider adding a @property annotation.
Loading history...
34
    }
35
36
    /** @noinspection PhpUndefinedFieldInspection */
37
    public function testNamedFieldWithInvalidData(): void
38
    {
39
        $profile = new ChasterAppResourceOwner([]);
40
        $this->assertEquals('', $profile->getId());
41
        $this->assertArrayNotHasKey('_id', $profile->toArray());
42
        $this->assertEquals(null, $profile->_id);
0 ignored issues
show
Bug Best Practice introduced by
The property _id does not exist on Austomos\OAuth2\Client\P...ChasterAppResourceOwner. Since you implemented __get, consider adding a @property annotation.
Loading history...
43
44
        $this->assertEquals('', $profile->getUsername());
45
        $this->assertArrayNotHasKey('username', $profile->toArray());
46
        $this->assertEquals(null, $profile->username);
0 ignored issues
show
Bug Best Practice introduced by
The property username does not exist on Austomos\OAuth2\Client\P...ChasterAppResourceOwner. Since you implemented __get, consider adding a @property annotation.
Loading history...
47
48
        $this->assertEquals('', $profile->getEmail());
49
        $this->assertArrayNotHasKey('email', $profile->toArray());
50
        $this->assertEquals(null, $profile->email);
0 ignored issues
show
Bug Best Practice introduced by
The property email does not exist on Austomos\OAuth2\Client\P...ChasterAppResourceOwner. Since you implemented __get, consider adding a @property annotation.
Loading history...
51
52
        $this->assertArrayNotHasKey('mock', $profile->toArray());
53
        $this->assertEquals(null, $profile->mock);
0 ignored issues
show
Bug Best Practice introduced by
The property mock does not exist on Austomos\OAuth2\Client\P...ChasterAppResourceOwner. Since you implemented __get, consider adding a @property annotation.
Loading history...
54
    }
55
}
56