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

YumlClientTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 115
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 5
c 1
b 0
f 1
lcom 1
cbo 3
dl 0
loc 115
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A testIsInstanceOf() 0 22 1
B testGetMetadata() 0 41 1
A testGetGraphUrl() 0 8 1
A testDownloadFile() 0 20 1
1
<?php
2
namespace OnurbTest\Bundle\YumlBundle\Yuml;
3
4
use Onurb\Bundle\YumlBundle\DataCollector\DoctrineYumlDataCollector;
5
use Onurb\Bundle\YumlBundle\Yuml\YumlClient;
6
use Onurb\Doctrine\ORMMetadataGrapher\YUMLMetadataGrapherInterface;
7
use Symfony\Component\HttpFoundation\Response;
8
use Symfony\Component\HttpFoundation\Request;
9
use Doctrine\ORM\EntityManagerInterface;
10
11
class YumlClientTest extends \PHPUnit_Framework_TestCase
12
{
13
14
    public function setUp()
15
    {
16
        parent::setUp();
17
    }
18
19
    /**
20
     * @covers \Onurb\Bundle\YumlBundle\Yuml\YumlClient
21
     */
22
    public function testIsInstanceOf()
23
    {
24
        $entityManager = $this->getMock("Doctrine\\ORM\\EntityManagerInterface");
25
        $metadataFactory = $this->getMockBuilder("Doctrine\\Common\\Persistence\\Mapping\\ClassMetadataFactory")
26
            ->setMethods(array(
27
                'getAllMetadata',
28
                'getMetadataFor',
29
                'hasMetadataFor',
30
                'setMetadataFor',
31
                'isTransient',
32
                'setEntityManager',
33
            ))
34
            ->getMock();
35
36
        $metadataFactory->expects($this->once())->method('setEntityManager');
37
38
        $metadataGrapher = $this->getMockBuilder('Onurb\\Doctrine\\ORMMetadataGrapher\\YUMLMetadataGrapherInterface')
39
            ->getMock();
40
41
        $client = new YumlClient($entityManager, $metadataFactory, $metadataGrapher);
42
        $this->assertInstanceOf("Onurb\\Bundle\\YumlBundle\\Yuml\\YumlClient", $client);
43
    }
44
45
    /**
46
     * @covers \Onurb\Bundle\YumlBundle\Yuml\YumlClient
47
     */
48
    public function testGetMetadata()
49
    {
50
        $entityManager = $this->getMock("Doctrine\\ORM\\EntityManagerInterface");
51
52
        $metadataFactory = $this->getMockBuilder("Doctrine\\Common\\Persistence\\Mapping\\ClassMetadataFactory")
53
            ->setMethods(array(
54
                'getAllMetadata',
55
                'getMetadataFor',
56
                'hasMetadataFor',
57
                'setMetadataFor',
58
                'isTransient',
59
                'setEntityManager',
60
            ))
61
            ->getMock();
62
63
        $metadataFactory->expects($this->once())->method('setEntityManager');
64
65
        $class = $class = $this->getMock('Doctrine\\Common\\Persistence\\Mapping\\ClassMetadata');
66
        $class->expects($this->any())->method('getName')->will($this->returnValue('Simple\\Entity'));
67
        $class->expects($this->any())->method('getFieldNames')->will($this->returnValue(array('a', 'b', 'c')));
68
        $class->expects($this->any())->method('getAssociationNames')->will($this->returnValue(array()));
69
        $class->expects($this->any())->method('isIdentifier')->will(
70
            $this->returnCallback(
71
                function ($field) {
72
                    return $field === 'a';
73
                }
74
            )
75
        );
76
77
        $metadataFactory->expects($this->once())->method('getAllMetadata')->will($this->returnValue(array($class)));
78
79
        $metadataGrapher = $this->getMockBuilder('Onurb\\Doctrine\\ORMMetadataGrapher\\YUMLMetadataGrapherInterface')
80
            ->getMock();
81
82
        $metadataGrapher->expects($this->once())->method('generateFromMetadata')
83
            ->will($this->returnValue('[Simple.Entity|+a;b;c]'));
84
85
        $client = new YumlClient($entityManager, $metadataFactory, $metadataGrapher);
86
87
        $this->assertSame('[Simple.Entity|+a;b;c]', $client->makeDslText());
88
    }
89
90
    /**
91
     * @covers \Onurb\Bundle\YumlBundle\Yuml\YumlClient
92
     */
93
    public function testGetGraphUrl()
94
    {
95
        $entityManager = $this->getMock("Doctrine\\ORM\\EntityManagerInterface");
96
97
        $client = new YumlClient($entityManager);
98
99
        $this->assertSame('http://yuml.me/15a98c92.png', $client->getGraphUrl('[Simple.Entity|+a;b;c]'));
100
    }
101
102
    /**
103
     * @covers \Onurb\Bundle\YumlBundle\Yuml\YumlClient
104
     */
105
    public function testDownloadFile()
106
    {
107
        $filename = 'test.png';
108
        $entityManager = $this->getMock("Doctrine\\ORM\\EntityManagerInterface");
109
110
        $client = new YumlClient($entityManager);
111
112
        $curl = $this->getMockBuilder('Onurb\\Bundle\\YumlBundle\\Curl\\CurlInterface')
113
            ->setMethods(array(
114
                '__construct',
115
                'setPosts',
116
                'setOutput',
117
                'getResponse',
118
            ))
119
            ->getMock();
120
        $curl->expects($this->once())->method('setOutput');
121
        $curl->expects($this->once())->method('getResponse')->will($this->returnValue(true));
122
        $result = $client->downloadImage('http://testUrl.test', $filename, $curl);
123
        $this->assertSame(true, $result);
124
    }
125
}
126