Passed
Push — develop ( 5f4d18...5cbd49 )
by Mathieu
01:36
created

CurlTest::testMethod()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 9
rs 10
1
<?php
2
/**
3
 * @SuppressWarnings("StaticAccess")
4
 */
5
class CurlTest extends \PHPUnit\Framework\TestCase
6
{
7
    public function testConstruct()
8
    {
9
        $handler = \Suricate\Suricate::Curl();
0 ignored issues
show
Bug introduced by
The method Curl() does not exist on Suricate\Suricate. Since you implemented __callStatic, consider adding a @method annotation. ( Ignorable by Annotation )

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

9
        /** @scrutinizer ignore-call */ 
10
        $handler = \Suricate\Suricate::Curl();
Loading history...
10
        $reflection = new \ReflectionClass(get_class($handler));
11
        $property = $reflection->getProperty('response');
12
        $property->setAccessible(true);
13
        $this->assertInstanceOf(\Suricate\Request::class, $property->getValue($handler));
14
15
        $property = $reflection->getProperty('request');
16
        $property->setAccessible(true);
17
        $this->assertInstanceOf(\Suricate\Request::class, $property->getValue($handler));
18
    }
19
20
    public function testGetSetUrl()
21
    {
22
        $handler = \Suricate\Suricate::Curl();
23
        $this->assertSame(null, $handler->getUrl());
24
        $handler->setUrl('https://www.google.com');
25
        $this->assertSame('https://www.google.com', $handler->getUrl());
26
    }
27
28
    public function testMethod()
29
    {
30
        $handler = \Suricate\Suricate::Curl();
31
        $handler->setMethod('DELETE');
32
        $reflection = new \ReflectionClass(get_class($handler));
33
        $property = $reflection->getProperty('request');
34
        $property->setAccessible(true);
35
        $request = $property->getValue($handler);
36
        $this->assertSame('DELETE', $request->getMethod());
37
    }
38
39
    public function testSetUA()
40
    {
41
        $handler = \Suricate\Suricate::Curl();
42
        $handler->setUserAgent('GoogleBot');
43
44
        $this->assertSame('GoogleBot', $handler->userAgent);
45
    }
46
47
    public function testAddHeader()
48
    {
49
        $handler = \Suricate\Suricate::Curl();
50
51
        $this->assertSame([], $handler->headers);
52
        $handler->addHeader('Content-type: application/json');
53
        $this->assertSame(['Content-type: application/json'], $handler->headers);
54
        $handler->addHeader('Content-length: 42');
55
        $this->assertSame(['Content-type: application/json', 'Content-length: 42'], $handler->headers);
56
    }
57
}
58