Pull merge.
[yaffs-website] / web / core / modules / file / src / Tests / FileFieldWidgetTest.php
index ad47d77841713d94e62ef7e00eb0bbd31d34c4a1..3102bd744d79252cbc07f42ad97d89ca1a4e2247 100644 (file)
@@ -4,7 +4,6 @@ namespace Drupal\file\Tests;
 
 use Drupal\comment\Entity\Comment;
 use Drupal\comment\Tests\CommentTestTrait;
-use Drupal\Component\Utility\Unicode;
 use Drupal\Core\Url;
 use Drupal\field\Entity\FieldConfig;
 use Drupal\field\Entity\FieldStorageConfig;
@@ -160,7 +159,7 @@ class FileFieldWidgetTest extends FileFieldTestBase {
       $this->drupalGet("node/add/$type_name");
       foreach ([$field_name2, $field_name] as $each_field_name) {
         for ($delta = 0; $delta < 3; $delta++) {
-          $edit = ['files[' . $each_field_name . '_' . $delta . '][]' => drupal_realpath($test_file->getFileUri())];
+          $edit = ['files[' . $each_field_name . '_' . $delta . '][]' => \Drupal::service('file_system')->realpath($test_file->getFileUri())];
           // If the Upload button doesn't exist, drupalPostForm() will automatically
           // fail with an assertion message.
           $this->drupalPostForm(NULL, $edit, t('Upload'));
@@ -270,7 +269,7 @@ class FileFieldWidgetTest extends FileFieldTestBase {
     // Try to upload exactly the allowed number of files on revision. Create an
     // empty node first, to fill it in its first revision.
     $node = $this->drupalCreateNode([
-      'type' => $type_name
+      'type' => $type_name,
     ]);
     $this->uploadNodeFile($test_file, $field_name, $node->id(), 1);
     $node_storage->resetCache([$nid]);
@@ -373,7 +372,7 @@ class FileFieldWidgetTest extends FileFieldTestBase {
     // Add a comment with a file.
     $text_file = $this->getTestFile('text');
     $edit = [
-      'files[field_' . $name . '_' . 0 . ']' => drupal_realpath($text_file->getFileUri()),
+      'files[field_' . $name . '_' . 0 . ']' => \Drupal::service('file_system')->realpath($text_file->getFileUri()),
       'comment_body[0][value]' => $comment_body = $this->randomMachineName(),
     ];
     $this->drupalPostForm('node/' . $node->id(), $edit, t('Save'));
@@ -429,7 +428,7 @@ class FileFieldWidgetTest extends FileFieldTestBase {
       $name = 'files[' . $field_name . '_0]';
 
       // Upload file with incorrect extension, check for validation error.
-      $edit[$name] = drupal_realpath($test_file_image->getFileUri());
+      $edit[$name] = \Drupal::service('file_system')->realpath($test_file_image->getFileUri());
       switch ($type) {
         case 'nojs':
           $this->drupalPostForm(NULL, $edit, t('Upload'));
@@ -443,7 +442,7 @@ class FileFieldWidgetTest extends FileFieldTestBase {
       $this->assertRaw($error_message, t('Validation error when file with wrong extension uploaded (JSMode=%type).', ['%type' => $type]));
 
       // Upload file with correct extension, check that error message is removed.
-      $edit[$name] = drupal_realpath($test_file_text->getFileUri());
+      $edit[$name] = \Drupal::service('file_system')->realpath($test_file_text->getFileUri());
       switch ($type) {
         case 'nojs':
           $this->drupalPostForm(NULL, $edit, t('Upload'));
@@ -461,7 +460,7 @@ class FileFieldWidgetTest extends FileFieldTestBase {
    * Tests file widget element.
    */
   public function testWidgetElement() {
-    $field_name = Unicode::strtolower($this->randomMachineName());
+    $field_name = mb_strtolower($this->randomMachineName());
     $html_name = str_replace('_', '-', $field_name);
     $this->createFileField($field_name, 'node', 'article', ['cardinality' => FieldStorageConfig::CARDINALITY_UNLIMITED]);
     $file = $this->getTestFile('text');