class RevisionVersionHistoryTranslatableTest
Same name and namespace in other branches
- 11.x core/tests/Drupal/FunctionalTests/Entity/RevisionVersionHistoryTranslatableTest.php \Drupal\FunctionalTests\Entity\RevisionVersionHistoryTranslatableTest
- 10 core/tests/Drupal/FunctionalTests/Entity/RevisionVersionHistoryTranslatableTest.php \Drupal\FunctionalTests\Entity\RevisionVersionHistoryTranslatableTest
Tests version history page with translations.
Attributes
#[CoversClass(VersionHistoryController::class)]
#[Group('Entity')]
#[RunTestsInSeparateProcesses]
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Tests\DrupalTestCaseTrait, \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\PhpUnitCompatibilityTrait, \Drupal\TestTools\Extension\DeprecationBridge\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\FunctionalTests\Entity\RevisionVersionHistoryTranslatableTest extends \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of RevisionVersionHistoryTranslatableTest
File
-
core/
tests/ Drupal/ FunctionalTests/ Entity/ RevisionVersionHistoryTranslatableTest.php, line 18
Namespace
Drupal\FunctionalTests\EntityView source
final class RevisionVersionHistoryTranslatableTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'entity_test_revlog',
'content_translation',
'language',
'user',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
ConfigurableLanguage::createFromLangcode('es')->save();
// Rebuild the container so that the new languages are picked up by services
// that hold a list of languages.
$this->rebuildContainer();
}
/**
* Tests the version history page for translations.
*/
public function testVersionHistoryTranslations() : void {
$label = 'view all revisions,revert,delete revision';
$entity = EntityTestMulWithRevisionLog::create([
'name' => $label,
'type' => 'entity_test_mul_revlog',
]);
$entity->addTranslation('es', [
'label' => 'version history test translations es',
]);
$entity->save();
$firstRevisionId = $entity->getRevisionId();
$entity->setNewRevision();
$entity->setName($label . ',2')
->save();
$this->drupalGet($entity->toUrl('version-history'));
$this->assertSession()
->statusCodeEquals(200);
$this->assertSession()
->elementsCount('css', 'table tbody tr', 2);
/** @var \Drupal\Core\Entity\RevisionableStorageInterface $storage */
$storage = $this->container
->get('entity_type.manager')
->getStorage($entity->getEntityTypeId());
$firstRevision = $storage->loadRevision($firstRevisionId);
$this->assertSession()
->linkByHrefExists($firstRevision->toUrl('revision-revert-form')
->toString());
$this->assertSession()
->linkByHrefExists($firstRevision->toUrl('revision-delete-form')
->toString());
$this->assertSession()
->linkByHrefNotExists($firstRevision->getTranslation('es')
->toUrl('revision-revert-form')
->toString());
$this->assertSession()
->linkByHrefNotExists($firstRevision->getTranslation('es')
->toUrl('revision-delete-form')
->toString());
$this->drupalGet($entity->getTranslation('es')
->toUrl('version-history'));
$this->assertSession()
->linkByHrefNotExistsExact($firstRevision->toUrl('revision-revert-form')
->toString());
$this->assertSession()
->linkByHrefNotExistsExact($firstRevision->toUrl('revision-delete-form')
->toString());
$this->assertSession()
->linkByHrefExists($firstRevision->getTranslation('es')
->toUrl('revision-revert-form')
->toString());
$this->assertSession()
->linkByHrefExists($firstRevision->getTranslation('es')
->toUrl('revision-delete-form')
->toString());
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.