Commit b9f30c93 authored by larowlan's avatar larowlan

Issue #3052272 by mikelutz: Remove entityManager use in EntityKernelTestBase...

Issue #3052272 by mikelutz: Remove entityManager use in EntityKernelTestBase and all tests which extend it
parent 31a5cba3
......@@ -38,14 +38,14 @@ public function testValidation() {
$user->save();
// Add comment type.
$this->entityManager->getStorage('comment_type')->create([
$this->entityTypeManager->getStorage('comment_type')->create([
'id' => 'comment',
'label' => 'comment',
'target_entity_type_id' => 'node',
])->save();
// Add comment field to content.
$this->entityManager->getStorage('field_storage_config')->create([
$this->entityTypeManager->getStorage('field_storage_config')->create([
'entity_type' => 'node',
'field_name' => 'comment',
'type' => 'comment',
......@@ -55,14 +55,14 @@ public function testValidation() {
])->save();
// Create a page node type.
$this->entityManager->getStorage('node_type')->create([
$this->entityTypeManager->getStorage('node_type')->create([
'type' => 'page',
'name' => 'page',
])->save();
// Add comment field to page content.
/** @var \Drupal\field\FieldConfigInterface $field */
$field = $this->entityManager->getStorage('field_config')->create([
$field = $this->entityTypeManager->getStorage('field_config')->create([
'field_name' => 'comment',
'entity_type' => 'node',
'bundle' => 'page',
......@@ -70,13 +70,13 @@ public function testValidation() {
]);
$field->save();
$node = $this->entityManager->getStorage('node')->create([
$node = $this->entityTypeManager->getStorage('node')->create([
'type' => 'page',
'title' => 'test',
]);
$node->save();
$comment = $this->entityManager->getStorage('comment')->create([
$comment = $this->entityTypeManager->getStorage('comment')->create([
'entity_id' => $node->id(),
'entity_type' => 'node',
'field_name' => 'comment',
......@@ -141,7 +141,7 @@ public function testValidation() {
\Drupal::entityManager()->getStorage('node')->resetCache([$node->id()]);
$node = Node::load($node->id());
// Create a new comment with the new field.
$comment = $this->entityManager->getStorage('comment')->create([
$comment = $this->entityTypeManager->getStorage('comment')->create([
'entity_id' => $node->id(),
'entity_type' => 'node',
'field_name' => 'comment',
......@@ -155,7 +155,7 @@ public function testValidation() {
$this->assertEqual($violations[0]->getMessage(), t('You have to specify a valid author.'));
// Test creating a default comment with a given user id works.
$comment = $this->entityManager->getStorage('comment')->create([
$comment = $this->entityTypeManager->getStorage('comment')->create([
'entity_id' => $node->id(),
'entity_type' => 'node',
'field_name' => 'comment',
......@@ -166,7 +166,7 @@ public function testValidation() {
$this->assertEqual(count($violations), 0, 'No violations when validating a default comment with an author.');
// Test specifying a wrong author name does not work.
$comment = $this->entityManager->getStorage('comment')->create([
$comment = $this->entityTypeManager->getStorage('comment')->create([
'entity_id' => $node->id(),
'entity_type' => 'node',
'field_name' => 'comment',
......
......@@ -93,7 +93,7 @@ protected function setUp() {
$this->contentTranslationManager = $this->container->get('content_translation.manager');
$this->contentTranslationManager->setEnabled($entity_type_id, $entity_type_id, TRUE);
$this->storage = $this->entityManager->getStorage($entity_type_id);
$this->storage = $this->entityTypeManager->getStorage($entity_type_id);
foreach ($this->getTestFiles('image') as $file) {
$entity = File::create((array) $file + ['status' => 1]);
......
......@@ -239,7 +239,7 @@ public function testEntityFormatterRecursiveRendering() {
/** @var \Drupal\Core\Render\RendererInterface $renderer */
$renderer = $this->container->get('renderer');
$formatter = 'entity_reference_entity_view';
$view_builder = $this->entityManager->getViewBuilder($this->entityType);
$view_builder = $this->entityTypeManager->getViewBuilder($this->entityType);
// Set the default view mode to use the 'entity_reference_entity_view'
// formatter.
......@@ -301,7 +301,7 @@ public function testEntityFormatterRecursiveRendering() {
*/
public function testEntityReferenceRecursiveProtectionWithManyRenderedEntities() {
$formatter = 'entity_reference_entity_view';
$view_builder = $this->entityManager->getViewBuilder($this->entityType);
$view_builder = $this->entityTypeManager->getViewBuilder($this->entityType);
// Set the default view mode to use the 'entity_reference_entity_view'
// formatter.
......@@ -312,7 +312,7 @@ public function testEntityReferenceRecursiveProtectionWithManyRenderedEntities()
])
->save();
$storage = $this->entityManager->getStorage($this->entityType);
$storage = $this->entityTypeManager->getStorage($this->entityType);
/** @var \Drupal\Core\Entity\ContentEntityInterface $referenced_entity */
$referenced_entity = $storage->create(['name' => $this->randomMachineName()]);
......
......@@ -48,8 +48,8 @@ class NodeViewBuilderTest extends EntityKernelTestBase {
protected function setUp() {
parent::setUp();
$this->storage = $this->entityManager->getStorage('node');
$this->viewBuilder = $this->entityManager->getViewBuilder('node');
$this->storage = $this->entityTypeManager->getStorage('node');
$this->viewBuilder = $this->entityTypeManager->getViewBuilder('node');
$this->renderer = $this->container->get('renderer');
$type = NodeType::create([
......
......@@ -30,11 +30,11 @@ protected function setUp() {
* Tests the term validation constraints.
*/
public function testValidation() {
$this->entityManager->getStorage('taxonomy_vocabulary')->create([
$this->entityTypeManager->getStorage('taxonomy_vocabulary')->create([
'vid' => 'tags',
'name' => 'Tags',
])->save();
$term = $this->entityManager->getStorage('taxonomy_term')->create([
$term = $this->entityTypeManager->getStorage('taxonomy_term')->create([
'name' => 'test',
'vid' => 'tags',
]);
......
......@@ -47,8 +47,8 @@ protected function setUp() {
$this->installEntitySchema('entity_test_mul_changed');
$this->installEntitySchema('entity_test_mulrev_changed');
$this->mulChangedStorage = $this->entityManager->getStorage('entity_test_mul_changed');
$this->mulRevChangedStorage = $this->entityManager->getStorage('entity_test_mulrev_changed');
$this->mulChangedStorage = $this->entityTypeManager->getStorage('entity_test_mul_changed');
$this->mulRevChangedStorage = $this->entityTypeManager->getStorage('entity_test_mulrev_changed');
}
/**
......
......@@ -37,7 +37,7 @@ protected function setUp() {
$this->installEntitySchema('entity_test_field_methods');
$this->entityTestFieldMethodsStorage = $this->entityManager->getStorage('entity_test_field_methods');
$this->entityTestFieldMethodsStorage = $this->entityTypeManager->getStorage('entity_test_field_methods');
}
/**
......
......@@ -48,8 +48,8 @@ protected function setUp() {
$this->installEntitySchema('entity_test_mulrev');
$this->installEntitySchema('entity_test_rev');
$this->mulRev = $this->entityManager->getStorage('entity_test_mulrev');
$this->rev = $this->entityManager->getStorage('entity_test_rev');
$this->mulRev = $this->entityTypeManager->getStorage('entity_test_mulrev');
$this->rev = $this->entityTypeManager->getStorage('entity_test_rev');
}
/**
......@@ -184,7 +184,7 @@ public function testMultiColumnNonRevisionableBaseField() {
\Drupal::state()->set('entity_test.multi_column', TRUE);
$this->applyEntityUpdates('entity_test_mulrev');
// Refresh the storage.
$this->mulRev = $this->entityManager->getStorage('entity_test_mulrev');
$this->mulRev = $this->entityTypeManager->getStorage('entity_test_mulrev');
$user1 = $this->createUser();
// Create a test entity.
......
......@@ -49,7 +49,7 @@ public function testCustomBundleFieldUsage() {
// Check that an entity with bundle entity_test does not have the custom
// field.
$storage = $this->entityManager->getStorage('entity_test_update');
$storage = $this->entityTypeManager->getStorage('entity_test_update');
$entity = $storage->create([
'type' => 'entity_test_update',
]);
......
......@@ -45,7 +45,7 @@ protected function assertDefaultValues($entity_type_id) {
$entity = $this->container->get('entity_type.manager')
->getStorage($entity_type_id)
->create();
$definition = $this->entityManager->getDefinition($entity_type_id);
$definition = $this->entityTypeManager->getDefinition($entity_type_id);
$langcode_key = $definition->getKey('langcode');
$this->assertEqual($entity->{$langcode_key}->value, 'en', new FormattableMarkup('%entity_type: Default language', ['%entity_type' => $entity_type_id]));
$this->assertTrue(Uuid::isValid($entity->uuid->value), new FormattableMarkup('%entity_type: Default UUID', ['%entity_type' => $entity_type_id]));
......@@ -56,7 +56,7 @@ protected function assertDefaultValues($entity_type_id) {
* Tests custom default value callbacks.
*/
public function testDefaultValueCallback() {
$entity = $this->entityManager->getStorage('entity_test_default_value')->create();
$entity = $this->entityTypeManager->getStorage('entity_test_default_value')->create();
// The description field has a default value callback for testing, see
// entity_test_field_default_value().
$string = 'description_' . $entity->language()->getId();
......
......@@ -234,7 +234,7 @@ protected function doTestReadWrite($entity_type) {
}
// Access the language field.
$langcode_key = $this->entityManager->getDefinition($entity_type)->getKey('langcode');
$langcode_key = $this->entityTypeManager->getDefinition($entity_type)->getKey('langcode');
$this->assertEqual($langcode, $entity->{$langcode_key}->value, format_string('%entity_type: Language code can be read.', ['%entity_type' => $entity_type]));
$this->assertEqual(\Drupal::languageManager()->getLanguage($langcode), $entity->{$langcode_key}->language, format_string('%entity_type: Language object can be read.', ['%entity_type' => $entity_type]));
......@@ -376,7 +376,7 @@ public function testSave() {
* The entity type to run the tests with.
*/
protected function doTestSave($entity_type) {
$langcode_key = $this->entityManager->getDefinition($entity_type)->getKey('langcode');
$langcode_key = $this->entityTypeManager->getDefinition($entity_type)->getKey('langcode');
$entity = $this->createTestEntity($entity_type);
$entity->save();
$this->assertTrue((bool) $entity->id(), format_string('%entity_type: Entity has received an id.', ['%entity_type' => $entity_type]));
......@@ -431,7 +431,7 @@ protected function doTestIntrospection($entity_type) {
// Test deriving metadata from references.
$entity_definition = EntityDataDefinition::create($entity_type);
$langcode_key = $this->entityManager->getDefinition($entity_type)->getKey('langcode');
$langcode_key = $this->entityTypeManager->getDefinition($entity_type)->getKey('langcode');
$reference_definition = $entity_definition->getPropertyDefinition($langcode_key)
->getPropertyDefinition('language')
->getTargetDefinition();
......@@ -632,7 +632,7 @@ public function testDataTypes() {
* @see entity_test_entity_base_field_info_alter()
*/
public function testBaseFieldNonExistingBaseField() {
$this->entityManager->getStorage('node_type')->create([
$this->entityTypeManager->getStorage('node_type')->create([
'type' => 'page',
'name' => 'page',
])->save();
......
......@@ -2,6 +2,7 @@
namespace Drupal\KernelTests\Core\Entity;
use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait;
use Drupal\Core\Entity\EntityInterface;
use Drupal\KernelTests\KernelTestBase;
use Drupal\Tests\user\Traits\UserCreationTrait;
......@@ -10,7 +11,6 @@
* Defines an abstract test base for entity kernel tests.
*/
abstract class EntityKernelTestBase extends KernelTestBase {
use UserCreationTrait {
checkPermissions as drupalCheckPermissions;
createAdminRole as drupalCreateAdminRole;
......@@ -20,6 +20,7 @@ abstract class EntityKernelTestBase extends KernelTestBase {
setCurrentUser as drupalSetCurrentUser;
setUpCurrentUser as drupalSetUpCurrentUser;
}
use DeprecatedServicePropertyTrait;
/**
* Modules to enable.
......@@ -29,11 +30,11 @@ abstract class EntityKernelTestBase extends KernelTestBase {
public static $modules = ['user', 'system', 'field', 'text', 'filter', 'entity_test'];
/**
* The entity manager service.
* The list of deprecated services.
*
* @var \Drupal\Core\Entity\EntityManagerInterface
* @var array
*/
protected $entityManager;
protected $deprecatedProperties = ['entityManager' => 'entity.manager'];
/**
* The entity type manager service.
......@@ -59,7 +60,6 @@ abstract class EntityKernelTestBase extends KernelTestBase {
protected function setUp() {
parent::setUp();
$this->entityManager = $this->container->get('entity.manager');
$this->entityTypeManager = $this->container->get('entity_type.manager');
$this->state = $this->container->get('state');
......@@ -124,7 +124,7 @@ protected function createUser($values = [], $permissions = []) {
* The reloaded entity.
*/
protected function reloadEntity(EntityInterface $entity) {
$controller = $this->entityManager->getStorage($entity->getEntityTypeId());
$controller = $this->entityTypeManager->getStorage($entity->getEntityTypeId());
$controller->resetCache([$entity->id()]);
return $controller->load($entity->id());
}
......@@ -169,7 +169,7 @@ protected function uninstallModule($module) {
*/
protected function refreshServices() {
$this->container = \Drupal::getContainer();
$this->entityManager = $this->container->get('entity.manager');
$this->entityTypeManager = $this->container->get('entity_type.manager');
$this->state = $this->container->get('state');
}
......
......@@ -37,7 +37,7 @@ class EntityQueryAggregateTest extends EntityKernelTestBase {
protected function setUp() {
parent::setUp();
$this->entityStorage = $this->entityManager->getStorage('entity_test');
$this->entityStorage = $this->entityTypeManager->getStorage('entity_test');
// Add some fieldapi fields to be used in the test.
for ($i = 1; $i <= 2; $i++) {
......
......@@ -244,7 +244,7 @@ public function testReferencedEntitiesStringId() {
* Tests all the possible ways to autocreate an entity via the API.
*/
public function testAutocreateApi() {
$entity = $this->entityManager
$entity = $this->entityTypeManager
->getStorage($this->entityType)
->create(['name' => $this->randomString()]);
......@@ -317,7 +317,7 @@ public function testAutocreateApi() {
});
// Test target entity saving after setting it as new.
$storage = $this->entityManager->getStorage('user');
$storage = $this->entityTypeManager->getStorage('user');
$user_id = $this->generateRandomEntityId();
$user = $storage->create(['uid' => $user_id, 'name' => $this->randomString()]);
$entity->user_id = $user;
......@@ -338,7 +338,7 @@ public function testAutocreateApi() {
* TRUE if the user was autocreated, FALSE otherwise.
*/
protected function assertUserAutocreate(EntityInterface $entity, $setter_callback) {
$storage = $this->entityManager->getStorage('user');
$storage = $this->entityTypeManager->getStorage('user');
$user_id = $this->generateRandomEntityId();
$user = $storage->create(['uid' => $user_id, 'name' => $this->randomString()]);
$setter_callback($entity, $user);
......@@ -360,7 +360,7 @@ protected function assertUserAutocreate(EntityInterface $entity, $setter_callbac
* TRUE if the user was autocreated, FALSE otherwise.
*/
protected function assertUserRoleAutocreate(EntityInterface $entity, $setter_callback) {
$storage = $this->entityManager->getStorage('user_role');
$storage = $this->entityTypeManager->getStorage('user_role');
$role_id = $this->generateRandomEntityId(TRUE);
$role = $storage->create(['id' => $role_id, 'label' => $this->randomString()]);
$setter_callback($entity, $role);
......@@ -377,7 +377,7 @@ public function testTargetEntityNoLoad() {
// Setup a test entity type with an entity reference field to itself. We use
// a special storage class throwing exceptions when a load operation is
// triggered to be able to detect them.
$entity_type = clone $this->entityManager->getDefinition('entity_test_update');
$entity_type = clone $this->entityTypeManager->getDefinition('entity_test_update');
$entity_type->setHandlerClass('storage', '\Drupal\entity_test\EntityTestNoLoadStorage');
$this->state->set('entity_test_update.entity_type', $entity_type);
$definitions = [
......@@ -390,7 +390,7 @@ public function testTargetEntityNoLoad() {
$this->installEntitySchema($entity_type->id());
// Create the target entity.
$storage = $this->entityManager->getStorage($entity_type->id());
$storage = $this->entityTypeManager->getStorage($entity_type->id());
$target_id = $this->generateRandomEntityId();
$target = $storage->create(['id' => $target_id, 'name' => $this->randomString()]);
$target->save();
......@@ -400,7 +400,7 @@ public function testTargetEntityNoLoad() {
// trigger a load operation.
$message = 'The target entity was not loaded.';
try {
$entity = $this->entityManager
$entity = $this->entityTypeManager
->getStorage($entity_type->id())
->create(['name' => $this->randomString()]);
$entity->target_reference = $target_id;
......
......@@ -60,7 +60,7 @@ public function testNewRevisionAfterTranslation() {
*/
public function testRevertRevisionAfterTranslation() {
$user = $this->createUser();
$storage = $this->entityManager->getStorage('entity_test_mulrev');
$storage = $this->entityTypeManager->getStorage('entity_test_mulrev');
// Create a test entity.
$entity = EntityTestMulRev::create([
......@@ -95,7 +95,7 @@ public function testRevertRevisionAfterTranslation() {
*/
public function testTranslationValuesWhenSavingPendingRevisions() {
$user = $this->createUser();
$storage = $this->entityManager->getStorage('entity_test_mulrev');
$storage = $this->entityTypeManager->getStorage('entity_test_mulrev');
// Create a test entity and a translation for it.
$entity = EntityTestMulRev::create([
......@@ -197,7 +197,7 @@ public function testSetNewRevision() {
*/
public function testIsAnyStoredRevisionTranslated() {
/** @var \Drupal\Core\Entity\ContentEntityStorageInterface $storage */
$storage = $this->entityManager->getStorage('entity_test_mul');
$storage = $this->entityTypeManager->getStorage('entity_test_mul');
$method = new \ReflectionMethod(get_class($storage), 'isAnyStoredRevisionTranslated');
$method->setAccessible(TRUE);
......@@ -242,7 +242,7 @@ public function testIsAnyStoredRevisionTranslated() {
$this->assertTrue($method->invoke($storage, $entity));
/** @var \Drupal\Core\Entity\ContentEntityStorageInterface $storage */
$storage = $this->entityManager->getStorage('entity_test_mulrev');
$storage = $this->entityTypeManager->getStorage('entity_test_mulrev');
// Check that a revisionable new entity is handled correctly.
$entity = EntityTestMulRev::create();
......
......@@ -224,7 +224,7 @@ public function testIsLatestAffectedRevisionTranslation() {
// Check that no revision affecting Italian is available, given that no
// Italian translation has been created yet.
/** @var \Drupal\Core\Entity\ContentEntityStorageInterface $storage */
$storage = $this->entityManager->getStorage($entity->getEntityTypeId());
$storage = $this->entityTypeManager->getStorage($entity->getEntityTypeId());
$this->assertNull($storage->getLatestTranslationAffectedRevisionId($entity->id(), 'it'));
$this->assertEquals($pending_revision->getLoadedRevisionId(), $storage->getLatestRevisionId($entity->id()));
......
......@@ -215,7 +215,7 @@ public function testPrimaryKeyUpdate($entity_type_id, $field_name) {
// Now test updating a field with data.
/* @var \Drupal\Core\Entity\FieldableEntityStorageInterface $storage */
$storage = $this->entityManager->getStorage($entity_type_id);
$storage = $this->entityTypeManager->getStorage($entity_type_id);
// The schema of ID fields is incorrectly recreated as 'int' instead of
// 'serial', so we manually have to specify an ID.
// @todo Remove this in https://www.drupal.org/project/drupal/issues/2928906
......@@ -311,7 +311,7 @@ public function testModifyingTranslatableColumnSchema() {
$original_definition = $entity_field_manager->getBaseFieldDefinitions('entity_test_update')[$field_name];
$new_definition = clone $original_definition;
$new_definition->setLabel($original_definition->getLabel() . ', the other one');
$this->assertTrue($this->entityManager->getStorage('entity_test_update')
$this->assertTrue($this->entityTypeManager->getStorage('entity_test_update')
->requiresFieldDataMigration($new_definition, $original_definition));
}
}
......
......@@ -35,7 +35,7 @@ public function testEntityLanguageMethods() {
* The entity type to run the tests with.
*/
protected function doTestEntityLanguageMethods($entity_type) {
$langcode_key = $this->entityManager->getDefinition($entity_type)->getKey('langcode');
$langcode_key = $this->entityTypeManager->getDefinition($entity_type)->getKey('langcode');
$entity = $this->container->get('entity_type.manager')
->getStorage($entity_type)
->create([
......@@ -158,8 +158,8 @@ public function testMultilingualProperties() {
* The entity type to run the tests with.
*/
protected function doTestMultilingualProperties($entity_type) {
$langcode_key = $this->entityManager->getDefinition($entity_type)->getKey('langcode');
$default_langcode_key = $this->entityManager->getDefinition($entity_type)->getKey('default_langcode');
$langcode_key = $this->entityTypeManager->getDefinition($entity_type)->getKey('langcode');
$default_langcode_key = $this->entityTypeManager->getDefinition($entity_type)->getKey('default_langcode');
$name = $this->randomMachineName();
$uid = mt_rand(0, 127);
$langcode = $this->langcodes[0];
......@@ -326,11 +326,11 @@ public function testEntityTranslationAPI() {
protected function doTestEntityTranslationAPI($entity_type) {
$default_langcode = $this->langcodes[0];
$langcode = $this->langcodes[1];
$langcode_key = $this->entityManager->getDefinition($entity_type)->getKey('langcode');
$default_langcode_key = $this->entityManager->getDefinition($entity_type)->getKey('default_langcode');
$langcode_key = $this->entityTypeManager->getDefinition($entity_type)->getKey('langcode');
$default_langcode_key = $this->entityTypeManager->getDefinition($entity_type)->getKey('default_langcode');
/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
$entity = $this->entityManager
$entity = $this->entityTypeManager
->getStorage($entity_type)
->create(['name' => $this->randomMachineName(), $langcode_key => LanguageInterface::LANGCODE_NOT_SPECIFIED]);
......@@ -563,7 +563,7 @@ protected function doTestEntityTranslationAPI($entity_type) {
// 'entity_test_mul_default_value' entity type is translatable and uses
// entity_test_field_default_value() as a "default value callback" for its
// 'description' field.
$entity = $this->entityManager
$entity = $this->entityTypeManager
->getStorage('entity_test_mul_default_value')
->create(['name' => $this->randomMachineName(), 'langcode' => $langcode]);
$translation = $entity->addTranslation($langcode2);
......@@ -616,14 +616,14 @@ protected function doTestLanguageFallback($entity_type) {
$default_langcode = $this->langcodes[0];
$langcode = $this->langcodes[1];
$langcode2 = $this->langcodes[2];
$langcode_key = $this->entityManager->getDefinition($entity_type)->getKey('langcode');
$langcode_key = $this->entityTypeManager->getDefinition($entity_type)->getKey('langcode');
$languages = $this->languageManager->getLanguages();
$language = ConfigurableLanguage::load($languages[$langcode]->getId());
$language->set('weight', 1);
$language->save();
$this->languageManager->reset();
$controller = $this->entityManager->getStorage($entity_type);
$controller = $this->entityTypeManager->getStorage($entity_type);
$entity = $controller->create([$langcode_key => $default_langcode] + $values[$default_langcode]);
$entity->save();
......@@ -652,7 +652,7 @@ protected function doTestLanguageFallback($entity_type) {
// Check that if the entity has no translation no fallback is applied.
$entity2 = $controller->create([$langcode_key => $default_langcode]);
// Get an view builder.
$controller = $this->entityManager->getViewBuilder($entity_type);
$controller = $this->entityTypeManager->getViewBuilder($entity_type);
$entity2_build = $controller->view($entity2);
$entity2_output = (string) $renderer->renderRoot($entity2_build);
$translation = \Drupal::service('entity.repository')->getTranslationFromContext($entity2, $default_langcode);
......@@ -661,7 +661,7 @@ protected function doTestLanguageFallback($entity_type) {
$this->assertSame($entity2_output, $translation_output, 'When the entity has no translation no fallback is applied.');
// Checks that entity translations are rendered properly.
$controller = $this->entityManager->getViewBuilder($entity_type);
$controller = $this->entityTypeManager->getViewBuilder($entity_type);
$build = $controller->view($entity);
$renderer->renderRoot($build);
$this->assertEqual($build['label']['#markup'], $values[$current_langcode]['name'], 'By default the entity is rendered in the current language.');
......@@ -699,7 +699,7 @@ public function testFieldDefinitions() {
$this->assertTrue($definitions['name']->isTranslatable(), 'Field translatability can be enabled programmatically.');
// Check that field translatability is disabled by default.
$base_field_definitions = EntityTestMulRev::baseFieldDefinitions($this->entityManager->getDefinition($entity_type));
$base_field_definitions = EntityTestMulRev::baseFieldDefinitions($this->entityTypeManager->getDefinition($entity_type));
$this->assertTrue(!isset($base_field_definitions['id']->translatable), 'Translatability for the <em>id</em> field is not defined.');
$this->assertFalse($definitions['id']->isTranslatable(), 'Field translatability is disabled by default.');
......@@ -743,8 +743,8 @@ public function testLanguageChange() {
* The entity type to run the tests with.
*/
protected function doTestLanguageChange($entity_type) {
$langcode_key = $this->entityManager->getDefinition($entity_type)->getKey('langcode');
$controller = $this->entityManager->getStorage($entity_type);
$langcode_key = $this->entityTypeManager->getDefinition($entity_type)->getKey('langcode');
$controller = $this->entityTypeManager->getStorage($entity_type);
$langcode = $this->langcodes[0];
// check that field languages match entity language regardless of field
......@@ -795,7 +795,7 @@ public function testEntityAdapter() {
$entity_type = 'entity_test';
$default_langcode = 'en';
$values[$default_langcode] = ['name' => $this->randomString()];
$controller = $this->entityManager->getStorage($entity_type);
$controller = $this->entityTypeManager->getStorage($entity_type);
/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
$entity = $controller->create($values[$default_langcode]);
......@@ -817,7 +817,7 @@ public function testEntityAdapter() {
*/
public function testFieldEntityReference() {
$entity_type = 'entity_test_mul';
$controller = $this->entityManager->getStorage($entity_type);
$controller = $this->entityTypeManager->getStorage($entity_type);
/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
$entity = $controller->create();
......@@ -847,7 +847,7 @@ public function testFieldEntityReference() {
*/
public function testDeleteEntityTranslation() {
$entity_type = 'entity_test_mul';
$controller = $this->entityManager->getStorage($entity_type);
$controller = $this->entityTypeManager->getStorage($entity_type);
// Create a translatable test field.
$field_storage = FieldStorageConfig::create([
......@@ -939,7 +939,7 @@ public function testDeleteEntityTranslation() {
*/
public function testTranslationStatus() {
$entity_type = 'entity_test_mul';
$storage = $this->entityManager->getStorage($entity_type);
$storage = $this->entityTypeManager->getStorage($entity_type);
// Create an entity with both translatable and untranslatable test fields.
$values = [
......
......@@ -144,7 +144,7 @@ protected function checkValidation($entity_type) {
$this->assertEqual($violations[0]->getMessage(), t('%name: may not be longer than @max characters.', ['%name' => 'UUID', '@max' => 128]));
$test_entity = clone $entity;
$langcode_key = $this->entityManager->getDefinition($entity_type)->getKey('langcode');
$langcode_key = $this->entityTypeManager->getDefinition($entity_type)->getKey('langcode');
$test_entity->{$langcode_key}->value = $this->randomString(13);
$violations = $test_entity->validate();
// This should fail on AllowedValues and Length constraints.
......
......@@ -19,7 +19,7 @@ class FieldTranslationSqlStorageTest extends EntityLanguageTestBase {
public function testFieldSqlStorage() {
$entity_type = 'entity_test_mul';
$controller = $this->entityManager->getStorage($entity_type);
$controller = $this->entityTypeManager->getStorage($entity_type);
$values = [
$this->fieldName => $this->randomMachineName(),
$this->untranslatableFieldName => $this->randomMachineName(),
......
......@@ -143,7 +143,7 @@ public function testWasDefaultRevision() {
$this->assertFalse($entity->wasDefaultRevision());
// Check that the default revision status was stored correctly.
$storage = $this->entityManager->getStorage($entity_type_id);
$storage = $this->entityTypeManager->getStorage($entity_type_id);
foreach ([TRUE, FALSE, TRUE, FALSE] as $index => $expected) {
/** @var \Drupal\entity_test_revlog\Entity\EntityTestMulWithRevisionLog $revision */
$revision = $storage->loadRevision($index + 1);
......
......@@ -101,7 +101,7 @@ public function testOnFieldStorageDefinitionUpdateShared() {
$this->assertSame($expected, $actual);
// Now add an entity and repeat the process.
$entity_storage = $this->entityManager->getStorage('entity_test');
$entity_storage = $this->entityTypeManager->getStorage('entity_test');
$entity_storage->create([
'shape' => [
'shape' => 'rectangle',
......
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