- Timestamp:
- 02/12/2026 05:06:08 AM (3 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/block-supports/wpApplyDimensionsSupport.php
r55175 r61619 101 101 ); 102 102 } 103 104 /** 105 * Tests that width block support works as expected. 106 * 107 * @ticket 64200 108 * 109 * @covers ::wp_apply_dimensions_support 110 * 111 * @dataProvider data_width_block_support 112 * 113 * @param string $block_name The test block name to register. 114 * @param mixed $dimensions The dimensions block support settings. 115 * @param mixed $expected The expected results. 116 */ 117 public function test_width_block_support( $block_name, $dimensions, $expected ) { 118 $this->test_block_name = $block_name; 119 register_block_type( 120 $this->test_block_name, 121 array( 122 'api_version' => 2, 123 'attributes' => array( 124 'style' => array( 125 'type' => 'object', 126 ), 127 ), 128 'supports' => array( 129 'dimensions' => $dimensions, 130 ), 131 ) 132 ); 133 $registry = WP_Block_Type_Registry::get_instance(); 134 $block_type = $registry->get_registered( $this->test_block_name ); 135 $block_attrs = array( 136 'style' => array( 137 'dimensions' => array( 138 'width' => '300px', 139 ), 140 ), 141 ); 142 143 $actual = wp_apply_dimensions_support( $block_type, $block_attrs ); 144 145 $this->assertSame( $expected, $actual ); 146 } 147 148 /** 149 * Data provider. 150 * 151 * @return array 152 */ 153 public function data_width_block_support() { 154 return array( 155 'style is applied' => array( 156 'block_name' => 'test/width-style-is-applied', 157 'dimensions' => array( 158 'width' => true, 159 ), 160 'expected' => array( 161 'style' => 'width:300px;', 162 ), 163 ), 164 'style output is skipped when individual feature serialization is skipped' => array( 165 'block_name' => 'test/width-with-individual-skipped-serialization-block-supports', 166 'dimensions' => array( 167 'width' => true, 168 '__experimentalSkipSerialization' => array( 'width' ), 169 ), 170 'expected' => array(), 171 ), 172 ); 173 } 103 174 }
Note: See TracChangeset
for help on using the changeset viewer.