mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Follow-up to [46159], [46224], [52775], [52776], [52777]. See #54725, #54728. git-svn-id: https://develop.svn.wordpress.org/trunk@53322 602fd350-edb4-49c9-b593-d223f7449a82
64 lines
1.4 KiB
PHP
64 lines
1.4 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Tests for the wp_validate_boolean() function.
|
|
*
|
|
* @group functions.php
|
|
* @covers ::wp_validate_boolean
|
|
*/
|
|
class Tests_Functions_wpValidateBoolean extends WP_UnitTestCase {
|
|
|
|
/**
|
|
* Tests wp_validate_boolean().
|
|
*
|
|
* @dataProvider data_wp_validate_boolean
|
|
*
|
|
* @ticket 30238
|
|
* @ticket 39868
|
|
*
|
|
* @param mixed $test_value Test value.
|
|
* @param bool $expected Expected return value.
|
|
*/
|
|
public function test_wp_validate_boolean( $test_value, $expected ) {
|
|
$this->assertSame( $expected, wp_validate_boolean( $test_value ) );
|
|
}
|
|
|
|
/**
|
|
* Data provider for test_wp_validate_boolean().
|
|
*
|
|
* @return array[] Test parameters {
|
|
* @type mixed $test_value Test value.
|
|
* @type bool $expected Expected return value.
|
|
* }
|
|
*/
|
|
public function data_wp_validate_boolean() {
|
|
$std = new \stdClass();
|
|
|
|
return array(
|
|
array( null, false ),
|
|
array( true, true ),
|
|
array( false, false ),
|
|
array( 'true', true ),
|
|
array( 'false', false ),
|
|
array( 'FalSE', false ), // @ticket 30238
|
|
array( 'FALSE', false ), // @ticket 30238
|
|
array( 'TRUE', true ),
|
|
array( ' FALSE ', true ),
|
|
array( 'yes', true ),
|
|
array( 'no', true ),
|
|
array( 'string', true ),
|
|
array( '', false ),
|
|
array( array(), false ),
|
|
array( 1, true ),
|
|
array( 0, false ),
|
|
array( -1, true ),
|
|
array( 99, true ),
|
|
array( 0.1, true ),
|
|
array( 0.0, false ),
|
|
array( '1', true ),
|
|
array( '0', false ),
|
|
array( $std, true ),
|
|
);
|
|
}
|
|
}
|