| 
									
										
										
										
											2015-04-29 21:23:14 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class XEEValidatorTest extends PHPUnit_Framework_TestCase | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function setUp() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (!defined('PHPEXCEL_ROOT')) { | 
					
						
							|  |  |  |             define('PHPEXCEL_ROOT', APPLICATION_PATH . '/'); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-04-29 21:23:14 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * @dataProvider providerInvalidXML | 
					
						
							|  |  |  |      * @expectedException PHPExcel_Reader_Exception | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     public function testInvalidXML($filename) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2015-04-29 21:23:14 +00:00
										 |  |  |         $reader = $this->getMockForAbstractClass('PHPExcel_Reader_Abstract'); | 
					
						
							|  |  |  |         $expectedResult = 'FAILURE: Should throw an Exception rather than return a value'; | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |         $result = $reader->securityScanFile($filename); | 
					
						
							|  |  |  |         $this->assertEquals($expectedResult, $result); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-04-29 21:23:14 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     public function providerInvalidXML() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $tests = []; | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |         foreach (glob('rawTestData/Reader/XEETestInvalid*.xml') as $file) { | 
					
						
							| 
									
										
										
										
											2015-04-29 21:23:14 +00:00
										 |  |  |             $tests[] = [realpath($file), true]; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return $tests; | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-04-29 21:23:14 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * @dataProvider providerValidXML | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     public function testValidXML($filename, $expectedResult) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2015-04-29 21:23:14 +00:00
										 |  |  |         $reader = $this->getMockForAbstractClass('PHPExcel_Reader_Abstract'); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |         $result = $reader->securityScanFile($filename); | 
					
						
							|  |  |  |         $this->assertEquals($expectedResult, $result); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-04-29 21:23:14 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     public function providerValidXML() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $tests = []; | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |         foreach (glob('rawTestData/Reader/XEETestValid*.xml') as $file) { | 
					
						
							| 
									
										
										
										
											2015-04-29 21:23:14 +00:00
										 |  |  |             $tests[] = [realpath($file), file_get_contents($file)]; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return $tests; | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-04-29 21:23:14 +00:00
										 |  |  | } |