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.

ExcelFactoryTest::testCreateWriter()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
namespace OnurbTest\Bundle\ExcelBundle\Factory;
3
4
use Onurb\Bundle\ExcelBundle\Factory\ExcelFactory as Factory;
5
use PhpOffice\PhpSpreadsheet\Helper\Html;
6
use PhpOffice\PhpSpreadsheet\Spreadsheet;
7
use PhpOffice\PhpSpreadsheet\Reader\IReader;
8
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
9
use PhpOffice\PhpSpreadsheet\Writer\IWriter;
10
use PHPUnit\Framework\TestCase;
11
12
class ExcelFactoryTest extends TestCase
13
{
14
    /**
15
     * @var Factory
16
     */
17
    private $factory;
18
19
    public function setup()
20
    {
21
        $this->factory = new Factory();
22
    }
23
24
    /**
25
     * @covers \Onurb\Bundle\ExcelBundle\Factory\ExcelFactory
26
     */
27
    public function testCreate()
28
    {
29
        $this->assertInstanceOf(Spreadsheet::class, $this->factory->createSpreadsheet());
30
    }
31
32
    /**
33
     * @covers \Onurb\Bundle\ExcelBundle\Factory\ExcelFactory
34
     */
35
    public function testCreateReader()
36
    {
37
        $this->assertInstanceOf(IReader::class, $this->factory->createReader());
38
    }
39
40
    /**
41
     * @covers \Onurb\Bundle\ExcelBundle\Factory\ExcelFactory
42
     */
43
    public function testCreateWriter()
44
    {
45
        $this->assertInstanceOf(IWriter::class, $this->factory->createWriter($this->factory->createSpreadsheet()));
46
    }
47
48
    /**
49
     * @covers \Onurb\Bundle\ExcelBundle\Factory\ExcelFactory
50
     */
51
    public function testCreateStreamedResponse()
52
    {
53
        $writer = $this->createMock(IWriter::class);
54
        $writer->expects($this->once())
55
            ->method('save')
56
            ->with('php://output');
57
        $this->factory->createStreamedResponse($writer)->sendContent();
0 ignored issues
show
Documentation introduced by
$writer is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<PhpOffice\PhpSpreadsheet\Writer\IWriter>.

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...
58
    }
59
60
    /**
61
     * @covers \Onurb\Bundle\ExcelBundle\Factory\ExcelFactory
62
     */
63
    public function testCreateHelperHtml()
64
    {
65
        $helperHtml = $this->factory->createHelperHTML();
66
67
        $this->assertInstanceOf(Html::class, $helperHtml);
68
    }
69
70
    /**
71
     * @covers \Onurb\Bundle\ExcelBundle\Factory\ExcelFactory
72
     */
73
    public function testCreateSpreadsheetWorksheetDrawing()
74
    {
75
        $drawing = $this->factory->createSpreadsheetWorksheetDrawing();
76
77
        $this->assertInstanceOf(Drawing::class, $drawing);
78
    }
79
80
81
    /**
82
     * @expectedException \InvalidArgumentException
83
     * @covers \Onurb\Bundle\ExcelBundle\Factory\ExcelFactory
84
     */
85
    public function testCreateReaderThrowsExceptionIfTypeIsWrong()
86
    {
87
        $this->factory->createReader('WrongType');
88
    }
89
}
90