Passed
Push — master ( ddbf8b...086098 )
by Robbie
11:17
created

AjaxBypassTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 14
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testBypass() 0 12 1
1
<?php
2
3
namespace SilverStripe\Control\Tests\Middleware\ConfirmationMiddleware;
4
5
use SilverStripe\Control\HTTPRequest;
6
use SilverStripe\Control\Middleware\ConfirmationMiddleware\AjaxBypass;
7
use SilverStripe\Dev\SapphireTest;
8
9
class AjaxBypassTest extends SapphireTest
10
{
11
    public function testBypass()
12
    {
13
        $ajaxRequest = $this->createMock(HTTPRequest::class);
14
        $ajaxRequest->method('isAjax')->willReturn(true);
0 ignored issues
show
Bug introduced by
The method method() does not exist on PHPUnit\Framework\MockObject\MockObject. ( Ignorable by Annotation )

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

14
        $ajaxRequest->/** @scrutinizer ignore-call */ 
15
                      method('isAjax')->willReturn(true);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
15
16
        $simpleRequest = $this->createMock(HTTPRequest::class);
17
        $simpleRequest->method('isAjax')->willReturn(false);
18
19
        $ajaxBypass = new AjaxBypass();
20
21
        $this->assertFalse($ajaxBypass->checkRequestForBypass($simpleRequest));
22
        $this->assertTrue($ajaxBypass->checkRequestForBypass($ajaxRequest));
23
    }
24
}
25