mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
Allow get_comments_number() to officially accept $post or $post_id. Adds unit tests.
Props coffee2code, JanHenkG. Fixes #26240. git-svn-id: https://develop.svn.wordpress.org/trunk@28558 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* @group comment
|
||||
*/
|
||||
class Tests_Comment_Template extends WP_UnitTestCase {
|
||||
|
||||
function test_get_comments_number() {
|
||||
$post_id = $this->factory->post->create();
|
||||
|
||||
$this->assertEquals( 0, get_comments_number( 0 ) );
|
||||
$this->assertEquals( 0, get_comments_number( $post_id ) );
|
||||
$this->assertEquals( 0, get_comments_number( get_post( $post_id ) ) );
|
||||
|
||||
$this->factory->comment->create_post_comments( $post_id, 12 );
|
||||
|
||||
$this->assertEquals( 12, get_comments_number( $post_id ) );
|
||||
$this->assertEquals( 12, get_comments_number( get_post( $post_id ) ) );
|
||||
}
|
||||
|
||||
function test_get_comments_number_without_arg() {
|
||||
$post_id = $this->factory->post->create();
|
||||
$permalink = get_permalink( $post_id );
|
||||
$this->go_to( $permalink );
|
||||
|
||||
$this->assertEquals( 0, get_comments_number() );
|
||||
|
||||
$this->factory->comment->create_post_comments( $post_id, 12 );
|
||||
$this->go_to( $permalink );
|
||||
|
||||
$this->assertEquals( 12, get_comments_number() );
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user