generated from ghostwriter/wip
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Nathanael Esayeas <nathanael.esayeas@protonmail.com>
- Loading branch information
1 parent
d0b5bc2
commit 2316758
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |