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

DirAlgorithmTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4
Metric Value
wmc 2
lcom 0
cbo 4
dl 0
loc 34
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testInvalidKey() 0 11 1
A testValidCEK() 0 12 1
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