Skip to content
Closed
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion tests/phpunit/data/formatting/whole-posts.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php

function data_whole_posts() {
/**
* @return non-empty-list<array{ non-falsy-string }>
*/
function data_whole_posts(): array {
return array(

/* DIVIDER */
Expand Down
27 changes: 21 additions & 6 deletions tests/phpunit/tests/formatting/wpHtmlSplit.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,20 @@ class Tests_Formatting_wpHtmlSplit extends WP_UnitTestCase {
* Basic functionality goes here.
*
* @dataProvider data_basic_features
*
* @param non-falsy-string $input
* @param list<non-falsy-string> $output
*/
public function test_basic_features( $input, $output ) {
return $this->assertSame( $output, wp_html_split( $input ) );
public function test_basic_features( string $input, array $output ): void {
$this->assertSame( $output, wp_html_split( $input ) );
}

public static function data_basic_features() {
/**
* Data provider for {@see self::test_basic_features()}.
*
* @return list<array{ 0: non-falsy-string, 1: list<non-falsy-string> }>
*/
public static function data_basic_features(): array {
return array(
array(
'abcd efgh',
Expand All @@ -43,14 +51,21 @@ public static function data_basic_features() {
* @dataProvider data_whole_posts
*
* @covers ::get_html_split_regex
*
* @param non-falsy-string $input
*/
public function test_pcre_performance( $input ) {
public function test_pcre_performance( string $input ): void {
$regex = get_html_split_regex();
$result = benchmark_pcre_backtracking( $regex, $input, 'split' );
return $this->assertLessThan( 200, $result );
$this->assertLessThan( 200, $result );
}

public static function data_whole_posts() {
/**
* Data provider for {@see self::test_pcre_performance()}.
*
* @return non-empty-list<array{ non-falsy-string }>
*/
public static function data_whole_posts(): array {
require_once DIR_TESTDATA . '/formatting/whole-posts.php';
return data_whole_posts();
}
Expand Down
Loading
Loading