Valinor/tests/Unit/Mapper/Tree/Message/ThrowableMessageTest.php

33 lines
884 B
PHP
Raw Normal View History

2021-11-28 17:43:02 +01:00
<?php
declare(strict_types=1);
namespace CuyZ\Valinor\Tests\Unit\Mapper\Tree\Message;
use CuyZ\Valinor\Mapper\Tree\Message\ThrowableMessage;
use PHPUnit\Framework\TestCase;
use RuntimeException;
2021-11-28 17:43:02 +01:00
final class ThrowableMessageTest extends TestCase
{
public function test_properties_can_be_accessed(): void
{
$message = 'some message';
$code = 'some code';
$codedError = ThrowableMessage::new($message, $code);
2021-11-28 17:43:02 +01:00
self::assertSame($message, $codedError->body());
2021-11-28 17:43:02 +01:00
self::assertSame($code, $codedError->code());
}
public function test_from_throwable_returns_error_message(): void
{
$original = new RuntimeException('some message', 1337);
$message = ThrowableMessage::from($original);
self::assertSame('some message', $message->getMessage());
self::assertSame('1337', $message->code());
}
2021-11-28 17:43:02 +01:00
}