-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #250 from PHPCSStandards/bctokens/new-tokenname-me…
…thod-polyfill BCTokens: polyfill the tokenName() method
- Loading branch information
Showing
2 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
/** | ||
* PHPCSUtils, utility functions and classes for PHP_CodeSniffer sniff developers. | ||
* | ||
* @package PHPCSUtils | ||
* @copyright 2019-2020 PHPCSUtils Contributors | ||
* @license https://opensource.org/licenses/LGPL-3.0 LGPL3 | ||
* @link https://github.com/PHPCSStandards/PHPCSUtils | ||
*/ | ||
|
||
namespace PHPCSUtils\Tests\BackCompat\BCTokens; | ||
|
||
use PHPCSUtils\BackCompat\BCTokens; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* Test class. | ||
* | ||
* @covers \PHPCSUtils\BackCompat\BCTokens::tokenName | ||
* | ||
* @group tokens | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
class TokenNameTest extends TestCase | ||
{ | ||
|
||
/** | ||
* Test the method. | ||
* | ||
* @dataProvider dataTokenName | ||
* | ||
* @param int|string $tokenCode The PHP/PHPCS token code to get the name for. | ||
* @param string $expected The expected token name. | ||
* | ||
* @return void | ||
*/ | ||
public function testTokenName($tokenCode, $expected) | ||
{ | ||
$this->assertSame($expected, BCTokens::tokenName($tokenCode)); | ||
} | ||
|
||
/** | ||
* Data provider. | ||
* | ||
* @see testTokenName() For the array format. | ||
* | ||
* @return array | ||
*/ | ||
public function dataTokenName() | ||
{ | ||
return [ | ||
'PHP native token: T_COMMA' => [ | ||
\T_COMMA, | ||
'T_COMMA', | ||
], | ||
'PHP native token: T_SELF' => [ | ||
\T_SELF, | ||
'T_SELF', | ||
], | ||
'PHPCS native token: T_CLOSURE' => [ | ||
\T_CLOSURE, | ||
'T_CLOSURE', | ||
], | ||
'PHPCS native token: T_STRING_CONCAT' => [ | ||
\T_STRING_CONCAT, | ||
'T_STRING_CONCAT', | ||
], | ||
]; | ||
} | ||
} |