Skip to content

Commit 89d9c1d

Browse files
committed
WIP DB/PreparedSQLPlaceholders: add namespaced tests
Need to complete the list of tests
1 parent c54bd45 commit 89d9c1d

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

WordPress/Tests/DB/PreparedSQLPlaceholdersUnitTest.inc

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ $where = $wpdb->prepare(
8080
); // OK.
8181

8282
$where = $wpdb->prepare(
83-
sprintf(
83+
\sprintf(
8484
"{$wpdb->posts}.post_type IN (%s)
8585
AND {$wpdb->posts}.post_status IN (%s)",
8686
implode( ',', array_fill( 0, count($post_types), '%s' ), ),
@@ -518,3 +518,16 @@ $where = $wpdb->prepare(
518518
*/
519519
$callback = $wpdb->prepare(...); // OK.
520520

521+
/*
522+
* Safeguard correct handling of namespaced function calls.
523+
*/
524+
//$sql = MyNamespace\WPDB::prepare( "SELECT * FROM $wpdb->users WHERE id = %d AND user_login = %s" );
525+
//$sql = \MyNamespace\WPDB::prepare( "SELECT * FROM $wpdb->users WHERE id = %d AND user_login = %s" );
526+
//$sql = namespace\WPDB::prepare( "SELECT * FROM $wpdb->users WHERE id = %d AND user_login = %s" ); // The sniff should start flagging this once it can resolve relative namespaces.
527+
//$where = $wpdb->prepare(
528+
// MyNamespace\sprintf(
529+
// "{$wpdb->posts}.post_type IN (%s)",
530+
// MyNamespace\implode( ',', MyNamespace\array_fill( 0, count($post_types), '%s' ) )
531+
// ),
532+
// $post_types
533+
//);

0 commit comments

Comments
 (0)