|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of the login-cidadao project or it's bundles. |
|
4
|
|
|
* |
|
5
|
|
|
* (c) Guilherme Donato <guilhermednt on github> |
|
6
|
|
|
* |
|
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
8
|
|
|
* file that was distributed with this source code. |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace LoginCidadao\RemoteClaimsBundle\Tests\Entity; |
|
12
|
|
|
|
|
13
|
|
|
use LoginCidadao\RemoteClaimsBundle\Entity\RemoteClaim; |
|
14
|
|
|
use LoginCidadao\RemoteClaimsBundle\Model\ClaimProviderInterface; |
|
15
|
|
|
use LoginCidadao\RemoteClaimsBundle\Model\RemoteClaimInterface; |
|
16
|
|
|
use LoginCidadao\RemoteClaimsBundle\Model\TagUri; |
|
17
|
|
|
|
|
18
|
|
|
class RemoteClaimTest extends \PHPUnit_Framework_TestCase |
|
19
|
|
|
{ |
|
20
|
|
|
public function testRemoteClaim() |
|
21
|
|
|
{ |
|
22
|
|
|
$id = 'id'; |
|
23
|
|
|
$name = new TagUri(); |
|
24
|
|
|
$displayName = 'some claim'; |
|
25
|
|
|
$description = 'about my claim'; |
|
26
|
|
|
$recommended = ['scope1', 'scope2']; |
|
27
|
|
|
$essential = ['scope2', 'scope3']; |
|
28
|
|
|
$uri = 'https://some.uri/example'; |
|
29
|
|
|
|
|
30
|
|
|
/** @var ClaimProviderInterface $provider */ |
|
31
|
|
|
$provider = $this->getMock('LoginCidadao\RemoteClaimsBundle\Model\ClaimProviderInterface'); |
|
32
|
|
|
|
|
33
|
|
|
/** @var RemoteClaimInterface|RemoteClaim $remoteClaim */ |
|
34
|
|
|
$remoteClaim = (new RemoteClaim()) |
|
35
|
|
|
->setId($id) |
|
36
|
|
|
->setName($name) |
|
37
|
|
|
->setDisplayName($displayName) |
|
38
|
|
|
->setDescription($description) |
|
39
|
|
|
->setProvider($provider) |
|
40
|
|
|
->setUri($uri) |
|
41
|
|
|
->setRecommendedScope($recommended) |
|
42
|
|
|
->setEssentialScope($essential); |
|
43
|
|
|
|
|
44
|
|
|
$this->assertInstanceOf('LoginCidadao\RemoteClaimsBundle\Model\RemoteClaimInterface', $remoteClaim); |
|
45
|
|
|
$this->assertEquals($id, $remoteClaim->getId()); |
|
46
|
|
|
$this->assertEquals($name, $remoteClaim->getName()); |
|
47
|
|
|
$this->assertEquals($displayName, $remoteClaim->getDisplayName()); |
|
48
|
|
|
$this->assertEquals($description, $remoteClaim->getDescription()); |
|
49
|
|
|
$this->assertEquals($provider, $remoteClaim->getProvider()); |
|
50
|
|
|
$this->assertEquals($uri, $remoteClaim->getUri()); |
|
51
|
|
|
$this->assertEquals($recommended, $remoteClaim->getRecommendedScope()); |
|
52
|
|
|
$this->assertEquals($essential, $remoteClaim->getEssentialScope()); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function testScopeIsAlwaysArray() |
|
56
|
|
|
{ |
|
57
|
|
|
$remoteClaim = (new RemoteClaim()) |
|
58
|
|
|
->setRecommendedScope('scope1 scope2') |
|
59
|
|
|
->setEssentialScope('scope3 scope4'); |
|
60
|
|
|
|
|
61
|
|
|
$this->assertContains('scope1', $remoteClaim->getRecommendedScope()); |
|
62
|
|
|
$this->assertContains('scope2', $remoteClaim->getRecommendedScope()); |
|
63
|
|
|
|
|
64
|
|
|
$this->assertContains('scope3', $remoteClaim->getEssentialScope()); |
|
65
|
|
|
$this->assertContains('scope4', $remoteClaim->getEssentialScope()); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
public function testGetNameAlwaysReturnsTagUri() |
|
69
|
|
|
{ |
|
70
|
|
|
$remoteClaim = new RemoteClaim(); |
|
71
|
|
|
|
|
72
|
|
|
$reflectionClass = new \ReflectionClass(get_class($remoteClaim)); |
|
73
|
|
|
$nameProp = $reflectionClass->getProperty('name'); |
|
74
|
|
|
$nameProp->setAccessible(true); |
|
75
|
|
|
$nameProp->setValue($remoteClaim, 'tag:example.com,2018:test'); |
|
76
|
|
|
|
|
77
|
|
|
$this->assertInstanceOf('LoginCidadao\RemoteClaimsBundle\Model\TagUri', $remoteClaim->getName()); |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|