-
-
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.
BCTokens: add
magicConstants()
method
Upstream PR 3013 introduces a new `$magicConstants` tokens array to PHPCS, same as already existed in PHPCSUtils as `Collections::$magicConstants`. This PR backfills the PHPCS native array in the `BCTokens` class. Includes unit test.
- Loading branch information
Showing
2 changed files
with
75 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,48 @@ | ||
<?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::magicConstants | ||
* | ||
* @group tokens | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
class MagicConstantsTest extends TestCase | ||
{ | ||
|
||
/** | ||
* Test the method. | ||
* | ||
* @return void | ||
*/ | ||
public function testMagicConstants() | ||
{ | ||
$expected = [ | ||
\T_CLASS_C => \T_CLASS_C, | ||
\T_DIR => \T_DIR, | ||
\T_FILE => \T_FILE, | ||
\T_FUNC_C => \T_FUNC_C, | ||
\T_LINE => \T_LINE, | ||
\T_METHOD_C => \T_METHOD_C, | ||
\T_NS_C => \T_NS_C, | ||
\T_TRAIT_C => \T_TRAIT_C, | ||
]; | ||
|
||
$this->assertSame($expected, BCTokens::magicConstants()); | ||
} | ||
} |