function ModerationInformationTest::testGetDefaultRevisionId

Same name in other branches
  1. 8.9.x core/modules/content_moderation/tests/src/Kernel/ModerationInformationTest.php \Drupal\Tests\content_moderation\Kernel\ModerationInformationTest::testGetDefaultRevisionId()
  2. 10 core/modules/content_moderation/tests/src/Kernel/ModerationInformationTest.php \Drupal\Tests\content_moderation\Kernel\ModerationInformationTest::testGetDefaultRevisionId()
  3. 11.x core/modules/content_moderation/tests/src/Kernel/ModerationInformationTest.php \Drupal\Tests\content_moderation\Kernel\ModerationInformationTest::testGetDefaultRevisionId()

@covers ::getDefaultRevisionId

File

core/modules/content_moderation/tests/src/Kernel/ModerationInformationTest.php, line 64

Class

ModerationInformationTest
@coversDefaultClass \Drupal\content_moderation\ModerationInformation @group content_moderation

Namespace

Drupal\Tests\content_moderation\Kernel

Code

public function testGetDefaultRevisionId() {
    $entity_test_rev = EntityTestRev::create([
        'name' => 'Default Revision',
        'moderation_state' => 'published',
    ]);
    $entity_test_rev->save();
    $entity_test_rev->name = 'Pending revision';
    $entity_test_rev->moderation_state = 'draft';
    $entity_test_rev->save();
    // Check that moderation information service returns the correct default
    // revision ID.
    $default_revision_id = $this->moderationInformation
        ->getDefaultRevisionId('entity_test_rev', $entity_test_rev->id());
    $this->assertSame(1, $default_revision_id);
}

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