summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathaniel Catchpole2016-02-17 06:25:46 (GMT)
committerNathaniel Catchpole2016-02-17 06:25:46 (GMT)
commitdc111b405ec689df1cda596038256453d66799fc (patch)
treece18b9884b23c96926609e31f8434ea80eb9dd4d
parentc7af20e47fec7ef9840585e1ebfd913076468e5c (diff)
Issue #2641588 by naveenvalecha, Mac_Weber, dimaro, heykarthikwithu: Replace deprecated usage of entity_create('file') with a direct call to File::create()
-rw-r--r--core/modules/content_translation/src/Tests/ContentTranslationSyncImageTest.php3
-rw-r--r--core/modules/editor/src/Tests/EditorFileReferenceFilterTest.php5
-rw-r--r--core/modules/editor/src/Tests/EditorFileUsageTest.php3
-rw-r--r--core/modules/file/file.module6
-rw-r--r--core/modules/file/src/Tests/FileFieldTestBase.php2
-rw-r--r--core/modules/file/src/Tests/FileItemTest.php13
-rw-r--r--core/modules/file/src/Tests/FileListingTest.php4
-rw-r--r--core/modules/file/src/Tests/FileManagedTestBase.php5
-rw-r--r--core/modules/file/src/Tests/FileManagedUnitTestBase.php5
-rw-r--r--core/modules/file/src/Tests/SaveUploadTest.php2
-rw-r--r--core/modules/file/src/Tests/SpaceUsedTest.php5
-rw-r--r--core/modules/file/src/Tests/ValidatorTest.php11
-rw-r--r--core/modules/file/src/Tests/Views/RelationshipUserFileDataTest.php5
-rw-r--r--core/modules/hal/src/Tests/FileDenormalizeTest.php2
-rw-r--r--core/modules/hal/src/Tests/FileNormalizeTest.php3
-rw-r--r--core/modules/image/src/Tests/FileMoveTest.php3
-rw-r--r--core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php4
-rw-r--r--core/modules/image/src/Tests/ImageItemTest.php9
-rw-r--r--core/modules/image/src/Tests/ImageThemeFunctionTest.php5
-rw-r--r--core/modules/image/src/Tests/Views/RelationshipUserImageDataTest.php5
-rw-r--r--core/modules/locale/src/Tests/LocaleUpdateBase.php5
-rw-r--r--core/modules/rdf/src/Tests/StandardProfileTest.php3
-rw-r--r--core/modules/system/src/Tests/Entity/EntityCrudHookTest.php4
-rw-r--r--core/modules/system/src/Tests/TypedData/TypedDataTest.php3
-rw-r--r--core/modules/views/src/Tests/Plugin/NumericFormatPluralTest.php5
25 files changed, 69 insertions, 51 deletions
diff --git a/core/modules/content_translation/src/Tests/ContentTranslationSyncImageTest.php b/core/modules/content_translation/src/Tests/ContentTranslationSyncImageTest.php
index 380e1dc..281d7b8 100644
--- a/core/modules/content_translation/src/Tests/ContentTranslationSyncImageTest.php
+++ b/core/modules/content_translation/src/Tests/ContentTranslationSyncImageTest.php
@@ -10,6 +10,7 @@ namespace Drupal\content_translation\Tests;
use Drupal\Core\Entity\EntityInterface;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
+use Drupal\file\Entity\File;
/**
* Tests the field synchronization behavior for the image field.
@@ -139,7 +140,7 @@ class ContentTranslationSyncImageTest extends ContentTranslationTestBase {
'uid' => \Drupal::currentUser()->id(),
'status' => FILE_STATUS_PERMANENT,
);
- $file = entity_create('file', $field_values);
+ $file = File::create($field_values);
$file->save();
$fid = $file->id();
$this->files[$index]->fid = $fid;
diff --git a/core/modules/editor/src/Tests/EditorFileReferenceFilterTest.php b/core/modules/editor/src/Tests/EditorFileReferenceFilterTest.php
index 87809ef..aac6ae0 100644
--- a/core/modules/editor/src/Tests/EditorFileReferenceFilterTest.php
+++ b/core/modules/editor/src/Tests/EditorFileReferenceFilterTest.php
@@ -8,6 +8,7 @@
namespace Drupal\editor\Tests;
use Drupal\Core\Cache\Cache;
+use Drupal\file\Entity\File;
use Drupal\simpletest\KernelTestBase;
use Drupal\filter\FilterPluginCollection;
@@ -55,14 +56,14 @@ class EditorFileReferenceFilterTest extends KernelTestBase {
};
file_put_contents('public://llama.jpg', $this->randomMachineName());
- $image = entity_create('file', array('uri' => 'public://llama.jpg'));
+ $image = File::create(['uri' => 'public://llama.jpg']);
$image->save();
$id = $image->id();
$uuid = $image->uuid();
$cache_tag = ['file:' . $id];
file_put_contents('public://alpaca.jpg', $this->randomMachineName());
- $image_2 = entity_create('file', array('uri' => 'public://alpaca.jpg'));
+ $image_2 = File::create(['uri' => 'public://alpaca.jpg']);
$image_2->save();
$id_2 = $image_2->id();
$uuid_2 = $image_2->uuid();
diff --git a/core/modules/editor/src/Tests/EditorFileUsageTest.php b/core/modules/editor/src/Tests/EditorFileUsageTest.php
index e49ddb1..750edd3 100644
--- a/core/modules/editor/src/Tests/EditorFileUsageTest.php
+++ b/core/modules/editor/src/Tests/EditorFileUsageTest.php
@@ -9,6 +9,7 @@ namespace Drupal\editor\Tests;
use Drupal\editor\Entity\Editor;
use Drupal\node\Entity\NodeType;
+use Drupal\file\Entity\File;
use Drupal\system\Tests\Entity\EntityUnitTestBase;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
@@ -74,7 +75,7 @@ class EditorFileUsageTest extends EntityUnitTestBase {
$image_entities = array();
foreach ($image_paths as $key => $image_path) {
- $image = entity_create('file');
+ $image = File::create();
$image->setFileUri($image_path);
$image->setFilename(drupal_basename($image->getFileUri()));
$image->save();
diff --git a/core/modules/file/file.module b/core/modules/file/file.module
index fd17021..bffb84d 100644
--- a/core/modules/file/file.module
+++ b/core/modules/file/file.module
@@ -504,11 +504,11 @@ function file_save_data($data, $destination = NULL, $replace = FILE_EXISTS_RENAM
if ($uri = file_unmanaged_save_data($data, $destination, $replace)) {
// Create a file entity.
- $file = entity_create('file', array(
+ $file = File::create([
'uri' => $uri,
'uid' => $user->id(),
'status' => FILE_STATUS_PERMANENT,
- ));
+ ]);
// If we are replacing an existing file re-use its database record.
// @todo Do not create a new entity in order to update it. See
// https://www.drupal.org/node/2241865.
@@ -772,7 +772,7 @@ function file_save_upload($form_field_name, $validators = array(), $destination
'filesize' => $file_info->getSize(),
);
$values['filemime'] = \Drupal::service('file.mime_type.guesser')->guess($values['filename']);
- $file = entity_create('file', $values);
+ $file = File::create($values);
$extensions = '';
if (isset($validators['file_validate_extensions'])) {
diff --git a/core/modules/file/src/Tests/FileFieldTestBase.php b/core/modules/file/src/Tests/FileFieldTestBase.php
index 903c200..e9cdc24 100644
--- a/core/modules/file/src/Tests/FileFieldTestBase.php
+++ b/core/modules/file/src/Tests/FileFieldTestBase.php
@@ -50,7 +50,7 @@ abstract class FileFieldTestBase extends WebTestBase {
// \Drupal\file\Entity\File::load().
$file->filesize = filesize($file->uri);
- return entity_create('file', (array) $file);
+ return File::create((array) $file);
}
/**
diff --git a/core/modules/file/src/Tests/FileItemTest.php b/core/modules/file/src/Tests/FileItemTest.php
index 3440535..e94f4ee 100644
--- a/core/modules/file/src/Tests/FileItemTest.php
+++ b/core/modules/file/src/Tests/FileItemTest.php
@@ -13,6 +13,7 @@ use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Tests\FieldUnitTestBase;
use Drupal\field\Entity\FieldStorageConfig;
+use Drupal\file\Entity\File;
/**
* Tests using entity fields of the file field type.
@@ -62,9 +63,9 @@ class FileItemTest extends FieldUnitTestBase {
'settings' => array('file_directory' => $this->directory),
])->save();
file_put_contents('public://example.txt', $this->randomMachineName());
- $this->file = entity_create('file', array(
+ $this->file = File::create([
'uri' => 'public://example.txt',
- ));
+ ]);
$this->file->save();
}
@@ -99,9 +100,9 @@ class FileItemTest extends FieldUnitTestBase {
// Make sure the computed files reflects updates to the file.
file_put_contents('public://example-2.txt', $this->randomMachineName());
- $file2 = entity_create('file', array(
+ $file2 = File::create([
'uri' => 'public://example-2.txt',
- ));
+ ]);
$file2->save();
$entity->file_test->target_id = $file2->id();
@@ -124,9 +125,9 @@ class FileItemTest extends FieldUnitTestBase {
// Make sure the computed files reflects updates to the file.
file_put_contents('public://example-3.txt', $this->randomMachineName());
// Test unsaved file entity.
- $file3 = entity_create('file', array(
+ $file3 = File::create([
'uri' => 'public://example-3.txt',
- ));
+ ]);
$display = entity_get_display('entity_test', 'entity_test', 'default');
$display->setComponent('file_test', [
'label' => 'above',
diff --git a/core/modules/file/src/Tests/FileListingTest.php b/core/modules/file/src/Tests/FileListingTest.php
index 72b2378..47612ca 100644
--- a/core/modules/file/src/Tests/FileListingTest.php
+++ b/core/modules/file/src/Tests/FileListingTest.php
@@ -157,7 +157,7 @@ class FileListingTest extends FileFieldTestBase {
*/
protected function createFile() {
// Create a new file entity.
- $file = entity_create('file', array(
+ $file = File::create([
'uid' => 1,
'filename' => 'druplicon.txt',
'uri' => 'public://druplicon.txt',
@@ -165,7 +165,7 @@ class FileListingTest extends FileFieldTestBase {
'created' => 1,
'changed' => 1,
'status' => FILE_STATUS_PERMANENT,
- ));
+ ]);
file_put_contents($file->getFileUri(), 'hello world');
// Save it, inserting a new record.
diff --git a/core/modules/file/src/Tests/FileManagedTestBase.php b/core/modules/file/src/Tests/FileManagedTestBase.php
index ebaaaea..04b33aa 100644
--- a/core/modules/file/src/Tests/FileManagedTestBase.php
+++ b/core/modules/file/src/Tests/FileManagedTestBase.php
@@ -7,6 +7,7 @@
namespace Drupal\file\Tests;
+use Drupal\file\Entity\File;
use Drupal\file\FileInterface;
use Drupal\simpletest\WebTestBase;
@@ -152,10 +153,10 @@ abstract class FileManagedTestBase extends WebTestBase {
function createFile($filepath = NULL, $contents = NULL, $scheme = NULL) {
// Don't count hook invocations caused by creating the file.
\Drupal::state()->set('file_test.count_hook_invocations', FALSE);
- $file = entity_create('file', array(
+ $file = File::create([
'uri' => $this->createUri($filepath, $contents, $scheme),
'uid' => 1,
- ));
+ ]);
$file->save();
// Write the record directly rather than using the API so we don't invoke
// the hooks.
diff --git a/core/modules/file/src/Tests/FileManagedUnitTestBase.php b/core/modules/file/src/Tests/FileManagedUnitTestBase.php
index 61e5b25..62ee4c2 100644
--- a/core/modules/file/src/Tests/FileManagedUnitTestBase.php
+++ b/core/modules/file/src/Tests/FileManagedUnitTestBase.php
@@ -7,6 +7,7 @@
namespace Drupal\file\Tests;
+use Drupal\file\Entity\File;
use Drupal\file\FileInterface;
use Drupal\simpletest\KernelTestBase;
use Drupal\user\Entity\User;
@@ -165,10 +166,10 @@ abstract class FileManagedUnitTestBase extends KernelTestBase {
function createFile($filepath = NULL, $contents = NULL, $scheme = NULL) {
// Don't count hook invocations caused by creating the file.
\Drupal::state()->set('file_test.count_hook_invocations', FALSE);
- $file = entity_create('file', array(
+ $file = File::create([
'uri' => $this->createUri($filepath, $contents, $scheme),
'uid' => 1,
- ));
+ ]);
$file->save();
// Write the record directly rather than using the API so we don't invoke
// the hooks.
diff --git a/core/modules/file/src/Tests/SaveUploadTest.php b/core/modules/file/src/Tests/SaveUploadTest.php
index 7c3bd4c..9b6a090 100644
--- a/core/modules/file/src/Tests/SaveUploadTest.php
+++ b/core/modules/file/src/Tests/SaveUploadTest.php
@@ -52,7 +52,7 @@ class SaveUploadTest extends FileManagedTestBase {
$this->drupalLogin($account);
$image_files = $this->drupalGetTestFiles('image');
- $this->image = entity_create('file', (array) current($image_files));
+ $this->image = File::create((array) current($image_files));
list(, $this->imageExtension) = explode('.', $this->image->getFilename());
$this->assertTrue(is_file($this->image->getFileUri()), "The image file we're going to upload exists.");
diff --git a/core/modules/file/src/Tests/SpaceUsedTest.php b/core/modules/file/src/Tests/SpaceUsedTest.php
index 56ed974..3a4e8c3 100644
--- a/core/modules/file/src/Tests/SpaceUsedTest.php
+++ b/core/modules/file/src/Tests/SpaceUsedTest.php
@@ -6,6 +6,7 @@
*/
namespace Drupal\file\Tests;
+use Drupal\file\Entity\File;
/**
* Tests the spaceUsed() function.
@@ -44,11 +45,11 @@ class SpaceUsedTest extends FileManagedUnitTestBase {
*/
protected function createFileWithSize($uri, $size, $uid, $status = FILE_STATUS_PERMANENT) {
file_put_contents($uri, $this->randomMachineName($size));
- $file = entity_create('file', array(
+ $file = File::create([
'uri' => $uri,
'uid' => $uid,
'status' => $status,
- ));
+ ]);
$file->save();
return $file;
}
diff --git a/core/modules/file/src/Tests/ValidatorTest.php b/core/modules/file/src/Tests/ValidatorTest.php
index 8ad5939..be3e098 100644
--- a/core/modules/file/src/Tests/ValidatorTest.php
+++ b/core/modules/file/src/Tests/ValidatorTest.php
@@ -6,6 +6,7 @@
*/
namespace Drupal\file\Tests;
+use Drupal\file\Entity\File;
/**
* Tests the functions used to validate uploaded files.
@@ -31,11 +32,11 @@ class ValidatorTest extends FileManagedUnitTestBase {
protected function setUp() {
parent::setUp();
- $this->image = entity_create('file');
+ $this->image = File::create();
$this->image->setFileUri('core/misc/druplicon.png');
$this->image->setFilename(drupal_basename($this->image->getFileUri()));
- $this->nonImage = entity_create('file');
+ $this->nonImage = File::create();
$this->nonImage->setFileUri('core/assets/vendor/jquery/jquery.min.js');
$this->nonImage->setFilename(drupal_basename($this->nonImage->getFileUri()));
}
@@ -44,7 +45,7 @@ class ValidatorTest extends FileManagedUnitTestBase {
* Test the file_validate_extensions() function.
*/
function testFileValidateExtensions() {
- $file = entity_create('file', array('filename' => 'asdf.txt'));
+ $file = File::create(['filename' => 'asdf.txt']);
$errors = file_validate_extensions($file, 'asdf txt pork');
$this->assertEqual(count($errors), 0, 'Valid extension accepted.', 'File');
@@ -120,7 +121,7 @@ class ValidatorTest extends FileManagedUnitTestBase {
*/
function testFileValidateNameLength() {
// Create a new file entity.
- $file = entity_create('file');
+ $file = File::create();
// Add a filename with an allowed length and test it.
$file->setFilename(str_repeat('x', 240));
@@ -145,7 +146,7 @@ class ValidatorTest extends FileManagedUnitTestBase {
*/
function testFileValidateSize() {
// Create a file with a size of 1000 bytes, and quotas of only 1 byte.
- $file = entity_create('file', array('filesize' => 1000));
+ $file = File::create(['filesize' => 1000]);
$errors = file_validate_size($file, 0, 0);
$this->assertEqual(count($errors), 0, 'No limits means no errors.', 'File');
$errors = file_validate_size($file, 1, 0);
diff --git a/core/modules/file/src/Tests/Views/RelationshipUserFileDataTest.php b/core/modules/file/src/Tests/Views/RelationshipUserFileDataTest.php
index fc795d9..c1f1e2c 100644
--- a/core/modules/file/src/Tests/Views/RelationshipUserFileDataTest.php
+++ b/core/modules/file/src/Tests/Views/RelationshipUserFileDataTest.php
@@ -8,6 +8,7 @@
namespace Drupal\file\Tests\Views;
use Drupal\field\Entity\FieldConfig;
+use Drupal\file\Entity\File;
use Drupal\views\Tests\ViewTestBase;
use Drupal\views\Views;
use Drupal\views\Tests\ViewTestData;
@@ -60,7 +61,7 @@ class RelationshipUserFileDataTest extends ViewTestBase {
* Tests using the views file relationship.
*/
public function testViewsHandlerRelationshipUserFileData() {
- $file = entity_create('file', array(
+ $file = File::create([
'fid' => 2,
'uid' => 2,
'filename' => 'image-test.jpg',
@@ -69,7 +70,7 @@ class RelationshipUserFileDataTest extends ViewTestBase {
'created' => 1,
'changed' => 1,
'status' => FILE_STATUS_PERMANENT,
- ));
+ ]);
$file->enforceIsNew();
file_put_contents($file->getFileUri(), file_get_contents('core/modules/simpletest/files/image-1.png'));
$file->save();
diff --git a/core/modules/hal/src/Tests/FileDenormalizeTest.php b/core/modules/hal/src/Tests/FileDenormalizeTest.php
index 853b06d..b2e6ab5 100644
--- a/core/modules/hal/src/Tests/FileDenormalizeTest.php
+++ b/core/modules/hal/src/Tests/FileDenormalizeTest.php
@@ -36,7 +36,7 @@ class FileDenormalizeTest extends WebTestBase {
'status' => FILE_STATUS_PERMANENT,
);
// Create a new file entity.
- $file = entity_create('file', $file_params);
+ $file = File::create($file_params);
file_put_contents($file->getFileUri(), 'hello world');
$file->save();
diff --git a/core/modules/hal/src/Tests/FileNormalizeTest.php b/core/modules/hal/src/Tests/FileNormalizeTest.php
index 64ffd07..67406fb 100644
--- a/core/modules/hal/src/Tests/FileNormalizeTest.php
+++ b/core/modules/hal/src/Tests/FileNormalizeTest.php
@@ -8,6 +8,7 @@
namespace Drupal\hal\Tests;
use Drupal\Core\Cache\MemoryBackend;
+use Drupal\file\Entity\File;
use Drupal\hal\Encoder\JsonEncoder;
use Drupal\hal\Normalizer\FieldItemNormalizer;
use Drupal\hal\Normalizer\FileEntityNormalizer;
@@ -65,7 +66,7 @@ class FileNormalizeTest extends NormalizerTestBase {
'status' => FILE_STATUS_PERMANENT,
);
// Create a new file entity.
- $file = entity_create('file', $file_params);
+ $file = File::create($file_params);
file_put_contents($file->getFileUri(), 'hello world');
$file->save();
diff --git a/core/modules/image/src/Tests/FileMoveTest.php b/core/modules/image/src/Tests/FileMoveTest.php
index 34c54a7..4c11725 100644
--- a/core/modules/image/src/Tests/FileMoveTest.php
+++ b/core/modules/image/src/Tests/FileMoveTest.php
@@ -7,6 +7,7 @@
namespace Drupal\image\Tests;
+use Drupal\file\Entity\File;
use Drupal\simpletest\WebTestBase;
use Drupal\image\Entity\ImageStyle;
@@ -29,7 +30,7 @@ class FileMoveTest extends WebTestBase {
*/
function testNormal() {
// Pick a file for testing.
- $file = entity_create('file', (array) current($this->drupalGetTestFiles('image')));
+ $file = File::create((array) current($this->drupalGetTestFiles('image')));
// Create derivative image.
$styles = ImageStyle::loadMultiple();
diff --git a/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php b/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php
index 07e7575..627bd74 100644
--- a/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php
+++ b/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php
@@ -38,12 +38,12 @@ class ImageFieldDefaultImagesTest extends ImageFieldTestBase {
$filename = $this->randomMachineName() . "$i";
$desired_filepath = 'public://' . $filename;
file_unmanaged_copy($files[0]->uri, $desired_filepath, FILE_EXISTS_ERROR);
- $file = entity_create('file', array('uri' => $desired_filepath, 'filename' => $filename, 'name' => $filename));
+ $file = File::create(['uri' => $desired_filepath, 'filename' => $filename, 'name' => $filename]);
$file->save();
}
$default_images = array();
foreach (array('field', 'field', 'field2', 'field_new', 'field_new') as $image_target) {
- $file = entity_create('file', (array) array_pop($files));
+ $file = File::create((array) array_pop($files));
$file->save();
$default_images[$image_target] = $file;
}
diff --git a/core/modules/image/src/Tests/ImageItemTest.php b/core/modules/image/src/Tests/ImageItemTest.php
index 5969c41..983088f 100644
--- a/core/modules/image/src/Tests/ImageItemTest.php
+++ b/core/modules/image/src/Tests/ImageItemTest.php
@@ -13,6 +13,7 @@ use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Tests\FieldUnitTestBase;
use Drupal\field\Entity\FieldStorageConfig;
+use Drupal\file\Entity\File;
/**
* Tests using entity fields of the image field type.
@@ -58,9 +59,9 @@ class ImageItemTest extends FieldUnitTestBase {
'bundle' => 'entity_test',
])->save();
file_unmanaged_copy(\Drupal::root() . '/core/misc/druplicon.png', 'public://example.jpg');
- $this->image = entity_create('file', array(
+ $this->image = File::create([
'uri' => 'public://example.jpg',
- ));
+ ]);
$this->image->save();
$this->imageFactory = $this->container->get('image.factory');
}
@@ -91,9 +92,9 @@ class ImageItemTest extends FieldUnitTestBase {
// Make sure the computed entity reflects updates to the referenced file.
file_unmanaged_copy(\Drupal::root() . '/core/misc/druplicon.png', 'public://example-2.jpg');
- $image2 = entity_create('file', array(
+ $image2 = File::create([
'uri' => 'public://example-2.jpg',
- ));
+ ]);
$image2->save();
$entity->image_test->target_id = $image2->id();
diff --git a/core/modules/image/src/Tests/ImageThemeFunctionTest.php b/core/modules/image/src/Tests/ImageThemeFunctionTest.php
index e4f7b17..653ba55 100644
--- a/core/modules/image/src/Tests/ImageThemeFunctionTest.php
+++ b/core/modules/image/src/Tests/ImageThemeFunctionTest.php
@@ -10,6 +10,7 @@ namespace Drupal\image\Tests;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\Url;
use Drupal\field\Entity\FieldConfig;
+use Drupal\file\Entity\File;
use Drupal\image\Entity\ImageStyle;
use Drupal\simpletest\WebTestBase;
use Drupal\field\Entity\FieldStorageConfig;
@@ -55,9 +56,9 @@ class ImageThemeFunctionTest extends WebTestBase {
'bundle' => 'entity_test',
])->save();
file_unmanaged_copy(\Drupal::root() . '/core/misc/druplicon.png', 'public://example.jpg');
- $this->image = entity_create('file', array(
+ $this->image = File::create([
'uri' => 'public://example.jpg',
- ));
+ ]);
$this->image->save();
$this->imageFactory = $this->container->get('image.factory');
}
diff --git a/core/modules/image/src/Tests/Views/RelationshipUserImageDataTest.php b/core/modules/image/src/Tests/Views/RelationshipUserImageDataTest.php
index 8970a97..0ef0dd1 100644
--- a/core/modules/image/src/Tests/Views/RelationshipUserImageDataTest.php
+++ b/core/modules/image/src/Tests/Views/RelationshipUserImageDataTest.php
@@ -8,6 +8,7 @@
namespace Drupal\image\Tests\Views;
use Drupal\field\Entity\FieldConfig;
+use Drupal\file\Entity\File;
use Drupal\views\Tests\ViewTestBase;
use Drupal\views\Views;
use Drupal\views\Tests\ViewTestData;
@@ -60,7 +61,7 @@ class RelationshipUserImageDataTest extends ViewTestBase {
* Tests using the views image relationship.
*/
public function testViewsHandlerRelationshipUserImageData() {
- $file = entity_create('file', array(
+ $file = File::create([
'fid' => 2,
'uid' => 2,
'filename' => 'image-test.jpg',
@@ -69,7 +70,7 @@ class RelationshipUserImageDataTest extends ViewTestBase {
'created' => 1,
'changed' => 1,
'status' => FILE_STATUS_PERMANENT,
- ));
+ ]);
$file->enforceIsNew();
file_put_contents($file->getFileUri(), file_get_contents('core/modules/simpletest/files/image-1.png'));
$file->save();
diff --git a/core/modules/locale/src/Tests/LocaleUpdateBase.php b/core/modules/locale/src/Tests/LocaleUpdateBase.php
index cc2aed3..78c2b39 100644
--- a/core/modules/locale/src/Tests/LocaleUpdateBase.php
+++ b/core/modules/locale/src/Tests/LocaleUpdateBase.php
@@ -8,6 +8,7 @@
namespace Drupal\locale\Tests;
use Drupal\Core\StreamWrapper\PublicStream;
+use Drupal\file\Entity\File;
use Drupal\simpletest\WebTestBase;
use Drupal\Component\Utility\SafeMarkup;
@@ -133,14 +134,14 @@ EOF;
}
file_prepare_directory($path, FILE_CREATE_DIRECTORY);
- $file = entity_create('file', array(
+ $file = File::create([
'uid' => 1,
'filename' => $filename,
'uri' => $path . '/' . $filename,
'filemime' => 'text/x-gettext-translation',
'timestamp' => $timestamp,
'status' => FILE_STATUS_PERMANENT,
- ));
+ ]);
file_put_contents($file->getFileUri(), $po_header . $text);
touch(drupal_realpath($file->getFileUri()), $timestamp);
$file->save();
diff --git a/core/modules/rdf/src/Tests/StandardProfileTest.php b/core/modules/rdf/src/Tests/StandardProfileTest.php
index c1cd2a5..4a812ac 100644
--- a/core/modules/rdf/src/Tests/StandardProfileTest.php
+++ b/core/modules/rdf/src/Tests/StandardProfileTest.php
@@ -8,6 +8,7 @@
namespace Drupal\rdf\Tests;
use Drupal\Core\Url;
+use Drupal\file\Entity\File;
use Drupal\image\Entity\ImageStyle;
use Drupal\node\Entity\NodeType;
use Drupal\node\NodeInterface;
@@ -140,7 +141,7 @@ class StandardProfileTest extends WebTestBase {
// Create image.
file_unmanaged_copy(\Drupal::root() . '/core/misc/druplicon.png', 'public://example.jpg');
- $this->image = entity_create('file', array('uri' => 'public://example.jpg'));
+ $this->image = File::create(['uri' => 'public://example.jpg']);
$this->image->save();
// Create article.
diff --git a/core/modules/system/src/Tests/Entity/EntityCrudHookTest.php b/core/modules/system/src/Tests/Entity/EntityCrudHookTest.php
index ab2ab70..46ddaad 100644
--- a/core/modules/system/src/Tests/Entity/EntityCrudHookTest.php
+++ b/core/modules/system/src/Tests/Entity/EntityCrudHookTest.php
@@ -231,7 +231,7 @@ class EntityCrudHookTest extends EntityUnitTestBase {
$url = 'public://entity_crud_hook_test.file';
file_put_contents($url, 'Test test test');
- $file = entity_create('file', array(
+ $file = File::create([
'fid' => NULL,
'uid' => 1,
'filename' => 'entity_crud_hook_test.file',
@@ -241,7 +241,7 @@ class EntityCrudHookTest extends EntityUnitTestBase {
'status' => 1,
'created' => REQUEST_TIME,
'changed' => REQUEST_TIME,
- ));
+ ]);
$this->assertHookMessageOrder(array(
'entity_crud_hook_test_file_create called',
diff --git a/core/modules/system/src/Tests/TypedData/TypedDataTest.php b/core/modules/system/src/Tests/TypedData/TypedDataTest.php
index c6a7f1c..8c24946 100644
--- a/core/modules/system/src/Tests/TypedData/TypedDataTest.php
+++ b/core/modules/system/src/Tests/TypedData/TypedDataTest.php
@@ -12,6 +12,7 @@ use Drupal\Core\TypedData\DataDefinition;
use Drupal\Core\TypedData\ListDataDefinition;
use Drupal\Core\TypedData\MapDataDefinition;
use Drupal\Core\TypedData\TypedDataInterface;
+use Drupal\file\Entity\File;
use Drupal\simpletest\KernelTestBase;
use Drupal\Core\Datetime\DrupalDateTime;
@@ -247,7 +248,7 @@ class TypedDataTest extends KernelTestBase {
for ($i = 0; $i < 3; $i++){
$path = "public://example_$i.png";
file_unmanaged_copy(\Drupal::root() . '/core/misc/druplicon.png', $path);
- $image = entity_create('file', array('uri' => $path));
+ $image = File::create(['uri' => $path]);
$image->save();
$files[] = $image;
}
diff --git a/core/modules/views/src/Tests/Plugin/NumericFormatPluralTest.php b/core/modules/views/src/Tests/Plugin/NumericFormatPluralTest.php
index 8e75e4d..8efa45a 100644
--- a/core/modules/views/src/Tests/Plugin/NumericFormatPluralTest.php
+++ b/core/modules/views/src/Tests/Plugin/NumericFormatPluralTest.php
@@ -8,6 +8,7 @@
namespace Drupal\views\Tests\Plugin;
use Drupal\Component\Gettext\PoHeader;
+use Drupal\file\Entity\File;
use Drupal\views\Tests\ViewTestBase;
/**
@@ -144,7 +145,7 @@ class NumericFormatPluralTest extends ViewTestBase {
*/
protected function createFile() {
// Create a new file entity.
- $file = entity_create('file', array(
+ $file = File::create([
'uid' => 1,
'filename' => 'druplicon.txt',
'uri' => 'public://druplicon.txt',
@@ -152,7 +153,7 @@ class NumericFormatPluralTest extends ViewTestBase {
'created' => 1,
'changed' => 1,
'status' => FILE_STATUS_PERMANENT,
- ));
+ ]);
file_put_contents($file->getFileUri(), 'hello world');
// Save it, inserting a new record.