Skip to content

Commit

Permalink
phpcbf
Browse files Browse the repository at this point in the history
  • Loading branch information
adamsilverstein committed Nov 17, 2023
1 parent ba94b81 commit d6dd548
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions tests/phpunit/tests/post/metaRevisions.php
Original file line number Diff line number Diff line change
Expand Up @@ -739,10 +739,13 @@ public function test_wp_save_post_revision_with_array_meta() {
);

// Add the meta value to `_wp_post_revision_fields` which triggers it being compared for save consideration.
add_filter( '_wp_post_revision_fields', function( $fields ) {
$fields[ 'meta_revision_test' ] = 'Meta Revisions Test';
return $fields;
} );
add_filter(
'_wp_post_revision_fields',
function ( $fields ) {
$fields['meta_revision_test'] = 'Meta Revisions Test';
return $fields;
}
);

// Set up a new post.
$post_id = $this->factory->post->create(
Expand All @@ -762,13 +765,13 @@ public function test_wp_save_post_revision_with_array_meta() {

// Check that the meta is stored correctly.
$stored_data = get_post_meta( $post_id, 'meta_revision_test', true );
$this->assertEquals( array( 'test' ) , $stored_data );
$this->assertEquals( array( 'test' ), $stored_data );

// Also verify that the latest revision has stored the meta.
$revisions = wp_get_post_revisions( $post_id );
$last_revision = array_shift( $revisions );
$stored_data = get_post_meta( $last_revision->ID, 'meta_revision_test', true );
$this->assertEquals( array( 'test' ) , $stored_data );
$this->assertEquals( array( 'test' ), $stored_data );

// Update the meta.
update_post_meta( $post_id, 'meta_revision_test', array( 'changed' ) );
Expand Down Expand Up @@ -799,6 +802,5 @@ public function test_wp_save_post_revision_with_array_meta() {

// Verify the correct meta value is still returned.
$this->assertEquals( array( 'changed' ), get_post_meta( $post_id, 'meta_revision_test', true ) );

}
}

0 comments on commit d6dd548

Please sign in to comment.