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

LocaleTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 31
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testLocaleDependency() 0 11 1
A testRenderEn() 0 6 1
A testRenderRu() 0 8 1
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\Views;
13
14
use Spiral\Tests\Framework\BaseTest;
15
use Spiral\Translator\TranslatorInterface;
16
use Spiral\Translator\Views\LocaleDependency;
17
use Spiral\Views\ViewsInterface;
18
19
class LocaleTest extends BaseTest
20
{
21
    public function testRenderEn(): void
22
    {
23
        $app = $this->makeApp();
24
25
        $out = $app->get(ViewsInterface::class)->render('custom:locale');
26
        $this->assertSame('Hello English!', $out);
27
    }
28
29
    public function testRenderRu(): void
30
    {
31
        $app = $this->makeApp();
32
33
        $app->get(TranslatorInterface::class)->setLocale('ru');
34
35
        $out = $app->get(ViewsInterface::class)->render('custom:locale');
36
        $this->assertSame('Hello Мир!', $out);
37
    }
38
39
    public function testLocaleDependency(): void
40
    {
41
        $app = $this->makeApp();
42
        $d = $app->get(LocaleDependency::class);
43
44
        $d = $d->__debugInfo();
45
46
        $this->assertSame('en', $d['value']);
47
48
        $this->assertTrue(in_array('en', $d['variants']));
49
        $this->assertTrue(in_array('ru', $d['variants']));
50
    }
51
}
52