Changeset 61207
- Timestamp:
- 11/11/2025 04:43:21 AM (5 weeks ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/db.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/db.php
r60729 r61207 123 123 /** 124 124 * @ticket 10041 125 */ 126 public function test_esc_like() { 127 global $wpdb; 128 129 $inputs = array( 130 'howdy%', // Single percent. 131 'howdy_', // Single underscore. 132 'howdy\\', // Single slash. 133 'howdy\\howdy%howdy_', // The works. 134 'howdy\'"[[]*#[^howdy]!+)(*&$#@!~|}{=--`/.,<>?', // Plain text. 135 ); 136 $expected = array( 137 'howdy\\%', 138 'howdy\\_', 139 'howdy\\\\', 140 'howdy\\\\howdy\\%howdy\\_', 141 'howdy\'"[[]*#[^howdy]!+)(*&$#@!~|}{=--`/.,<>?', 142 ); 143 144 foreach ( $inputs as $key => $input ) { 145 $this->assertSame( $expected[ $key ], $wpdb->esc_like( $input ) ); 146 } 125 * 126 * @dataProvider data_esc_like 127 * 128 * @param string $input The input string. 129 * @param string $expected The expected escaped string. 130 */ 131 public function test_esc_like( $input, $expected ) { 132 global $wpdb; 133 134 $this->assertSame( $expected, $wpdb->esc_like( $input ) ); 135 } 136 137 public function data_esc_like() { 138 return array( 139 'single percent' => array( 140 'howdy%', 141 'howdy\\%', 142 ), 143 'single underscore' => array( 144 'howdy_', 145 'howdy\\_', 146 ), 147 'single slash' => array( 148 'howdy\\', 149 'howdy\\\\', 150 ), 151 'the works' => array( 152 'howdy\\howdy%howdy_', 153 'howdy\\\\howdy\\%howdy\\_', 154 ), 155 'plain text' => array( 156 'howdy\'"[[]*#[^howdy]!+)(*&$#@!~|}{=--`/.,<>?', 157 'howdy\'"[[]*#[^howdy]!+)(*&$#@!~|}{=--`/.,<>?', 158 ), 159 ); 147 160 } 148 161
Note: See TracChangeset
for help on using the changeset viewer.