Completed
Pull Request — master (#4)
by
unknown
07:36
created

AzineHybridAuthTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 16
rs 9.4285
c 1
b 0
f 1
cc 1
eloc 11
nc 1
nop 0
1
<?php
2
namespace Azine\HybridAuthBundle\Services;
3
4
use Azine\HybridAuthBundle\Entity\HybridAuthSessionData;
5
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
6
7
class AzineHybridAuthTest extends TestCase
8
{
9
10
    private $router;
11
    private $entityManager;
12
    private $user;
13
    private $azineHybridAuth;
14
15
16
    protected function setUp()
17
    {
18
        $this->user = $this->getMockBuilder('FOS\UserBundle\Model\User')->getMock();
19
20
        $this->router = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Routing\Router')
21
            ->disableOriginalConstructor()
22
            ->getMock();
23
24
        $this->entityManager = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')
25
            ->disableOriginalConstructor()
26
            ->getMock();
27
28
        $config = array('endpoint_route' => 'route', 'providers' => 'providers', 'debug_mode' => 'debug_mode', 'debug_file' => 'debug_file');
29
        $this->azineHybridAuth = new AzineHybridAuth($this->router, $this->user, $this->entityManager,
30
            $config, false, true, 55);
31
    }
32
33 View Code Duplication
    public function testIsExpiredSession()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
34
    {
35
36
        $sessionData = new HybridAuthSessionData();
37
        $sessionData->setUsername('dominik');
38
39
        $expirationDate = new \DateTime();
40
        $expirationDate->modify('- 1 day');
41
42
        $sessionData->setExpiresAt($expirationDate);
43
        $isExpired = $this->azineHybridAuth->isExpiredSession($sessionData);
44
45
        $this->assertEquals(true, $isExpired);
46
    }
47
48 View Code Duplication
    public function testIsNotExpiredSession()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
49
    {
50
51
        $sessionData = new HybridAuthSessionData();
52
        $sessionData->setUsername('dominik');
53
54
        $expirationDate = new \DateTime();
55
        $expirationDate->modify('+ 1 day');
56
57
        $sessionData->setExpiresAt($expirationDate);
58
        $isExpired = $this->azineHybridAuth->isExpiredSession($sessionData);
59
60
        $this->assertEquals(false, $isExpired);
61
    }
62
63
}