1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
<?php
namespace MediaWiki\Extensions\OAuth\Tests\Entity;
use MediaWikiTestCase;
/**
* @covers \MediaWiki\Extensions\OAuth\Entity\ClientEntity
*/
class ClientEntityTest extends MediaWikiTestCase {
public function testProperties() {
$domain = 'http://domain.com/oauth2';
$client = Mock_ClientEntity::newMock( $this->getTestUser()->getUser(), [
'consumerKey' => '123456789',
'callbackUrl' => $domain,
'name' => 'Test client',
'oauth2IsConfidential' => false,
'oauth2GrantTypes' => [ 'client_credentials' ]
] );
$this->assertSame(
$domain, $client->getRedirectUri(),
'Redirect URI should match the one given on registration'
);
$this->assertFalse(
$client->isConfidential(),
'Client should not be confidential'
);
$this->assertSame(
'123456789', $client->getConsumerKey(),
'ConsumerKey should be the same as the one given on registration'
);
$client->setIdentifier( '987654321' );
$this->assertSame(
'987654321', $client->getConsumerKey(),
'ConsumerKey should change when explicitly set'
);
$this->assertSame(
'Test client', $client->getName(),
'Client name should be same as the one given on registration'
);
$this->assertArrayEquals(
[ 'client_credentials' ], $client->getAllowedGrants(),
'Allowed grants should be the same as ones given on registration'
);
}
}
|