wordpress-develop/tests/phpunit/tests/formatting/wpHtmlSplit.php
Sergey Biryukov 191bf18e90 Tests: Correct some @covers tags in wp_html_split() and wptexturize() tests.
As `preg_split()` is not a user-defined function, it causes notices when generating the code coverage report:
{{{
"@covers ::preg_split" is invalid
}}}

Instead, it appears that the intention was to test the performance of these WordPress functions:

* `get_html_split_regex()`
* `_get_wptexturize_split_regex()`
* `_get_wptexturize_shortcode_regex()`

Follow-up to [34761], [53562].

See #39265, #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@54051 602fd350-edb4-49c9-b593-d223f7449a82
2022-09-01 16:40:33 +00:00

58 lines
1.2 KiB
PHP

<?php
/**
* @group formatting
*/
class Tests_Formatting_wpHtmlSplit extends WP_UnitTestCase {
/**
* Basic functionality goes here.
*
* @dataProvider data_basic_features
*
* @covers ::wp_html_split
*/
public function test_basic_features( $input, $output ) {
return $this->assertSame( $output, wp_html_split( $input ) );
}
public function data_basic_features() {
return array(
array(
'abcd efgh',
array( 'abcd efgh' ),
),
array(
'abcd <html> efgh',
array( 'abcd ', '<html>', ' efgh' ),
),
array(
'abcd <!-- <html> --> efgh',
array( 'abcd ', '<!-- <html> -->', ' efgh' ),
),
array(
'abcd <![CDATA[ <html> ]]> efgh',
array( 'abcd ', '<![CDATA[ <html> ]]>', ' efgh' ),
),
);
}
/**
* Automated performance testing of the main regex.
*
* @dataProvider data_whole_posts
*
* @covers ::get_html_split_regex
*/
public function test_pcre_performance( $input ) {
$regex = get_html_split_regex();
$result = benchmark_pcre_backtracking( $regex, $input, 'split' );
return $this->assertLessThan( 200, $result );
}
public function data_whole_posts() {
require_once DIR_TESTDATA . '/formatting/whole-posts.php';
return data_whole_posts();
}
}