Passed
Pull Request — master (#373)
by Nic
13:50
created

PasswordEncryptor_BCryptTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testEncrypt() 0 7 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
class PasswordEncryptor_BCryptTest extends FunctionalTest
9
{
10
    public function testGetCost()
11
    {
12
        $encryptor = new PasswordEncryptor_BCrypt();
13
14
        $this->assertEquals(10, $encryptor::get_cost());
15
    }
16
17
    public function testSetCost()
18
    {
19
        $encryptor = new PasswordEncryptor_BCrypt();
20
21
        $original = $encryptor::get_cost();
0 ignored issues
show
Unused Code introduced by
The assignment to $original is dead and can be removed.
Loading history...
22
23
        $encryptor::set_cost(15);
24
25
        $this->assertEquals(15, $encryptor::get_cost());
26
    }
27
28
    public function testEncrypt()
29
    {
30
        $encryptor = new PasswordEncryptor_BCrypt();
31
32
        $hash = $encryptor->encrypt('Mu$kie$9');
33
34
        $this->assertTrue(hash_equals('$2y$10$mLQR4g09Sy6nih4o6bQL6upWfGB3TAgrx9ddnaHjM7nY0Usl9EbLq', $hash));
35
    }
36
}
37