Completed
Push — master ( fa5fd4...7a15ce )
by Nic
07:40
created

PasswordEncryptor_BCryptTest::testEncrypt()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Dynamic\FoxyStripe\Test;
4
5
use Dynamic\FoxyStripe\Security\PasswordEncryptor_BCrypt;
6
use SilverStripe\Dev\FunctionalTest;
7
8
/**
9
 * Class PasswordEncryptor_BCryptTest
10
 * @package Dynamic\FoxyStripe\Test
11
 */
12
class PasswordEncryptor_BCryptTest extends FunctionalTest
13
{
14
    /**
15
     *
16
     */
17
    public function testGetCost()
18
    {
19
        $encryptor = new PasswordEncryptor_BCrypt();
20
21
        $this->assertEquals(10, $encryptor::get_cost());
22
    }
23
24
    /**
25
     *
26
     */
27
    public function testSetCost()
28
    {
29
        $encryptor = new PasswordEncryptor_BCrypt();
30
31
        $original = $encryptor::get_cost();
0 ignored issues
show
Unused Code introduced by
The assignment to $original is dead and can be removed.
Loading history...
32
33
        $encryptor::set_cost(15);
34
35
        $this->assertEquals(15, $encryptor::get_cost());
36
    }
37
38
    /**
39
     *
40
     */
41
    public function testEncrypt()
42
    {
43
        $encryptor = new PasswordEncryptor_BCrypt();
44
45
        $pass = 'foobarbaz';
46
47
        $expected = password_hash($pass, PASSWORD_BCRYPT, ['cost' => $encryptor::get_cost()]);
48
49
        $this->assertTrue(password_verify($pass, $expected));
50
    }
51
}
52