Code Duplication    Length = 10-11 lines in 3 locations

tests/CsrfHeaderCheckMiddlewareFactoryTest.php 1 location

@@ 11-20 (lines=10) @@
8
9
class CsrfHeaderCheckMiddlewareFactoryTest extends AbstractMiddlewareTest
10
{
11
    public function testFactory()
12
    {
13
        $request = new ServerRequest([], [], "http://alice.com/hello", "Get");
14
15
        $middleware = CsrfHeaderCheckMiddlewareFactory::createDefault();
16
17
        $response = $middleware->process($request, $this->getDelegate());
18
19
        $this->assertSame('foobar', (string) $response->getBody());
20
    }
21
}
22

tests/CsrfHeaderCheckMiddlewareTest.php 2 locations

@@ 17-27 (lines=11) @@
14
15
class CsrfHeaderCheckMiddlewareTest extends AbstractMiddlewareTest
16
{
17
    public function testGetRequest()
18
    {
19
        $request = new ServerRequest([], [], "http://alice.com/hello", "Get");
20
21
        $middleware = new CsrfHeaderCheckMiddleware(IsSafeHttpMethod::fromDefaultSafeMethods());
22
23
24
        $response = $middleware->process($request, $this->getDelegate());
25
26
        $this->assertSame('foobar', (string) $response->getBody());
27
    }
28
29
    public function testFailingPostRequestNoOrigin()
30
    {
@@ 29-39 (lines=11) @@
26
        $this->assertSame('foobar', (string) $response->getBody());
27
    }
28
29
    public function testFailingPostRequestNoOrigin()
30
    {
31
        $request = new ServerRequest([], [], "http://alice.com/hello", "Post");
32
33
        $middleware = new CsrfHeaderCheckMiddleware(IsSafeHttpMethod::fromDefaultSafeMethods());
34
35
        $this->expectException(CsrfHeaderCheckMiddlewareException::class);
36
        $this->expectExceptionMessage('Could not find neither the ORIGIN header nor the REFERER header in the HTTP request.');
37
38
        $response = $middleware->process($request, $this->getDelegate());
39
    }
40
41
    public function testFailingPostRequestNoHost()
42
    {