Unverified Commit 408c540c authored by alexpott's avatar alexpott
Browse files

Issue #2886622 by Berdir, martin107, Mile23, tim.plunkett, mikelutz,...

Issue #2886622 by Berdir, martin107, Mile23, tim.plunkett, mikelutz, jonathan1055: Deprecate all EntityManager methods with E_USER_DEPRECATED
parent d397f60c
......@@ -3,7 +3,6 @@
namespace Drupal\Tests\editor\Unit;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\Entity\EntityManager;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\editor\Entity\Editor;
use Drupal\Tests\UnitTestCase;
......@@ -80,16 +79,10 @@ protected function setUp() {
->disableOriginalConstructor()
->getMock();
$entity_manager = new EntityManager();
$container = new ContainerBuilder();
$container->set('entity.manager', $entity_manager);
$container->set('entity_type.manager', $this->entityTypeManager);
$container->set('uuid', $this->uuid);
$container->set('plugin.manager.editor', $this->editorPluginManager);
// Inject the container into entity.manager so it can defer to
// entity_type.manager.
$entity_manager->setContainer($container);
\Drupal::setContainer($container);
}
......
......@@ -83,7 +83,7 @@ public static function createInstance(ContainerInterface $container, EntityTypeI
$container->get('config.factory'),
$container->get('uuid'),
$container->get('language_manager'),
$container->get('entity.manager'),
$container->get('entity_type.manager'),
$container->get('plugin.manager.field.field_type'),
$container->get('entity_field.deleted_fields_repository'),
$container->get('entity.memory_cache')
......
......@@ -94,7 +94,7 @@ public static function createInstance(ContainerInterface $container, EntityTypeI
$container->get('config.factory'),
$container->get('uuid'),
$container->get('language_manager'),
$container->get('entity.manager'),
$container->get('entity_type.manager'),
$container->get('module_handler'),
$container->get('plugin.manager.field.field_type'),
$container->get('entity_field.deleted_fields_repository'),
......
......@@ -150,7 +150,7 @@ public function testFieldFormSingle() {
];
$this->drupalPostForm(NULL, $edit, t('Save'));
$this->assertText(t('entity_test @id has been updated.', ['@id' => $id]), 'Entity was updated');
$this->container->get('entity.manager')->getStorage('entity_test')->resetCache([$id]);
$this->container->get('entity_type.manager')->getStorage('entity_test')->resetCache([$id]);
$entity = EntityTest::load($id);
$this->assertEqual($entity->{$field_name}->value, $value, 'Field value was updated');
......@@ -161,7 +161,7 @@ public function testFieldFormSingle() {
];
$this->drupalPostForm('entity_test/manage/' . $id . '/edit', $edit, t('Save'));
$this->assertText(t('entity_test @id has been updated.', ['@id' => $id]), 'Entity was updated');
$this->container->get('entity.manager')->getStorage('entity_test')->resetCache([$id]);
$this->container->get('entity_type.manager')->getStorage('entity_test')->resetCache([$id]);
$entity = EntityTest::load($id);
$this->assertTrue($entity->{$field_name}->isEmpty(), 'Field was emptied');
}
......
......@@ -203,7 +203,7 @@ public function testEntityCache() {
$this->assertFalse(\Drupal::cache('entity')->get($cid), 'Cached: no cache entry on insert');
// Load, and check that a cache entry is present with the expected values.
$controller = $this->container->get('entity.manager')->getStorage($entity->getEntityTypeId());
$controller = $this->container->get('entity_type.manager')->getStorage($entity->getEntityTypeId());
$controller->resetCache();
$cached_entity = $controller->load($entity->id());
$cache = \Drupal::cache('entity')->get($cid);
......
......@@ -46,7 +46,7 @@ public function testFieldAttachSaveLoad() {
$values[$current_revision] = $current_values;
}
$storage = $this->container->get('entity.manager')->getStorage($entity_type);
$storage = $this->container->get('entity_type.manager')->getStorage($entity_type);
$storage->resetCache();
$entity = $storage->load($entity_id);
// Confirm current revision loads the correct data.
......@@ -249,7 +249,7 @@ public function testFieldAttachDelete() {
$entity->setNewRevision();
$entity->save();
$vids[] = $entity->getRevisionId();
$controller = $this->container->get('entity.manager')->getStorage($entity->getEntityTypeId());
$controller = $this->container->get('entity_type.manager')->getStorage($entity->getEntityTypeId());
$controller->resetCache();
// Confirm each revision loads
......@@ -361,7 +361,7 @@ public function testEntityDeleteBundle() {
entity_test_delete_bundle($this->fieldTestData->field->getTargetBundle(), $entity_type);
// Verify no data gets loaded
$controller = $this->container->get('entity.manager')->getStorage($entity->getEntityTypeId());
$controller = $this->container->get('entity_type.manager')->getStorage($entity->getEntityTypeId());
$controller->resetCache();
$entity = $controller->load($entity->id());
......
......@@ -337,7 +337,7 @@ public function testDeleteFieldCrossDeletion() {
$field->save();
$field_2 = FieldConfig::create($field_definition_2);
$field_2->save();
$this->container->get('entity.manager')->getStorage('field_config')->delete([$field, $field_2]);
$this->container->get('entity_type.manager')->getStorage('field_config')->delete([$field, $field_2]);
$this->assertFalse(FieldStorageConfig::loadByName('entity_test', $field_storage->getName()));
}
......
......@@ -136,7 +136,7 @@ public function testEntityCountAndHasData() {
$this->assertIdentical($this->fieldTestData->field_storage_2->hasData(), TRUE, 'There are entities with field data.');
$storage = $this->container->get('entity.manager')->getStorage($entity_type);
$storage = $this->container->get('entity_type.manager')->getStorage($entity_type);
$entity = $storage->loadRevision($first_revision);
$this->assertEqual(count($entity->{$this->fieldTestData->field_name_2}), $cardinality, format_string('Revision %revision_id: expected number of values.', ['%revision_id' => $first_revision]));
}
......
......@@ -129,7 +129,7 @@ protected function createFieldWithStorage($suffix = '', $entity_type = 'entity_t
*/
protected function entitySaveReload(EntityInterface $entity) {
$entity->save();
$controller = $this->container->get('entity.manager')->getStorage($entity->getEntityTypeId());
$controller = $this->container->get('entity_type.manager')->getStorage($entity->getEntityTypeId());
$controller->resetCache();
return $controller->load($entity->id());
}
......
......@@ -11,7 +11,6 @@
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\Entity\EntityFieldManagerInterface;
use Drupal\Core\Entity\EntityManager;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\field\Entity\FieldConfig;
use Drupal\Tests\UnitTestCase;
......@@ -32,13 +31,6 @@ class FieldConfigEntityUnitTest extends UnitTestCase {
/**
* The entity manager used for testing.
*
* @var \Drupal\Core\Entity\EntityManagerInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $entityManager;
/**
* The entity type manager used for testing.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $entityTypeManager;
......@@ -85,7 +77,6 @@ protected function setUp() {
$this->entityTypeId = $this->randomMachineName();
$this->entityType = $this->getMock('\Drupal\Core\Config\Entity\ConfigEntityTypeInterface');
$this->entityManager = new EntityManager();
$this->entityTypeManager = $this->getMock(EntityTypeManagerInterface::class);
$this->entityFieldManager = $this->getMock(EntityFieldManagerInterface::class);
......@@ -94,14 +85,10 @@ protected function setUp() {
$this->fieldTypePluginManager = $this->getMock('Drupal\Core\Field\FieldTypePluginManagerInterface');
$container = new ContainerBuilder();
$container->set('entity.manager', $this->entityManager);
$container->set('entity_field.manager', $this->entityFieldManager);
$container->set('entity_type.manager', $this->entityTypeManager);
$container->set('uuid', $this->uuid);
$container->set('plugin.manager.field.field_type', $this->fieldTypePluginManager);
// Inject the container into entity.manager so it can defer to
// entity_type.manager, etc.
$this->entityManager->setContainer($container);
\Drupal::setContainer($container);
// Create a mock FieldStorageConfig object.
......
......@@ -6,7 +6,6 @@
use Drupal\Core\Cache\Context\CacheContextsManager;
use Drupal\Core\Config\Entity\ConfigEntityTypeInterface;
use Drupal\Core\DependencyInjection\Container;
use Drupal\Core\Entity\EntityManager;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
......@@ -141,16 +140,10 @@ protected function setUp() {
['field_storage_config', $storage_access_control_handler],
]);
$entity_manager = new EntityManager();
$container = new Container();
$container->set('entity.manager', $entity_manager);
$container->set('entity_type.manager', $entity_type_manager);
$container->set('uuid', $this->getMock(UuidInterface::class));
$container->set('cache_contexts_manager', $this->prophesize(CacheContextsManager::class));
// Inject the container into entity.manager so it can defer to
// entity_type.manager.
$entity_manager->setContainer($container);
\Drupal::setContainer($container);
$this->entity = new FieldStorageConfig([
......
......@@ -8,7 +8,6 @@
namespace Drupal\Tests\field\Unit;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\Entity\EntityManager;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Field\FieldException;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
......@@ -55,19 +54,14 @@ class FieldStorageConfigEntityUnitTest extends UnitTestCase {
* {@inheritdoc}
*/
protected function setUp() {
$entity_manager = new EntityManager();
$this->entityTypeManager = $this->getMock(EntityTypeManagerInterface::class);
$this->uuid = $this->getMock('\Drupal\Component\Uuid\UuidInterface');
$this->fieldTypeManager = $this->getMock(FieldTypePluginManagerInterface::class);
$container = new ContainerBuilder();
$container->set('entity.manager', $entity_manager);
$container->set('entity_type.manager', $this->entityTypeManager);
$container->set('uuid', $this->uuid);
$container->set('plugin.manager.field.field_type', $this->fieldTypeManager);
// Inject the container into entity.manager so it can defer to
// entity_type.manager.
$entity_manager->setContainer($container);
\Drupal::setContainer($container);
}
......
......@@ -28,11 +28,6 @@ class ManageDisplayTest extends WebDriverTestBase {
*/
protected $type;
/**
* @var \Drupal\Core\Entity\EntityManagerInterface
*/
protected $entity_manager;
/**
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
......@@ -60,7 +55,6 @@ protected function setUp() {
$this->type = $type->id();
$this->entity_type_manager = $this->container->get('entity_type.manager');
$this->entity_manager = $this->container->get('entity.manager');
}
/**
......
......@@ -197,7 +197,7 @@ public function uploadNodeFiles(array $files, $field_name, $nid_or_type, $new_re
'revision' => (string) (int) $new_revision,
];
$node_storage = $this->container->get('entity.manager')->getStorage('node');
$node_storage = $this->container->get('entity_type.manager')->getStorage('node');
if (is_numeric($nid_or_type)) {
$nid = $nid_or_type;
$node_storage->resetCache([$nid]);
......@@ -277,7 +277,7 @@ public function assertFileExists($file, $message = NULL) {
* Asserts that a file exists in the database.
*/
public function assertFileEntryExists($file, $message = NULL) {
$this->container->get('entity.manager')->getStorage('file')->resetCache();
$this->container->get('entity_type.manager')->getStorage('file')->resetCache();
$db_file = File::load($file->id());
$message = isset($message) ? $message : format_string('File %file exists in database at the correct path.', ['%file' => $file->getFileUri()]);
$this->assertEqual($db_file->getFileUri(), $file->getFileUri(), $message);
......@@ -295,7 +295,7 @@ public function assertFileNotExists($file, $message = NULL) {
* Asserts that a file does not exist in the database.
*/
public function assertFileEntryNotExists($file, $message) {
$this->container->get('entity.manager')->getStorage('file')->resetCache();
$this->container->get('entity_type.manager')->getStorage('file')->resetCache();
$message = isset($message) ? $message : format_string('File %file exists in database at the correct path.', ['%file' => $file->getFileUri()]);
$this->assertFalse(File::load($file->id()), $message);
}
......
......@@ -65,7 +65,7 @@ public function testNodeDisplay() {
$nid = $this->uploadNodeFile($test_file, $field_name, $type_name);
// Check that the default formatter is displaying with the file name.
$node_storage = $this->container->get('entity.manager')->getStorage('node');
$node_storage = $this->container->get('entity_type.manager')->getStorage('node');
$node_storage->resetCache([$nid]);
$node = $node_storage->load($nid);
$node_file = File::load($node->{$field_name}->target_id);
......
......@@ -16,7 +16,7 @@ class FileFieldPathTest extends FileFieldTestBase {
*/
public function testUploadPath() {
/** @var \Drupal\node\NodeStorageInterface $node_storage */
$node_storage = $this->container->get('entity.manager')->getStorage('node');
$node_storage = $this->container->get('entity_type.manager')->getStorage('node');
$field_name = strtolower($this->randomMachineName());
$type_name = 'article';
$this->createFileField($field_name, 'node', $type_name);
......
......@@ -22,7 +22,7 @@ class FileFieldRSSContentTest extends FileFieldTestBase {
* Tests RSS enclosure formatter display for RSS feeds.
*/
public function testFileFieldRSSContent() {
$node_storage = $this->container->get('entity.manager')->getStorage('node');
$node_storage = $this->container->get('entity_type.manager')->getStorage('node');
$field_name = strtolower($this->randomMachineName());
$type_name = 'article';
......
......@@ -29,7 +29,7 @@ public function testRevisions() {
$this->config('file.settings')
->set('make_unused_managed_files_temporary', TRUE)
->save();
$node_storage = $this->container->get('entity.manager')->getStorage('node');
$node_storage = $this->container->get('entity_type.manager')->getStorage('node');
$type_name = 'article';
$field_name = strtolower($this->randomMachineName());
$this->createFileField($field_name, 'node', $type_name);
......
......@@ -126,7 +126,7 @@ public function uploadNodeFiles(array $files, $field_name, $nid_or_type, $new_re
'revision' => (string) (int) $new_revision,
];
$node_storage = $this->container->get('entity.manager')->getStorage('node');
$node_storage = $this->container->get('entity_type.manager')->getStorage('node');
if (is_numeric($nid_or_type)) {
$nid = $nid_or_type;
$node_storage->resetCache([$nid]);
......@@ -220,7 +220,7 @@ public static function assertFileExists($file, $message = NULL) {
* Asserts that a file exists in the database.
*/
public function assertFileEntryExists($file, $message = NULL) {
$this->container->get('entity.manager')->getStorage('file')->resetCache();
$this->container->get('entity_type.manager')->getStorage('file')->resetCache();
$db_file = File::load($file->id());
$message = isset($message) ? $message : format_string('File %file exists in database at the correct path.', ['%file' => $file->getFileUri()]);
$this->assertEqual($db_file->getFileUri(), $file->getFileUri(), $message);
......@@ -247,7 +247,7 @@ public static function assertFileNotExists($file, $message = NULL) {
* Asserts that a file does not exist in the database.
*/
public function assertFileEntryNotExists($file, $message) {
$this->container->get('entity.manager')->getStorage('file')->resetCache();
$this->container->get('entity_type.manager')->getStorage('file')->resetCache();
$message = isset($message) ? $message : format_string('File %file exists in database at the correct path.', ['%file' => $file->getFileUri()]);
$this->assertFalse(File::load($file->id()), $message);
}
......
......@@ -18,7 +18,7 @@ class FileFieldValidateTest extends FileFieldTestBase {
* Tests the required property on file fields.
*/
public function testRequired() {
$node_storage = $this->container->get('entity.manager')->getStorage('node');
$node_storage = $this->container->get('entity_type.manager')->getStorage('node');
$type_name = 'article';
$field_name = strtolower($this->randomMachineName());
$storage = $this->createFileField($field_name, 'node', $type_name, [], ['required' => '1']);
......@@ -66,7 +66,7 @@ public function testRequired() {
* Tests the max file size validator.
*/
public function testFileMaxSize() {
$node_storage = $this->container->get('entity.manager')->getStorage('node');
$node_storage = $this->container->get('entity_type.manager')->getStorage('node');
$type_name = 'article';
$field_name = strtolower($this->randomMachineName());
$this->createFileField($field_name, 'node', $type_name, [], ['required' => '1']);
......@@ -117,7 +117,7 @@ public function testFileMaxSize() {
* Tests file extension checking.
*/
public function testFileExtension() {
$node_storage = $this->container->get('entity.manager')->getStorage('node');
$node_storage = $this->container->get('entity_type.manager')->getStorage('node');
$type_name = 'article';
$field_name = strtolower($this->randomMachineName());
$this->createFileField($field_name, 'node', $type_name);
......@@ -160,7 +160,7 @@ public function testFileExtension() {
* Checks that a file can always be removed if it does not pass validation.
*/
public function testFileRemoval() {
$node_storage = $this->container->get('entity.manager')->getStorage('node');
$node_storage = $this->container->get('entity_type.manager')->getStorage('node');
$type_name = 'article';
$field_name = 'file_test';
$this->createFileField($field_name, 'node', $type_name);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment