test_if_specific_locale_is_returned()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace App\Containers\Localization\Tests\Unit;
4
5
use App\Containers\Localization\Tasks\GetAllLocalizationsTask;
6
use App\Containers\Localization\Tests\TestCase;
7
use App\Containers\Localization\Values\Localization;
8
use Illuminate\Support\Facades\App;
9
use Illuminate\Support\Facades\Config;
10
11
/**
12
 * Class GetLocalizationsTest.
13
 *
14
 * @group localization
15
 * @group unit
16
 */
17
class GetLocalizationsTest extends TestCase
18
{
19
20
    /**
21
     * @test
22
     */
23
    public function test_if_all_supported_languages_are_returned()
24
    {
25
        $class = App::make(GetAllLocalizationsTask::class);
26
        $localizations = $class->run();
27
28
        $configuredLocalizations = Config::get('localization-container.supported_languages', []);
29
30
        // assert that they have the same amount of fields
31
        $this->assertEquals(count($configuredLocalizations), $localizations->count());
32
33
        // now we check all localizations in particular
34
    }
35
36
    public function test_if_specific_locale_is_returned()
37
    {
38
        $class = App::make(GetAllLocalizationsTask::class);
39
        $localizations = $class->run();
40
41
        $unsupportedLocale = new Localization('fr');
42
43
        $this->assertContainsEquals($unsupportedLocale, $localizations);
44
    }
45
46
    public function test_if_specific_locale_with_regions_is_returned()
47
    {
48
        $class = App::make(GetAllLocalizationsTask::class);
49
        $localizations = $class->run();
50
51
        $unsupportedLocale = new Localization('en', ['en-GB', 'en-US']);
52
53
        $this->assertContainsEquals($unsupportedLocale, $localizations);
54
    }
55
56
    public function test_if_wrong_locale_is_not_returned()
57
    {
58
        $class = App::make(GetAllLocalizationsTask::class);
59
        $localizations = $class->run();
60
61
        $unsupportedLocale = new Localization('xxx');
62
63
        $this->assertNotContainsEquals($unsupportedLocale, $localizations);
64
    }
65
}
66