GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

CurlTest   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 78
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 78
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testIsInstanceOf() 0 11 1
A testResponseWithWrongUrl() 0 7 1
A testResponseWithCorrectUrl() 0 8 1
A testResponseWithPostData() 0 13 1
A testDowloadFile() 0 16 2
1
<?php
2
namespace OnurbTest\Bundle\YumlBundle\Curl;
3
4
use Onurb\Bundle\YumlBundle\Curl\Curl;
5
use PHPUnit\Framework\TestCase;
6
7
class CurlTest extends TestCase
8
{
9
    /**
10
     * @covers \Onurb\Bundle\YumlBundle\Curl\Curl
11
     */
12
    public function testIsInstanceOf()
13
    {
14
        $testUrl = 'http://testUrl.test';
15
        $curl = curl_init();
16
        $curlClass = new Curl($testUrl, $curl);
17
        $this->assertInstanceOf('Onurb\\Bundle\\YumlBundle\\Curl\\CurlInterface', $curlClass);
18
19
        $this->assertSame($testUrl, curl_getinfo($curl, CURLINFO_EFFECTIVE_URL));
20
21
        curl_close($curl);
22
    }
23
24
    /**
25
     * @covers \Onurb\Bundle\YumlBundle\Curl\Curl
26
     * @expectedException \Exception
27
     */
28
    public function testResponseWithWrongUrl()
29
    {
30
        $testUrl = 'http://localhost.test/url_that_doesnt_exists';
31
        $curl = new Curl($testUrl);
32
33
        $curl->getResponse();
34
    }
35
36
    /**
37
     * @covers \Onurb\Bundle\YumlBundle\Curl\Curl
38
     */
39
    public function testResponseWithCorrectUrl()
40
    {
41
        $testUrl = 'https://yuml.me';
42
        $curl = new Curl($testUrl);
43
44
        $response = $curl->getResponse();
45
        $this->assertSame('<!DOCTYPE', explode(' ', $response)[0]);
46
    }
47
48
    /**
49
     * @covers \Onurb\Bundle\YumlBundle\Curl\Curl
50
     */
51
    public function testResponseWithPostData()
52
    {
53
        $testUrl = 'https://yuml.me/diagram/plain/class';
54
        $curl = new Curl($testUrl);
55
56
        $posts = array(
57
            'dsl_text' => '[Simple.Entity|+a;b;c]'
58
        );
59
        $curl->setPosts($posts);
60
        $response = $curl->getResponse();
61
62
        $this->assertSame('15a98c92.png', $response);
63
    }
64
65
    /**
66
     * @covers \Onurb\Bundle\YumlBundle\Curl\Curl
67
     */
68
    public function testDowloadFile()
69
    {
70
        $fileUrl = 'https://yuml.me/15a98c92.png';
71
        $fileName = 'test.png';
72
73
        $this->assertFalse(file_exists($fileName));
74
75
        $curl = new Curl($fileUrl);
76
        $curl->setOutput($fileName);
77
        $curl->getResponse();
78
79
        $this->assertTrue(file_exists($fileName));
80
        if (file_exists($fileName)) {
81
            unlink($fileName);
82
        }
83
    }
84
}
85