Passed
Push — master ( bb11e3...34e12f )
by michael
03:06
created

U2fKeyTest::testUser()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 8
rs 10
c 0
b 0
f 0
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\Key;
13
14
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
15
use Mbarbey\U2fSecurityBundle\Model\Key\U2fKey;
16
use Mbarbey\U2fSecurityBundle\Model\User\U2fUser;
17
18
class U2fKeyTest extends TestCase
19
{
20
    public function testKeyHandle()
21
    {
22
        $key = $this->getKey();
23
        $this->assertNull($key->keyHandle);
0 ignored issues
show
Bug introduced by
Accessing keyHandle on the interface PHPUnit\Framework\MockObject\MockObject suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
24
25
        $key->keyHandle = 'test1';
26
        $this->assertEquals($key->keyHandle, 'test1');
27
        $this->assertEquals($key->getKeyHandle(), 'test1');
0 ignored issues
show
Bug introduced by
The method getKeyHandle() does not exist on PHPUnit\Framework\MockObject\MockObject. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

27
        $this->assertEquals($key->/** @scrutinizer ignore-call */ getKeyHandle(), 'test1');

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.

Loading history...
28
29
        $key->setKeyHandle('test2');
0 ignored issues
show
Bug introduced by
The method setKeyHandle() does not exist on PHPUnit\Framework\MockObject\MockObject. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

29
        $key->/** @scrutinizer ignore-call */ 
30
              setKeyHandle('test2');

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.

Loading history...
30
        $this->assertEquals($key->keyHandle, 'test2');
31
        $this->assertEquals($key->getKeyHandle(), 'test2');
32
    }
33
34
    public function testPublicKey()
35
    {
36
        $key = $this->getKey();
37
        $this->assertNull($key->publicKey);
0 ignored issues
show
Bug introduced by
Accessing publicKey on the interface PHPUnit\Framework\MockObject\MockObject suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
38
39
        $key->publicKey = 'test1';
40
        $this->assertEquals($key->publicKey, 'test1');
41
        $this->assertEquals($key->getPublicKey(), 'test1');
0 ignored issues
show
Bug introduced by
The method getPublicKey() does not exist on PHPUnit\Framework\MockObject\MockObject. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

41
        $this->assertEquals($key->/** @scrutinizer ignore-call */ getPublicKey(), 'test1');

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.

Loading history...
42
43
        $key->setPublicKey('test2');
0 ignored issues
show
Bug introduced by
The method setPublicKey() does not exist on PHPUnit\Framework\MockObject\MockObject. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

43
        $key->/** @scrutinizer ignore-call */ 
44
              setPublicKey('test2');

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.

Loading history...
44
        $this->assertEquals($key->publicKey, 'test2');
45
        $this->assertEquals($key->getPublicKey(), 'test2');
46
    }
47
48
    public function testCertificate()
49
    {
50
        $key = $this->getKey();
51
        $this->assertNull($key->certificate);
0 ignored issues
show
Bug introduced by
Accessing certificate on the interface PHPUnit\Framework\MockObject\MockObject suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
52
53
        $key->certificate = 'test1';
54
        $this->assertEquals($key->certificate, 'test1');
55
        $this->assertEquals($key->getCertificate(), 'test1');
0 ignored issues
show
Bug introduced by
The method getCertificate() does not exist on PHPUnit\Framework\MockObject\MockObject. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

55
        $this->assertEquals($key->/** @scrutinizer ignore-call */ getCertificate(), 'test1');

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.

Loading history...
56
57
        $key->setCertificate('test2');
0 ignored issues
show
Bug introduced by
The method setCertificate() does not exist on PHPUnit\Framework\MockObject\MockObject. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

57
        $key->/** @scrutinizer ignore-call */ 
58
              setCertificate('test2');

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.

Loading history...
58
        $this->assertEquals($key->certificate, 'test2');
59
        $this->assertEquals($key->getCertificate(), 'test2');
60
    }
61
62
    public function testCounter()
63
    {
64
        $key = $this->getKey();
65
        $this->assertNull($key->counter);
0 ignored issues
show
Bug introduced by
Accessing counter on the interface PHPUnit\Framework\MockObject\MockObject suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
66
67
        $key->counter = 100;
68
        $this->assertEquals($key->counter, 100);
69
        $this->assertEquals($key->getCounter(), 100);
0 ignored issues
show
Bug introduced by
The method getCounter() does not exist on PHPUnit\Framework\MockObject\MockObject. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

69
        $this->assertEquals($key->/** @scrutinizer ignore-call */ getCounter(), 100);

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.

Loading history...
70
71
        $key->setCounter(200);
0 ignored issues
show
Bug introduced by
The method setCounter() does not exist on PHPUnit\Framework\MockObject\MockObject. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

71
        $key->/** @scrutinizer ignore-call */ 
72
              setCounter(200);

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.

Loading history...
72
        $this->assertEquals($key->counter, 200);
73
        $this->assertEquals($key->getCounter(), 200);
74
    }
75
76
    public function testUser()
77
    {
78
        $key = $this->getKey();
79
        $this->assertNull($key->getUser());
0 ignored issues
show
Bug introduced by
The method getUser() does not exist on PHPUnit\Framework\MockObject\MockObject. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

79
        $this->assertNull($key->/** @scrutinizer ignore-call */ getUser());

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.

Loading history...
80
81
        $user = $this->getMockForAbstractClass(U2fUser::class);
82
        $key->setUser($user);
0 ignored issues
show
Bug introduced by
The method setUser() does not exist on PHPUnit\Framework\MockObject\MockObject. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

82
        $key->/** @scrutinizer ignore-call */ 
83
              setUser($user);

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.

Loading history...
83
        $this->assertEquals($key->getUser(), $user);
84
    }
85
86
    protected function getKey()
87
    {
88
        return $this->getMockForAbstractClass(U2fKey::class);
89
    }
90
}
91