ImmutableTest::testImmutable()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Widgets\Tests\FragmentCache;
6
7
use PHPUnit\Framework\TestCase;
8
use Yiisoft\Cache\Dependency\TagDependency;
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\View\Cache\DynamicContent;
14
use Yiisoft\Yii\Widgets\FragmentCache;
15
use Yiisoft\Yii\Widgets\Tests\Support\TestTrait;
16
17
/**
18
 * @psalm-suppress PropertyNotSetInConstructor
19
 */
20
final class ImmutableTest extends TestCase
21
{
22
    use TestTrait;
23
24
    /**
25
     * @throws CircularReferenceException
26
     * @throws InvalidConfigException
27
     * @throws NotFoundException
28
     * @throws NotInstantiableException
29
     */
30
    public function testImmutable(): void
31
    {
32
        $widget = FragmentCache::widget();
33
        $this->assertNotSame($widget, $widget->id(''));
0 ignored issues
show
Bug introduced by
The method id() does not exist on Yiisoft\Widget\Widget. It seems like you code against a sub-type of said class. However, the method does not exist in Yiisoft\Yii\Widgets\Menu or Yiisoft\Yii\Widgets\ContentDecorator or Yiisoft\Yii\Widgets\Breadcrumbs. Are you sure you never get one of those? ( Ignorable by Annotation )

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

33
        $this->assertNotSame($widget, $widget->/** @scrutinizer ignore-call */ id(''));
Loading history...
34
        $this->assertNotSame($widget, $widget->ttl(3600));
0 ignored issues
show
Bug introduced by
The method ttl() 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\FragmentCache. ( Ignorable by Annotation )

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

34
        $this->assertNotSame($widget, $widget->/** @scrutinizer ignore-call */ ttl(3600));
Loading history...
35
        $this->assertNotSame($widget, $widget->dependency(new TagDependency('test')));
0 ignored issues
show
Bug introduced by
The method dependency() 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\FragmentCache. ( Ignorable by Annotation )

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

35
        $this->assertNotSame($widget, $widget->/** @scrutinizer ignore-call */ dependency(new TagDependency('test')));
Loading history...
36
        $this->assertNotSame($widget, $widget->dynamicContents(new DynamicContent('test', fn (): string => 'test')));
0 ignored issues
show
Bug introduced by
The method dynamicContents() 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\FragmentCache. ( Ignorable by Annotation )

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

36
        $this->assertNotSame($widget, $widget->/** @scrutinizer ignore-call */ dynamicContents(new DynamicContent('test', fn (): string => 'test')));
Loading history...
37
        $this->assertNotSame($widget, $widget->variations(''));
0 ignored issues
show
Bug introduced by
The method variations() 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\FragmentCache. ( Ignorable by Annotation )

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

37
        $this->assertNotSame($widget, $widget->/** @scrutinizer ignore-call */ variations(''));
Loading history...
38
    }
39
}
40