| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | class Test_Draft_Child_URL extends WP_UnitTestCase { |
|---|
| 4 | |
|---|
| 5 | public function setUp() { |
|---|
| 6 | |
|---|
| 7 | parent::setUp(); |
|---|
| 8 | |
|---|
| 9 | global $wp_rewrite; |
|---|
| 10 | $wp_rewrite->set_permalink_structure('/%postname%/'); |
|---|
| 11 | |
|---|
| 12 | // Set up custom post type - 'test' |
|---|
| 13 | $args = array( 'hierarchical' => true, 'public' => true ); |
|---|
| 14 | register_post_type( 'test', $args ); |
|---|
| 15 | |
|---|
| 16 | } |
|---|
| 17 | |
|---|
| 18 | public function test_draft_child_post_link() { |
|---|
| 19 | $draft = $this->factory->post->create(array('post_type' => 'test', 'post_status' => 'draft')); |
|---|
| 20 | $public_draft_child = $this->factory->post->create(array('post_type' => 'test', 'post_status' => 'publish', 'post_parent' => $draft)); |
|---|
| 21 | |
|---|
| 22 | $public_draft_child = get_post( $public_draft_child ); |
|---|
| 23 | |
|---|
| 24 | $permalink = get_post_permalink( $public_draft_child ); |
|---|
| 25 | $expected = 'http://example.org/test/post-title-1/'; |
|---|
| 26 | |
|---|
| 27 | $this->assertEquals( $expected, $permalink ); |
|---|
| 28 | } |
|---|
| 29 | } |
|---|