WordPress.org

Make WordPress Core

Ticket #21101: 21101-ut.diff

File 21101-ut.diff, 1.6 KB (added by ryan, 6 years ago)
  • tests/comment/query.php

     
    111111                $comments = get_comments( array( 'meta_value' => 'value1', 'orderby' => array( 'meta_value' ) ) );
    112112                $this->assertEquals( 1, count( $comments ) );
    113113        }
     114
     115        function test_get_status() {
     116                $post_id = $this->factory->post->create();
     117                $this->factory->comment->create_post_comments( $post_id, 10 );
     118
     119                $post_id2 = $this->factory->post->create();
     120                $this->factory->comment->create_post_comments( $post_id2, 10 );
     121
     122                $post_id3 = $this->factory->post->create();
     123                $this->factory->comment->create_post_comments( $post_id3, 10, array( 'comment_approved' => '0' ) );
     124
     125                $post_id4 = $this->factory->post->create();
     126                $this->factory->comment->create_post_comments( $post_id4, 10, array( 'comment_approved' => 'trash' ) );
     127
     128                $post_id5 = $this->factory->post->create();
     129                $this->factory->comment->create_post_comments( $post_id5, 10, array( 'comment_approved' => 'spam' ) );
     130
     131                $this->assertEquals( 30, count( get_comments() ) );
     132                $this->assertEquals( 30, count( get_comments( array( 'status' => 'all' ) ) ) );
     133                $this->assertEquals( 50, count( get_comments( array( 'status' => 'full' ) ) ) );
     134                $this->assertEquals( 20, count( get_comments( array( 'status' => 'approve' ) ) ) );
     135                $this->assertEquals( 10, count( get_comments( array( 'status' => 'hold' ) ) ) );
     136                $this->assertEquals( 10, count( get_comments( array( 'status' => 'trash' ) ) ) );
     137                $this->assertEquals( 10, count( get_comments( array( 'status' => 'spam' ) ) ) );
     138        }
    114139}