Passed
Push — master ( 9c0ce0...43ac81 )
by Alex
52s queued 11s
created

CurlWrapperUnitTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 10
dl 0
loc 29
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetRequest() 0 6 1
A testPostRequest() 0 12 1
1
<?php
2
3
namespace Mezon\CustomClient\Tests;
4
5
use PHPUnit\Framework\TestCase;
6
use Mezon\CustomClient\CurlWrapper;
7
8
class CurlWrapperUnitTest extends TestCase
9
{
10
11
    /**
12
     * Testing GET requests
13
     */
14
    public function testGetRequest()
15
    {
16
        list ($body, $code) = CurlWrapper::sendRequest('http://google.com', [], 'GET');
17
18
        $this->assertStringContainsString('', $body, 'Invalid HTML was returned');
0 ignored issues
show
Bug introduced by
It seems like $body can also be of type boolean; however, parameter $haystack of PHPUnit\Framework\Assert...tStringContainsString() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

18
        $this->assertStringContainsString('', /** @scrutinizer ignore-type */ $body, 'Invalid HTML was returned');
Loading history...
19
        $this->assertEquals(301, $code, 'Invalid HTTP code');
20
    }
21
22
    /**
23
     * Testing POST requests
24
     */
25
    public function testPostRequest()
26
    {
27
        list ($body, $code) = CurlWrapper::sendRequest(
28
            'http://google.com',
29
            [],
30
            'POST',
31
            [
32
                'data' => 1
33
            ]);
34
35
        $this->assertStringContainsString('', $body, 'Invalid HTML was returned');
0 ignored issues
show
Bug introduced by
It seems like $body can also be of type boolean; however, parameter $haystack of PHPUnit\Framework\Assert...tStringContainsString() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

35
        $this->assertStringContainsString('', /** @scrutinizer ignore-type */ $body, 'Invalid HTML was returned');
Loading history...
36
        $this->assertEquals(405, $code, 'Invalid HTTP code');
37
    }
38
}
39