Completed
Push — v2.0.x ( 255948...c24837 )
by Florent
03:51
created

DirAlgorithmTest::testValidCEK()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 12
rs 9.4285
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
3
/*
4
 * The MIT License (MIT)
5
 *
6
 * Copyright (c) 2014-2016 Spomky-Labs
7
 *
8
 * This software may be modified and distributed under the terms
9
 * of the MIT license.  See the LICENSE file for details.
10
 */
11
12
use Base64Url\Base64Url;
13
use Jose\Algorithm\KeyEncryption\Dir;
14
use Jose\Object\JWK;
15
use Jose\Test\TestCase;
16
17
/**
18
 * Class DirAlgorithmTest.
19
 */
20
class DirAlgorithmTest extends TestCase
21
{
22
    /**
23
     * @expectedException \InvalidArgumentException
24
     * @expectedExceptionMessage The key is not valid
25
     */
26
    public function testInvalidKey()
27
    {
28
        $header = [];
29
        $key = new JWK([
30
            'kty' => 'EC',
31
        ]);
32
33
        $dir = new Dir();
34
35
        $dir->getCEK($key, $header);
0 ignored issues
show
Unused Code introduced by
The call to Dir::getCEK() has too many arguments starting with $header.

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.

Loading history...
36
    }
37
38
    /**
39
     *
40
     */
41
    public function testValidCEK()
42
    {
43
        $header = [];
44
        $key = new JWK([
45
            'kty' => 'dir',
46
            'dir' => Base64Url::encode('ABCD'),
47
        ]);
48
49
        $dir = new Dir();
50
51
        $this->assertEquals('ABCD', $dir->getCEK($key, $header));
0 ignored issues
show
Unused Code introduced by
The call to Dir::getCEK() has too many arguments starting with $header.

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.

Loading history...
52
    }
53
}
54