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);
}
}
|