Code Duplication    Length = 21-21 lines in 2 locations

docs/examples/bootstrap.php 1 location

@@ 53-73 (lines=21) @@
50
// WordPress requires PHPUnit 7.5 or earlier and hacks around a few things to
51
// make it work with PHP 8. Unfortunately for MockObjects they do it via
52
// composer.json rather than bootstrap.php, so we have to manually do it here.
53
if ( version_compare( PHP_VERSION, '8.0', '>=' ) &&
54
	( ! class_exists( PHPUnit\Runner\Version::class ) || version_compare( PHPUnit\Runner\Version::id(), '9.3', '<' ) )
55
) {
56
	if ( ! class_exists( PHPUnit\Framework\MockObject\InvocationMocker::class, false ) &&
57
		file_exists( "$_tests_dir/includes/phpunit7/MockObject/InvocationMocker.php" )
58
	) {
59
		require "$_tests_dir/includes/phpunit7/MockObject/Builder/NamespaceMatch.php";
60
		require "$_tests_dir/includes/phpunit7/MockObject/Builder/ParametersMatch.php";
61
		require "$_tests_dir/includes/phpunit7/MockObject/InvocationMocker.php";
62
		require "$_tests_dir/includes/phpunit7/MockObject/MockMethod.php";
63
	} else {
64
		fprintf(
65
			STDOUT,
66
			"Warning: PHPUnit <9.3 is not compatible with PHP 8.0+, and the hack could not be loaded.\n  Class %s exists: %s\n  File %s exists: %s\n",
67
			PHPUnit\Framework\MockObject\InvocationMocker::class,
68
			class_exists( PHPUnit\Framework\MockObject\InvocationMocker::class, false ) ? 'yes (bad)' : 'no (good)',
69
			"$_tests_dir/includes/phpunit7/MockObject/InvocationMocker.php",
70
			file_exists( "$_tests_dir/includes/phpunit7/MockObject/InvocationMocker.php" ) ? 'yes (good)' : 'no (bad)'
71
		);
72
	}
73
}
74
75
// Give access to tests_add_filter() function.
76
require_once $_tests_dir . '/includes/functions.php';

projects/plugins/jetpack/tests/php/bootstrap.php 1 location

@@ 59-79 (lines=21) @@
56
// WordPress requires PHPUnit 7.5 or earlier and hacks around a few things to
57
// make it work with PHP 8. Unfortunately for MockObjects they do it via
58
// composer.json rather than bootstrap.php, so we have to manually do it here.
59
if ( version_compare( PHP_VERSION, '8.0', '>=' ) &&
60
	( ! class_exists( PHPUnit\Runner\Version::class ) || version_compare( PHPUnit\Runner\Version::id(), '9.3', '<' ) )
61
) {
62
	if ( ! class_exists( PHPUnit\Framework\MockObject\InvocationMocker::class, false ) &&
63
		file_exists( "$test_root/includes/phpunit7/MockObject/InvocationMocker.php" )
64
	) {
65
		require "$test_root/includes/phpunit7/MockObject/Builder/NamespaceMatch.php";
66
		require "$test_root/includes/phpunit7/MockObject/Builder/ParametersMatch.php";
67
		require "$test_root/includes/phpunit7/MockObject/InvocationMocker.php";
68
		require "$test_root/includes/phpunit7/MockObject/MockMethod.php";
69
	} else {
70
		fprintf(
71
			STDOUT,
72
			"Warning: PHPUnit <9.3 is not compatible with PHP 8.0+, and the hack could not be loaded.\n  Class %s exists: %s\n  File %s exists: %s\n",
73
			PHPUnit\Framework\MockObject\InvocationMocker::class,
74
			class_exists( PHPUnit\Framework\MockObject\InvocationMocker::class, false ) ? 'yes (bad)' : 'no (good)',
75
			"$test_root/includes/phpunit7/MockObject/InvocationMocker.php",
76
			file_exists( "$test_root/includes/phpunit7/MockObject/InvocationMocker.php" ) ? 'yes (good)' : 'no (bad)'
77
		);
78
	}
79
}
80
81
if ( '1' != getenv( 'WP_MULTISITE' ) &&
82
 ( defined( 'WP_TESTS_MULTISITE') && ! WP_TESTS_MULTISITE ) ) {