-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExceptionTest.php
57 lines (47 loc) · 1.25 KB
/
ExceptionTest.php
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
55
56
57
<?php
declare(strict_types=1);
namespace Horat1us\Yii\Monitoring\Tests\Unit;
use Horat1us\Yii\Monitoring;
use PHPUnit\Framework\TestCase;
/**
* Class ExceptionTest
* @package Horat1us\Yii\Monitoring\Tests\Unit
*/
class ExceptionTest extends TestCase
{
protected const MESSAGE = 'Message';
protected const CODE = -1;
protected const DETAILS = [
'key' => 'value',
];
/** @var Monitoring\Exception */
protected $exception;
protected function setUp(): void
{
parent::setUp();
$this->exception = new Monitoring\Exception(
static::MESSAGE,
static::CODE,
static::DETAILS
);
}
public function getGetMessage(): void
{
$this->assertEquals(static::MESSAGE, $this->exception->getMessage());
}
public function testGetCode(): void
{
$this->assertEquals(static::CODE, $this->exception->getCode());
}
public function testGetDetails(): void
{
$this->assertEquals(static::DETAILS, $this->exception->getDetails());
}
public function testToString(): void
{
$this->assertStringEndsWith(
'Details:' . PHP_EOL . '{"key":"value"}' . PHP_EOL,
(string)$this->exception
);
}
}