ExceptionTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 28
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testBodyTag() 0 5 1
A testHeaderTag() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Widgets\Tests\Alert;
6
7
use InvalidArgumentException;
8
use PHPUnit\Framework\TestCase;
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\Alert;
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
     */
29
    public function testBodyTag(): void
30
    {
31
        $this->expectException(InvalidArgumentException::class);
32
        $this->expectExceptionMessage('Body tag must be a string and cannot be empty.');
33
        Alert::widget()->bodyTag('');
0 ignored issues
show
Bug introduced by
The method bodyTag() does not exist on Yiisoft\Widget\Widget. It seems like you code against a sub-type of Yiisoft\Widget\Widget such as Yiisoft\Yii\Widgets\Alert. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

33
        Alert::widget()->/** @scrutinizer ignore-call */ bodyTag('');
Loading history...
34
    }
35
36
    /**
37
     * @throws CircularReferenceException
38
     * @throws InvalidConfigException
39
     * @throws NotFoundException
40
     * @throws NotInstantiableException
41
     */
42
    public function testHeaderTag(): void
43
    {
44
        $this->expectException(InvalidArgumentException::class);
45
        $this->expectExceptionMessage('Header tag must be a string and cannot be empty.');
46
        Alert::widget()->headerTag('');
0 ignored issues
show
Bug introduced by
The method headerTag() does not exist on Yiisoft\Widget\Widget. It seems like you code against a sub-type of Yiisoft\Widget\Widget such as Yiisoft\Yii\Widgets\Alert or Yiisoft\Yii\Widgets\Dropdown. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

46
        Alert::widget()->/** @scrutinizer ignore-call */ headerTag('');
Loading history...
47
    }
48
}
49