| 
									
										
										
										
											2016-12-08 15:15:22 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace PhpOffice\PhpSpreadsheetTests; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | use PhpOffice\PhpSpreadsheet\IOFactory; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class IOFactoryTest extends \PHPUnit_Framework_TestCase | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * @dataProvider providerIdentify | 
					
						
							| 
									
										
										
										
											2016-12-22 14:43:37 +00:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @param mixed $file | 
					
						
							|  |  |  |      * @param mixed $expected | 
					
						
							| 
									
										
										
										
											2016-12-08 15:15:22 +00:00
										 |  |  |      */ | 
					
						
							|  |  |  |     public function testIdentify($file, $expected) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $actual = IOFactory::identify($file); | 
					
						
							|  |  |  |         $this->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'], | 
					
						
							| 
									
										
										
										
											2017-01-22 08:39:23 +00:00
										 |  |  |             ['../samples/templates/SylkTest.slk', 'Slk'], | 
					
						
							|  |  |  |             ['../samples/templates/Excel2003XMLTest.xml', 'Xml'], | 
					
						
							| 
									
										
										
										
											2016-12-08 15:15:22 +00:00
										 |  |  |         ]; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * @expectedException \InvalidArgumentException | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function testIdentifyNonExistingFileThrowException() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         IOFactory::identify('/non/existing/file'); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * @expectedException \InvalidArgumentException | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public function testIdentifyExistingDirectoryThrowExceptions() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         IOFactory::identify('.'); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } |