Completed
Push — master ( c3efa2...a812ec )
by Guilherme
13s
created

SubjectIdentifierTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 44
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testGettersSetters() 0 22 1
A testLifecycleCallbacks() 0 15 1
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