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); |
|
|
|
|
22
|
|
|
|
23
|
|
|
$this->assertEquals('mock_username', $profile->getUsername()); |
24
|
|
|
$this->assertEquals('mock_username', $profile->toArray()['username']); |
25
|
|
|
$this->assertEquals('mock_username', $profile->username); |
|
|
|
|
26
|
|
|
|
27
|
|
|
$this->assertEquals('mock_email', $profile->getEmail()); |
28
|
|
|
$this->assertEquals('mock_email', $profile->toArray()['email']); |
29
|
|
|
$this->assertEquals('mock_email', $profile->email); |
|
|
|
|
30
|
|
|
|
31
|
|
|
$this->assertEquals('mock_value', $profile->toArray()['mock']); |
32
|
|
|
$this->assertEquals('mock_value', $profile->mock); |
|
|
|
|
33
|
|
|
$this->assertEquals(null, $profile->invalidMock); |
|
|
|
|
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); |
|
|
|
|
43
|
|
|
|
44
|
|
|
$this->assertEquals('', $profile->getUsername()); |
45
|
|
|
$this->assertArrayNotHasKey('username', $profile->toArray()); |
46
|
|
|
$this->assertEquals(null, $profile->username); |
|
|
|
|
47
|
|
|
|
48
|
|
|
$this->assertEquals('', $profile->getEmail()); |
49
|
|
|
$this->assertArrayNotHasKey('email', $profile->toArray()); |
50
|
|
|
$this->assertEquals(null, $profile->email); |
|
|
|
|
51
|
|
|
|
52
|
|
|
$this->assertArrayNotHasKey('mock', $profile->toArray()); |
53
|
|
|
$this->assertEquals(null, $profile->mock); |
|
|
|
|
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|