SettingsTest::it_gets_a_setting_without_locale()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 10

Duplication

Lines 19
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 19
loc 19
rs 9.4286
c 1
b 0
f 1
cc 1
eloc 10
nc 1
nop 0
1
<?php namespace Modules\Setting\Tests;
2
3
class SettingsTest extends BaseSettingTest
4
{
5
    /**
6
     * @var \Modules\Setting\Support\Settings
7
     */
8
    protected $setting;
9
10
    public function setUp()
11
    {
12
        parent::setUp();
13
        $this->setting = app('Modules\Setting\Support\Settings');
14
    }
15
16
    /** @test */
17 View Code Duplication
    public function it_gets_a_setting_without_locale()
18
    {
19
        // Prepare
20
        $data = [
21
            'core::site-name' => [
22
                'en' => 'AsgardCMS_en',
23
                'fr' => 'AsgardCMS_fr',
24
            ],
25
            'core::template' => 'asgard',
26
            'blog::posts-per-page' => 10,
27
        ];
28
29
        // Run
30
        $this->settingRepository->createOrUpdate($data);
31
32
        // Assert
33
        $setting = $this->setting->get('core::site-name');
34
        $this->assertEquals('AsgardCMS_en', $setting);
35
    }
36
37
    /** @test */
38 View Code Duplication
    public function it_gets_setting_in_given_locale()
39
    {
40
        // Prepare
41
        $data = [
42
            'core::site-name' => [
43
                'en' => 'AsgardCMS_en',
44
                'fr' => 'AsgardCMS_fr',
45
            ],
46
            'core::template' => 'asgard',
47
            'blog::posts-per-page' => 10,
48
        ];
49
50
        // Run
51
        $this->settingRepository->createOrUpdate($data);
52
53
        // Assert
54
        $setting = $this->setting->get('core::site-name', 'fr');
55
        $this->assertEquals('AsgardCMS_fr', $setting);
56
    }
57
58
    /** @test */
59
    public function it_returns_a_default_value_if_no_setting_found()
60
    {
61
        // Prepare
62
        $setting = $this->setting->get('core::non-existing-setting', 'en', 'defaultValue');
63
64
        // Assert
65
        $this->assertEquals('defaultValue', $setting);
66
    }
67
}
68