Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / tests / Drupal / Tests / Component / Utility / UnicodeTest.php
index 6bfc6cb0d2f71bcf29dfe376ee43bd6a1454060e..960d1812adc53a3264e62cf714e03d07f33c4fbf 100644 (file)
@@ -33,7 +33,12 @@ class UnicodeTest extends TestCase {
    */
   public function testStatus($value, $expected, $invalid = FALSE) {
     if ($invalid) {
-      $this->setExpectedException('InvalidArgumentException');
+      if (method_exists($this, 'expectException')) {
+        $this->expectException('InvalidArgumentException');
+      }
+      else {
+        $this->setExpectedException('InvalidArgumentException');
+      }
     }
     Unicode::setStatus($value);
     $this->assertEquals($expected, Unicode::getStatus());
@@ -371,7 +376,7 @@ class UnicodeTest extends TestCase {
    *     - (optional) Boolean for the $add_ellipsis flag. Defaults to FALSE.
    */
   public function providerTruncate() {
-    return [
+    $tests = [
       ['frànçAIS is über-åwesome', 24, 'frànçAIS is über-åwesome'],
       ['frànçAIS is über-åwesome', 23, 'frànçAIS is über-åwesom'],
       ['frànçAIS is über-åwesome', 17, 'frànçAIS is über-'],
@@ -417,6 +422,24 @@ class UnicodeTest extends TestCase {
       ['Help! Help! Help!', 3, 'He…', TRUE, TRUE],
       ['Help! Help! Help!', 2, 'H…', TRUE, TRUE],
     ];
+
+    // Test truncate on text with multiple lines.
+    $multi_line = <<<EOF
+This is a text that spans multiple lines.
+Line 2 goes here.
+EOF;
+    $multi_line_wordsafe = <<<EOF
+This is a text that spans multiple lines.
+Line 2
+EOF;
+    $multi_line_non_wordsafe = <<<EOF
+This is a text that spans multiple lines.
+Line 2 go
+EOF;
+    $tests[] = [$multi_line, 51, $multi_line_wordsafe, TRUE];
+    $tests[] = [$multi_line, 51, $multi_line_non_wordsafe, FALSE];
+
+    return $tests;
   }
 
   /**