Code Duplication    Length = 15-16 lines in 2 locations

module/Rest/test/Middleware/BodyParserMiddlewareTest.php 2 locations

@@ 44-59 (lines=16) @@
41
    /**
42
     * @test
43
     */
44
    public function jsonRequestsAreJsonDecoded()
45
    {
46
        $body = new Stream('php://temp', 'wr');
47
        $body->write('{"foo": "bar", "bar": ["one", 5]}');
48
        $request = ServerRequestFactory::fromGlobals()->withMethod('PUT')
49
                                                      ->withBody($body)
50
                                                      ->withHeader('content-type', 'application/json');
51
        $test = $this;
52
        $this->middleware->__invoke($request, new Response(), function (Request $req, $resp) use ($test, $request) {
53
            $test->assertNotSame($request, $req);
54
            $test->assertEquals([
55
                'foo' => 'bar',
56
                'bar' => ['one', 5],
57
            ], $req->getParsedBody());
58
        });
59
    }
60
61
    /**
62
     * @test
@@ 64-78 (lines=15) @@
61
    /**
62
     * @test
63
     */
64
    public function regularRequestsAreUrlDecoded()
65
    {
66
        $body = new Stream('php://temp', 'wr');
67
        $body->write('foo=bar&bar[]=one&bar[]=5');
68
        $request = ServerRequestFactory::fromGlobals()->withMethod('PUT')
69
                                                      ->withBody($body);
70
        $test = $this;
71
        $this->middleware->__invoke($request, new Response(), function (Request $req, $resp) use ($test, $request) {
72
            $test->assertNotSame($request, $req);
73
            $test->assertEquals([
74
                'foo' => 'bar',
75
                'bar' => ['one', 5],
76
            ], $req->getParsedBody());
77
        });
78
    }
79
}
80