Completed
Push — master ( e3e13b...942b41 )
by Charles
11:47
created

UtilsTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 21
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testSigningKeypairGeneration() 0 5 1
A testKeypairGeneration() 0 5 1
A testZero() 0 5 1
1
<?php declare(strict_types=1);
2
3
namespace ncryptf\Tests;
4
5
use ncryptf\Utils;
6
use PHPUnit\Framework\TestCase;
7
8
class UtilsTest extends TestCase
9
{
10
    public function testKeypairGeneration()
11
    {
12
        $keypair = Utils::generateKeypair();
13
        $this->assertEquals(32, \strlen($keypair['public']));
14
        $this->assertEquals(32, \strlen($keypair['secret']));
15
    }
16
17
    public function testSigningKeypairGeneration()
18
    {
19
        $keypair = Utils::generateSigningKeypair();
20
        $this->assertEquals(64, \strlen($keypair['public']));
21
        $this->assertEquals(32, \strlen($keypair['secret']));
22
    }
23
24
    public function testZero()
25
    {
26
        $data = \random_bytes(32);
27
        $zero = Utils::zero($data);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $zero is correct as ncryptf\Utils::zero($data) targeting ncryptf\Utils::zero() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
28
        $this->assertEquals($zero, null);
29
    }
30
}
31