Passed
Pull Request — master (#60)
by Tim
02:17
created

HMACOutputLengthTest::provideHMACOutputLength()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 10
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 12
rs 9.9332
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\Test\XMLSecurity\Assert;
6
7
use PHPUnit\Framework\Attributes\{CoversClass, DataProvider};
2 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\Attributes\DataProvider was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
Bug introduced by
The type PHPUnit\Framework\Attributes\CoversClass was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use PHPUnit\Framework\TestCase;
9
use SimpleSAML\Assert\AssertionFailedException;
10
use SimpleSAML\XMLSecurity\Assert\Assert;
11
12
/**
13
 * Class \SimpleSAML\Test\XMLSecurity\Assert\HMACOutputLengthTest
14
 *
15
 * @package simplesamlphp/xml-security
16
 */
17
#[CoversClass(Assert::class)]
18
final class HMACOutputLengthTest extends TestCase
19
{
20
    /**
21
     * @param boolean $shouldPass
22
     * @param string $HMACOutputLength
23
     */
24
    #[DataProvider('provideHMACOutputLength')]
25
    public function testValidHMACOutputLength(bool $shouldPass, string $HMACOutputLength): void
26
    {
27
        try {
28
            Assert::validHMACOutputLength($HMACOutputLength);
29
            $this->assertTrue($shouldPass);
30
        } catch (AssertionFailedException $e) {
31
            $this->assertFalse($shouldPass);
32
        }
33
    }
34
35
36
    /**
37
     * @return array<string, array{0: bool, 1: string}>
38
     */
39
    public static function provideHMACOutputLength(): array
40
    {
41
        return [
42
            'empty' => [false, ''],
43
            'valid positive integer' => [true, '128'],
44
            'invalid indivisible by 8' => [false, '4'],
45
            'invalid signed positive integer' => [false, '+128'],
46
            'invalid zero' => [false, '0'],
47
            'invalid leading zeros' => [false, '0000000000000000000128'],
48
            'invalid with fractional' => [false, '1.'],
49
            'invalid negative' => [false, '-128'],
50
            'invalid with thousands-delimiter' => [false, '1,28'],
51
        ];
52
    }
53
}
54