WordPress.org

Make WordPress Core

Changeset 1059 in tests


Ignore:
Timestamp:
10/01/12 15:32:11 (19 months ago)
Author:
ryan
Message:

Tests for the status arg to get_comments(). see #WP21101

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/comment/query.php

    r1058 r1059  
    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( 20, count( get_comments( array( 'status' => 'approve' ) ) ) ); 
     134        $this->assertEquals( 10, count( get_comments( array( 'status' => 'hold' ) ) ) ); 
     135        $this->assertEquals( 10, count( get_comments( array( 'status' => 'trash' ) ) ) ); 
     136        $this->assertEquals( 10, count( get_comments( array( 'status' => 'spam' ) ) ) ); 
     137    } 
    114138} 
Note: See TracChangeset for help on using the changeset viewer.