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

AzineHybridAuthTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 57
Duplicated Lines 49.12 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
lcom 1
cbo 3
dl 28
loc 57
rs 10
c 1
b 0
f 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 16 1
A testIsExpiredSession() 14 14 1
A testIsNotExpiredSession() 14 14 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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
}