Skip to content

Commit 178ed0f

Browse files
committed
GetDeclarationNameTest: move parse error test to separate file
1 parent 6b11ef6 commit 178ed0f

File tree

4 files changed

+42
-8
lines changed

4 files changed

+42
-8
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
/* testLiveCoding */
4+
// Intentional parse error. This must be the only test in the file.
5+
function // Comment.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
/**
3+
* Tests for the \PHP_CodeSniffer\Files\File::getDeclarationName method.
4+
*
5+
* @author Juliette Reinders Folmer <[email protected]>
6+
* @copyright 2025 PHPCSStandards Contributors
7+
* @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
8+
*/
9+
10+
namespace PHP_CodeSniffer\Tests\Core\File;
11+
12+
use PHP_CodeSniffer\Tests\Core\AbstractMethodUnitTest;
13+
14+
/**
15+
* Tests for the \PHP_CodeSniffer\Files\File:getDeclarationName method.
16+
*
17+
* @covers \PHP_CodeSniffer\Files\File::getDeclarationName
18+
*/
19+
final class GetDeclarationNameParseError1Test extends AbstractMethodUnitTest
20+
{
21+
22+
23+
/**
24+
* Test receiving "null" in case of a parse error.
25+
*
26+
* @return void
27+
*/
28+
public function testGetDeclarationNameNull()
29+
{
30+
$target = $this->getTargetToken('/* testLiveCoding */', T_FUNCTION);
31+
$result = self::$phpcsFile->getDeclarationName($target);
32+
$this->assertNull($result);
33+
34+
}//end testGetDeclarationNameNull()
35+
36+
37+
}//end class

tests/Core/File/GetDeclarationNameTest.inc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,3 @@ function &self() {}
9696

9797
/* testFunctionReturnByRefWithReservedKeywordStatic */
9898
function &static() {}
99-
100-
/* testLiveCoding */
101-
// Intentional parse error. This has to be the last test in the file.
102-
function // Comment.

tests/Core/File/GetDeclarationNameTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,6 @@ public static function dataGetDeclarationNameNull()
8484
'testMarker' => '/* testAnonClassExtendsWithoutParens */',
8585
'targetType' => T_ANON_CLASS,
8686
],
87-
'live-coding' => [
88-
'testMarker' => '/* testLiveCoding */',
89-
'targetType' => T_FUNCTION,
90-
],
9187
];
9288

9389
}//end dataGetDeclarationNameNull()

0 commit comments

Comments
 (0)