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.

FakeControllerTest   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 95
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

6 Methods

Rating   Name   Duplication   Size   Complexity  
A testStreamAction() 0 19 1
A testSaveAction() 0 15 1
A testSaveWithDrawingAction() 0 15 1
A testReaderAction() 0 16 1
A testReadAndSaveAction() 0 15 1
A cleanFile() 0 6 2
1
<?php
2
namespace OnurbTest\Bundle\ExcelBundle\Controller;
3
4
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
5
use Symfony\Component\HttpFoundation\Request;
6
use Symfony\Component\HttpFoundation\Response;
7
8
class FakeControllerTest extends WebTestCase
9
{
10
    public function testStreamAction()
11
    {
12
        $client = static::createClient();
13
        $client->request(Request::METHOD_GET, '/fake/stream');
14
        $client->getResponse()->sendContent();
15
        $content = ob_get_contents();
16
        ob_clean();
17
        $this->assertEquals(
18
            Response::HTTP_OK,
19
            $client->getResponse()->getStatusCode(),
20
            $client->getResponse()->getContent()
21
        );
22
        $this->assertStringStartsWith(
23
            'attachment;filename=',
24
            $client->getResponse()->headers->get('content-disposition')
25
        );
26
        $this->assertNotEmpty($content, 'Response should not be empty');
27
        $this->assertNotNull($content, 'Response should not be null');
28
    }
29
30
    public function testSaveAction()
31
    {
32
        $client = static::createClient();
33
        $client->request(Request::METHOD_GET, '/fake/store');
34
        $this->assertEquals(
35
            Response::HTTP_CREATED,
36
            $client->getResponse()->getStatusCode(),
37
            $client->getResponse()->getContent()
38
        );
39
        $content = $client->getResponse()->getContent();
40
        $this->assertStringEndsWith('.xls', $content);
41
        $this->assertFileExists($content, sprintf('file %s should exist', $content));
42
43
        $this->cleanFile($content);
44
    }
45
46
    public function testSaveWithDrawingAction()
47
    {
48
        $client = static::createClient();
49
        $client->request(Request::METHOD_GET, '/fake/drawing');
50
        $this->assertEquals(
51
            Response::HTTP_CREATED,
52
            $client->getResponse()->getStatusCode(),
53
            $client->getResponse()->getContent()
54
        );
55
        $content = $client->getResponse()->getContent();
56
        $this->assertStringEndsWith('.xls', $content);
57
        $this->assertFileExists($content, sprintf('file %s should exist', $content));
58
59
        $this->cleanFile($content);
60
    }
61
62
    public function testReaderAction()
63
    {
64
        $client = static::createClient();
65
        $client->request(Request::METHOD_GET, '/fake/reader');
66
        $client->getResponse()->sendContent();
67
        $content = ob_get_contents();
68
        ob_clean();
69
        $this->assertEquals(
70
            Response::HTTP_OK,
71
            $client->getResponse()->getStatusCode(),
72
            $client->getResponse()->getContent()
73
        );
74
        $this->assertEquals('Hello world!', $client->getResponse()->getContent());
75
        $this->assertNotEmpty($content, 'Response should not be empty');
76
        $this->assertNotNull($content, 'Response should not be null');
77
    }
78
79
    public function testReadAndSaveAction()
80
    {
81
        $client = static::createClient();
82
        $client->request(Request::METHOD_GET, '/fake/read');
83
        $this->assertEquals(
84
            Response::HTTP_CREATED,
85
            $client->getResponse()->getStatusCode(),
86
            $client->getResponse()->getContent()
87
        );
88
        $content = $client->getResponse()->getContent();
89
        $this->assertStringEndsWith('.xls', $content);
90
        $this->assertFileExists($content, sprintf('file %s should exist', $content));
91
92
        $this->cleanFile($content);
93
    }
94
95
96
    private function cleanFile($file)
97
    {
98
        if (file_exists($file)) {
99
            unlink($file);
100
        }
101
    }
102
}
103