Skip to content

Commit af178b5

Browse files
committed
fixup! add editorconfig to keep tabs tabs
1 parent 353954d commit af178b5

File tree

1 file changed

+27
-11
lines changed

1 file changed

+27
-11
lines changed

tests/PHPStan/Ast/Attributes/AttributesTest.php

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,47 @@
22

33
namespace PHPStan\PhpDocParser\Ast\Attributes;
44

5+
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode;
56
use PHPStan\PhpDocParser\Lexer\Lexer;
67
use PHPStan\PhpDocParser\Parser\ConstExprParser;
78
use PHPStan\PhpDocParser\Parser\PhpDocParser;
9+
use PHPStan\PhpDocParser\Parser\TokenIterator;
810
use PHPStan\PhpDocParser\Parser\TypeParser;
911
use PHPUnit\Framework\TestCase;
1012

1113
final class AttributesTest extends TestCase
1214
{
1315

14-
/**
15-
* @var Lexer
16-
*/
17-
private $lexer;
18-
19-
/**
20-
* @var PhpDocParser
21-
*/
22-
private $phpDocParser;
16+
/** @var PhpDocNode */
17+
private $phpDocNode;
2318

2419
protected function setUp(): void
2520
{
2621
parent::setUp();
27-
$this->lexer = new Lexer();
22+
$lexer = new Lexer();
2823
$constExprParser = new ConstExprParser();
29-
$this->phpDocParser = new PhpDocParser(new TypeParser($constExprParser), $constExprParser);
24+
$phpDocParser = new PhpDocParser(new TypeParser($constExprParser), $constExprParser);
25+
26+
$input = '/** @var string */';
27+
$tokens = new TokenIterator($lexer->tokenize($input));
28+
$this->phpDocNode = $phpDocParser->parse($tokens);
29+
}
30+
31+
public function testGetAttribute(): void
32+
{
33+
$defaultValue = $this->phpDocNode->getAttribute('unknown_with_default', 100);
34+
$this->assertSame(100, $defaultValue);
35+
36+
$unKnownValue = $this->phpDocNode->getAttribute('unknown');
37+
$this->assertNull($unKnownValue);
38+
}
39+
40+
public function testSetAttribute(): void
41+
{
42+
$this->phpDocNode->setAttribute('key', 'value');
43+
44+
$attributeValue = $this->phpDocNode->getAttribute('key');
45+
$this->assertSame('value', $attributeValue);
3046
}
3147

3248
}

0 commit comments

Comments
 (0)