function EntityManagerTest::testGetTranslationFromContext

Tests the getTranslationFromContext() method.

@covers ::getTranslationFromContext

@expectedDeprecation EntityManagerInterface::getTranslationFromContext() is deprecated in 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal\Core\Entity\EntityRepository::getTranslationFromContext() instead. See https://www.drupal.org/node/2549139.

File

core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php, line 275

Class

EntityManagerTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Entity%21EntityManager.php/class/EntityManager/8.9.x" title="Provides a wrapper around many other services relating to entities." class="local">\Drupal\Core\Entity\EntityManager</a> @group Entity @group legacy

Namespace

Drupal\Tests\Core\Entity

Code

public function testGetTranslationFromContext() {
    $entity = $this->prophesize(EntityInterface::class);
    $this->entityRepository
        ->getTranslationFromContext($entity->reveal(), 'de', [
        'example' => 'context',
    ])
        ->shouldBeCalled();
    $this->entityManager
        ->getTranslationFromContext($entity->reveal(), 'de', [
        'example' => 'context',
    ]);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.