Completed
Push — master ( 0d1193...76ec59 )
by
unknown
15s
created

MethodTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 5 1
A testDefaultTotpCodeLength() 0 4 1
A testIsAvailable() 0 9 1
1
<?php
2
3
namespace SilverStripe\TOTP\Tests;
4
5
use SilverStripe\Core\Environment;
6
use SilverStripe\Dev\SapphireTest;
7
use SilverStripe\TOTP\Method;
8
9
class MethodTest extends SapphireTest
10
{
11
    protected function setUp()
12
    {
13
        parent::setUp();
14
15
        Method::config()->set('code_length', 6);
16
    }
17
18
    public function testIsAvailable()
19
    {
20
        $method = new Method();
21
22
        Environment::setEnv('SS_MFA_SECRET_KEY', '');
23
        $this->assertFalse($method->isAvailable());
24
25
        Environment::setEnv('SS_MFA_SECRET_KEY', 'foo123');
26
        $this->assertTrue($method->isAvailable());
27
    }
28
29
    public function testDefaultTotpCodeLength()
30
    {
31
        $method = new Method();
32
        $this->assertSame(6, $method->getCodeLength(), 'Default code length should be 6');
33
    }
34
}
35