File: TokenTest.php

package info (click to toggle)
php-doctrine-lexer 2.1.0-2%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 240 kB
  • sloc: php: 556; xml: 63; makefile: 21
file content (54 lines) | stat: -rw-r--r-- 1,658 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php

declare(strict_types=1);

namespace Doctrine\Tests\Common\Lexer;

use Doctrine\Common\Lexer\Token;
use Doctrine\Deprecations\PHPUnit\VerifyDeprecations;
use PHPUnit\Framework\TestCase;

final class TokenTest extends TestCase
{
    use VerifyDeprecations;

    public function testIsA(): void
    {
        /** @var Token<'string'|'int', string> $token */
        $token = new Token('foo', 'string', 1);

        self::assertTrue($token->isA('string'));
        self::assertTrue($token->isA('int', 'string'));
        self::assertFalse($token->isA('int'));
    }

    public function testOffsetGetIsDeprecated(): void
    {
        $token = new Token('foo', 'string', 1);
        self::expectDeprecationWithIdentifier('https://github.com/doctrine/lexer/pull/79');
        self::assertSame('foo', $token['value']);
    }

    public function testOffsetExistsIsDeprecated(): void
    {
        $token = new Token('foo', 'string', 1);
        self::expectDeprecationWithIdentifier('https://github.com/doctrine/lexer/pull/79');
        self::assertTrue(isset($token['value']));
    }

    public function testOffsetSetIsDeprecated(): void
    {
        $token = new Token('foo', 'string', 1);
        self::expectDeprecationWithIdentifier('https://github.com/doctrine/lexer/pull/79');
        $token['value'] = 'bar';
        self::assertSame('bar', $token->value);
    }

    public function testOffsetUnsetIsDeprecated(): void
    {
        $token = new Token('foo', 'string', 1);
        self::expectDeprecationWithIdentifier('https://github.com/doctrine/lexer/pull/79');
        unset($token['value']);
        self::assertNull($token->value);
    }
}