WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#21 closed enhancement (fixed)

Unit tests for *_metadata_by_mid

Reported by: kovshenin Owned by:
Milestone: Legacy - Add New Tests Priority: normal
Component: Capabilities Keywords:
Cc: kovshenin

Description

Let's create a few tests for the get, update and delete _metadata_by_mid() functions.

Attachments (4)

test_includes_meta.patch (1.6 KB) - added by kovshenin 3 years ago.
Here's a patch for the update_metadata_by_mid function test.
test_includes_meta2.patch (2.3 KB) - added by kovshenin 3 years ago.
Improved version of the test case
test_includes_meta3.patch (2.7 KB) - added by kovshenin 3 years ago.
Testing for cached values
test_includes_meta4.patch (3.6 KB) - added by kovshenin 3 years ago.
Tests both update and delete _metadata_by_mid functions

Download all attachments as: .zip

Change History (9)

kovshenin3 years ago

Here's a patch for the update_metadata_by_mid function test.

comment:1 kovshenin3 years ago

Howdy all, this is my first time at unit testing for WordPress, so go easy on me. I've created a short test for the update_metadata_by_mid() function which has a patch in this ticket http://core.trac.wordpress.org/ticket/18195

A local run went smooth with 5 assertions. Hoping for some feedback!

kovshenin3 years ago

Improved version of the test case

comment:2 kovshenin3 years ago

I've attached an improved version of the test case, moved all the initialization to the setup method, added some invalid keys and meta id runs. Cleanup after usage. Hopefully this will do better.

kovshenin3 years ago

Testing for cached values

comment:3 kovshenin3 years ago

Third patch runs a test to see if caches got cleared after a meta update. This works with the latest patch to the function itself over at #wp18195. Let me know how this works for you. Thanks!

kovshenin3 years ago

Tests both update and delete _metadata_by_mid functions

comment:4 kovshenin3 years ago

Here's a version that tests both update and delete functions. The patch for both functions together has been uploaded here #wp18195. Have a good day!

comment:5 ryan3 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [384]) Update and delete by mid tests. Props kovshenin. fixes #21

Note: See TracTickets for help on using tickets.