Passed
Push — master ( 82973f...cdeab4 )
by Alexander
01:27
created

WidgetTest::testShouldTriggerAfterRun()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 12
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Widget\Tests;
6
7
use Yiisoft\Widget\Tests\Stubs\Injectable;
8
use Yiisoft\Widget\Tests\Stubs\TestInjectionWidget;
9
use Yiisoft\Widget\Tests\Stubs\TestWidget;
10
use Yiisoft\Widget\Tests\Stubs\TestWidgetA;
11
use Yiisoft\Widget\Tests\Stubs\TestWidgetB;
12
use Yiisoft\Widget\Exception\InvalidConfigException;
13
14
final class WidgetTest extends TestCase
15
{
16
    public function testWidget(): void
17
    {
18
        $output = TestWidget::widget()->id('w0')->render();
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\Widget\Tests\Stubs\TestInjectionWidget. 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

18
        $output = TestWidget::widget()->/** @scrutinizer ignore-call */ id('w0')->render();
Loading history...
19
20
        $this->assertSame('<run-w0>', $output);
21
    }
22
23
    public function testWidgetArrayConfig(): void
24
    {
25
        $output = TestWidget::widget(['id()' => ['w0']])->render();
26
27
        $this->assertSame('<run-w0>', $output);
28
    }
29
30
    public function testBeginEnd(): void
31
    {
32
        TestWidgetA::begin()->id('test');
33
        $output = TestWidgetA::end();
34
35
        $this->assertSame('<run-test>', $output);
36
    }
37
38
    /**
39
     * @depends testBeginEnd
40
     */
41
    public function testStackTracking(): void
42
    {
43
        $this->expectException(InvalidConfigException::class);
44
        TestWidget::end();
45
    }
46
47
    /**
48
     * @depends testBeginEnd
49
     */
50
    public function testStackTrackingDisorder(): void
51
    {
52
        $this->expectException(InvalidConfigException::class);
53
        TestWidgetA::begin();
54
        TestWidgetB::begin();
55
        TestWidgetA::end();
56
        TestWidgetB::end();
57
    }
58
59
    public function testInjection(): void
60
    {
61
        $widget = TestInjectionWidget::widget();
62
        $this->assertInstanceOf(Injectable::class, $widget->getInjectable());
0 ignored issues
show
Bug introduced by
The method getInjectable() does not exist on Yiisoft\Widget\Widget. It seems like you code against a sub-type of Yiisoft\Widget\Widget such as Yiisoft\Widget\Tests\Stubs\TestInjectionWidget. ( Ignorable by Annotation )

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

62
        $this->assertInstanceOf(Injectable::class, $widget->/** @scrutinizer ignore-call */ getInjectable());
Loading history...
63
    }
64
}
65