Passed
Pull Request — master (#13)
by Simon
01:50
created

YubikeyFormTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 9 1
A testAuthenticatorName() 0 3 1
A testBackURL() 0 5 1
1
<?php
2
3
namespace Firesphere\YubiAuth\Tests;
4
5
6
use Firesphere\YubiAuth\Forms\YubikeyForm;
7
use SilverStripe\Control\Controller;
8
use SilverStripe\Control\HTTPRequest;
9
use SilverStripe\Control\Session;
10
use SilverStripe\Dev\SapphireTest;
11
12
class YubikeyFormTest extends SapphireTest
13
{
14
15
    protected $form;
16
17
    protected function setUp()
18
    {
19
        parent::setUp();
20
        $backURL = '/test/url';
21
        $request = new HTTPRequest('GET', '/', ['BackURL' => $backURL]);
22
        $request->setSession(new Session(['hi' => 'bye']));
23
        $controller = new Controller();
24
        $controller->setRequest($request);
25
        $this->form = YubikeyForm::create($controller);
26
    }
27
28
    public function testBackURL()
29
    {
30
        $fields = $this->form->getFormFields();
31
32
        $this->assertNotNull($fields->dataFieldByName('BackURL'));
33
34
    }
35
36
    public function testAuthenticatorName()
37
    {
38
        $this->assertEquals('Yubikey authentication', $this->form->getAuthenticatorName());
39
    }
40
41
}