packages/sql-semantics-sqlite/tests/Unit/Model/Diagnostic/ResourceLimitExceededTest.php
1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Model\Diagnostic;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\Small;
9use PHPUnit\Framework\TestCase;
10use RuntimeException;
11use SqlSemantics\Platform\Sqlite\Model\Diagnostic\ResourceLimitExceeded;
12
13#[CoversClass(ResourceLimitExceeded::class)]
14#[Small]
15final class ResourceLimitExceededTest extends TestCase
16{
17 public function testTheMessageIsKept(): void
18 {
19 $limit = new ResourceLimitExceeded('The statement nests deeper than the configured limit.');
20
21 self::assertSame('The statement nests deeper than the configured limit.', $limit->getMessage());
22 }
23
24 public function testTheCauseIsChained(): void
25 {
26 $cause = new RuntimeException('The nesting counter overflowed.');
27
28 $limit = new ResourceLimitExceeded('The work limit was reached.', 0, $cause);
29
30 self::assertSame($cause, $limit->getPrevious());
31 }
32}
33