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 ( 99f3de...be50a6 )
by Bruno
22:10 queued 20:28
created

YumlClientTest::testGetGraphUrl()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 72
Code Lines 51

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 1
Metric Value
c 1
b 1
f 1
dl 0
loc 72
rs 9.102
cc 1
eloc 51
nc 1
nop 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
namespace OnurbTest\Bundle\YumlBundle\Yuml;
3
4
use Onurb\Bundle\YumlBundle\Yuml\YumlClient;
5
use PHPUnit\Framework\TestCase;
6
7
class YumlClientTest extends TestCase
8
{
9
10
    public function setUp()
11
    {
12
        parent::setUp();
13
    }
14
15
    /**
16
     * @covers \Onurb\Bundle\YumlBundle\Yuml\YumlClient
17
     */
18
    public function testIsInstanceOf()
19
    {
20
        $entityManager = $this->createMock("Doctrine\\ORM\\EntityManagerInterface");
21
        $metadataFactory = $this->getMockBuilder("Doctrine\\Common\\Persistence\\Mapping\\ClassMetadataFactory")
22
            ->setMethods(array(
23
                'getAllMetadata',
24
                'getMetadataFor',
25
                'hasMetadataFor',
26
                'setMetadataFor',
27
                'isTransient',
28
                'setEntityManager',
29
            ))
30
            ->getMock();
31
32
        $metadataFactory->expects($this->once())->method('setEntityManager');
33
34
        $metadataGrapher = $this->getMockBuilder('Onurb\\Doctrine\\ORMMetadataGrapher\\YUMLMetadataGrapherInterface')
35
            ->getMock();
36
37
        $client = new YumlClient($entityManager, $metadataFactory, $metadataGrapher);
0 ignored issues
show
Documentation introduced by Nono1971
$entityManager is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Doctrine\ORM\EntityManagerInterface>.

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...
Documentation introduced by Nono1971
$metadataGrapher is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a null|object<Onurb\Doctri...tadataGrapherInterface>.

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...
38
        $this->assertInstanceOf("Onurb\\Bundle\\YumlBundle\\Yuml\\YumlClient", $client);
39
    }
40
41
    /**
42
     * @covers \Onurb\Bundle\YumlBundle\Yuml\YumlClient
43
     */
44
    public function testGetMetadata()
45
    {
46
        $entityManager = $this->createMock("Doctrine\\ORM\\EntityManagerInterface");
47
48
        $metadataFactory = $this->getMockBuilder("Doctrine\\Common\\Persistence\\Mapping\\ClassMetadataFactory")
49
            ->setMethods(array(
50
                'getAllMetadata',
51
                'getMetadataFor',
52
                'hasMetadataFor',
53
                'setMetadataFor',
54
                'isTransient',
55
                'setEntityManager',
56
            ))
57
            ->getMock();
58
59
        $metadataFactory->expects($this->once())->method('setEntityManager');
60
61
        $class = $this->createmock('Doctrine\\Common\\Persistence\\Mapping\\ClassMetadata');
62
        $class->expects($this->any())->method('getName')->will($this->returnValue('Simple\\Entity'));
63
        $class->expects($this->any())->method('getFieldNames')->will($this->returnValue(array('a', 'b', 'c')));
64
        $class->expects($this->any())->method('getAssociationNames')->will($this->returnValue(array()));
65
        $class->expects($this->any())->method('isIdentifier')->will(
66
            $this->returnCallback(
67
                function ($field) {
68
                    return $field === 'a';
69
                }
70
            )
71
        );
72
73
        $metadataFactory->expects($this->once())->method('getAllMetadata')->will($this->returnValue(array($class)));
74
75
        $metadataGrapher = $this->getMockBuilder('Onurb\\Doctrine\\ORMMetadataGrapher\\YUMLMetadataGrapherInterface')
76
            ->getMock();
77
78
        $metadataGrapher->expects($this->once())->method('generateFromMetadata')
79
            ->will($this->returnValue('[Simple.Entity|+a;b;c]'));
80
81
        $client = new YumlClient($entityManager, $metadataFactory, $metadataGrapher);
0 ignored issues
show
Documentation introduced by Nono1971
$entityManager is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Doctrine\ORM\EntityManagerInterface>.

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...
Documentation introduced by Nono1971
$metadataGrapher is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a null|object<Onurb\Doctri...tadataGrapherInterface>.

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...
82
83
        $this->assertSame('[Simple.Entity|+a;b;c]', $client->makeDslText());
84
    }
85
86
    /**
87
     * @covers \Onurb\Bundle\YumlBundle\Yuml\YumlClient
88
     */
89
    public function testGetGraphUrl()
90
    {
91
        $entityManager = $this->createMock("Doctrine\\ORM\\EntityManagerInterface");
92
93
        $client = new YumlClient($entityManager);
0 ignored issues
show
Documentation introduced by Nono1971
$entityManager is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Doctrine\ORM\EntityManagerInterface>.

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...
94
95
        $this->assertSame(
96
            'https://yuml.me/15a98c92.png',
97
            $client->getGraphUrl(
98
                '[Simple.Entity|+a;b;c]',
99
                'plain',
100
                'png',
101
                'TB',
102
                'normal'
103
            )
104
        );
105
106
        $this->assertSame(
107
            'https://yuml.me/15a98c92.jpg',
108
            $client->getGraphUrl(
109
                '[Simple.Entity|+a;b;c]',
110
                'plain',
111
                'jpg',
112
                'TB',
113
                'normal'
114
            )
115
        );
116
117
        $this->assertSame(
118
            'https://yuml.me/d6ba9ce1.png',
119
            $client->getGraphUrl(
120
                '[Simple.Entity|+a;b;c]',
121
                'plain',
122
                'png',
123
                'LR',
124
                'huge'
125
            )
126
        );
127
128
        $this->assertSame(
129
            'https://yuml.me/4f52303c.png',
130
            $client->getGraphUrl(
131
                '[Simple.Entity|+a;b;c]',
132
                'scruffy',
133
                'png',
134
                'LR',
135
                'big'
136
            )
137
        );
138
139
        $this->assertSame(
140
            'https://yuml.me/0df97f73.png',
141
            $client->getGraphUrl(
142
                '[Simple.Entity|+a;b;c]',
143
                'plain',
144
                'png',
145
                'RL',
146
                'small'
147
            )
148
        );
149
150
        $this->assertSame(
151
            'https://yuml.me/c066b235.svg',
152
            $client->getGraphUrl(
153
                '[Simple.Entity|+a;b;c]',
154
                'plain',
155
                'svg',
156
                'TB',
157
                'tiny'
158
            )
159
        );
160
    }
161
162
    /**
163
     * @covers \Onurb\Bundle\YumlBundle\Yuml\YumlClient
164
     */
165
    public function testDownloadFile()
166
    {
167
        $filename = 'test.png';
168
        $entityManager = $this->createMock("Doctrine\\ORM\\EntityManagerInterface");
169
170
        $client = new YumlClient($entityManager);
0 ignored issues
show
Documentation introduced by Nono1971
$entityManager is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Doctrine\ORM\EntityManagerInterface>.

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...
171
172
        $curl = $this->getMockBuilder('Onurb\\Bundle\\YumlBundle\\Curl\\CurlInterface')
173
            ->setMethods(array(
174
                '__construct',
175
                'setPosts',
176
                'setOutput',
177
                'getResponse',
178
            ))
179
            ->getMock();
180
        $curl->expects($this->once())->method('setOutput');
181
        $curl->expects($this->once())->method('getResponse')->will($this->returnValue(true));
182
        $result = $client->downloadImage('http://testUrl.test', $filename, $curl);
183
        $this->assertSame(true, $result);
184
    }
185
}
186