|
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\OpenIDBundle\Tests\Entity; |
|
12
|
|
|
|
|
13
|
|
|
use LoginCidadao\OpenIDBundle\Entity\SubjectIdentifier; |
|
14
|
|
|
|
|
15
|
|
|
class SubjectIdentifierTest extends \PHPUnit_Framework_TestCase |
|
16
|
|
|
{ |
|
17
|
|
|
public function testGettersSetters() |
|
18
|
|
|
{ |
|
19
|
|
|
$subId = 'some_subject_identifier'; |
|
20
|
|
|
$person = $this->getMock('LoginCidadao\CoreBundle\Model\PersonInterface'); |
|
21
|
|
|
$client = $this->getMock('LoginCidadao\OAuthBundle\Model\ClientInterface'); |
|
22
|
|
|
$createdAt = new \DateTime(); |
|
23
|
|
|
$updatedAt = new \DateTime(); |
|
24
|
|
|
|
|
25
|
|
|
$sub = new SubjectIdentifier(); |
|
26
|
|
|
$sub |
|
27
|
|
|
->setSubjectIdentifier($subId) |
|
28
|
|
|
->setPerson($person) |
|
29
|
|
|
->setClient($client) |
|
30
|
|
|
->setCreatedAt($createdAt) |
|
31
|
|
|
->setUpdatedAt($updatedAt); |
|
32
|
|
|
|
|
33
|
|
|
$this->assertEquals($subId, $sub->getSubjectIdentifier()); |
|
34
|
|
|
$this->assertEquals($person, $sub->getPerson()); |
|
35
|
|
|
$this->assertEquals($client, $sub->getClient()); |
|
36
|
|
|
$this->assertEquals($createdAt, $sub->getCreatedAt()); |
|
37
|
|
|
$this->assertEquals($updatedAt, $sub->getUpdatedAt()); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @group time-sensitive |
|
42
|
|
|
*/ |
|
43
|
|
|
public function testLifecycleCallbacks() |
|
44
|
|
|
{ |
|
45
|
|
|
$sub = new SubjectIdentifier(); |
|
46
|
|
|
$sub->setUpdatedAt() |
|
47
|
|
|
->setCreatedAt(); |
|
48
|
|
|
|
|
49
|
|
|
$this->assertInstanceOf('\DateTime', $sub->getCreatedAt()); |
|
50
|
|
|
$this->assertInstanceOf('\DateTime', $sub->getUpdatedAt()); |
|
51
|
|
|
|
|
52
|
|
|
$previousDate = $sub->getUpdatedAt(); |
|
53
|
|
|
sleep(1); |
|
54
|
|
|
$sub->setUpdatedAt(); |
|
55
|
|
|
|
|
56
|
|
|
$this->assertNotEquals($previousDate, $sub->getUpdatedAt()); |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|