1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace MewesK\TwigSpreadsheetBundle\Tests\Twig; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class ErrorTwigTest. |
7
|
|
|
*/ |
8
|
|
|
class ErrorTwigTest extends BaseTwigTest |
9
|
|
|
{ |
10
|
|
|
protected static $TEMP_PATH = '/../../tmp/error/'; |
11
|
|
|
|
12
|
|
|
// |
13
|
|
|
// PhpUnit |
14
|
|
|
// |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @return array |
18
|
|
|
*/ |
19
|
|
|
public function formatProvider() |
20
|
|
|
{ |
21
|
|
|
return [['ods'], ['xls'], ['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 testCellIndexError($format) |
36
|
|
|
{ |
37
|
|
|
$this->expectException(\TypeError::class); |
38
|
|
|
$this->expectExceptionMessage('Argument 1 passed to MewesK\TwigSpreadsheetBundle\Wrapper\PhpSpreadsheetWrapper::setCellIndex() must be of the type integer'); |
39
|
|
|
|
40
|
|
|
$this->getDocument('cellIndexError', $format); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @param string $format |
45
|
|
|
* |
46
|
|
|
* @throws \Exception |
47
|
|
|
* |
48
|
|
|
* @dataProvider formatProvider |
49
|
|
|
*/ |
50
|
|
|
public function testDocumentError($format) |
51
|
|
|
{ |
52
|
|
|
$this->expectException(\Twig_Error_Syntax::class); |
53
|
|
|
$this->expectExceptionMessage('Node "MewesK\TwigSpreadsheetBundle\Twig\Node\DocumentNode" is not allowed inside of Node "MewesK\TwigSpreadsheetBundle\Twig\Node\SheetNode"'); |
54
|
|
|
|
55
|
|
|
$this->getDocument('documentError', $format); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @param string $format |
60
|
|
|
* |
61
|
|
|
* @throws \Exception |
62
|
|
|
* |
63
|
|
|
* @dataProvider formatProvider |
64
|
|
|
*/ |
65
|
|
|
public function testDocumentErrorTextAfter($format) |
66
|
|
|
{ |
67
|
|
|
$this->expectException(\Twig_Error_Syntax::class); |
68
|
|
|
$this->expectExceptionMessage('Node "Twig_Node_Text" is not allowed after Node "MewesK\TwigSpreadsheetBundle\Twig\Node\DocumentNode"'); |
69
|
|
|
|
70
|
|
|
$this->getDocument('documentErrorTextAfter', $format); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @param string $format |
75
|
|
|
* |
76
|
|
|
* @throws \Exception |
77
|
|
|
* |
78
|
|
|
* @dataProvider formatProvider |
79
|
|
|
*/ |
80
|
|
|
public function testDocumentErrorTextBefore($format) |
81
|
|
|
{ |
82
|
|
|
$this->expectException(\Twig_Error_Syntax::class); |
83
|
|
|
$this->expectExceptionMessage('Node "Twig_Node_Text" is not allowed before Node "MewesK\TwigSpreadsheetBundle\Twig\Node\DocumentNode"'); |
84
|
|
|
|
85
|
|
|
$this->getDocument('documentErrorTextBefore', $format); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @param string $format |
90
|
|
|
* |
91
|
|
|
* @throws \Exception |
92
|
|
|
* |
93
|
|
|
* @dataProvider formatProvider |
94
|
|
|
*/ |
95
|
|
|
public function testRowIndexError($format) |
96
|
|
|
{ |
97
|
|
|
$this->expectException(\TypeError::class); |
98
|
|
|
$this->expectExceptionMessage('Argument 1 passed to MewesK\TwigSpreadsheetBundle\Wrapper\PhpSpreadsheetWrapper::setRowIndex() must be of the type integer'); |
99
|
|
|
|
100
|
|
|
$this->getDocument('rowIndexError', $format); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @param string $format |
105
|
|
|
* |
106
|
|
|
* @throws \Exception |
107
|
|
|
* |
108
|
|
|
* @dataProvider formatProvider |
109
|
|
|
*/ |
110
|
|
|
public function testSheetError($format) |
111
|
|
|
{ |
112
|
|
|
$this->expectException(\Twig_Error_Syntax::class); |
113
|
|
|
$this->expectExceptionMessage('Node "MewesK\TwigSpreadsheetBundle\Twig\Node\RowNode" is not allowed inside of Node "MewesK\TwigSpreadsheetBundle\Twig\Node\DocumentNode"'); |
114
|
|
|
|
115
|
|
|
$this->getDocument('sheetError', $format); |
116
|
|
|
} |
117
|
|
|
} |
118
|
|
|
|