grantUserPermissionToCreateContentOfType example

/** * A node type without moderation state disabled. * * @covers \Drupal\content_moderation\EntityTypeInfo::formAlter * @covers \Drupal\content_moderation\Entity\Handler\NodeModerationHandler::enforceRevisionsBundleFormAlter */
  public function testNotModerated() {
    $this->drupalLogin($this->adminUser);
    $this->createContentTypeFromUi('Not moderated', 'not_moderated');
    $this->assertSession()->pageTextContains('The content type Not moderated has been added.');
    $this->grantUserPermissionToCreateContentOfType($this->adminUser, 'not_moderated');
    $this->drupalGet('node/add/not_moderated');
    $this->assertSession()->pageTextContains('Save');
    $this->submitForm([
      'title[0][value]' => 'Test',
    ], 'Save');
    $this->assertSession()->pageTextContains('Not moderated Test has been created.');
  }

  /** * Tests enabling moderation on an existing node-type, with content. * * @covers \Drupal\content_moderation\EntityTypeInfo::formAlter * @covers \Drupal\content_moderation\Entity\Handler\NodeModerationHandler::enforceRevisionsBundleFormAlter */
'use editorial transition publish',
    'bypass node access',
  ];

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();
    $this->drupalLogin($this->adminUser);
    $this->createContentTypeFromUi('Moderated content', 'moderated_content', FALSE);
    $this->grantUserPermissionToCreateContentOfType($this->adminUser, 'moderated_content');

    // Add the private field to the node type.     node_access_test_add_field(NodeType::load('moderated_content'));

    // Rebuild permissions because hook_node_grants() is implemented by the     // node_access_test_empty module.     node_access_rebuild();
  }

  /** * Verifies that a non-admin user can still access the appropriate pages. */

  protected $defaultTheme = 'stark';

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();
    $this->drupalLogin($this->adminUser);
    $this->createContentTypeFromUi('Moderated content', 'moderated_content', TRUE);
    $this->grantUserPermissionToCreateContentOfType($this->adminUser, 'moderated_content');
  }

  /** * Tests creating and deleting content. */
  public function testCreatingContent() {
    $this->drupalGet('node/add/moderated_content');
    $this->submitForm([
      'title[0][value]' => 'moderated content',
      'moderation_state[0][state]' => 'draft',
    ], 'Save');
    

  protected $defaultTheme = 'stark';

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();
    $this->drupalLogin($this->adminUser);
    $this->createContentTypeFromUi('Moderated content', 'moderated_content', TRUE);
    $this->grantUserPermissionToCreateContentOfType($this->adminUser, 'moderated_content');
  }

  /** * Tests a workflow with a default moderation state set. */
  public function testPublishedDefaultState() {
    // Set the default moderation state to be "published".     $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');
    

  protected $defaultTheme = 'stark';

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();
    $this->drupalLogin($this->adminUser);
    $this->createContentTypeFromUi('Moderated content', 'moderated_content', TRUE);
    $this->grantUserPermissionToCreateContentOfType($this->adminUser, 'moderated_content');
  }

  /** * Tests the moderation form that shows on the latest version page. * * The latest version page only shows if there is a pending revision. * * @see \Drupal\content_moderation\EntityOperations * @see \Drupal\Tests\content_moderation\Functional\ModerationStateBlockTest::testCustomBlockModeration */
  public function testModerationForm() {
    
Home | Imprint | This part of the site doesn't use cookies.