Skip to content

Commit 89512f5

Browse files
committed
WP/GetMetaSingle: add tests for namespaced names
1 parent c4fec3d commit 89512f5

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

WordPress/Tests/WP/GetMetaSingleUnitTest.inc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ $incorrect_but_ok = get_metadata( 'post' );
3131
* These should all be flagged with a warning.
3232
*/
3333
$warning = \get_post_meta( $post_id, $meta_key );
34-
implode(', ', get_post_meta( $post_id, $meta_key ));
34+
implode(', ', \GET_POST_META( $post_id, $meta_key ));
3535
if (get_post_meta( $post_id, key: $meta_key )) {}
3636
$warning = get_post_meta( $post_id, key: $meta_key, sinngle: true ); // Typo in parameter name.
3737
echo get_comment_meta( $comment_id, $meta_key );
@@ -46,3 +46,11 @@ $warning = get_metadata(
4646
);
4747
$warning = get_metadata_raw( 'post', $post_id, $meta_key );
4848
$warning = get_metadata_default( 'post', $post_id, $meta_key );
49+
50+
/*
51+
* Safeguard correct handling of fully qualified and relative namespaced function calls (fully qualified global function
52+
* call and partially qualified namespaced function call are already handled above).
53+
*/
54+
\MyNamespace\get_user_meta( $user_id, $meta_key );
55+
namespace\get_metadata( 'post', $post_id, $meta_key ); // The sniff should start flagging this once it can resolve relative namespaces.
56+
namespace\Sub\get_comment_meta( $comment_id, $meta_key );

0 commit comments

Comments
 (0)