function RevisionDeleteFormTest::doTestPageTitle

Tests title by whether entity supports revision creation dates.

@covers ::getQuestion

Parameters

string $entityTypeId: The entity type to test.

string $expectedQuestion: The expected question/page title.

1 call to RevisionDeleteFormTest::doTestPageTitle()
RevisionDeleteFormTest::testPageTitle in core/tests/Drupal/FunctionalTests/Entity/RevisionDeleteFormTest.php
Tests title by whether entity supports revision creation dates.

File

core/tests/Drupal/FunctionalTests/Entity/RevisionDeleteFormTest.php, line 65

Class

RevisionDeleteFormTest
Tests deleting a revision with revision delete form.

Namespace

Drupal\FunctionalTests\Entity

Code

protected function doTestPageTitle(string $entityTypeId, string $expectedQuestion) : void {
    
    /** @var \Drupal\Core\Entity\RevisionableStorageInterface $storage */
    $storage = \Drupal::entityTypeManager()->getStorage($entityTypeId);
    $entity = $storage->create([
        'type' => $entityTypeId,
        'name' => 'delete revision',
    ]);
    if ($entity instanceof RevisionLogInterface) {
        $date = new \DateTime('11 January 2009 4:00:00pm');
        $entity->setRevisionCreationTime($date->getTimestamp());
    }
    $entity->setNewRevision();
    $entity->save();
    $revisionId = $entity->getRevisionId();
    // Create a new latest revision.
    if ($entity instanceof RevisionLogInterface) {
        $entity->setRevisionCreationTime($date->modify('+1 hour')
            ->getTimestamp());
    }
    $entity->setNewRevision();
    $entity->save();
    // Reload the entity.
    $revision = $storage->loadRevision($revisionId);
    $this->drupalGet($revision->toUrl('revision-delete-form'));
    $this->assertSession()
        ->pageTextContains($expectedQuestion);
    $this->assertSession()
        ->buttonExists('Delete');
    $this->assertSession()
        ->linkExists('Cancel');
}

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