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.
Test Failed
Push — master ( 06bc6c...e92c95 )
by Mewes
03:57
created

XlsxTwigTest   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 266
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 1
dl 0
loc 266
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace MewesK\TwigSpreadsheetBundle\Tests\Twig;
4
5
/**
6
 * Class XlsxTwigTest.
7
 *
8
 * @coversNothing
9
 */
10
class XlsxTwigTest extends BaseTwigTest
11
{
12
    protected static $TEMP_PATH = '/../../tmp/xlsx/';
13
14
    //
15
    // PhpUnit
16
    //
17
18
    /**
19
     * @return array
20
     */
21
    public function formatProvider()
22
    {
23
        return [['xlsx']];
24
    }
25
26
    //
27
    // Tests
28
    //
29
30
    /**
31
     * @param string $format
32
     *
33
     * @throws \Exception
34
     *
35
     * @dataProvider formatProvider
36
     */
37
    public function testCellProperties($format)
38
    {
39
        $document = $this->getDocument('cellProperties', $format);
40
        $sheet = $document->getSheetByName('Test');
41
        $cell = $sheet->getCell('A1');
42
        $dataValidation = $cell->getDataValidation();
43
44
        static::assertTrue($dataValidation->getAllowBlank(), 'Unexpected value in allowBlank');
45
        static::assertEquals('Test error', $dataValidation->getError(), 'Unexpected value in error');
46
        static::assertEquals('information', $dataValidation->getErrorStyle(), 'Unexpected value in errorStyle');
47
        static::assertEquals('Test errorTitle', $dataValidation->getErrorTitle(), 'Unexpected value in errorTitle');
48
        static::assertEquals('', $dataValidation->getFormula1(), 'Unexpected value in formula1');
49
        static::assertEquals('', $dataValidation->getFormula2(), 'Unexpected value in formula2');
50
        static::assertEquals('', $dataValidation->getOperator(), 'Unexpected value in operator');
51
        static::assertEquals('Test prompt', $dataValidation->getPrompt(), 'Unexpected value in prompt');
52
        static::assertEquals('Test promptTitle', $dataValidation->getPromptTitle(), 'Unexpected value in promptTitle');
53
        static::assertTrue($dataValidation->getShowDropDown(), 'Unexpected value in showDropDown');
54
        static::assertTrue($dataValidation->getShowErrorMessage(), 'Unexpected value in showErrorMessage');
55
        static::assertTrue($dataValidation->getShowInputMessage(), 'Unexpected value in showInputMessage');
56
        static::assertEquals('custom', $dataValidation->getType(), 'Unexpected value in type');
57
    }
58
59
    /**
60
     * The following attributes are not supported by the readers and therefore cannot be tested:
61
     * $security->getLockRevision() -> true
62
     * $security->getLockStructure() -> true
63
     * $security->getLockWindows() -> true
64
     * $security->getRevisionsPassword() -> 'test'
65
     * $security->getWorkbookPassword() -> 'test'.
66
     *
67
     * @param string $format
68
     *
69
     * @throws \Exception
70
     *
71
     * @dataProvider formatProvider
72
     */
73
    public function testDocumentProperties($format)
74
    {
75
        $document = $this->getDocument('documentProperties', $format);
76
        $properties = $document->getProperties();
77
78
        static::assertEquals('Test company', $properties->getCompany(), 'Unexpected value in company');
79
        static::assertEquals('Test manager', $properties->getManager(), 'Unexpected value in manager');
80
    }
81
82
    /**
83
     * @param string $format
84
     *
85
     * @throws \Exception
86
     *
87
     * @dataProvider formatProvider
88
     */
89
    public function testDocumentTemplate($format)
90
    {
91
        $document = $this->getDocument('documentTemplateAdvanced', $format);
92
        static::assertNotNull($document, 'Document does not exist');
93
94
        $sheet = $document->getSheet(0);
95
        static::assertNotNull($sheet, 'Sheet does not exist');
96
97
        static::assertEquals('Hello2', $sheet->getCell('A1')->getValue(), 'Unexpected value in A1');
98
        static::assertEquals('World', $sheet->getCell('B1')->getValue(), 'Unexpected value in B1');
99
        static::assertEquals('Foo', $sheet->getCell('A2')->getValue(), 'Unexpected value in A2');
100
        static::assertEquals('Bar2', $sheet->getCell('B2')->getValue(), 'Unexpected value in B2');
101
102
        static::assertTrue($sheet->getCell('A1')->getStyle()->getFont()->getBold(), 'Unexpected value in bold');
103
        static::assertTrue($sheet->getCell('B1')->getStyle()->getFont()->getItalic(), 'Unexpected value in italic');
104
        static::assertEquals('single', $sheet->getCell('A2')->getStyle()->getFont()->getUnderline(), 'Unexpected value in underline');
105
        static::assertEquals('FFFF3333', $sheet->getCell('B2')->getStyle()->getFont()->getColor()->getARGB(), 'Unexpected value in color');
106
107
        $headerFooter = $sheet->getHeaderFooter();
108
        static::assertNotNull($headerFooter, 'HeaderFooter does not exist');
109
        static::assertContains('Left area header', $headerFooter->getOddHeader(), 'Unexpected value in oddHeader');
110
        static::assertContains('12Center area header', $headerFooter->getOddHeader(), 'Unexpected value in oddHeader');
111
        static::assertContains('12Right area header', $headerFooter->getOddHeader(), 'Unexpected value in oddHeader');
112
        static::assertContains('Left area footer', $headerFooter->getOddFooter(), 'Unexpected value in oddFooter');
113
        static::assertContains('12Center area footer', $headerFooter->getOddFooter(), 'Unexpected value in oddFooter');
114
        static::assertContains('12Right area footer', $headerFooter->getOddFooter(), 'Unexpected value in oddFooter');
115
116
        $drawings = $sheet->getDrawingCollection();
117
        static::assertCount(1, $drawings, 'Not enough drawings exist');
118
119
        $drawing = $drawings[0];
120
        static::assertEquals(196, $drawing->getWidth(), 'Unexpected value in width');
121
        static::assertEquals(187, $drawing->getHeight(), 'Unexpected value in height');
122
    }
123
124
    /**
125
     * @param string $format
126
     *
127
     * @throws \Exception
128
     *
129
     * @dataProvider formatProvider
130
     */
131
    public function testDrawingProperties($format)
132
    {
133
        $document = $this->getDocument('drawingProperties', $format);
134
        static::assertNotNull($document, 'Document does not exist');
135
136
        $sheet = $document->getSheetByName('Test');
137
        static::assertNotNull($sheet, 'Sheet does not exist');
138
139
        $drawings = $sheet->getDrawingCollection();
140
        static::assertCount(1, $drawings, 'Not enough drawings exist');
141
142
        $drawing = $drawings[0];
143
        static::assertEquals('Test Description', $drawing->getDescription(), 'Unexpected value in description');
144
        static::assertEquals('Test Name', $drawing->getName(), 'Unexpected value in name');
145
        static::assertEquals(30, $drawing->getOffsetX(), 'Unexpected value in offsetX');
146
        static::assertEquals(20, $drawing->getOffsetY(), 'Unexpected value in offsetY');
147
        static::assertEquals(45, $drawing->getRotation(), 'Unexpected value in rotation');
148
149
        $shadow = $drawing->getShadow();
150
        static::assertEquals('ctr', $shadow->getAlignment(), 'Unexpected value in alignment');
151
        static::assertEquals(100, $shadow->getAlpha(), 'Unexpected value in alpha');
152
        static::assertEquals(11, $shadow->getBlurRadius(), 'Unexpected value in blurRadius');
153
        static::assertEquals('0000cc', $shadow->getColor()->getRGB(), 'Unexpected value in color');
154
        static::assertEquals(30, $shadow->getDirection(), 'Unexpected value in direction');
155
        static::assertEquals(4, $shadow->getDistance(), 'Unexpected value in distance');
156
        static::assertTrue($shadow->getVisible(), 'Unexpected value in visible');
157
    }
158
159
    /**
160
     * @param string $format
161
     *
162
     * @throws \Exception
163
     *
164
     * @dataProvider formatProvider
165
     */
166
    public function testHeaderFooterComplex($format)
167
    {
168
        $document = $this->getDocument('headerFooterComplex', $format);
169
        static::assertNotNull($document, 'Document does not exist');
170
171
        $sheet = $document->getSheetByName('Test');
172
        static::assertNotNull($sheet, 'Sheet does not exist');
173
174
        $headerFooter = $sheet->getHeaderFooter();
175
        static::assertNotNull($headerFooter, 'HeaderFooter does not exist');
176
        static::assertEquals('&LfirstHeader left&CfirstHeader center&RfirstHeader right',
177
            $headerFooter->getFirstHeader(),
178
            'Unexpected value in firstHeader');
179
        static::assertEquals('&LevenHeader left&CevenHeader center&RevenHeader right',
180
            $headerFooter->getEvenHeader(),
181
            'Unexpected value in evenHeader');
182
        static::assertEquals('&LfirstFooter left&CfirstFooter center&RfirstFooter right',
183
            $headerFooter->getFirstFooter(),
184
            'Unexpected value in firstFooter');
185
        static::assertEquals('&LevenFooter left&CevenFooter center&RevenFooter right',
186
            $headerFooter->getEvenFooter(),
187
            'Unexpected value in evenFooter');
188
    }
189
190
    /**
191
     * @param string $format
192
     *
193
     * @throws \Exception
194
     *
195
     * @dataProvider formatProvider
196
     */
197
    public function testHeaderFooterDrawing($format)
198
    {
199
        $document = $this->getDocument('headerFooterDrawing', $format);
200
        static::assertNotNull($document, 'Document does not exist');
201
202
        $sheet = $document->getSheetByName('Test');
203
        static::assertNotNull($sheet, 'Sheet does not exist');
204
205
        $headerFooter = $sheet->getHeaderFooter();
206
        static::assertNotNull($headerFooter, 'HeaderFooter does not exist');
207
        static::assertEquals('&L&G&CHeader', $headerFooter->getFirstHeader(), 'Unexpected value in firstHeader');
208
        static::assertEquals('&L&G&CHeader', $headerFooter->getEvenHeader(), 'Unexpected value in evenHeader');
209
        static::assertEquals('&L&G&CHeader', $headerFooter->getOddHeader(), 'Unexpected value in oddHeader');
210
        static::assertEquals('&LFooter&R&G', $headerFooter->getFirstFooter(), 'Unexpected value in firstFooter');
211
        static::assertEquals('&LFooter&R&G', $headerFooter->getEvenFooter(), 'Unexpected value in evenFooter');
212
        static::assertEquals('&LFooter&R&G', $headerFooter->getOddFooter(), 'Unexpected value in oddFooter');
213
214
        $drawings = $headerFooter->getImages();
215
        static::assertCount(2, $drawings, 'Sheet has not exactly 2 drawings');
216
        static::assertArrayHasKey('LH', $drawings, 'Header drawing does not exist');
217
        static::assertArrayHasKey('RF', $drawings, 'Footer drawing does not exist');
218
219
        $drawing = $drawings['LH'];
220
        static::assertNotNull($drawing, 'Header drawing is null');
221
        static::assertEquals(40, $drawing->getWidth(), 'Unexpected value in width');
222
        static::assertEquals(40, $drawing->getHeight(), 'Unexpected value in height');
223
224
        $drawing = $drawings['RF'];
225
        static::assertNotNull($drawing, 'Footer drawing is null');
226
        static::assertEquals(20, $drawing->getWidth(), 'Unexpected value in width');
227
        static::assertEquals(20, $drawing->getHeight(), 'Unexpected value in height');
228
    }
229
230
    /**
231
     * @param string $format
232
     *
233
     * @throws \Exception
234
     *
235
     * @dataProvider formatProvider
236
     */
237
    public function testHeaderFooterProperties($format)
238
    {
239
        $document = $this->getDocument('headerFooterProperties', $format);
240
        static::assertNotNull($document, 'Document does not exist');
241
242
        $sheet = $document->getSheetByName('Test');
243
        static::assertNotNull($sheet, 'Sheet does not exist');
244
245
        $headerFooter = $sheet->getHeaderFooter();
246
        static::assertNotNull($headerFooter, 'HeaderFooter does not exist');
247
248
        static::assertEquals('&CHeader', $headerFooter->getFirstHeader(), 'Unexpected value in firstHeader');
249
        static::assertEquals('&CHeader', $headerFooter->getEvenHeader(), 'Unexpected value in evenHeader');
250
        static::assertEquals('&CHeader', $headerFooter->getOddHeader(), 'Unexpected value in oddHeader');
251
        static::assertEquals('&CFooter', $headerFooter->getFirstFooter(), 'Unexpected value in firstFooter');
252
        static::assertEquals('&CFooter', $headerFooter->getEvenFooter(), 'Unexpected value in evenFooter');
253
        static::assertEquals('&CFooter', $headerFooter->getOddFooter(), 'Unexpected value in oddFooter');
254
255
        static::assertFalse($headerFooter->getAlignWithMargins(), 'Unexpected value in alignWithMargins');
256
        static::assertFalse($headerFooter->getScaleWithDocument(), 'Unexpected value in scaleWithDocument');
257
    }
258
259
    /**
260
     * @param string $format
261
     *
262
     * @throws \Exception
263
     *
264
     * @dataProvider formatProvider
265
     */
266
    public function testSheetProperties($format)
267
    {
268
        $document = $this->getDocument('sheetProperties', $format);
269
        static::assertNotNull($document, 'Document does not exist');
270
271
        $sheet = $document->getSheetByName('Test');
272
        static::assertNotNull($sheet, 'Sheet does not exist');
273
        static::assertEquals('A1:B1', $sheet->getAutoFilter()->getRange(), 'Unexpected value in autoFilter');
274
    }
275
}
276