| 
									
										
										
										
											2012-06-18 20:35:21 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-31 17:18:12 +00:00
										 |  |  | namespace PhpOffice\PhpSpreadsheetTests\Shared; | 
					
						
							| 
									
										
										
										
											2012-06-18 20:35:21 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-31 17:18:12 +00:00
										 |  |  | use PhpOffice\PhpSpreadsheet\Exception; | 
					
						
							|  |  |  | use PhpOffice\PhpSpreadsheet\Shared\CodePage; | 
					
						
							| 
									
										
										
										
											2017-05-17 22:02:17 +00:00
										 |  |  | use PHPUnit_Framework_TestCase; | 
					
						
							| 
									
										
										
										
											2016-08-14 04:08:43 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-17 22:02:17 +00:00
										 |  |  | class CodePageTest extends PHPUnit_Framework_TestCase | 
					
						
							| 
									
										
										
										
											2012-06-18 20:35:21 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * @dataProvider providerCodePage | 
					
						
							| 
									
										
										
										
											2017-01-23 05:49:10 +00:00
										 |  |  |      * | 
					
						
							|  |  |  |      * @param mixed $expectedResult | 
					
						
							| 
									
										
										
										
											2012-06-18 20:35:21 +00:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2017-01-23 05:49:10 +00:00
										 |  |  |     public function testCodePageNumberToName($expectedResult, ...$args) | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-01-23 05:49:10 +00:00
										 |  |  |         $result = CodePage::numberToName(...$args); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |         $this->assertEquals($expectedResult, $result); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-06-18 20:35:21 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     public function providerCodePage() | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2016-08-16 12:00:19 +00:00
										 |  |  |         return require 'data/Shared/CodePage.php'; | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-06-18 20:35:21 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     public function testNumberToNameWithInvalidCodePage() | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         $invalidCodePage = 12345; | 
					
						
							|  |  |  |         try { | 
					
						
							| 
									
										
										
										
											2016-08-26 06:39:29 +00:00
										 |  |  |             CodePage::numberToName($invalidCodePage); | 
					
						
							| 
									
										
										
										
											2016-08-14 04:08:43 +00:00
										 |  |  |         } catch (Exception $e) { | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |             $this->assertEquals($e->getMessage(), 'Unknown codepage: 12345'); | 
					
						
							| 
									
										
										
										
											2016-08-16 15:33:57 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |             return; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         $this->fail('An expected exception has not been raised.'); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-06-18 20:35:21 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     public function testNumberToNameWithUnsupportedCodePage() | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         $unsupportedCodePage = 720; | 
					
						
							|  |  |  |         try { | 
					
						
							| 
									
										
										
										
											2016-08-26 06:39:29 +00:00
										 |  |  |             CodePage::numberToName($unsupportedCodePage); | 
					
						
							| 
									
										
										
										
											2016-08-14 04:08:43 +00:00
										 |  |  |         } catch (Exception $e) { | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |             $this->assertEquals($e->getMessage(), 'Code page 720 not supported.'); | 
					
						
							| 
									
										
										
										
											2016-08-16 15:33:57 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |             return; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         $this->fail('An expected exception has not been raised.'); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-06-18 20:35:21 +00:00
										 |  |  | } |