CsvTwigTest::testDocumentTemplate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 1
1
<?php
2
3
namespace MewesK\TwigExcelBundle\Tests\Twig;
4
5
/**
6
 * Class CsvTwigTest
7
 * @package MewesK\TwigExcelBundle\Tests\Twig
8
 */
9
class CsvTwigTest extends AbstractTwigTest
10
{
11
    protected static $TEMP_PATH = '/../../tmp/csv/';
12
13
    //
14
    // PhpUnit
15
    //
16
17
    /**
18
     * @return array
19
     */
20
    public function formatProvider()
21
    {
22
        return [['csv']];
23
    }
24
25
    //
26
    // Tests
27
    //
28
29
    /**
30
     * @param string $format
31
     * @throws \Exception
32
     *
33
     * @dataProvider formatProvider
34
     */
35
    public function testBasic($format)
36
    {
37
        $path = $this->getDocument('documentSimple', $format);
38
39
        static::assertFileExists($path, 'File does not exist');
40
        static::assertGreaterThan(0, filesize($path), 'File is empty');
41
        static::assertEquals("\"Foo\",\"Bar\"".PHP_EOL."\"Hello\",\"World\"".PHP_EOL, file_get_contents($path), 'Unexpected content');
42
    }
43
44
    /**
45
     * @param string $format
46
     * @throws \Exception
47
     *
48
     * @dataProvider formatProvider
49
     */
50
    public function testDocumentTemplate($format)
51
    {
52
        $path = $this->getDocument('documentTemplate.csv', $format);
53
54
        static::assertFileExists($path, 'File does not exist');
55
        static::assertGreaterThan(0, filesize($path), 'File is empty');
56
        static::assertEquals("\"Hello2\",\"World\"".PHP_EOL."\"Foo\",\"Bar2\"".PHP_EOL, file_get_contents($path), 'Unexpected content');
57
    }
58
}
59