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 ( df8a9b...9b5ad9 )
by Bruno
03:20
created

Bundle/YumlBundle/Yuml/YumlClientTest.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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);
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) {
0 ignored issues
show
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
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);
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);
94
95
        $this->assertSame('https://yuml.me/15a98c92.png', $client->getGraphUrl('[Simple.Entity|+a;b;c]'));
96
    }
97
98
    /**
99
     * @covers \Onurb\Bundle\YumlBundle\Yuml\YumlClient
100
     */
101
    public function testDownloadFile()
102
    {
103
        $filename = 'test.png';
104
        $entityManager = $this->createMock("Doctrine\\ORM\\EntityManagerInterface");
105
106
        $client = new YumlClient($entityManager);
107
108
        $curl = $this->getMockBuilder('Onurb\\Bundle\\YumlBundle\\Curl\\CurlInterface')
109
            ->setMethods(array(
110
                '__construct',
111
                'setPosts',
112
                'setOutput',
113
                'getResponse',
114
            ))
115
            ->getMock();
116
        $curl->expects($this->once())->method('setOutput');
117
        $curl->expects($this->once())->method('getResponse')->will($this->returnValue(true));
118
        $result = $client->downloadImage('http://testUrl.test', $filename, $curl);
119
        $this->assertSame(true, $result);
120
    }
121
}
122