ConfigActionsTest.php

Same filename in this branch
  1. 11.x core/modules/media/tests/src/Kernel/ConfigActionsTest.php
  2. 11.x core/modules/language/tests/src/Kernel/ConfigActionsTest.php
  3. 11.x core/modules/field/tests/src/Kernel/ConfigActionsTest.php
  4. 11.x core/modules/contact/tests/src/Kernel/ConfigActionsTest.php
  5. 11.x core/modules/image/tests/src/Kernel/ConfigActionsTest.php
  6. 11.x core/modules/block/tests/src/Kernel/ConfigActionsTest.php

Namespace

Drupal\Tests\node\Kernel

File

core/modules/node/tests/src/Kernel/ConfigActionsTest.php

View source
<?php

declare (strict_types=1);
namespace Drupal\Tests\node\Kernel;

use Drupal\Core\Config\Action\ConfigActionManager;
use Drupal\KernelTests\KernelTestBase;
use Drupal\node\Entity\NodeType;
use Drupal\Tests\node\Traits\ContentTypeCreationTrait;

/**
 * @group node
 */
class ConfigActionsTest extends KernelTestBase {
    use ContentTypeCreationTrait;
    
    /**
     * {@inheritdoc}
     */
    protected static $modules = [
        'field',
        'node',
        'system',
        'text',
        'user',
    ];
    private readonly ConfigActionManager $configActionManager;
    
    /**
     * {@inheritdoc}
     */
    protected function setUp() : void {
        parent::setUp();
        $this->installConfig('node');
        $this->configActionManager = $this->container
            ->get('plugin.manager.config_action');
    }
    public function testConfigActions() : void {
        $node_type = $this->createContentType();
        $this->assertTrue($node_type->shouldCreateNewRevision());
        $this->assertSame(DRUPAL_OPTIONAL, $node_type->getPreviewMode());
        $this->assertTrue($node_type->displaySubmitted());
        $this->configActionManager
            ->applyAction('entity_method:node.type:setNewRevision', $node_type->getConfigDependencyName(), FALSE);
        $this->configActionManager
            ->applyAction('entity_method:node.type:setPreviewMode', $node_type->getConfigDependencyName(), DRUPAL_REQUIRED);
        $this->configActionManager
            ->applyAction('entity_method:node.type:setDisplaySubmitted', $node_type->getConfigDependencyName(), FALSE);
        $node_type = NodeType::load($node_type->id());
        $this->assertFalse($node_type->shouldCreateNewRevision());
        $this->assertSame(DRUPAL_REQUIRED, $node_type->getPreviewMode());
        $this->assertFalse($node_type->displaySubmitted());
    }

}

Classes

Title Deprecated Summary
ConfigActionsTest @group node

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