1 | <?php |
||||||
2 | |||||||
3 | namespace JosephNC\Translation\Tests; |
||||||
4 | |||||||
5 | use Illuminate\Support\Facades\Cache; |
||||||
6 | use JosephNC\Translation\Facades\Translation; |
||||||
7 | use JosephNC\Translation\Models\Translation as TranslationModel; |
||||||
8 | |||||||
9 | class TranslationTest extends FunctionalTestCase |
||||||
10 | { |
||||||
11 | public function testTranslationInvalidText() |
||||||
12 | { |
||||||
13 | $this->setExpectedException('InvalidArgumentException'); |
||||||
0 ignored issues
–
show
|
|||||||
14 | |||||||
15 | Translation::translate( [ 'Invalid' ] ); |
||||||
0 ignored issues
–
show
The method
translate() does not exist on JosephNC\Translation\Facades\Translation . Since you implemented __callStatic , consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
16 | } |
||||||
17 | |||||||
18 | public function testTranslationPlaceHoldersDynamicLanguage() |
||||||
19 | { |
||||||
20 | $replace = ['name' => 'John']; |
||||||
21 | |||||||
22 | $this->assertEquals('Hello John', Translation::translate('Hello :name', $replace, 'en')); |
||||||
23 | $this->assertEquals('Bonjour John', Translation::translate('Hello :name', $replace, 'fr')); |
||||||
24 | } |
||||||
25 | |||||||
26 | public function testTranslationPlaceHoldersMultiple() |
||||||
27 | { |
||||||
28 | $replace = [ |
||||||
29 | 'name' => 'John', |
||||||
30 | 'apples' => '10', |
||||||
31 | 'bananas' => '15', |
||||||
32 | 'grapes' => '20', |
||||||
33 | ]; |
||||||
34 | $expected = 'Hello John, I see you have 10 apples, 15 bananas, and 20 grapes.'; |
||||||
35 | $translation = 'Hello :name, I see you have :apples apples, :bananas bananas, and :grapes grapes.'; |
||||||
36 | |||||||
37 | $this->assertEquals($expected, Translation::translate($translation, $replace)); |
||||||
38 | } |
||||||
39 | |||||||
40 | public function testTranslationPlaceHoldersMultipleOfTheSame() |
||||||
41 | { |
||||||
42 | $replace = [ |
||||||
43 | 'name' => 'Name', |
||||||
44 | ]; |
||||||
45 | $expected = 'Name Name Name Name Name'; |
||||||
46 | $translation = ':name :name :name :name :name'; |
||||||
47 | |||||||
48 | $this->assertEquals($expected, Translation::translate($translation, $replace)); |
||||||
49 | } |
||||||
50 | |||||||
51 | public function testTranslationPlaceHoldersCaseInsensitivity() |
||||||
52 | { |
||||||
53 | $replace = [ |
||||||
54 | 'name' => 'John', |
||||||
55 | 'NAME' => 'Test', |
||||||
56 | ]; |
||||||
57 | |||||||
58 | $translation = ':name :NAME'; |
||||||
59 | $expected = 'John John'; |
||||||
60 | |||||||
61 | $this->assertEquals($expected, Translation::translate($translation, $replace)); |
||||||
62 | } |
||||||
63 | } |
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.