Skip to content

Commit b40d9bd

Browse files
authored
FormattingFunctionsHelper::is_formatting_function(): add tests (#2713)
1 parent b050cb4 commit b40d9bd

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
/**
3+
* WordPress Coding Standard.
4+
*
5+
* @package WPCS\WordPressCodingStandards
6+
* @link https://github.com/WordPress/WordPress-Coding-Standards
7+
* @license https://opensource.org/licenses/MIT MIT
8+
*/
9+
10+
namespace WordPressCS\WordPress\Tests\Helpers\FormattingFunctionsHelper;
11+
12+
use PHPUnit\Framework\TestCase;
13+
use WordPressCS\WordPress\Helpers\FormattingFunctionsHelper;
14+
15+
/**
16+
* Tests for the `FormattingFunctionsHelper::is_formatting_function()` method.
17+
*
18+
* @since 3.4.0
19+
*
20+
* @covers \WordPressCS\WordPress\Helpers\FormattingFunctionsHelper::is_formatting_function
21+
*/
22+
final class IsFormattingFunctionUnitTest extends TestCase {
23+
24+
/**
25+
* Test is_formatting_function().
26+
*
27+
* @dataProvider dataIsFormattingFunction
28+
*
29+
* @param string $functionName The function name to test.
30+
* @param bool $expectedResult The expected return value.
31+
*
32+
* @return void
33+
*/
34+
public function testIsFormattingFunction( $functionName, $expectedResult ) {
35+
$this->assertSame(
36+
$expectedResult,
37+
FormattingFunctionsHelper::is_formatting_function( $functionName )
38+
);
39+
}
40+
41+
/**
42+
* Data provider.
43+
*
44+
* @see testIsFormattingFunction()
45+
*
46+
* @return array<string, array<string, bool|string>>
47+
*/
48+
public static function dataIsFormattingFunction() {
49+
return array(
50+
'lowercase_name' => array(
51+
'functionName' => 'sprintf',
52+
'expectedResult' => true,
53+
),
54+
'mixedcase_name' => array(
55+
'functionName' => 'iMpLoDe',
56+
'expectedResult' => true,
57+
),
58+
'not_a_formatting_function' => array(
59+
'functionName' => 'printf',
60+
'expectedResult' => false,
61+
),
62+
);
63+
}
64+
}

0 commit comments

Comments
 (0)