Issue #2641588 by naveenvalecha, Mac_Weber, dimaro, heykarthikwithu: Replace deprecated usage of entity_create('file') with a direct call to File::create()
parent
c7af20e47f
commit
dc111b405e
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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'])) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.");
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue