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

PasswordEncryptor_BCryptTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testEncrypt() 0 9 1
A testGetCost() 0 5 1
A testSetCost() 0 9 1
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