| 1 | <?php |
| 2 | /** |
| 3 | * @group formatting |
| 4 | */ |
| 5 | class Tests_Formatting_SanitizePost extends WP_UnitTestCase { |
| 6 | |
| 7 | public function setUp() { |
| 8 | parent::setUp(); |
| 9 | $post_id = wp_insert_post( array( |
| 10 | 'post_type' => 'post', |
| 11 | 'post_status' => 'draft', |
| 12 | 'post_content' => 'content', |
| 13 | 'post_title' => 'title', |
| 14 | ) ); |
| 15 | $this->post = get_post( $post_id ); |
| 16 | } |
| 17 | |
| 18 | /** |
| 19 | * @ticket 22324 |
| 20 | */ |
| 21 | function test_int_fields() { |
| 22 | $int_fields = array( 'ID', 'post_parent', 'menu_order', 'post_author', 'comment_count' ); |
| 23 | foreach ( $int_fields as $field ) |
| 24 | $this->post->{$field} = 'string'; |
| 25 | |
| 26 | sanitize_post( $this->post ); |
| 27 | |
| 28 | foreach ( $int_fields as $field ) |
| 29 | $this->assertTrue( is_int( $this->post->{$field} ), "Expected integer: {$field}" ); |
| 30 | } |
| 31 | |
| 32 | public function tearDown() { |
| 33 | parent::tearDown(); |
| 34 | wp_delete_post( $this->post->ID, true ); |
| 35 | } |
| 36 | } |