Passed
Branch master (27c48c)
by Wilmer
02:16
created

ExceptionTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 19
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testCacheFragmentThrowExceptionIfNotSetId() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Widgets\Tests\FragmentCache;
6
7
use PHPUnit\Framework\TestCase;
8
use RuntimeException;
9
use Yiisoft\Definitions\Exception\CircularReferenceException;
10
use Yiisoft\Definitions\Exception\InvalidConfigException;
11
use Yiisoft\Definitions\Exception\NotInstantiableException;
12
use Yiisoft\Factory\NotFoundException;
13
use Yiisoft\Yii\Widgets\FragmentCache;
14
use Yiisoft\Yii\Widgets\Tests\Support\TestTrait;
15
16
/**
17
 * @psalm-suppress PropertyNotSetInConstructor
18
 */
19
final class ExceptionTest extends TestCase
20
{
21
    use TestTrait;
22
23
    /**
24
     * @throws CircularReferenceException
25
     * @throws InvalidConfigException
26
     * @throws NotFoundException
27
     * @throws NotInstantiableException
28
     * @throws RuntimeException
29
     */
30
    public function testCacheFragmentThrowExceptionIfNotSetId(): void
31
    {
32
        $this->expectException(RuntimeException::class);
33
        $this->expectExceptionMessage('You must assign the "id" using the "id()" setter.');
34
35
        FragmentCache::widget()->begin();
36
        echo 'cached fragment';
37
        FragmentCache::end();
38
    }
39
}
40