Changeset 56588
- Timestamp:
- 09/14/2023 02:54:41 PM (13 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-block-type-controller.php
r56587 r56588 202 202 $settings = array( 203 203 'title' => true, 204 'category' => true, 205 'parent' => 'invalid_parent', 206 'ancestor' => 'invalid_ancestor', 207 'icon' => true, 204 208 'description' => true, 205 'icon' => true, 209 'keywords' => 'invalid_keywords', 210 'textdomain' => true, 206 211 'attributes' => 'invalid_attributes', 207 212 'provides_context' => 'invalid_provides_context', 208 213 'uses_context' => 'invalid_uses_context', 214 'selectors' => 'invalid_selectors', 215 'supports' => 'invalid_supports', 216 'styles' => array(), 217 'example' => 'invalid_example', 218 'variations' => 'invalid_variations', 209 219 'block_hooks' => 'invalid_block_hooks', 210 ' category' => true,220 'render_callback' => 'invalid_callback', 211 221 'editor_script' => true, 212 222 'script' => true, … … 214 224 'editor_style' => true, 215 225 'style' => true, 216 'keywords' => 'invalid_keywords',217 'example' => 'invalid_example',218 'parent' => 'invalid_parent',219 'ancestor' => 'invalid_ancestor',220 'selectors' => 'invalid_selectors',221 'supports' => 'invalid_supports',222 'styles' => array(),223 'render_callback' => 'invalid_callback',224 'textdomain' => true,225 'variations' => 'invalid_variations',226 226 ); 227 227 register_block_type( $block_type, $settings ); … … 232 232 $this->assertSame( $block_type, $data['name'] ); 233 233 $this->assertSame( '1', $data['title'] ); 234 $this->assertNull( $data['category'] ); 235 $this->assertSameSets( array( 'invalid_parent' ), $data['parent'] ); 236 $this->assertSameSets( array( 'invalid_ancestor' ), $data['ancestor'] ); 237 $this->assertNull( $data['icon'] ); 234 238 $this->assertSame( '1', $data['description'] ); 235 $this->assertNull( $data['icon'] ); 239 $this->assertSameSets( array( 'invalid_keywords' ), $data['keywords'] ); 240 $this->assertNull( $data['textdomain'] ); 241 $this->assertSameSetsWithIndex( 242 array( 243 'lock' => array( 'type' => 'object' ), 244 ), 245 $data['attributes'] 246 ); 247 $this->assertSameSets( array( 'invalid_uses_context' ), $data['uses_context'] ); 248 $this->assertSameSets( array(), $data['provides_context'] ); 249 $this->assertSameSets( array(), $data['selectors'], 'invalid selectors defaults to empty array' ); 250 $this->assertSameSets( array(), $data['supports'] ); 251 $this->assertSameSets( array(), $data['styles'] ); 252 $this->assertNull( $data['example'] ); 253 $this->assertSameSets( array( array() ), $data['variations'] ); 254 $this->assertSameSets( array(), $data['block_hooks'], 'invalid block_hooks defaults to empty array' ); 236 255 $this->assertSameSets( array(), $data['editor_script_handles'] ); 237 256 $this->assertSameSets( array(), $data['script_handles'] ); … … 239 258 $this->assertSameSets( array(), $data['editor_style_handles'] ); 240 259 $this->assertSameSets( array(), $data['style_handles'] ); 241 $this->assertSameSets( array(), $data['provides_context'] );242 $this->assertSameSetsWithIndex(243 array(244 'lock' => array( 'type' => 'object' ),245 ),246 $data['attributes']247 );248 $this->assertSameSets( array( 'invalid_uses_context' ), $data['uses_context'] );249 $this->assertSameSets( array(), $data['block_hooks'], 'invalid block_hooks defaults to empty array' );250 $this->assertSameSets( array( 'invalid_keywords' ), $data['keywords'] );251 $this->assertSameSets( array( 'invalid_parent' ), $data['parent'] );252 $this->assertSameSets( array( 'invalid_ancestor' ), $data['ancestor'] );253 $this->assertSameSets( array(), $data['selectors'], 'invalid selectors defaults to empty array' );254 $this->assertSameSets( array(), $data['supports'] );255 $this->assertSameSets( array(), $data['styles'] );256 $this->assertNull( $data['example'] );257 $this->assertNull( $data['category'] );258 $this->assertNull( $data['textdomain'] );259 260 $this->assertFalse( $data['is_dynamic'] ); 260 $this->assertSameSets( array( array() ), $data['variations'] );261 261 // Deprecated properties. 262 262 $this->assertNull( $data['editor_script'] ); … … 276 276 $settings = array( 277 277 'title' => false, 278 'category' => false, 279 'parent' => false, 280 'ancestor' => false, 281 'icon' => false, 278 282 'description' => false, 279 'icon' => false, 283 'keywords' => false, 284 'textdomain' => false, 280 285 'attributes' => false, 281 286 'provides_context' => false, 282 287 'uses_context' => false, 288 'selectors' => false, 289 'supports' => false, 290 'styles' => false, 291 'example' => false, 292 'variations' => false, 283 293 'block_hooks' => false, 284 'category' => false,285 294 'editor_script' => false, 286 295 'script' => false, … … 288 297 'editor_style' => false, 289 298 'style' => false, 290 'keywords' => false,291 'parent' => false,292 'ancestor' => false,293 'selectors' => false,294 'supports' => false,295 'styles' => false,296 299 'render_callback' => false, 297 'textdomain' => false,298 'example' => false,299 'variations' => false,300 300 ); 301 301 register_block_type( $block_type, $settings ); … … 306 306 $this->assertSame( $block_type, $data['name'] ); 307 307 $this->assertSame( '', $data['title'] ); 308 $this->assertNull( $data['category'] ); 309 $this->assertSameSets( array(), $data['parent'] ); 310 $this->assertSameSets( array(), $data['ancestor'] ); 311 $this->assertNull( $data['icon'] ); 308 312 $this->assertSame( '', $data['description'] ); 309 $this->assertNull( $data['icon'] ); 313 $this->assertSameSets( array(), $data['keywords'] ); 314 $this->assertNull( $data['textdomain'] ); 315 $this->assertSameSetsWithIndex( 316 array( 317 'lock' => array( 'type' => 'object' ), 318 ), 319 $data['attributes'] 320 ); 321 $this->assertSameSets( array(), $data['provides_context'] ); 322 $this->assertSameSets( array(), $data['uses_context'] ); 323 $this->assertSameSets( array(), $data['selectors'], 'selectors defaults to empty array' ); 324 $this->assertSameSets( array(), $data['supports'] ); 325 $this->assertSameSets( array(), $data['styles'] ); 326 $this->assertNull( $data['example'] ); 327 $this->assertSameSets( array(), $data['variations'] ); 328 $this->assertSameSets( array(), $data['block_hooks'], 'block_hooks defaults to empty array' ); 310 329 $this->assertSameSets( array(), $data['editor_script_handles'] ); 311 330 $this->assertSameSets( array(), $data['script_handles'] ); … … 313 332 $this->assertSameSets( array(), $data['editor_style_handles'] ); 314 333 $this->assertSameSets( array(), $data['style_handles'] ); 315 $this->assertSameSetsWithIndex(316 array(317 'lock' => array( 'type' => 'object' ),318 ),319 $data['attributes']320 );321 $this->assertSameSets( array(), $data['provides_context'] );322 $this->assertSameSets( array(), $data['block_hooks'], 'block_hooks defaults to empty array' );323 $this->assertSameSets( array(), $data['uses_context'] );324 $this->assertSameSets( array(), $data['keywords'] );325 $this->assertSameSets( array(), $data['parent'] );326 $this->assertSameSets( array(), $data['ancestor'] );327 $this->assertSameSets( array(), $data['selectors'], 'selectors defaults to empty array' );328 $this->assertSameSets( array(), $data['supports'] );329 $this->assertSameSets( array(), $data['styles'] );330 $this->assertNull( $data['example'] );331 $this->assertNull( $data['category'] );332 $this->assertNull( $data['example'] );333 $this->assertNull( $data['textdomain'] );334 334 $this->assertFalse( $data['is_dynamic'] ); 335 $this->assertSameSets( array(), $data['variations'] );336 335 // Deprecated properties. 337 336 $this->assertNull( $data['editor_script'] ); … … 555 554 $this->assertCount( 30, $properties ); 556 555 $this->assertArrayHasKey( 'api_version', $properties ); 556 $this->assertArrayHasKey( 'name', $properties ); 557 557 $this->assertArrayHasKey( 'title', $properties ); 558 $this->assertArrayHasKey( 'category', $properties ); 559 $this->assertArrayHasKey( 'parent', $properties ); 560 $this->assertArrayHasKey( 'ancestor', $properties ); 558 561 $this->assertArrayHasKey( 'icon', $properties ); 559 562 $this->assertArrayHasKey( 'description', $properties ); 560 563 $this->assertArrayHasKey( 'keywords', $properties ); 561 $this->assertArrayHasKey( 'styles', $properties );562 564 $this->assertArrayHasKey( 'textdomain', $properties ); 563 $this->assertArrayHasKey( 'name', $properties );564 565 $this->assertArrayHasKey( 'attributes', $properties ); 566 $this->assertArrayHasKey( 'provides_context', $properties ); 567 $this->assertArrayHasKey( 'uses_context', $properties ); 565 568 $this->assertArrayHasKey( 'selectors', $properties, 'schema must contain selectors' ); 566 569 $this->assertArrayHasKey( 'supports', $properties ); 567 $this->assertArrayHasKey( 'category', $properties ); 568 $this->assertArrayHasKey( 'is_dynamic', $properties ); 570 $this->assertArrayHasKey( 'styles', $properties ); 571 $this->assertArrayHasKey( 'example', $properties ); 572 $this->assertArrayHasKey( 'variations', $properties ); 573 $this->assertArrayHasKey( 'block_hooks', $properties ); 569 574 $this->assertArrayHasKey( 'editor_script_handles', $properties ); 570 575 $this->assertArrayHasKey( 'script_handles', $properties ); … … 572 577 $this->assertArrayHasKey( 'editor_style_handles', $properties ); 573 578 $this->assertArrayHasKey( 'style_handles', $properties ); 574 $this->assertArrayHasKey( 'parent', $properties ); 575 $this->assertArrayHasKey( 'example', $properties ); 576 $this->assertArrayHasKey( 'uses_context', $properties ); 577 $this->assertArrayHasKey( 'provides_context', $properties ); 578 $this->assertArrayHasKey( 'block_hooks', $properties ); 579 $this->assertArrayHasKey( 'variations', $properties ); 580 $this->assertArrayHasKey( 'ancestor', $properties ); 579 $this->assertArrayHasKey( 'is_dynamic', $properties ); 581 580 // Deprecated properties. 582 581 $this->assertArrayHasKey( 'editor_script', $properties ); … … 687 686 'api_version', 688 687 'name', 688 'title', 689 689 'category', 690 'parent', 691 'ancestor', 692 'icon', 693 'description', 694 'keywords', 695 'textdomain', 696 'provides_context', 697 'uses_context', 698 'selectors', 699 'supports', 700 'styles', 701 'example', 702 'variations', 703 'block_hooks', 690 704 'editor_script_handles', 691 705 'script_handles', … … 693 707 'editor_style_handles', 694 708 'style_handles', 695 'title',696 'icon',697 'description',698 'keywords',699 'parent',700 'provides_context',701 'uses_context',702 'block_hooks',703 'supports',704 'styles',705 'textdomain',706 'example',707 709 // Deprecated fields. 708 710 'editor_script',
Note: See TracChangeset
for help on using the changeset viewer.