Changeset 58312
- Timestamp:
- 06/03/2024 11:34:24 PM (4 months ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/block-supports/shadow.php
r57510 r58312 44 44 * 45 45 * @since 6.3.0 46 * @since 6.6.0 Return early if __experimentalSkipSerialization is true. 46 47 * @access private 47 48 * … … 53 54 $has_shadow_support = block_has_support( $block_type, 'shadow', false ); 54 55 55 if ( ! $has_shadow_support ) { 56 if ( 57 ! $has_shadow_support || 58 wp_should_skip_block_supports_serialization( $block_type, 'shadow' ) 59 ) { 56 60 return array(); 57 61 } -
trunk/tests/phpunit/tests/block-supports/shadow.php
r58181 r58312 23 23 24 24 /** 25 * @ticket 58590 25 * Registers a new block for testing shadow support. 26 * 27 * @param string $block_name Name for the test block. 28 * @param array $supports Array defining block support configuration. 29 * 30 * @return WP_Block_Type The block type for the newly registered test block. 26 31 */ 27 p ublic function test_shadow_style_is_applied() {28 $this->test_block_name = 'test/shadow-style-is-applied';32 private function register_shadow_block_with_support( $block_name, $supports = array() ) { 33 $this->test_block_name = $block_name; 29 34 register_block_type( 30 35 $this->test_block_name, … … 36 41 ), 37 42 ), 38 'supports' => array( 39 'shadow' => true, 40 ), 43 'supports' => $supports, 41 44 ) 42 45 ); 43 $registry = WP_Block_Type_Registry::get_instance(); 44 $block_type = $registry->get_registered( $this->test_block_name ); 45 $block_atts = array( 46 'style' => array( 47 'shadow' => '60px -16px teal', 48 ), 46 $registry = WP_Block_Type_Registry::get_instance(); 47 48 return $registry->get_registered( $this->test_block_name ); 49 } 50 51 /** 52 * Tests the generation of shadow block support styles. 53 * 54 * @dataProvider data_generate_shadow_fixtures 55 * 56 * @param boolean|array $support Shadow block support configuration. 57 * @param string $value Shadow style value for style attribute object. 58 * @param array $expected Expected shadow block support styles. 59 */ 60 public function test_wp_apply_shadow_support( $support, $value, $expected ) { 61 $block_type = self::register_shadow_block_with_support( 62 'test/shadow-block', 63 array( 'shadow' => $support ) 49 64 ); 50 51 $actual = wp_apply_shadow_support( $block_type, $block_atts ); 52 $expected = array( 53 'style' => 'box-shadow:60px -16px teal;', 54 ); 65 $block_attrs = array( 'style' => array( 'shadow' => $value ) ); 66 $actual = wp_apply_shadow_support( $block_type, $block_attrs ); 55 67 56 68 $this->assertSame( $expected, $actual ); … … 58 70 59 71 /** 60 * @ticket 58590 72 * Data provider. 73 * 74 * @return array 61 75 */ 62 public function test_shadow_without_block_supports() { 63 $this->test_block_name = 'test/shadow-with-skipped-serialization-block-supports'; 64 register_block_type( 65 $this->test_block_name, 66 array( 67 'api_version' => 2, 68 'attributes' => array( 69 'style' => array( 70 'type' => 'object', 71 ), 72 ), 73 'supports' => array(), 74 ) 75 ); 76 $registry = WP_Block_Type_Registry::get_instance(); 77 $block_type = $registry->get_registered( $this->test_block_name ); 78 $block_atts = array( 79 'style' => array( 80 'shadow' => '60px -16px teal', 76 public function data_generate_shadow_fixtures() { 77 return array( 78 'with no styles' => array( 79 'support' => true, 80 'value' => '', 81 'expected' => array(), 82 ), 83 'without support' => array( 84 'support' => false, 85 'value' => '1px 1px 1px #000', 86 'expected' => array(), 87 ), 88 'with single shadow' => array( 89 'support' => true, 90 'value' => '1px 1px 1px #000', 91 'expected' => array( 'style' => 'box-shadow:1px 1px 1px #000;' ), 92 ), 93 'with comma separated shadows' => array( 94 'support' => true, 95 'value' => '1px 1px 1px #000, 2px 2px 2px #fff', 96 'expected' => array( 'style' => 'box-shadow:1px 1px 1px #000, 2px 2px 2px #fff;' ), 97 ), 98 'with preset shadow' => array( 99 'support' => true, 100 'value' => 'var:preset|shadow|natural', 101 'expected' => array( 'style' => 'box-shadow:var(--wp--preset--shadow--natural);' ), 102 ), 103 'with serialization skipped' => array( 104 'support' => array( '__experimentalSkipSerialization' => true ), 105 'value' => '1px 1px 1px #000', 106 'expected' => array(), 81 107 ), 82 108 ); 83 84 $actual = wp_apply_spacing_support( $block_type, $block_atts );85 $expected = array();86 87 $this->assertSame( $expected, $actual );88 109 } 89 110 }
Note: See TracChangeset
for help on using the changeset viewer.