YubikeyFormTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 28
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
use Firesphere\YubiAuth\Forms\YubikeyForm;
6
use SilverStripe\Control\Controller;
7
use SilverStripe\Control\HTTPRequest;
8
use SilverStripe\Control\Session;
9
use SilverStripe\Dev\SapphireTest;
10
11
class YubikeyFormTest extends SapphireTest
12
{
13
    /**
14
     * @var YubikeyForm;
15
     */
16
    protected $form;
17
18
    public function testBackURL()
19
    {
20
        $fields = $this->form->getFormFields();
21
22
        $this->assertNotNull($fields->dataFieldByName('BackURL'));
0 ignored issues
show
Bug introduced by
The method dataFieldByName() does not exist on Firesphere\YubiAuth\Forms\YubikeyForm. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

22
        $this->assertNotNull($fields->/** @scrutinizer ignore-call */ dataFieldByName('BackURL'));
Loading history...
23
    }
24
25
    public function testAuthenticatorName()
26
    {
27
        $this->assertEquals('Yubikey authentication', $this->form->getAuthenticatorName());
28
    }
29
30
    protected function setUp()
31
    {
32
        parent::setUp();
33
        $backURL = '/test/url';
34
        $request = new HTTPRequest('GET', '/', ['BackURL' => $backURL]);
35
        $request->setSession(new Session(['hi' => 'bye']));
36
        $controller = new Controller();
37
        $controller->setRequest($request);
38
        $this->form = YubikeyForm::create($controller);
39
    }
40
}
41