- Timestamp:
- 09/23/2019 08:24:59 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php
r46252 r46272 4527 4527 } 4528 4528 4529 /** 4530 * @ticket 45677 4531 */ 4532 public function test_get_for_post_type_reuses_same_instance() { 4533 $this->assertSame( 4534 get_post_type_object( 'post' )->get_rest_controller(), 4535 get_post_type_object( 'post' )->get_rest_controller() 4536 ); 4537 } 4538 4539 /** 4540 * @ticket 45677 4541 */ 4542 public function test_get_for_post_type_returns_null_if_post_type_does_not_show_in_rest() { 4543 register_post_type( 4544 'not_in_rest', 4545 array( 4546 'show_in_rest' => false, 4547 ) 4548 ); 4549 4550 $this->assertNull( get_post_type_object( 'not_in_rest' )->get_rest_controller() ); 4551 } 4552 4553 /** 4554 * @ticket 45677 4555 */ 4556 public function test_get_for_post_type_returns_null_if_class_does_not_exist() { 4557 register_post_type( 4558 'class_not_found', 4559 array( 4560 'show_in_rest' => true, 4561 'rest_controller_class' => 'Class_That_Does_Not_Exist', 4562 ) 4563 ); 4564 4565 $this->assertNull( get_post_type_object( 'class_not_found' )->get_rest_controller() ); 4566 } 4567 4568 /** 4569 * @ticket 45677 4570 */ 4571 public function test_get_for_post_type_returns_null_if_class_does_not_subclass_rest_controller() { 4572 register_post_type( 4573 'invalid_class', 4574 array( 4575 'show_in_rest' => true, 4576 'rest_controller_class' => 'WP_Post', 4577 ) 4578 ); 4579 4580 $this->assertNull( get_post_type_object( 'invalid_class' )->get_rest_controller() ); 4581 } 4582 4583 /** 4584 * @ticket 45677 4585 */ 4586 public function test_get_for_post_type_returns_posts_controller_if_custom_class_not_specified() { 4587 register_post_type( 4588 'test', 4589 array( 4590 'show_in_rest' => true, 4591 ) 4592 ); 4593 4594 $this->assertInstanceOf( 4595 WP_REST_Posts_Controller::class, 4596 get_post_type_object( 'test' )->get_rest_controller() 4597 ); 4598 } 4599 4600 /** 4601 * @ticket 45677 4602 */ 4603 public function test_get_for_post_type_returns_provided_controller_class() { 4604 $this->assertInstanceOf( 4605 WP_REST_Blocks_Controller::class, 4606 get_post_type_object( 'wp_block' )->get_rest_controller() 4607 ); 4608 } 4609 4529 4610 public function tearDown() { 4530 4611 _unregister_post_type( 'private-post' );
Note: See TracChangeset
for help on using the changeset viewer.