Completed
Push — master ( 17598f...abee1f )
by Kirill
13s queued 11s
created

ViewsTest::testRenderViewWithTranslator()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Spiral Framework.
5
 *
6
 * @license   MIT
7
 * @author    Anton Titov (Wolfy-J)
8
 */
9
10
declare(strict_types=1);
11
12
namespace Spiral\Tests\Framework;
13
14
use Spiral\Views\ViewsInterface;
15
use Symfony\Component\Translation\TranslatorInterface;
16
17
abstract class ViewsTest extends BaseTest
18
{
19
    public function testRenderViewWithTranslator(): void
20
    {
21
        $app = $this->makeApp();
22
23
        /** @var ViewsInterface $views */
24
        $views = $app->get(ViewsInterface::class);
25
26
        $this->assertSame('Hello, English!', $views->render('home'));
27
    }
28
29
    public function testRenderViewWithAnotherLanguage(): void
30
    {
31
        $app = $this->makeApp();
32
33
        /** @var ViewsInterface $views */
34
        $views = $app->get(ViewsInterface::class);
35
36
        $this->assertSame('Hello, English!', $views->render('home'));
37
38
        $app->get(TranslatorInterface::class)->setLocale('ru');
39
        $this->assertSame('Hello, Мир!', $views->render('home'));
40
41
        $app->get(TranslatorInterface::class)->setLocale('en');
42
        $this->assertSame('Hello, English!', $views->render('home'));
43
    }
44
}
45