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.

CompatibilityControllerTest::testStreamAction()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 9.6333
c 0
b 0
f 0
cc 1
nc 1
nop 0
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 CompatibilityControllerTest extends WebTestCase
9
{
10
11
    public function testStreamAction()
12
    {
13
        $client = static::createClient();
14
        $client->request(Request::METHOD_GET, '/compatibility/stream');
15
        $client->getResponse()->sendContent();
16
        $content = ob_get_contents();
17
        ob_clean();
18
        $this->assertEquals(
19
            Response::HTTP_OK,
20
            $client->getResponse()->getStatusCode(),
21
            $client->getResponse()->getContent()
22
        );
23
        $this->assertStringStartsWith(
24
            'attachment;filename=',
25
            $client->getResponse()->headers->get('content-disposition')
26
        );
27
        $this->assertNotEmpty($content, 'Response should not be empty');
28
        $this->assertNotNull($content, 'Response should not be null');
29
    }
30
31
32
    public function testSaveAction()
33
    {
34
        $client = static::createClient();
35
        $client->request(Request::METHOD_GET, '/compatibility/store');
36
        $this->assertEquals(
37
            Response::HTTP_CREATED,
38
            $client->getResponse()->getStatusCode(),
39
            $client->getResponse()->getContent()
40
        );
41
        $content = $client->getResponse()->getContent();
42
        $this->assertStringEndsWith('.xls', $content);
43
        $this->assertFileExists($content, sprintf('file %s should exist', $content));
44
    }
45
46
    /**
47
     * @depends testSaveAction
48
     */
49
    public function testReaderAction()
50
    {
51
        $client = static::createClient();
52
        $client->request(Request::METHOD_GET, '/compatibility/reader');
53
        $client->getResponse()->sendContent();
54
        $content = ob_get_contents();
55
        ob_clean();
56
        $this->assertEquals(
57
            Response::HTTP_OK,
58
            $client->getResponse()->getStatusCode(),
59
            $client->getResponse()->getContent()
60
        );
61
        $this->assertEquals('Hello world!', $client->getResponse()->getContent());
62
        $this->assertNotEmpty($content, 'Response should not be empty');
63
        $this->assertNotNull($content, 'Response should not be null');
64
    }
65
66
    /**
67
     * @depends testSaveAction
68
     */
69
    public function testReadAndSaveAction()
70
    {
71
        $client = static::createClient();
72
        $client->request(Request::METHOD_GET, '/compatibility/read');
73
        $this->assertEquals(
74
            Response::HTTP_CREATED,
75
            $client->getResponse()->getStatusCode(),
76
            $client->getResponse()->getContent()
77
        );
78
        $content = $client->getResponse()->getContent();
79
        $this->assertStringEndsWith('.xls', $content);
80
        $this->assertFileExists($content, sprintf('file %s should exist', $content));
81
82
        $this->cleanFile($content);
83
    }
84
85
    public function testSaveWithDrawingAction()
86
    {
87
        $client = static::createClient();
88
        $client->request(Request::METHOD_GET, '/compatibility/drawing');
89
        $this->assertEquals(
90
            Response::HTTP_CREATED,
91
            $client->getResponse()->getStatusCode(),
92
            $client->getResponse()->getContent()
93
        );
94
        $content = $client->getResponse()->getContent();
95
        $this->assertStringEndsWith('.xls', $content);
96
        $this->assertFileExists($content, sprintf('file %s should exist', $content));
97
98
        $this->cleanFile($content);
99
    }
100
101
    /**
102
     * @param $file
103
     */
104
    private function cleanFile($file)
105
    {
106
        if (file_exists($file)) {
107
            unlink($file);
108
        }
109
    }
110
}
111