Skip to content

Commit

Permalink
Add TokenTest.php
Browse files Browse the repository at this point in the history
Signed-off-by: Nathanael Esayeas <nathanael.esayeas@protonmail.com>
  • Loading branch information
ghostwriter committed Aug 30, 2024
1 parent d0b5bc2 commit 2316758
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests/Unit/TokenTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

declare(strict_types=1);

namespace Tests\Unit;

use Ghostwriter\Plex\Interface\TokenInterface;
use Ghostwriter\Plex\Token;
use PHPUnit\Framework\Attributes\CoversClass;
use Throwable;

use const JSON_THROW_ON_ERROR;

use function json_encode;

#[CoversClass(Token::class)]
final class TokenTest extends AbstractTestCase
{
/**
* @throws Throwable
*/
public function testConstruct(): void
{
$expectedToken = new Token('type', 'value', 1, 1, ['matches']);

$actualToken = Token::new('type', 'value', 1, 1, ['matches']);

self::assertSame((string) $expectedToken, (string) $actualToken);

self::assertSame(
json_encode($expectedToken, JSON_THROW_ON_ERROR),
json_encode($actualToken, JSON_THROW_ON_ERROR)
);

self::assertInstanceof(TokenInterface::class, $actualToken);
self::assertInstanceof(TokenInterface::class, $expectedToken);
}
}

0 comments on commit 2316758

Please sign in to comment.