mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
Pass all updated meta IDs to filters in update_metadata().
Props wonderboymusic. Fixes #11683. git-svn-id: https://develop.svn.wordpress.org/trunk@30140 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
* @group meta
|
||||
*/
|
||||
class Tests_Meta extends WP_UnitTestCase {
|
||||
protected $updated_mids = array();
|
||||
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
$this->author = new WP_User( $this->factory->user->create( array( 'role' => 'author' ) ) );
|
||||
@@ -76,6 +78,32 @@ class Tests_Meta extends WP_UnitTestCase {
|
||||
$this->assertFalse( $first === $second );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 11683
|
||||
*/
|
||||
public function test_update_metadata_hooks_for_multiple_updated_rows() {
|
||||
add_metadata( 'post', 1, 'test_key', 'value_1' );
|
||||
add_metadata( 'post', 1, 'test_key', 'value_2' );
|
||||
add_action( 'update_post_meta', array( $this, 'updated_meta' ) );
|
||||
add_action( 'update_postmeta', array( $this, 'updated_meta' ) );
|
||||
add_action( 'updated_post_meta', array( $this, 'updated_meta' ) );
|
||||
add_action( 'updated_postmeta', array( $this, 'updated_meta' ) );
|
||||
|
||||
update_metadata( 'post', 1, 'test_key', 'value_3' );
|
||||
|
||||
remove_action( 'update_post_meta', array( $this, 'updated_meta' ) );
|
||||
remove_action( 'update_postmeta', array( $this, 'updated_meta' ) );
|
||||
remove_action( 'updated_post_meta', array( $this, 'updated_meta' ) );
|
||||
remove_action( 'updated_postmeta', array( $this, 'updated_meta' ) );
|
||||
|
||||
$found = $this->updated_mids;
|
||||
$this->updated_mids = array();
|
||||
|
||||
foreach ( $found as $action => $mids ) {
|
||||
$this->assertSame( 2, count( $mids ) );
|
||||
}
|
||||
}
|
||||
|
||||
function test_metadata_exists() {
|
||||
$this->assertFalse( metadata_exists( 'user', $this->author->ID, 'foobarbaz' ) );
|
||||
$this->assertTrue( metadata_exists( 'user', $this->author->ID, 'meta_key' ) );
|
||||
@@ -300,4 +328,10 @@ class Tests_Meta extends WP_UnitTestCase {
|
||||
|
||||
$this->assertSame( array( $data ), $found['foo'] );
|
||||
}
|
||||
|
||||
/** Helpers **********************************************************/
|
||||
|
||||
public function updated_meta( $meta_id ) {
|
||||
$this->updated_mids[ current_action() ][] = $meta_id;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user