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

YubikeyFormTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

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

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
     * @var YubikeyForm;
16
     */
17
    protected $form;
18
19
    protected function setUp()
20
    {
21
        parent::setUp();
22
        $backURL = '/test/url';
23
        $request = new HTTPRequest('GET', '/', ['BackURL' => $backURL]);
24
        $request->setSession(new Session(['hi' => 'bye']));
25
        $controller = new Controller();
26
        $controller->setRequest($request);
27
        $this->form = YubikeyForm::create($controller);
28
    }
29
30
    public function testBackURL()
31
    {
32
        $fields = $this->form->getFormFields();
33
34
        $this->assertNotNull($fields->dataFieldByName('BackURL'));
35
36
    }
37
38
    public function testAuthenticatorName()
39
    {
40
        $this->assertEquals('Yubikey authentication', $this->form->getAuthenticatorName());
41
    }
42
43
}