Completed
Push — master ( 12acd0...0a5e06 )
by
unknown
10s
created

test_if_wrong_locale_is_not_returned()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 9
rs 9.6666
cc 1
eloc 5
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 View Code Duplication
    public function test_if_specific_locale_is_returned()
0 ignored issues
show
Duplication introduced by Johannes Schobel
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
37
    {
38
        $class = App::make(GetAllLocalizationsTask::class);
39
        $localizations = $class->run();
40
41
        $unsupportedLocale = new Localization('fr');
42
43
        $this->assertContains($unsupportedLocale, $localizations, '', false, false, false);
44
    }
45
46 View Code Duplication
    public function test_if_specific_locale_with_regions_is_returned()
0 ignored issues
show
Duplication introduced by Johannes Schobel
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
47
    {
48
        $class = App::make(GetAllLocalizationsTask::class);
49
        $localizations = $class->run();
50
51
        $unsupportedLocale = new Localization('en', ['en-GB', 'en-US']);
52
53
        $this->assertContains($unsupportedLocale, $localizations, '', false, false, false);
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->assertNotContains($unsupportedLocale, $localizations, '', false, false, false);
64
    }
65
}
66