Passed
Push — master ( 17aa29...702623 )
by Alexander
01:34
created

PasswordHasherTest::testPasswordHash()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 11
rs 10
cc 1
nc 1
nop 0
1
<?php
2
namespace Yiisoft\Security\Tests;
3
4
use PHPUnit\Framework\TestCase;
5
use Yiisoft\Security\PasswordHasher;
6
7
class PasswordHasherTest extends TestCase
8
{
9
    public function testPasswordHash(): void
10
    {
11
        $password = new PasswordHasher(PASSWORD_BCRYPT, [
12
            // minimum blowfish's value is enough for tests
13
            'cost' => 4,
14
        ]);
15
16
        $secret = 'secret';
17
        $hash = $password->hash($secret);
18
        $this->assertTrue($password->validate($secret, $hash));
19
        $this->assertFalse($password->validate('test', $hash));
20
    }
21
}
22