wordpress-develop/tests/phpunit/tests/functions/wpValidateBoolean.php
Tonya Mork 40ac5de838 Coding Standards: Add visibility to methods in tests/phpunit/tests/.
Adds a `public` visibility to test fixtures, tests, data providers, and callbacks methods.

Adds a `private` visibility to helper methods within test classes.

Renames callbacks and helpers that previously started with a `_` prefix. Why? For consistency and to leverage using the method visibility. Further naming standardizations is beyond the scope of this commit.

Props costdev, jrf, hellofromTonya.
Fixes #54177.

git-svn-id: https://develop.svn.wordpress.org/trunk@52010 602fd350-edb4-49c9-b593-d223f7449a82
2021-11-04 15:22:47 +00:00

60 lines
1.3 KiB
PHP

<?php
/**
* Tests the wp_validate_boolean function.
*
* @group functions.php
* @covers ::wp_validate_boolean
*/
class Tests_Functions_wpValidateBoolean extends WP_UnitTestCase {
/**
* Provides test scenarios for all possible scenarios in wp_validate_boolean().
*
* @return array
*/
public function data_provider() {
$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 ),
);
}
/**
* Test wp_validate_boolean().
*
* @dataProvider data_provider
*
* @param mixed $test_value
* @param bool $expected
*
* @ticket 30238
* @ticket 39868
*/
public function test_wp_validate_boolean( $test_value, $expected ) {
$this->assertSame( wp_validate_boolean( $test_value ), $expected );
}
}