function EntityRevisionsTest::testEntityRevisionParamConverter
Same name in other branches
- 9 core/modules/system/tests/src/Functional/Entity/EntityRevisionsTest.php \Drupal\Tests\system\Functional\Entity\EntityRevisionsTest::testEntityRevisionParamConverter()
- 8.9.x core/modules/system/tests/src/Functional/Entity/EntityRevisionsTest.php \Drupal\Tests\system\Functional\Entity\EntityRevisionsTest::testEntityRevisionParamConverter()
- 10 core/modules/system/tests/src/Functional/Entity/EntityRevisionsTest.php \Drupal\Tests\system\Functional\Entity\EntityRevisionsTest::testEntityRevisionParamConverter()
Tests that an entity revision is upcasted in the correct language.
File
-
core/
modules/ system/ tests/ src/ Functional/ Entity/ EntityRevisionsTest.php, line 189
Class
- EntityRevisionsTest
- Tests modifying an entity with revisions.
Namespace
Drupal\Tests\system\Functional\EntityCode
public function testEntityRevisionParamConverter() : void {
// Create a test entity with multiple revisions and translations for them.
$entity = EntityTestMulRev::create([
'name' => 'default revision - en',
'user_id' => $this->webUser,
'language' => 'en',
]);
$entity->addTranslation('de', [
'name' => 'default revision - de',
]);
$entity->save();
$pending_revision = \Drupal::entityTypeManager()->getStorage('entity_test_mulrev')
->loadUnchanged($entity->id());
$pending_revision->setNewRevision();
$pending_revision->isDefaultRevision(FALSE);
$pending_revision->name = 'pending revision - en';
$pending_revision->save();
$pending_revision_translation = $pending_revision->getTranslation('de');
$pending_revision_translation->name = 'pending revision - de';
$pending_revision_translation->save();
// Check that the entity revision is upcasted in the correct language.
$revision_url = 'entity_test_mulrev/' . $entity->id() . '/revision/' . $pending_revision->getRevisionId() . '/view';
$this->drupalGet($revision_url);
$this->assertSession()
->pageTextContains('pending revision - en');
$this->assertSession()
->pageTextNotContains('pending revision - de');
$this->drupalGet('de/' . $revision_url);
$this->assertSession()
->pageTextContains('pending revision - de');
$this->assertSession()
->pageTextNotContains('pending revision - en');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.