function DefaultRevisionStateTest::assertModerationState

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

Verifies the expected moderation state revision exists.

Parameters

int $revision_id: The revision ID of the host entity.

string $langcode: The language code of the host entity to check.

string $expected_state: The state the content moderation state revision should be in.

string $expected_workflow: The workflow the content moderation state revision should be using.

1 call to DefaultRevisionStateTest::assertModerationState()
DefaultRevisionStateTest::testMultilingual in core/modules/content_moderation/tests/src/Kernel/DefaultRevisionStateTest.php
Tests a translatable Node.

File

core/modules/content_moderation/tests/src/Kernel/DefaultRevisionStateTest.php, line 127

Class

DefaultRevisionStateTest
Tests the correct default revision is set.

Namespace

Drupal\Tests\content_moderation\Kernel

Code

protected function assertModerationState($revision_id, $langcode, $expected_state, $expected_workflow = 'editorial') {
    $moderation_state_storage = $this->entityTypeManager
        ->getStorage('content_moderation_state');
    $query = $moderation_state_storage->getQuery();
    $results = $query->allRevisions()
        ->condition('content_entity_revision_id', $revision_id)
        ->condition('langcode', $langcode)
        ->execute();
    $this->assertCount(1, $results);
    $moderation_state = $moderation_state_storage->loadRevision(key($results))
        ->getTranslation($langcode);
    $this->assertEquals($expected_state, $moderation_state->get('moderation_state')->value);
    $this->assertEquals($expected_workflow, $moderation_state->get('workflow')->target_id);
}

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