Argon2HasherTest::testArgon2Hashing()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 13
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
namespace KoenHoeijmakers\LaravelArgon2\Tests\Unit;
4
5
use PHPUnit\Framework\TestCase;
6
use KoenHoeijmakers\LaravelArgon2\Argon2Hasher;
7
8
class Argon2HasherTest extends TestCase
9
{
10
    public function testArgon2Hashing()
11
    {
12
        if (! defined('PASSWORD_ARGON2I')) {
13
            $this->markTestSkipped('PHP not compiled with argon2 hashing support.');
14
        }
15
16
        $hasher = new Argon2Hasher();
17
18
        $value = $hasher->make('password');
19
        $this->assertNotSame('password', $value);
20
        $this->assertTrue($hasher->check('password', $value));
21
        $this->assertFalse($hasher->needsRehash($value));
22
        $this->assertTrue($hasher->needsRehash($value, ['threads' => 1]));
23
    }
24
}
25