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.
Completed
Push — master ( cd261d...1a4b18 )
by Bruno
41:57
created

CurlTest::testResponseWithPostData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 13
rs 9.4285
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
namespace OnurbTest\Bundle\YumlBundle\Curl;
3
4
use Onurb\Bundle\YumlBundle\Curl\Curl;
5
6
class CurlTest extends \PHPUnit_Framework_TestCase
7
{
8
    /**
9
     * @covers \Onurb\Bundle\YumlBundle\Curl\Curl
10
     */
11
    public function testIsInstanceOf()
12
    {
13
        $testUrl = 'http://testUrl.test';
14
        $curl = curl_init();
15
        $curlClass = new Curl($testUrl, $curl);
0 ignored issues
show
Documentation introduced by
$curl is of type resource, but the function expects a string|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
16
        $this->assertInstanceOf('Onurb\\Bundle\\YumlBundle\\Curl\\CurlInterface', $curlClass);
17
18
        $this->assertSame($testUrl, curl_getinfo($curl, CURLINFO_EFFECTIVE_URL));
19
20
        curl_close($curl);
21
    }
22
23
    /**
24
     * @covers \Onurb\Bundle\YumlBundle\Curl\Curl
25
     * @expectedException \Exception
26
     */
27
    public function testResponseWithWrongUrl()
28
    {
29
        $testUrl = 'http://localhost.test/url_that_doesnt_exists';
30
        $curl = new Curl($testUrl);
31
32
        $curl->getResponse();
33
    }
34
35
    /**
36
     * @covers \Onurb\Bundle\YumlBundle\Curl\Curl
37
     */
38
    public function testResponseWithCorrectUrl()
39
    {
40
        $testUrl = 'http://yuml.me';
41
        $curl = new Curl($testUrl);
42
43
        $response = $curl->getResponse();
44
        $this->assertSame('<!DOCTYPE', explode(' ', $response)[0]);
45
    }
46
47
    /**
48
     * @covers \Onurb\Bundle\YumlBundle\Curl\Curl
49
     */
50
    public function testResponseWithPostData()
51
    {
52
        $testUrl = 'http://yuml.me/diagram/plain/class';
53
        $curl = new Curl($testUrl);
54
55
        $posts = array(
56
            'dsl_text' => '[Simple.Entity|+a;b;c]'
57
        );
58
        $curl->setPosts($posts);
59
        $response = $curl->getResponse();
60
61
        $this->assertSame('15a98c92.png', $response);
62
    }
63
64
    /**
65
     * @covers \Onurb\Bundle\YumlBundle\Curl\Curl
66
     */
67
    public function testDowloadFile()
68
    {
69
        $fileUrl = 'http://yuml.me/15a98c92.png';
70
        $fileName = 'test.png';
71
72
        $this->assertFalse(file_exists($fileName));
73
74
        $curl = new Curl($fileUrl);
75
        $curl->setOutput($fileName);
76
        $curl->getResponse();
77
78
        $this->assertTrue(file_exists($fileName));
79
        if (file_exists($fileName)) {
80
            unlink($fileName);
81
        }
82
    }
83
}
84