Completed
Push — master ( 3af88c...d76c98 )
by Mewes
05:10
created

ErrorTwigTest::testMacroError()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 13
rs 9.4285
cc 2
eloc 8
nc 2
nop 1
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