1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the U2F Security bundle. |
5
|
|
|
* |
6
|
|
|
* (c) Michael Barbey <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Mbarbey\U2fSecurityBundle\Tests\Entity\User; |
13
|
|
|
|
14
|
|
|
use Symfony\Bundle\FrameworkBundle\Tests\TestCase; |
15
|
|
|
use Mbarbey\U2fSecurityBundle\Model\User\U2fUser; |
16
|
|
|
use Mbarbey\U2fSecurityBundle\Model\Key\U2fKey; |
17
|
|
|
|
18
|
|
|
class U2fUserTest extends TestCase |
19
|
|
|
{ |
20
|
|
|
public function testKeys() |
21
|
|
|
{ |
22
|
|
|
$user = $this->getUser(); |
23
|
|
|
$this->assertEquals($user->getU2fKeys()->count(), 0); |
|
|
|
|
24
|
|
|
|
25
|
|
|
$key1 = $this->getMockForAbstractClass(U2fKey::class); |
26
|
|
|
$user->addU2fKey($key1); |
|
|
|
|
27
|
|
|
$this->assertEquals($user->getU2fKeys()->count(), 1); |
28
|
|
|
$this->assertEquals($user->getU2fKeys()->first(), $key1); |
29
|
|
|
$this->assertEquals($key1->getUser(), $user); |
|
|
|
|
30
|
|
|
|
31
|
|
|
$key2 = $this->getMockForAbstractClass(U2fKey::class); |
32
|
|
|
$user->addU2fKey($key2); |
33
|
|
|
$this->assertEquals($user->getU2fKeys()->count(), 2); |
34
|
|
|
$this->assertEquals($user->getU2fKeys()->get(0), $key1); |
35
|
|
|
$this->assertEquals($user->getU2fKeys()->get(1), $key2); |
36
|
|
|
$this->assertEquals($key2->getUser(), $user); |
37
|
|
|
|
38
|
|
|
$user->removeU2fKey($key1); |
|
|
|
|
39
|
|
|
$this->assertNull($key1->getUser()); |
40
|
|
|
$this->assertEquals($user->getU2fKeys()->count(), 1); |
41
|
|
|
$this->assertEquals($user->getU2fKeys()->first(), $key2); |
42
|
|
|
|
43
|
|
|
$user->removeU2fKey($key2); |
44
|
|
|
$this->assertNull($key2->getUser()); |
45
|
|
|
$this->assertEquals($user->getU2fKeys()->count(), 0); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
protected function getUser() |
49
|
|
|
{ |
50
|
|
|
return $this->getMockForAbstractClass(U2fUser::class); |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.