Tests: Use the data_ prefix for various data provider methods.

This aims to bring more consistency to the test suite, as the vast majority of data providers already use that prefix.

Includes moving some data providers next to the tests they are used in.

Follow-up to [55464].

See #57841.

git-svn-id: https://develop.svn.wordpress.org/trunk@55562 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2023-03-19 12:03:30 +00:00
parent 81fd448129
commit d1046dc5f3
60 changed files with 680 additions and 679 deletions

View File

@@ -5,12 +5,28 @@
* @covers ::links_add_target
*/
class Tests_Formatting_LinksAddTarget extends WP_UnitTestCase {
/**
* Validate the normalize_whitespace function
*
* @dataProvider data_links_add_target
*/
public function test_links_add_target( $content, $target, $tags, $exp_str ) {
if ( true === is_null( $target ) ) {
$this->assertSame( $exp_str, links_add_target( $content ) );
} elseif ( true === is_null( $tags ) ) {
$this->assertSame( $exp_str, links_add_target( $content, $target ) );
} else {
$this->assertSame( $exp_str, links_add_target( $content, $target, $tags ) );
}
}
/**
* Test Content DataProvider
*
* array ( input_txt, converted_output_txt)
*/
public function get_input_output() {
public function data_links_add_target() {
return array(
array(
'MY CONTENT <div> SOME ADDITIONAL TEXT <a href="XYZ" src="ABC">LINK</a> HERE </div> END TEXT',
@@ -92,19 +108,4 @@ class Tests_Formatting_LinksAddTarget extends WP_UnitTestCase {
),
);
}
/**
* Validate the normalize_whitespace function
*
* @dataProvider get_input_output
*/
public function test_normalize_whitespace( $content, $target, $tags, $exp_str ) {
if ( true === is_null( $target ) ) {
$this->assertSame( $exp_str, links_add_target( $content ) );
} elseif ( true === is_null( $tags ) ) {
$this->assertSame( $exp_str, links_add_target( $content, $target ) );
} else {
$this->assertSame( $exp_str, links_add_target( $content, $target, $tags ) );
}
}
}