mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Editor: Prevent PHP warning when parsing duotone hue values.
Props jacobcassidy, rahmohn, mukesh27. Fixes #59496. git-svn-id: https://develop.svn.wordpress.org/trunk@57652 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
a1d6aa3644
commit
ba644b94df
@ -209,10 +209,7 @@ class WP_Duotone {
|
|||||||
'rad' => 360 / ( M_PI * 2 ),
|
'rad' => 360 / ( M_PI * 2 ),
|
||||||
);
|
);
|
||||||
|
|
||||||
$factor = $angle_units[ $unit ];
|
$factor = isset( $angle_units[ $unit ] ) ? $angle_units[ $unit ] : 1;
|
||||||
if ( ! $factor ) {
|
|
||||||
$factor = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (float) $value * $factor;
|
return (float) $value * $factor;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
*
|
*
|
||||||
* @group block-supports
|
* @group block-supports
|
||||||
*
|
*
|
||||||
* @package WordPress
|
* @coversDefaultClass WP_Duotone
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class Tests_Block_Supports_Duotone extends WP_UnitTestCase {
|
class Tests_Block_Supports_Duotone extends WP_UnitTestCase {
|
||||||
@ -166,4 +166,32 @@ class Tests_Block_Supports_Duotone extends WP_UnitTestCase {
|
|||||||
'invalid' => array( 'not a valid attribute', false ),
|
'invalid' => array( 'not a valid attribute', false ),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider data_colord_parse_hue
|
||||||
|
* @ticket 59496
|
||||||
|
*/
|
||||||
|
public function test_colord_parse_hue( $value, $unit, $expected ) {
|
||||||
|
$reflection = new ReflectionMethod( 'WP_Duotone', 'colord_parse_hue' );
|
||||||
|
$reflection->setAccessible( true );
|
||||||
|
|
||||||
|
$this->assertSame( $expected, $reflection->invoke( null, $value, $unit ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data provider.
|
||||||
|
*
|
||||||
|
* @return array[].
|
||||||
|
*/
|
||||||
|
public function data_colord_parse_hue() {
|
||||||
|
return array(
|
||||||
|
'deg-angle-unit' => array( 120, 'deg', 120.0 ),
|
||||||
|
'grad-angle-unit' => array( 120, 'grad', 108.0 ),
|
||||||
|
'turn-angle-unit' => array( 120, 'turn', 43200.0 ),
|
||||||
|
'rad-angle-unit' => array( 120, 'rad', 6875.493541569878 ),
|
||||||
|
'empty-angle-unit' => array( 120, '', 120.0 ),
|
||||||
|
'invalid-angle-unit' => array( 120, 'invalid', 120.0 ),
|
||||||
|
'negative-value-deg-angle-unit' => array( -120, 'deg', -120.0 ),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user