function ModerationInformationTest::testIsDefaultRevisionPublishedMultilingual

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

@covers ::isDefaultRevisionPublished

File

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

Class

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

Namespace

Drupal\Tests\content_moderation\Kernel

Code

public function testIsDefaultRevisionPublishedMultilingual() {
    $entity = EntityTestMulRevPub::create([
        'moderation_state' => 'draft',
    ]);
    $entity->save();
    $this->assertEquals('draft', $entity->moderation_state->value);
    $translated = $entity->addTranslation('de');
    $translated->moderation_state = 'published';
    $translated->save();
    $this->assertEquals('published', $translated->moderation_state->value);
    // Test a scenario where the default revision exists with the default
    // language in a draft state and a non-default language in a published
    // state. The method returns TRUE if any of the languages for the default
    // revision are in a published state.
    $this->assertTrue($this->moderationInformation
        ->isDefaultRevisionPublished($entity));
}

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