Skip to content

Commit d142619

Browse files
committed
Cover static method calls
1 parent e63e407 commit d142619

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

tests/TranslationTest.php

+12-6
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,29 @@ public function testTranslationEquality(): void
3131

3232
public function testTranslationKeyExtraction(): void
3333
{
34-
$result = $this->tr->setSource('en')->setTarget('fr')->preserveParameters()->translate('Hello :name, how are :type_of_greeting?');
34+
$resultOne = GoogleTranslate::trans('Hello :name how are :type_of_greeting?', 'fr', 'en', preserveParameters: true);
35+
$resultTwo = $this->tr->setSource('en')->setTarget('fr')->preserveParameters()->translate('Hello :name, how are :type_of_greeting?');
3536

36-
$this->assertEquals('Bonjour :name, comment vont :type_of_greeting ?', $result, 'Translation should be correct with proper key extraction.');
37+
$this->assertEquals('Bonjour :name, comment vont :type_of_greeting ?', $resultOne, 'Translation should be correct with proper key extraction.');
38+
$this->assertEquals('Bonjour :name, comment vont :type_of_greeting ?', $resultTwo, 'Translation should be correct with proper key extraction.');
3739
}
3840

3941
public function testCanIgnoreTranslationKeyExtraction(): void
4042
{
41-
$result = $this->tr->setSource('en')->setTarget('fr')->translate('Hello :name how are :greeting?');
43+
$resultOne = GoogleTranslate::trans('Hello :name how are :greeting?', 'fr', 'en');
44+
$resultTwo = $this->tr->setSource('en')->setTarget('fr')->translate('Hello :name how are :greeting?');
4245

43-
$this->assertEquals('Bonjour :nom, comment allez-vous :salut ?', $result, 'Translation should be correct and ignores key extraction if not set.');
46+
$this->assertEquals('Bonjour :nom, comment allez-vous :salut ?', $resultOne, 'Translation should be correct and ignores key extraction if not set.');
47+
$this->assertEquals('Bonjour :nom, comment allez-vous :salut ?', $resultTwo, 'Translation should be correct and ignores key extraction if not set.');
4448
}
4549

4650
public function testCanCustomizeExtractionPattern(): void
4751
{
48-
$result = $this->tr->setSource('en')->setTarget('fr')->preserveParameters('/\{\{([^}]+)\}\}/')->translate('Hello {{name}}, how are {{type_of_greeting}}?');
52+
$resultOne = GoogleTranslate::trans('Hello {{name}}, how are {{type_of_greeting}}?', 'fr', 'en', preserveParameters: '/\{\{([^}]+)\}\}/');
53+
$resultTwo = $this->tr->setSource('en')->setTarget('fr')->preserveParameters('/\{\{([^}]+)\}\}/')->translate('Hello {{name}}, how are {{type_of_greeting}}?');
4954

50-
$this->assertEquals('Bonjour {{name}}, comment vont {{type_of_greeting}} ?', $result, 'Translation should be correct and ignores key extraction if not set.');
55+
$this->assertEquals('Bonjour {{name}}, comment vont {{type_of_greeting}} ?', $resultOne, 'Translation should be correct and ignores key extraction if not set.');
56+
$this->assertEquals('Bonjour {{name}}, comment vont {{type_of_greeting}} ?', $resultTwo, 'Translation should be correct and ignores key extraction if not set.');
5157
}
5258

5359
public function testNewerLanguageTranslation(): void

0 commit comments

Comments
 (0)