Changeset 58201 for trunk/tests/phpunit/tests/post/types.php
- Timestamp:
- 05/27/2024 09:04:10 AM (4 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/post/types.php
r57987 r58201 218 218 /** 219 219 * @ticket 21586 220 * @ticket 41172 220 221 */ 221 222 public function test_post_type_with_no_support() { 222 223 register_post_type( 'foo', array( 'supports' => array() ) ); 223 $this->assertTrue( post_type_supports( 'foo', 'editor' ) ); 224 $this->assertTrue( post_type_supports( 'foo', 'title' ) ); 224 $this->assertTrue( post_type_supports( 'foo', 'editor' ), 'Editor support should be enabled by default.' ); 225 $this->assertTrue( post_type_supports( 'foo', 'title' ), 'Title support should be enabled by default.' ); 226 $this->assertTrue( post_type_supports( 'foo', 'autosave' ), 'Autosaves support should be enabled by default.' ); 225 227 _unregister_post_type( 'foo' ); 226 228 227 229 register_post_type( 'foo', array( 'supports' => false ) ); 228 $this->assertFalse( post_type_supports( 'foo', 'editor' ) ); 229 $this->assertFalse( post_type_supports( 'foo', 'title' ) ); 230 $this->assertFalse( post_type_supports( 'foo', 'editor' ), 'Editor support should be disabled.' ); 231 $this->assertFalse( post_type_supports( 'foo', 'title' ), 'Title support should be disabled.' ); 232 $this->assertFalse( post_type_supports( 'foo', 'autosave' ), 'Autosaves support should be disabled.' ); 230 233 _unregister_post_type( 'foo' ); 231 234 } … … 433 436 $this->assertSameSetsWithIndex( 434 437 array( 435 'editor' => true, 436 'author' => true, 437 'title' => true, 438 'editor' => true, 439 'author' => true, 440 'title' => true, 441 'autosave' => true, 438 442 ), 439 443 $_wp_post_type_features['foo'] … … 590 594 $this->assertSameSets( array(), get_post_types_by_support( 'somefeature' ) ); 591 595 } 596 597 /** 598 * @ticket 41172 599 */ 600 public function test_post_type_supports_autosave_based_on_editor_support() { 601 register_post_type( 'foo', array( 'supports' => array( 'editor' ) ) ); 602 $this->assertTrue( post_type_supports( 'foo', 'autosave' ) ); 603 _unregister_post_type( 'foo' ); 604 605 register_post_type( 'foo', array( 'supports' => array( 'title' ) ) ); 606 $this->assertFalse( post_type_supports( 'foo', 'autosave' ) ); 607 _unregister_post_type( 'foo' ); 608 } 609 610 /** 611 * @ticket 41172 612 */ 613 public function test_removing_autosave_support_removes_rest_api_controller() { 614 register_post_type( 615 'foo', 616 array( 617 'show_in_rest' => true, 618 'supports' => array( 'editor' ), 619 ) 620 ); 621 622 $post_type_object = get_post_type_object( 'foo' ); 623 $this->assertInstanceOf( 'WP_REST_Autosaves_Controller', $post_type_object->get_autosave_rest_controller(), 'Autosave controller should be set by default.' ); 624 625 remove_post_type_support( 'foo', 'autosave' ); 626 $post_type_object = get_post_type_object( 'foo' ); 627 $this->assertSame( null, $post_type_object->get_autosave_rest_controller(), 'Autosave controller should be removed.' ); 628 _unregister_post_type( 'foo' ); 629 } 630 631 /** 632 * @ticket 41172 633 */ 634 public function test_removing_editor_support_does_not_remove_autosave_support() { 635 register_post_type( 636 'foo', 637 array( 638 'show_in_rest' => true, 639 'supports' => array( 'editor' ), 640 ) 641 ); 642 remove_post_type_support( 'foo', 'editor' ); 643 644 $this->assertFalse( post_type_supports( 'foo', 'editor' ), 'Post type should not support editor.' ); 645 $this->assertTrue( post_type_supports( 'foo', 'autosave' ), 'Post type should still support autosaves.' ); 646 } 592 647 }
Note: See TracChangeset
for help on using the changeset viewer.