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