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

AjaxBypassTest::testBypass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
nc 1
nop 0
dl 0
loc 12
rs 10
c 0
b 0
f 0
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