Completed
Push — develop ( 5e03e2...c8a8fd )
by Adrien
28:49
created

IOFactoryTest::testIdentify()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace PhpOffice\PhpSpreadsheetTests;
4
5
use PhpOffice\PhpSpreadsheet\IOFactory;
6
7
class IOFactoryTest extends \PHPUnit_Framework_TestCase
8
{
9
    /**
10
     * @dataProvider providerIdentify
11
     */
12
    public function testIdentify($file, $expected)
13
    {
14
        $actual = IOFactory::identify($file);
15
        $this->assertSame($expected, $actual);
16
    }
17
18
    public function providerIdentify()
19
    {
20
        return [
21
            ['../samples/templates/26template.xlsx', 'Xlsx'],
22
            ['../samples/templates/GnumericTest.gnumeric', 'Gnumeric'],
23
            ['../samples/templates/30template.xls', 'Xls'],
24
            ['../samples/templates/OOCalcTest.ods', 'Ods'],
25
            ['../samples/templates/SylkTest.slk', 'SYLK'],
26
            ['../samples/templates/Excel2003XMLTest.xml', 'Excel2003XML'],
27
        ];
28
    }
29
30
    /**
31
     * @expectedException \InvalidArgumentException
32
     */
33
    public function testIdentifyNonExistingFileThrowException()
34
    {
35
        IOFactory::identify('/non/existing/file');
36
    }
37
38
    /**
39
     * @expectedException \InvalidArgumentException
40
     */
41
    public function testIdentifyExistingDirectoryThrowExceptions()
42
    {
43
        IOFactory::identify('.');
44
    }
45
}
46