mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Build, Test Tools: Test PHP and WP compatibility functions.
Introduce tests for `is_php_version_compatible()` and `is_wp_version_compatible()`. Props pbearne, hellofromTonya, mikeschroder, peterwilsoncc, toro_unit. Fixes #54257. git-svn-id: https://develop.svn.wordpress.org/trunk@53227 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
059cab0e71
commit
c690f60df4
53
tests/phpunit/tests/functions/isPhpVersionCompatible.php
Normal file
53
tests/phpunit/tests/functions/isPhpVersionCompatible.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Tests the is_php_version_compatible function.
|
||||
*
|
||||
* @group functions.php
|
||||
* @covers ::is_php_version_compatible
|
||||
*/
|
||||
class Tests_Functions_isPhpVersionCompatible extends WP_UnitTestCase {
|
||||
/**
|
||||
* Tests is_php_version_compatible().
|
||||
*
|
||||
* @dataProvider data_is_php_version_compatible
|
||||
*
|
||||
* @param mixed $test_value
|
||||
* @param bool $expected
|
||||
*
|
||||
* @ticket 54257
|
||||
*/
|
||||
public function test_is_php_version_compatible( $test_value, $expected ) {
|
||||
$this->assertSame( is_php_version_compatible( $test_value ), $expected );
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides test scenarios for test_php_version_compatible.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function data_is_php_version_compatible() {
|
||||
$php_version = phpversion();
|
||||
|
||||
$more = explode( '.', $php_version );
|
||||
$less = $more;
|
||||
|
||||
-- $less[ count( $less ) - 1 ];
|
||||
++ $more[ count( $less ) - 1 ];
|
||||
|
||||
return array(
|
||||
'greater' => array(
|
||||
'test_value' => implode( '.', $more ),
|
||||
'expected' => false,
|
||||
),
|
||||
'same' => array(
|
||||
'test_value' => $php_version,
|
||||
'expected' => true,
|
||||
),
|
||||
'less' => array(
|
||||
'test_value' => implode( '.', $less ),
|
||||
'expected' => true,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
53
tests/phpunit/tests/functions/isWpVersionCompatible.php
Normal file
53
tests/phpunit/tests/functions/isWpVersionCompatible.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Tests the is_php_version_compatible function.
|
||||
*
|
||||
* @group functions.php
|
||||
* @covers ::is_wp_version_compatible
|
||||
*/
|
||||
class Tests_Functions_isWpVersionCompatible extends WP_UnitTestCase {
|
||||
/**
|
||||
* Test is_wp_version_compatible().
|
||||
*
|
||||
* @dataProvider data_is_wp_version_compatible
|
||||
*
|
||||
* @param mixed $test_value
|
||||
* @param bool $expected
|
||||
*
|
||||
* @ticket 54257
|
||||
*/
|
||||
public function test_is_wp_version_compatible( $test_value, $expected ) {
|
||||
$this->assertSame( is_wp_version_compatible( $test_value ), $expected );
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides test scenarios test_is_wp_version_compatible.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function data_is_wp_version_compatible() {
|
||||
$wp_version = get_bloginfo( 'version' );
|
||||
|
||||
$more = explode( '.', $wp_version );
|
||||
$less = $more;
|
||||
|
||||
-- $less[0];
|
||||
++ $more[0];
|
||||
|
||||
return array(
|
||||
'greater' => array(
|
||||
'test_value' => implode( '.', $more ),
|
||||
'expected' => false,
|
||||
),
|
||||
'same' => array(
|
||||
'test_value' => $wp_version,
|
||||
'expected' => true,
|
||||
),
|
||||
'less' => array(
|
||||
'test_value' => implode( '.', $less ),
|
||||
'expected' => true,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user