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

MethodTest::testDefaultTotpCodeLength()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
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