Passed
Push — master ( 70dd87...6f141b )
by Alexander
08:24
created

ContentDecoratorTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 21
c 1
b 0
f 0
dl 0
loc 32
rs 10
wmc 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Widgets\Tests;
6
7
use Yiisoft\Yii\Widgets\ContentDecorator;
8
9
/**
10
 * ContentDecoratorTest.
11
 */
12
final class ContentDecoratorTest extends TestCase
13
{
14
    /**
15
     * {@see https://github.com/yiisoft/yii2/issues/15536}
16
     */
17
    public function testContentDecorator(): void
18
    {
19
        ob_start();
20
        ob_implicit_flush(0);
21
22
        ContentDecorator::begin()
23
            ->viewFile($this->aliases->get('@view/layout.php'))
24
            ->params([])
25
            ->start();
26
27
        echo "\t\t<div class='left-column'>\n";
28
        echo "\t\t\t<p>This is a left bar!</p>\n";
29
        echo "\t\t</div>\n\n";
30
        echo "\t\t<div class='right-column'>\n";
31
        echo "\t\t\t<p>This is a right bar!</p>\n";
32
        echo "\t\t</div>\n";
33
34
        echo ContentDecorator::end();
35
36
        $expected = "\t\t<div class='left-column'>\n" .
37
                    "\t\t\t<p>This is a left bar!</p>\n" .
38
                    "\t\t</div>\n\n" .
39
                    "\t\t<div class='right-column'>\n" .
40
                    "\t\t\t<p>This is a right bar!</p>\n" .
41
                    "\t\t</div>\n";
42
43
        $this->assertStringContainsString($expected, ob_get_clean());
44
    }
45
}
46