Completed
Pull Request — master (#2)
by thomas
71:58
created

EncryptionMnemonicTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 4
dl 0
loc 23
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getConsistencyCheckVectors() 0 6 1
A testConsistency() 0 5 1
1
<?php
2
3
namespace Btccom\JustEncrypt\Test;
4
5
use BitWasp\Buffertools\Buffer;
6
use BitWasp\Buffertools\BufferInterface;
7
use Btccom\JustEncrypt\EncryptionMnemonic;
8
9
class EncryptionMnemonicTest extends AbstractTestCase
10
{
11
    /**
12
     * @return array
13
     */
14
    public function getConsistencyCheckVectors()
15
    {
16
        return array_map(function (array $row) {
17
            return [Buffer::hex($row['data']), $row['mnemonic']];
18
        }, $this->getTestVectors()['mnemonic']);
19
    }
20
21
    /**
22
     * @dataProvider getConsistencyCheckVectors
23
     * @param BufferInterface $data
24
     * @param $mnemonic
25
     */
26
    public function testConsistency(BufferInterface $data, $mnemonic)
27
    {
28
        $this->assertEquals($mnemonic, EncryptionMnemonic::encode($data));
29
        $this->assertTrue($data->equals(EncryptionMnemonic::decode($mnemonic)));
0 ignored issues
show
Documentation introduced by
\Btccom\JustEncrypt\Encr...onic::decode($mnemonic) is of type object<BitWasp\Buffertools\BufferInterface>, but the function expects a object<self>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
30
    }
31
}
32