| 1 | <?php |
| 2 | class Tests_Post_Redirects extends WP_UnitTestCase { |
| 3 | |
| 4 | var $post; |
| 5 | |
| 6 | function setUp() { |
| 7 | parent::setUp(); |
| 8 | $post = array( |
| 9 | 'post_name' => 'foo', |
| 10 | 'post_title' => 'Foo', |
| 11 | 'post_status' => 'publish' |
| 12 | ); |
| 13 | $post['ID'] = wp_insert_post( $post ); |
| 14 | $this->post = $post; |
| 15 | } |
| 16 | |
| 17 | function test_old_slugs_private() { |
| 18 | $id = $this->post['ID']; |
| 19 | $before_post = get_post( $id ); |
| 20 | $this->post['post_name'] = 'foobar'; |
| 21 | $this->post['post_status'] = 'private'; |
| 22 | wp_update_post( $this->post ); |
| 23 | $old_slugs = (array) get_post_meta( $id, '_wp_old_slug' ); |
| 24 | $this->AssertTrue( in_array( 'foo', $old_slugs ) ); |
| 25 | } |
| 26 | |
| 27 | function test_old_slugs_publish() { |
| 28 | $id = $this->post['ID']; |
| 29 | $this->post['post_name'] = 'foobar'; |
| 30 | $this->post['post_status'] = 'private'; |
| 31 | wp_update_post( $this->post ); |
| 32 | $this->post['post_name'] = 'foo'; |
| 33 | $this->post['post_status'] = 'publish'; |
| 34 | wp_update_post( $this->post ); |
| 35 | $old_slugs = (array) get_post_meta( $id, '_wp_old_slug' ); |
| 36 | $this->AssertFalse( in_array( 'foo', $old_slugs ) ); |
| 37 | } |
| 38 | |
| 39 | } |
| 40 | No newline at end of file |