mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
This changeset adds caching to `wp_count_attachments()`, for better consistency with `wp_count_posts()`. Props jeherve, antpb, mukesh27, robinwpdeveloper, costdev. Fixes #55227. git-svn-id: https://develop.svn.wordpress.org/trunk@54255 602fd350-edb4-49c9-b593-d223f7449a82
34 lines
665 B
PHP
34 lines
665 B
PHP
<?php
|
|
|
|
/**
|
|
* @group post
|
|
* @group media
|
|
* @group upload
|
|
*
|
|
* @covers ::wp_count_attachments
|
|
*/
|
|
class Tests_Post_wpCountAttachments extends WP_UnitTestCase {
|
|
|
|
/**
|
|
* Tests that the result is cached.
|
|
*
|
|
* @ticket 55227
|
|
*/
|
|
public function test_wp_count_attachments_should_cache_the_result() {
|
|
$mime_type = 'image/jpeg';
|
|
$cache_key = 'attachments:image_jpeg';
|
|
|
|
self::factory()->post->create_many(
|
|
3,
|
|
array(
|
|
'post_type' => 'attachment',
|
|
'post_mime_type' => $mime_type,
|
|
)
|
|
);
|
|
$expected = wp_count_attachments( $mime_type );
|
|
$actual = wp_cache_get( $cache_key, 'counts' );
|
|
|
|
$this->assertEquals( $expected, $actual );
|
|
}
|
|
}
|