LanguageTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 67
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 9 1
A translateReturnsTranslatedString() 0 9 1
A translateWithWrongLLLKeyReturnsEmptyString() 0 9 1
A translateWithRandomStringReturnsRandomString() 0 5 1
1
<?php
2
namespace TildBJ\Seeder\Tests\Unit\Traits;
3
4
/***************************************************************
5
 *  Copyright notice
6
 *
7
 *  (c) 2016 Dennis Römmich <[email protected]>
8
 *
9
 *  All rights reserved
10
 *
11
 *  This script is part of the TYPO3 project. The TYPO3 project is
12
 *  free software; you can redistribute it and/or modify
13
 *  it under the terms of the GNU General Public License as published by
14
 *  the Free Software Foundation; either version 2 of the License, or
15
 *  (at your option) any later version.
16
 *
17
 *  The GNU General Public License can be found at
18
 *  http://www.gnu.org/copyleft/gpl.html.
19
 *
20
 *  This script is distributed in the hope that it will be useful,
21
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 *  GNU General Public License for more details.
24
 *
25
 *  This copyright notice MUST APPEAR in all copies of the script!
26
 ***************************************************************/
27
use TildBJ\Seeder\Tests\Unit\AccessibleTraitForTest;
28
use Nimut\TestingFramework\TestCase\UnitTestCase;
29
use TildBJ\Seeder\Traits;
30
use TYPO3\CMS\Lang\LanguageService;
31
32
/**
33
 * Test case for class \TildBJ\Seeder\Tests\Traits\LanguageTest
34
 *
35
 * @author Dennis Römmich <[email protected]>
36
 */
37
class LanguageTest extends UnitTestCase
38
{
39
    use AccessibleTraitForTest;
40
41
    /**
42
     * subject
43
     *
44
     * @var Traits\Language $subject
45
     */
46
    protected $subject;
47
48
    /**
49
     * setUp
50
     *
51
     * @return void
52
     */
53
    public function setUp()
54
    {
55
        parent::setUp();
56
57
        $GLOBALS['LANG'] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(LanguageService::class);
58
        $GLOBALS['LANG']->init('default');
59
60
        $this->subject = $this->getObjectForTrait(Traits\Language::class);
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->getObjectForTrait...Traits\Language::class) of type object<PHPUnit\Framework\MockObject\MockObject> is incompatible with the declared type object<TildBJ\Seeder\Traits\Language> of property $subject.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
61
    }
62
63
    /**
64
     * translateReturnsTranslatedString
65
     *
66
     * @test
67
     */
68
    public function translateReturnsTranslatedString()
69
    {
70
        $translation = $this->accessProtectedMethod(
71
            $this->subject,
72
            'translate',
73
            'LLL:EXT:lang/locallang_tca.xlf:pages'
74
        );
75
        $this->assertSame('Page', $translation);
76
    }
77
78
    /**
79
     * translateWithWrongArgumentShouldReturnEmptyString
80
     *
81
     * @test
82
     */
83
    public function translateWithWrongLLLKeyReturnsEmptyString()
84
    {
85
        $translation = $this->accessProtectedMethod(
86
            $this->subject,
87
            'translate',
88
            'LLL:EXT:lang/locallang_tca.xlf:FooBar'
89
        );
90
        $this->assertSame('', $translation);
91
    }
92
93
    /**
94
     * translateWithRandomStringReturnsRandomString
95
     *
96
     * @test
97
     */
98
    public function translateWithRandomStringReturnsRandomString()
99
    {
100
        $translation = $this->accessProtectedMethod($this->subject, 'translate', 'FooBar');
101
        $this->assertSame('FooBar', $translation);
102
    }
103
}
104