| 
									
										
										
										
											2012-08-03 20:21:32 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-13 17:22:11 +00:00
										 |  |  | namespace PhpSpreadsheet\Tests\Shared; | 
					
						
							| 
									
										
										
										
											2012-08-03 20:21:32 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-14 04:08:43 +00:00
										 |  |  | use PHPExcel\Shared\Font; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-22 14:35:50 +00:00
										 |  |  | class FontTest extends \PHPUnit_Framework_TestCase | 
					
						
							| 
									
										
										
										
											2012-08-03 20:21:32 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     public function testGetAutoSizeMethod() | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2016-08-14 04:08:43 +00:00
										 |  |  |         $expectedResult = Font::AUTOSIZE_METHOD_APPROX; | 
					
						
							| 
									
										
										
										
											2012-08-03 20:21:32 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-14 04:08:43 +00:00
										 |  |  |         $result = call_user_func(array(Font::class,'getAutoSizeMethod')); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |         $this->assertEquals($expectedResult, $result); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-08-03 20:21:32 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     public function testSetAutoSizeMethod() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $autosizeMethodValues = array( | 
					
						
							| 
									
										
										
										
											2016-08-14 04:08:43 +00:00
										 |  |  |             Font::AUTOSIZE_METHOD_EXACT, | 
					
						
							|  |  |  |             Font::AUTOSIZE_METHOD_APPROX, | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |         ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         foreach ($autosizeMethodValues as $autosizeMethodValue) { | 
					
						
							| 
									
										
										
										
											2016-08-14 04:08:43 +00:00
										 |  |  |             $result = call_user_func(array(Font::class,'setAutoSizeMethod'), $autosizeMethodValue); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |             $this->assertTrue($result); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-08-03 20:21:32 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     public function testSetAutoSizeMethodWithInvalidValue() | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         $unsupportedAutosizeMethod = 'guess'; | 
					
						
							| 
									
										
										
										
											2012-08-03 20:21:32 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-14 04:08:43 +00:00
										 |  |  |         $result = call_user_func(array(Font::class,'setAutoSizeMethod'), $unsupportedAutosizeMethod); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |         $this->assertFalse($result); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-08-03 20:21:32 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * @dataProvider providerFontSizeToPixels | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     public function testFontSizeToPixels() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $args = func_get_args(); | 
					
						
							|  |  |  |         $expectedResult = array_pop($args); | 
					
						
							| 
									
										
										
										
											2016-08-14 04:08:43 +00:00
										 |  |  |         $result = call_user_func_array(array(Font::class,'fontSizeToPixels'), $args); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |         $this->assertEquals($expectedResult, $result); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-08-03 20:21:32 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     public function providerFontSizeToPixels() | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2016-08-16 12:00:19 +00:00
										 |  |  |         return require 'data/Shared/FontSizeToPixels.php'; | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-08-03 20:21:32 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * @dataProvider providerInchSizeToPixels | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     public function testInchSizeToPixels() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $args = func_get_args(); | 
					
						
							|  |  |  |         $expectedResult = array_pop($args); | 
					
						
							| 
									
										
										
										
											2016-08-14 04:08:43 +00:00
										 |  |  |         $result = call_user_func_array(array(Font::class,'inchSizeToPixels'), $args); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |         $this->assertEquals($expectedResult, $result); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-08-03 20:21:32 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     public function providerInchSizeToPixels() | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2016-08-16 12:00:19 +00:00
										 |  |  |         return require 'data/Shared/InchSizeToPixels.php'; | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-08-03 20:21:32 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * @dataProvider providerCentimeterSizeToPixels | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     public function testCentimeterSizeToPixels() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $args = func_get_args(); | 
					
						
							|  |  |  |         $expectedResult = array_pop($args); | 
					
						
							| 
									
										
										
										
											2016-08-14 04:08:43 +00:00
										 |  |  |         $result = call_user_func_array(array(Font::class,'centimeterSizeToPixels'), $args); | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |         $this->assertEquals($expectedResult, $result); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-08-03 20:21:32 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     public function providerCentimeterSizeToPixels() | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2016-08-16 12:00:19 +00:00
										 |  |  |         return require 'data/Shared/CentimeterSizeToPixels.php'; | 
					
						
							| 
									
										
										
										
											2015-05-17 13:00:02 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-08-03 20:21:32 +00:00
										 |  |  | } |