WordPress.org

Make WordPress Core

Opened 5 years ago

Last modified 6 months ago

#28759 new enhancement

Cache API unit tests should verify public function, not WP_Object_Cache methods

Reported by: tollmanz Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Cache API Keywords: has-patch
Focuses: Cc:
PR Number:

Description

The public API for the WP object cache uses the global wp_cache_* functions. Traditionally, these functions are mapped to a class, WP_Object_Cache, that provides the logic for the cache through different class methods. The public API is then a wrapper for these methods. I think we should transition our unit tests to test the public API, especially as this makes it easier to test 3rd party caches against these tests. 3rd party object caches shouldn't be required to implement the WP_Object_Cache methods; they should only be required to implement the public functions.

Additionally, having these tests test the public API will help should we ever decide to change the WP_Object_Cache internals.

Attachments (1)

28759-cache-unit-tests.diff (37.1 KB) - added by jipmoors 5 years ago.
Split unit tests for Public API and WP_Cache_Object

Download all attachments as: .zip

Change History (8)

#1 @SergeyBiryukov
5 years ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to Future Release

#2 @jipmoors
5 years ago

  • Keywords needs-unit-tests added; needs-patch removed

I took this improvement into consideration in the arguments used to sketch a new way to implement the public functions via filters in 22661.

Having these tests would make a lot more sense if the public functions are always used to handle cache requests instead of having external sources implement these themselves, which does not guarantee passing the tests.

@jipmoors
5 years ago

Split unit tests for Public API and WP_Cache_Object

#3 @jipmoors
5 years ago

  • Keywords close added; needs-unit-tests removed

#4 @jipmoors
5 years ago

  • Keywords has-patch added

#5 @jipmoors
5 years ago

Please note #31600 having a patch to failed tests

#6 @jipmoors
5 years ago

  • Keywords close removed

This ticket was mentioned in Slack in #core by jip. View the logs.


5 years ago

Note: See TracTickets for help on using tickets.