Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 013cf80

Browse files
committed
- add Testcase for Handling of html5-Tags
1 parent 66b9013 commit 013cf80

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

tests/integration/DeepLApiTest.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,4 +273,50 @@ public function testTranslateFormalityFail()
273273
'more' //$formality
274274
);
275275
}
276+
277+
278+
/**
279+
* Test to Test the Tag-Handling.
280+
*/
281+
public function testTranslateWithHTML()
282+
{
283+
if (self::$authKey === false) {
284+
$this->markTestSkipped('DeepL Auth Key (DEEPL_AUTH_KEY) is not configured.');
285+
}
286+
287+
$deepl = new DeepL(self::$authKey);
288+
$textToTranslate = array(
289+
'Hello World<strong>This should stay the same</strong>',
290+
'Another Text<br> new line <p>this is a paragraph</p>'
291+
);
292+
293+
$expectedArray = array(
294+
array(
295+
'detected_source_language' => "EN",
296+
'text' => "Hallo Welt<strong>This should stay the same</strong>",
297+
),
298+
array(
299+
'detected_source_language' => "EN",
300+
'text' => "Ein weiterer Text neue Zeile <p>dies ist ein Absatz</p>",
301+
),
302+
303+
);
304+
305+
$translatedText = $deepl->translate(
306+
$textToTranslate,
307+
'en', //$sourceLanguage
308+
'de', //$destinationLanguage
309+
'xml', //$tagHandling
310+
array('strong'), //$ignoreTags
311+
'less', //$formality
312+
'translate',
313+
1,
314+
0,
315+
array('br'),
316+
1,
317+
array('p')
318+
);
319+
320+
$this->assertEquals($expectedArray, $translatedText);
321+
}
276322
}

0 commit comments

Comments
 (0)