Skip to content

Commit

Permalink
update test to include specific french example
Browse files Browse the repository at this point in the history
  • Loading branch information
kylemilloy committed Jan 24, 2024
1 parent 4e9388b commit 4541093
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions .phpunit.result.cache
@@ -0,0 +1 @@
{"version":1,"defects":{"Stichoza\\GoogleTranslate\\Tests\\TranslationTest::testItProperlyTranslateStringsInFrenchThatWouldOtherwiseCauseIssues":3},"times":{"Stichoza\\GoogleTranslate\\Tests\\ExceptionTest::testRateLimitException":0.668,"Stichoza\\GoogleTranslate\\Tests\\ExceptionTest::testRateLimitCaptchaException":0.483,"Stichoza\\GoogleTranslate\\Tests\\ExceptionTest::testLargeTextException":0.474,"Stichoza\\GoogleTranslate\\Tests\\ExceptionTest::testTranslationRequestException":0.486,"Stichoza\\GoogleTranslate\\Tests\\ExceptionTest::testTranslationDecodingException":0.501,"Stichoza\\GoogleTranslate\\Tests\\ExceptionTest::testInheritanceForUnexpectedValueException":0.59,"Stichoza\\GoogleTranslate\\Tests\\ExceptionTest::testInheritanceForErrorException":0.647,"Stichoza\\GoogleTranslate\\Tests\\LanguageDetectionTest::testSingleWord":0.726,"Stichoza\\GoogleTranslate\\Tests\\LanguageDetectionTest::testSingleSentence":0.327,"Stichoza\\GoogleTranslate\\Tests\\LanguageDetectionTest::testMultipleSentence":0.344,"Stichoza\\GoogleTranslate\\Tests\\TranslationTest::testTranslation":0.161,"Stichoza\\GoogleTranslate\\Tests\\TranslationTest::testTranslationEquality":0.361,"Stichoza\\GoogleTranslate\\Tests\\TranslationTest::testTranslationKeyExtraction":0.371,"Stichoza\\GoogleTranslate\\Tests\\TranslationTest::testCanIgnoreTranslationKeyExtraction":0.301,"Stichoza\\GoogleTranslate\\Tests\\TranslationTest::testCanCustomizeExtractionPattern":0.45,"Stichoza\\GoogleTranslate\\Tests\\TranslationTest::testNewerLanguageTranslation":0.256,"Stichoza\\GoogleTranslate\\Tests\\TranslationTest::testUTF16Translation":0.311,"Stichoza\\GoogleTranslate\\Tests\\TranslationTest::testLargeTextTranslation":0.266,"Stichoza\\GoogleTranslate\\Tests\\TranslationTest::testRawResponse":0.16,"Stichoza\\GoogleTranslate\\Tests\\TranslationTest::testItProperlyTranslateStringsInFrenchThatWouldOtherwiseCauseIssues":0.451,"Stichoza\\GoogleTranslate\\Tests\\UtilityTest::testIsValidLocale":0.002,"Stichoza\\GoogleTranslate\\Tests\\UtilityTest::testSetOptions":0.358,"Stichoza\\GoogleTranslate\\Tests\\UtilityTest::testSetUrl":0.145,"Stichoza\\GoogleTranslate\\Tests\\UtilityTest::testSetClient":0.001}}
12 changes: 12 additions & 0 deletions tests/TranslationTest.php
Expand Up @@ -87,4 +87,16 @@ public function testRawResponse(): void

$this->assertIsArray($rawResult, 'Method getResponse() should return an array');
}

/**
* @see https://github.com/Stichoza/google-translate-php/issues/201
*/
public function testItProperlyTranslateStringsInFrenchThatWouldOtherwiseCauseIssues(): void
{
$resultOne = $this->tr->setSource('en')->setTarget('fr')->translate('What is :real_q_encoded?');
$resultTwo = $this->tr->setSource('en')->setTarget('fr')->preserveParameters('#\{([^}]+)}#')->translate('What is {real_q_encoded}?');

$this->assertEquals('Qu\'est-ce que :real_q_encoded ?', $resultOne, 'Translation should be correct.');
$this->assertEquals('Qu\'est-ce que {real_q_encoded} ?', $resultTwo, 'Translation should be correct.');
}
}

0 comments on commit 4541093

Please sign in to comment.