1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace MewesK\TwigExcelBundle\Tests\Twig; |
4
|
|
|
|
5
|
|
|
use Twig_Error_Runtime; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class ErrorTwigTest |
9
|
|
|
* @package MewesK\TwigExcelBundle\Tests\Twig |
10
|
|
|
*/ |
11
|
|
|
class ErrorTwigTest extends AbstractTwigTest |
12
|
|
|
{ |
13
|
|
|
protected static $TEMP_PATH = '/../../tmp/error/'; |
14
|
|
|
|
15
|
|
|
// |
16
|
|
|
// PhpUnit |
17
|
|
|
// |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @return array |
21
|
|
|
*/ |
22
|
|
|
public function formatProvider() |
23
|
|
|
{ |
24
|
|
|
return [['ods'], ['xls'], ['xlsx']]; |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
// |
28
|
|
|
// Tests |
29
|
|
|
// |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @param string $format |
33
|
|
|
* |
34
|
|
|
* @throws \PHPExcel_Exception |
35
|
|
|
* |
36
|
|
|
* @dataProvider formatProvider |
37
|
|
|
*/ |
38
|
|
|
public function testBlockError($format) |
39
|
|
|
{ |
40
|
|
|
$this->setExpectedException( |
41
|
|
|
'\Twig_Error_Syntax', |
42
|
|
|
'Block tags do not work together with Twig tags provided by TwigExcelBundle. Please use \'xlsblock\' instead in "blockError.twig".' |
43
|
|
|
); |
44
|
|
|
|
45
|
|
|
try { |
46
|
|
|
$this->getDocument('blockError', $format); |
47
|
|
|
} catch (Twig_Error_Runtime $e) { |
48
|
|
|
static::fail($e->getMessage()); |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @param string $format |
54
|
|
|
* |
55
|
|
|
* @throws \PHPExcel_Exception |
56
|
|
|
* |
57
|
|
|
* @dataProvider formatProvider |
58
|
|
|
*/ |
59
|
|
|
public function testDocumentError($format) |
60
|
|
|
{ |
61
|
|
|
$this->setExpectedException( |
62
|
|
|
'\Twig_Error_Syntax', |
63
|
|
|
'Node "MewesK\TwigExcelBundle\Twig\Node\XlsDocumentNode" is not allowed inside of Node "MewesK\TwigExcelBundle\Twig\Node\XlsSheetNode"' |
64
|
|
|
); |
65
|
|
|
|
66
|
|
|
try { |
67
|
|
|
$this->getDocument('documentError', $format); |
68
|
|
|
} catch (Twig_Error_Runtime $e) { |
69
|
|
|
static::fail($e->getMessage()); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @param string $format |
75
|
|
|
* |
76
|
|
|
* @throws \PHPExcel_Exception |
77
|
|
|
* |
78
|
|
|
* @dataProvider formatProvider |
79
|
|
|
*/ |
80
|
|
|
public function testMacroError($format) |
81
|
|
|
{ |
82
|
|
|
$this->setExpectedException( |
83
|
|
|
'\Twig_Error_Syntax', |
84
|
|
|
'Macro tags do not work together with Twig tags provided by TwigExcelBundle. Please use \'xlsmacro\' instead in "macroError.twig".' |
85
|
|
|
); |
86
|
|
|
|
87
|
|
|
try { |
88
|
|
|
$this->getDocument('macroError', $format); |
89
|
|
|
} catch (Twig_Error_Runtime $e) { |
90
|
|
|
static::fail($e->getMessage()); |
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
|