DefaultModerationStateTest.php in Drupal 10
File
core/modules/content_moderation/tests/src/Functional/DefaultModerationStateTest.php
View source
<?php
namespace Drupal\Tests\content_moderation\Functional;
class DefaultModerationStateTest extends ModerationStateTestBase {
protected $defaultTheme = 'stark';
protected function setUp() : void {
parent::setUp();
$this
->drupalLogin($this->adminUser);
$this
->createContentTypeFromUi('Moderated content', 'moderated_content', TRUE);
$this
->grantUserPermissionToCreateContentOfType($this->adminUser, 'moderated_content');
}
public function testPublishedDefaultState() {
$this
->drupalGet('admin/config/workflow/workflows/manage/' . $this->workflow
->id());
$this
->submitForm([
'type_settings[workflow_settings][default_moderation_state]' => 'published',
], 'Save');
$this
->drupalGet('node/add/moderated_content');
$this
->assertEquals('published', $this
->assertSession()
->selectExists('moderation_state[0][state]')
->getValue());
$this
->submitForm([
'title[0][value]' => 'moderated content',
], 'Save');
$node = $this
->getNodeByTitle('moderated content');
$this
->assertEquals('published', $node->moderation_state->value);
}
public function testDeleteDefaultStateAccess() {
$this
->drupalGet('admin/config/workflow/workflows/manage/editorial/state/archived/delete');
$this
->assertSession()
->statusCodeEquals(200);
$this
->drupalGet('admin/config/workflow/workflows/manage/' . $this->workflow
->id());
$this
->submitForm([
'type_settings[workflow_settings][default_moderation_state]' => 'archived',
], 'Save');
$this
->drupalGet('admin/config/workflow/workflows/manage/editorial/state/archived/delete');
$this
->assertSession()
->statusCodeEquals(403);
}
}