Skip to content

Commit f5a08d2

Browse files
committed
dataproviders allow for the tests to all run rather than stopping at one failure. They also provide for better messages on failure.
1 parent 3624bf1 commit f5a08d2

File tree

1 file changed

+27
-18
lines changed

1 file changed

+27
-18
lines changed

tests/phpunit/tests/db.php

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -122,28 +122,37 @@ public function test_locale_floats() {
122122

123123
/**
124124
* @ticket 10041
125+
* @dataProvider data_esc_like
125126
*/
126-
public function test_esc_like() {
127+
public function test_esc_like( $input, $expected ) {
127128
global $wpdb;
128129

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-
);
130+
$this->assertSame( $expected, $wpdb->esc_like( $input ) );
131+
}
143132

144-
foreach ( $inputs as $key => $input ) {
145-
$this->assertSame( $expected[ $key ], $wpdb->esc_like( $input ) );
146-
}
133+
public function data_esc_like() {
134+
return array(
135+
'single percent' => array(
136+
'howdy%',
137+
'howdy\\%',
138+
),
139+
'single underscore' => array(
140+
'howdy_',
141+
'howdy\\_',
142+
),
143+
'single slash' => array(
144+
'howdy\\',
145+
'howdy\\\\',
146+
),
147+
'the works' => array(
148+
'howdy\\howdy%howdy_',
149+
'howdy\\\\howdy\\%howdy\\_',
150+
),
151+
'plain text' => array(
152+
'howdy\'"[[]*#[^howdy]!+)(*&$#@!~|}{=--`/.,<>?',
153+
'howdy\'"[[]*#[^howdy]!+)(*&$#@!~|}{=--`/.,<>?',
154+
),
155+
);
147156
}
148157

149158
/**

0 commit comments

Comments
 (0)