Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 27 additions & 18 deletions tests/phpunit/tests/db.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,28 +122,37 @@ public function test_locale_floats() {

/**
* @ticket 10041
* @dataProvider data_esc_like
Comment on lines 124 to +125
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @ticket 10041
* @dataProvider data_esc_like
* @ticket 10041
*
* @dataProvider data_esc_like
*
* @param string $input The input string.
* @param string $expected The expected escaped string.

*/
public function test_esc_like() {
public function test_esc_like( $input, $expected ) {
global $wpdb;

$inputs = array(
'howdy%', // Single percent.
'howdy_', // Single underscore.
'howdy\\', // Single slash.
'howdy\\howdy%howdy_', // The works.
'howdy\'"[[]*#[^howdy]!+)(*&$#@!~|}{=--`/.,<>?', // Plain text.
);
$expected = array(
'howdy\\%',
'howdy\\_',
'howdy\\\\',
'howdy\\\\howdy\\%howdy\\_',
'howdy\'"[[]*#[^howdy]!+)(*&$#@!~|}{=--`/.,<>?',
);
$this->assertSame( $expected, $wpdb->esc_like( $input ) );
}

foreach ( $inputs as $key => $input ) {
$this->assertSame( $expected[ $key ], $wpdb->esc_like( $input ) );
}
public function data_esc_like() {
return array(
'single percent' => array(
'howdy%',
'howdy\\%',
),
'single underscore' => array(
'howdy_',
'howdy\\_',
),
'single slash' => array(
'howdy\\',
'howdy\\\\',
),
'the works' => array(
'howdy\\howdy%howdy_',
'howdy\\\\howdy\\%howdy\\_',
),
'plain text' => array(
'howdy\'"[[]*#[^howdy]!+)(*&$#@!~|}{=--`/.,<>?',
'howdy\'"[[]*#[^howdy]!+)(*&$#@!~|}{=--`/.,<>?',
),
);
}

/**
Expand Down
Loading