Code Duplication    Length = 16-17 lines in 5 locations

tests/JCRequestTest.php 5 locations

@@ 37-53 (lines=17) @@
34
        $this->assertEquals(200, $response->status());
35
    }
36
37
    public function testGetWithParams()
38
    {
39
        $url = $this->baseUrl . '/get?a=1';
40
41
        $response = JCRequest::get($url, $this->params, $this->headers);
42
        $this->assertEquals(200, $response->status());
43
        $this->assertNotEmpty($response->body());
44
45
        $responseData = $response->json();
46
        $this->assertEquals('https://httpbin.org/get?a=1&b=2&c=3', $responseData->url);
47
        $this->assertEquals(1, $responseData->args->a);
48
        $this->assertEquals(2, $responseData->args->b);
49
        $this->assertEquals(3, $responseData->args->c);
50
51
        $this->assertEquals('Jared Chu', $responseData->headers->{'User-Agent'});
52
        $this->assertEquals('application/json', $responseData->headers->{'Accept'});
53
    }
54
55
    public function testPost()
56
    {
@@ 55-70 (lines=16) @@
52
        $this->assertEquals('application/json', $responseData->headers->{'Accept'});
53
    }
54
55
    public function testPost()
56
    {
57
        $url = $this->baseUrl . '/post?a=1';
58
59
        $response = JCRequest::post($url, $this->params, $this->headers);
60
        $this->assertEquals(200, $response->status());
61
62
        $responseData = $response->json();
63
        $this->assertEquals('https://httpbin.org/post?a=1', $responseData->url);
64
        $this->assertEquals(1, $responseData->args->a);
65
        $this->assertEquals(2, $responseData->form->b);
66
        $this->assertEquals(3, $responseData->form->c);
67
68
        $this->assertEquals('Jared Chu', $responseData->headers->{'User-Agent'});
69
        $this->assertEquals('application/json', $responseData->headers->{'Accept'});
70
    }
71
72
    public function testPut()
73
    {
@@ 72-87 (lines=16) @@
69
        $this->assertEquals('application/json', $responseData->headers->{'Accept'});
70
    }
71
72
    public function testPut()
73
    {
74
        $url = $this->baseUrl . '/put?a=1';
75
76
        $response = JCRequest::put($url, $this->params, $this->headers);
77
        $this->assertEquals(200, $response->status());
78
79
        $responseData = $response->json();
80
        $this->assertEquals('https://httpbin.org/put?a=1', $responseData->url);
81
        $this->assertEquals(1, $responseData->args->a);
82
        $this->assertEquals(2, $responseData->form->b);
83
        $this->assertEquals(3, $responseData->form->c);
84
85
        $this->assertEquals('Jared Chu', $responseData->headers->{'User-Agent'});
86
        $this->assertEquals('application/json', $responseData->headers->{'Accept'});
87
    }
88
89
    public function testPatch()
90
    {
@@ 89-104 (lines=16) @@
86
        $this->assertEquals('application/json', $responseData->headers->{'Accept'});
87
    }
88
89
    public function testPatch()
90
    {
91
        $url = $this->baseUrl . '/patch?a=1';
92
93
        $response = JCRequest::patch($url, $this->params, $this->headers);
94
        $this->assertEquals(200, $response->status());
95
96
        $responseData = $response->json();
97
        $this->assertEquals('https://httpbin.org/patch?a=1', $responseData->url);
98
        $this->assertEquals(1, $responseData->args->a);
99
        $this->assertEquals(2, $responseData->form->b);
100
        $this->assertEquals(3, $responseData->form->c);
101
102
        $this->assertEquals('Jared Chu', $responseData->headers->{'User-Agent'});
103
        $this->assertEquals('application/json', $responseData->headers->{'Accept'});
104
    }
105
106
    public function testDelete()
107
    {
@@ 106-121 (lines=16) @@
103
        $this->assertEquals('application/json', $responseData->headers->{'Accept'});
104
    }
105
106
    public function testDelete()
107
    {
108
        $url = $this->baseUrl . '/delete?a=1';
109
110
        $response = JCRequest::delete($url, $this->params, $this->headers);
111
        $this->assertEquals(200, $response->status());
112
113
        $responseData = $response->json();
114
        $this->assertEquals('https://httpbin.org/delete?a=1', $responseData->url);
115
        $this->assertEquals(1, $responseData->args->a);
116
        $this->assertEquals(2, $responseData->form->b);
117
        $this->assertEquals(3, $responseData->form->c);
118
119
        $this->assertEquals('Jared Chu', $responseData->headers->{'User-Agent'});
120
        $this->assertEquals('application/json', $responseData->headers->{'Accept'});
121
    }
122
123
    public function testHead()
124
    {