Make WordPress Core


Ignore:
Timestamp:
07/02/2015 12:21:28 AM (11 years ago)
Author:
obenland
Message:

Turn of comments for pages by default.

Pages are static content, for which comments are not expected out of the box.

Props valendesigns, rachelbaker.
Fixes #31168.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/post.php

    r32604 r33041  
    951951                }
    952952        }
     953
     954        /**
     955         * @ticket 31168
     956         */
     957        function test_wp_insert_post_default_comment_ping_status_open() {
     958                $post_id = $this->factory->post->create( array(
     959                        'post_author' => $this->author_id,
     960                        'post_status' => 'public',
     961                        'post_content' => rand_str(),
     962                        'post_title' => rand_str(),
     963                ) );
     964                $post = get_post( $post_id );
     965
     966                $this->assertEquals( 'open', $post->comment_status );
     967                $this->assertEquals( 'open', $post->ping_status );
     968        }
     969
     970        /**
     971         * @ticket 31168
     972         */
     973        function test_wp_insert_post_page_default_comment_ping_status_closed() {
     974                $post_id = $this->factory->post->create( array(
     975                        'post_author' => $this->author_id,
     976                        'post_status' => 'public',
     977                        'post_content' => rand_str(),
     978                        'post_title' => rand_str(),
     979                        'post_type' => 'page',
     980                ) );
     981                $post = get_post( $post_id );
     982
     983                $this->assertEquals( 'closed', $post->comment_status );
     984                $this->assertEquals( 'closed', $post->ping_status );
     985        }
     986
     987        /**
     988         * @ticket 31168
     989         */
     990        function test_wp_insert_post_cpt_default_comment_ping_status_open() {
     991                $post_type = rand_str(20);
     992                register_post_type( $post_type, array( 'supports' => array( 'comments', 'trackbacks' ) ) );
     993                $post_id = $this->factory->post->create( array(
     994                        'post_author' => $this->author_id,
     995                        'post_status' => 'public',
     996                        'post_content' => rand_str(),
     997                        'post_title' => rand_str(),
     998                        'post_type' => $post_type,
     999                ) );
     1000                $post = get_post( $post_id );
     1001
     1002                $this->assertEquals( 'open', $post->comment_status );
     1003                $this->assertEquals( 'open', $post->ping_status );
     1004                _unregister_post_type( $post_type );
     1005        }
     1006
     1007        /**
     1008         * @ticket 31168
     1009         */
     1010        function test_wp_insert_post_cpt_default_comment_ping_status_closed() {
     1011                $post_type = rand_str(20);
     1012                register_post_type( $post_type );
     1013                $post_id = $this->factory->post->create( array(
     1014                        'post_author' => $this->author_id,
     1015                        'post_status' => 'public',
     1016                        'post_content' => rand_str(),
     1017                        'post_title' => rand_str(),
     1018                        'post_type' => $post_type,
     1019                ) );
     1020                $post = get_post( $post_id );
     1021
     1022                $this->assertEquals( 'closed', $post->comment_status );
     1023                $this->assertEquals( 'closed', $post->ping_status );
     1024                _unregister_post_type( $post_type );
     1025        }
    9531026}
Note: See TracChangeset for help on using the changeset viewer.