mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
As of [55749] wp_queue_comments_for_comment_meta_lazyload is no longer used in core. This commit, deprecates this function. Update docs and tests accordingly. Props sh4lin, spacedmonkey, costdev, peterwilsoncc. Fixes #58301. git-svn-id: https://develop.svn.wordpress.org/trunk@55855 602fd350-edb4-49c9-b593-d223f7449a82
71 lines
2.0 KiB
PHP
71 lines
2.0 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @group comments
|
|
* @group meta
|
|
*/
|
|
class Tests_Lazy_Load_Comment_Meta extends WP_UnitTestCase {
|
|
|
|
/**
|
|
* @var int
|
|
*/
|
|
protected static $post_id;
|
|
|
|
/**
|
|
* @var array
|
|
*/
|
|
protected static $comment_ids = array();
|
|
|
|
public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
|
|
|
|
self::$post_id = $factory->post->create();
|
|
self::$comment_ids = $factory->comment->create_post_comments( self::$post_id, 11 );
|
|
}
|
|
|
|
/**
|
|
* @ticket 57901
|
|
*
|
|
* @covers ::wp_queue_comments_for_comment_meta_lazyload
|
|
*
|
|
* @expectedDeprecated wp_queue_comments_for_comment_meta_lazyload
|
|
*/
|
|
public function test_wp_queue_comments_for_comment_meta_lazyload() {
|
|
$filter = new MockAction();
|
|
add_filter( 'update_comment_metadata_cache', array( $filter, 'filter' ), 10, 2 );
|
|
$comments = array_map( 'get_comment', self::$comment_ids );
|
|
$comment_id = reset( self::$comment_ids );
|
|
wp_queue_comments_for_comment_meta_lazyload( $comments );
|
|
get_comment_meta( $comment_id );
|
|
|
|
$args = $filter->get_args();
|
|
$first = reset( $args );
|
|
$comment_meta_ids = end( $first );
|
|
$this->assertSameSets( self::$comment_ids, $comment_meta_ids );
|
|
}
|
|
|
|
/**
|
|
* @ticket 57901
|
|
*
|
|
* @covers ::wp_queue_comments_for_comment_meta_lazyload
|
|
*
|
|
* @expectedDeprecated wp_queue_comments_for_comment_meta_lazyload
|
|
*/
|
|
public function test_wp_queue_comments_for_comment_meta_lazyload_new_comment() {
|
|
$filter = new MockAction();
|
|
add_filter( 'update_comment_metadata_cache', array( $filter, 'filter' ), 10, 2 );
|
|
$comments = array_map( 'get_comment', self::$comment_ids );
|
|
$comment_id = self::factory()->comment->create(
|
|
array(
|
|
'comment_post_ID' => self::$post_id,
|
|
)
|
|
);
|
|
wp_queue_comments_for_comment_meta_lazyload( $comments );
|
|
get_comment_meta( $comment_id );
|
|
|
|
$args = $filter->get_args();
|
|
$first = reset( $args );
|
|
$comment_meta_ids = end( $first );
|
|
$this->assertContains( $comment_id, $comment_meta_ids );
|
|
}
|
|
}
|