|
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\OAuthBundle\Tests\Entity; |
|
12
|
|
|
|
|
13
|
|
|
use LoginCidadao\CoreBundle\Entity\Person; |
|
14
|
|
|
use LoginCidadao\OAuthBundle\Entity\Client; |
|
15
|
|
|
use LoginCidadao\OAuthBundle\Entity\Organization; |
|
16
|
|
|
|
|
17
|
|
|
class OrganizationTest extends \PHPUnit_Framework_TestCase |
|
18
|
|
|
{ |
|
19
|
|
|
public function testOrganization() |
|
20
|
|
|
{ |
|
21
|
|
|
$organization = (new Organization()) |
|
22
|
|
|
->setId($id = 'orgId') |
|
23
|
|
|
->setName($name = 'My Organization') |
|
24
|
|
|
->setMembers($members = [new Person()]) |
|
25
|
|
|
->setVerifiedAt($verifiedAt = new \DateTime()) |
|
26
|
|
|
->setDomain($domain = 'example.com') |
|
27
|
|
|
->setClients($clients = [new Client()]) |
|
28
|
|
|
->setValidationUrl($validationUri = 'https://example.com/validate') |
|
29
|
|
|
->setValidationSecret($validationSecret = 'val-secret') |
|
30
|
|
|
->setValidatedUrl($validatedUri = 'https://example.com/validated') |
|
31
|
|
|
->setTrusted(true) |
|
32
|
|
|
->setSectorIdentifierUri($sectorUri = 'https://example.com'); |
|
33
|
|
|
|
|
34
|
|
|
$this->assertSame($id, $organization->getId()); |
|
35
|
|
|
$this->assertSame($name, $organization->getName()); |
|
36
|
|
|
$this->assertSame($members, $organization->getMembers()); |
|
37
|
|
|
$this->assertSame($verifiedAt, $organization->getVerifiedAt()); |
|
38
|
|
|
$this->assertSame($domain, $organization->getDomain()); |
|
39
|
|
|
$this->assertSame($clients, $organization->getClients()); |
|
40
|
|
|
$this->assertSame($validationUri, $organization->getValidationUrl()); |
|
41
|
|
|
$this->assertSame($validationSecret, $organization->getValidationSecret()); |
|
42
|
|
|
$this->assertSame($sectorUri, $organization->getSectorIdentifierUri()); |
|
43
|
|
|
|
|
44
|
|
|
$this->assertTrue($organization->isTrusted()); |
|
45
|
|
|
$this->assertTrue($organization->isVerified()); |
|
46
|
|
|
|
|
47
|
|
|
$this->assertFalse($organization->checkValidation()); |
|
48
|
|
|
$this->assertNull($organization->getVerifiedAt()); |
|
49
|
|
|
$this->assertFalse($organization->isVerified()); |
|
50
|
|
|
|
|
51
|
|
|
$organization->setValidatedUrl($organization->getValidationUrl()); |
|
52
|
|
|
$organization->setVerifiedAt(new \DateTime()); |
|
53
|
|
|
$this->assertTrue($organization->checkValidation()); |
|
54
|
|
|
$this->assertSame($name, $organization->__toString()); |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
|