Code Duplication    Length = 25-30 lines in 2 locations

src/Tests/Request/ContentDecoder/ContentDecoderJmsSerializerCompatibilityTest.php 2 locations

@@ 49-78 (lines=30) @@
46
    /**
47
     * @test
48
     */
49
    public function canDeserializeIntoObject()
50
    {
51
        $content = [
52
            'foo' => 'bar'
53
        ];
54
        $request = new Request([], [], [], [], [], [], json_encode($content));
55
        $request->headers->set('Content-Type', 'application/json');
56
57
58
        $operationDefinition = (object)[
59
            'parameters' => [
60
                (object)[
61
                    "in"     => "body",
62
                    "name"   => "body",
63
                    "schema" => (object)[
64
                        '$ref' => "#/definitions/JmsAnnotatedResourceStub"
65
                    ]
66
                ]
67
            ]
68
        ];
69
70
        $operationObject = OperationObject::createFromOperationDefinition((object)$operationDefinition);
71
72
        $actual = $this->contentDecoder->decodeContent($request, $operationObject);
73
74
        $className = 'KleijnWeb\SwaggerBundle\Tests\Request\ContentDecoder\JmsAnnotatedResourceStub';
75
        $expected = (new $className)->setFoo('bar');
76
77
        $this->assertEquals($expected, $actual);
78
    }
79
80
    /**
81
     * @test
@@ 101-125 (lines=25) @@
98
     *
99
     * @param string $contentType
100
     */
101
    public function willAlwaysDecodeJson($contentType)
102
    {
103
        $content = '{ "foo": "bar" }';
104
        $request = new Request([], [], [], [], [], [], $content);
105
        $request->headers->set('Content-Type', $contentType);
106
107
        $operationDefinition = (object)[
108
            'parameters' => [
109
                (object)[
110
                    "in"     => "body",
111
                    "name"   => "body",
112
                    "schema" => (object)[
113
                        '$ref' => "#/definitions/JmsAnnotatedResourceStub"
114
                    ]
115
                ]
116
            ]
117
        ];
118
119
        $operationObject = OperationObject::createFromOperationDefinition((object)$operationDefinition);
120
121
        $actual = $this->contentDecoder->decodeContent($request, $operationObject);
122
        $className = 'KleijnWeb\SwaggerBundle\Tests\Request\ContentDecoder\JmsAnnotatedResourceStub';
123
        $expected = (new $className)->setFoo('bar');
124
        $this->assertEquals($expected, $actual);
125
    }
126
127
    /**
128
     * @return array