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 ( 0dcb27...fb7903 )
by Mewes
11:26
created

XlsxTwigTest::testDrawingProperties()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 27
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

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