function RevisionVersionHistoryTest::testDescriptionRevLog

Same name in other branches
  1. 10 core/tests/Drupal/FunctionalTests/Entity/RevisionVersionHistoryTest.php \Drupal\FunctionalTests\Entity\RevisionVersionHistoryTest::testDescriptionRevLog()

Test description with entity implementing revision log.

@covers ::getRevisionDescription

File

core/tests/Drupal/FunctionalTests/Entity/RevisionVersionHistoryTest.php, line 100

Class

RevisionVersionHistoryTest
Tests version history page.

Namespace

Drupal\FunctionalTests\Entity

Code

public function testDescriptionRevLog() : void {
    
    /** @var \Drupal\entity_test_revlog\Entity\EntityTestWithRevisionLog $entity */
    $entity = EntityTestWithRevisionLog::create([
        'type' => 'entity_test_revlog',
    ]);
    $entity->setName('view all revisions');
    $user = $this->drupalCreateUser([], $this->randomMachineName());
    $entity->setRevisionUser($user);
    $entity->setRevisionCreationTime((new \DateTime('2 February 2013 4:00:00pm'))->getTimestamp());
    $entity->save();
    $this->drupalGet($entity->toUrl('version-history'));
    $this->assertSession()
        ->elementTextContains('css', 'table tbody tr:nth-child(1)', '2 Feb 2013 - 16:00');
    $this->assertSession()
        ->elementTextContains('css', 'table tbody tr:nth-child(1)', $user->getAccountName());
}

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