Passed
Pull Request — master (#3)
by Robbie
02:02
created

MethodAuthenticationHandlerTest::testVerify()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
nc 1
nop 0
dl 0
loc 15
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace SilverStripe\MFA\Tests\BasicMath;
4
5
use PHPUnit_Framework_MockObject_MockObject;
6
use SilverStripe\Control\HTTPRequest;
7
use SilverStripe\Dev\SapphireTest;
8
use SilverStripe\MFA\BasicMath\MethodAuthenticationHandler;
9
use SilverStripe\MFA\Store\StoreInterface;
10
11
class MethodAuthenticationHandlerTest extends SapphireTest
12
{
13
    public function testStart()
14
    {
15
        $handler = new MethodAuthenticationHandler();
16
17
        /** @var StoreInterface|PHPUnit_Framework_MockObject_MockObject $store */
18
        $store = $this->createMock(StoreInterface::class);
19
        $store->expects($this->once())->method('setState');
20
21
        $this->assertArrayHasKey('numbers', $handler->start($store));
22
    }
23
24
    public function testVerify()
25
    {
26
        $handler = new MethodAuthenticationHandler();
27
28
        /** @var HTTPRequest|PHPUnit_Framework_MockObject_MockObject $request */
29
        $request = $this->createMock(HTTPRequest::class);
30
        $request->expects($this->once())->method('param')->with('answer')->willReturn(10);
31
32
        /** @var StoreInterface|PHPUnit_Framework_MockObject_MockObject $store */
33
        $store = $this->createMock(StoreInterface::class);
34
        $store->expects($this->once())->method('getState')->willReturn([
35
            'answer' => 10,
36
        ]);
37
38
        $this->assertTrue($handler->verify($request, $store));
39
    }
40
}
41