aef4d711f5
Because even if it doesn't make a difference in practice, it is technically more correct to call static methods statically. It also better advertise that those methods can be used from any context.
50 lines
1.3 KiB
PHP
50 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests;
|
|
|
|
use PhpOffice\PhpSpreadsheet\IOFactory;
|
|
use PHPUnit_Framework_TestCase;
|
|
|
|
class IOFactoryTest extends PHPUnit_Framework_TestCase
|
|
{
|
|
/**
|
|
* @dataProvider providerIdentify
|
|
*
|
|
* @param mixed $file
|
|
* @param mixed $expected
|
|
*/
|
|
public function testIdentify($file, $expected)
|
|
{
|
|
$actual = IOFactory::identify($file);
|
|
self::assertSame($expected, $actual);
|
|
}
|
|
|
|
public function providerIdentify()
|
|
{
|
|
return [
|
|
['../samples/templates/26template.xlsx', 'Xlsx'],
|
|
['../samples/templates/GnumericTest.gnumeric', 'Gnumeric'],
|
|
['../samples/templates/30template.xls', 'Xls'],
|
|
['../samples/templates/OOCalcTest.ods', 'Ods'],
|
|
['../samples/templates/SylkTest.slk', 'Slk'],
|
|
['../samples/templates/Excel2003XMLTest.xml', 'Xml'],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @expectedException \InvalidArgumentException
|
|
*/
|
|
public function testIdentifyNonExistingFileThrowException()
|
|
{
|
|
IOFactory::identify('/non/existing/file');
|
|
}
|
|
|
|
/**
|
|
* @expectedException \InvalidArgumentException
|
|
*/
|
|
public function testIdentifyExistingDirectoryThrowExceptions()
|
|
{
|
|
IOFactory::identify('.');
|
|
}
|
|
}
|