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 $azineHybridAuth; |
11
|
|
|
|
12
|
|
|
protected function setUp() |
13
|
|
|
{ |
14
|
|
|
$user = $this->getMockBuilder('FOS\UserBundle\Model\User')->getMock(); |
15
|
|
|
|
16
|
|
|
$router = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Routing\Router') |
17
|
|
|
->disableOriginalConstructor() |
18
|
|
|
->getMock(); |
19
|
|
|
|
20
|
|
|
$entityManager = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager') |
21
|
|
|
->disableOriginalConstructor() |
22
|
|
|
->getMock(); |
23
|
|
|
|
24
|
|
|
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface') |
25
|
|
|
->disableOriginalConstructor() |
26
|
|
|
->getMock(); |
27
|
|
|
|
28
|
|
|
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken') |
29
|
|
|
->setConstructorArgs(array('key', $user)) |
30
|
|
|
->getMock(); |
31
|
|
|
|
32
|
|
|
$tokenStorage->expects($this->any()) |
33
|
|
|
->method('getToken') |
34
|
|
|
->will($this->returnValue($token)); |
35
|
|
|
|
36
|
|
|
|
37
|
|
|
$config = array('endpoint_route' => 'route', 'providers' => 'providers', 'debug_mode' => 'debug_mode', 'debug_file' => 'debug_file'); |
38
|
|
|
$this->azineHybridAuth = new AzineHybridAuth($router, $tokenStorage, $entityManager, |
39
|
|
|
$config, false, true, 55); |
|
|
|
|
40
|
|
|
} |
41
|
|
|
|
42
|
|
View Code Duplication |
public function testIsExpiredSession() |
|
|
|
|
43
|
|
|
{ |
44
|
|
|
|
45
|
|
|
$sessionData = new HybridAuthSessionData(); |
46
|
|
|
$sessionData->setUsername('dominik'); |
47
|
|
|
|
48
|
|
|
$expirationDate = new \DateTime(); |
49
|
|
|
$expirationDate->modify('- 1 day'); |
50
|
|
|
|
51
|
|
|
$sessionData->setExpiresAt($expirationDate); |
52
|
|
|
$isExpired = $this->azineHybridAuth->isExpiredSession($sessionData); |
53
|
|
|
|
54
|
|
|
$this->assertEquals(true, $isExpired); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
View Code Duplication |
public function testIsNotExpiredSession() |
|
|
|
|
58
|
|
|
{ |
59
|
|
|
|
60
|
|
|
$sessionData = new HybridAuthSessionData(); |
61
|
|
|
$sessionData->setUsername('dominik'); |
62
|
|
|
|
63
|
|
|
$expirationDate = new \DateTime(); |
64
|
|
|
$expirationDate->modify('+ 1 day'); |
65
|
|
|
|
66
|
|
|
$sessionData->setExpiresAt($expirationDate); |
67
|
|
|
$isExpired = $this->azineHybridAuth->isExpiredSession($sessionData); |
68
|
|
|
|
69
|
|
|
$this->assertEquals(false, $isExpired); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
} |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.