function DefaultRevisionStateTest::assertModerationState
Same name in other branches
- 9 core/modules/content_moderation/tests/src/Kernel/DefaultRevisionStateTest.php \Drupal\Tests\content_moderation\Kernel\DefaultRevisionStateTest::assertModerationState()
- 8.9.x core/modules/content_moderation/tests/src/Kernel/DefaultRevisionStateTest.php \Drupal\Tests\content_moderation\Kernel\DefaultRevisionStateTest::assertModerationState()
- 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.
@internal
Parameters
string $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 132
Class
- DefaultRevisionStateTest
- Tests the correct default revision is set.
Namespace
Drupal\Tests\content_moderation\KernelCode
protected function assertModerationState(string $revision_id, string $langcode, string $expected_state, string $expected_workflow = 'editorial') : void {
$moderation_state_storage = $this->entityTypeManager
->getStorage('content_moderation_state');
$query = $moderation_state_storage->getQuery()
->accessCheck(FALSE);
$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.