Change method name to delete_meta_data_value
This commit is contained in:
parent
3c64b953a0
commit
4f38c051bf
|
@ -1,4 +1,4 @@
|
|||
Significance: minor
|
||||
Type: add
|
||||
|
||||
Add method delete_matched_meta_data to WC_Data objects
|
||||
Add method delete_meta_data_value to WC_Data objects
|
||||
|
|
|
@ -513,7 +513,7 @@ abstract class WC_Data {
|
|||
* @param string $key Meta key.
|
||||
* @param mixed $value Meta value. Entries will only be removed that match the value.
|
||||
*/
|
||||
public function delete_matched_meta_data( $key, $value ) {
|
||||
public function delete_meta_data_value( $key, $value ) {
|
||||
$this->maybe_read_meta_data();
|
||||
$array_keys = array_keys( wp_list_pluck( $this->meta_data, 'key' ), $key, true );
|
||||
|
||||
|
|
|
@ -328,7 +328,7 @@ class WC_Tests_CRUD_Data extends WC_Unit_Test_Case {
|
|||
/**
|
||||
* Test deleting meta selectively.
|
||||
*/
|
||||
public function test_delete_matched_meta_data() {
|
||||
public function test_delete_meta_data_value() {
|
||||
$object = $this->create_test_post();
|
||||
$object_id = $object->get_id();
|
||||
add_metadata( 'post', $object_id, 'test_meta_key', 'val1' );
|
||||
|
@ -338,13 +338,13 @@ class WC_Tests_CRUD_Data extends WC_Unit_Test_Case {
|
|||
|
||||
$this->assertCount( 3, $object->get_meta( 'test_meta_key', false ) );
|
||||
|
||||
$object->delete_matched_meta_data( 'test_meta_key', 'val1' );
|
||||
$object->delete_meta_data_value( 'test_meta_key', 'val1' );
|
||||
$this->assertCount( 2, $object->get_meta( 'test_meta_key', false ) );
|
||||
|
||||
$object->delete_matched_meta_data( 'test_meta_key', array( 'bar', 'baz' ) );
|
||||
$object->delete_meta_data_value( 'test_meta_key', array( 'bar', 'baz' ) );
|
||||
$this->assertCount( 2, $object->get_meta( 'test_meta_key', false ) );
|
||||
|
||||
$object->delete_matched_meta_data( 'test_meta_key', array( 'foo', 'bar' ) );
|
||||
$object->delete_meta_data_value( 'test_meta_key', array( 'foo', 'bar' ) );
|
||||
$this->assertCount( 1, $object->get_meta( 'test_meta_key', false ) );
|
||||
|
||||
$this->assertEquals( 'val2', $object->get_meta( 'test_meta_key' ) );
|
||||
|
|
Loading…
Reference in New Issue