ConfigActionsTest.php

Same filename in this branch
  1. 11.x core/modules/media/tests/src/Kernel/ConfigActionsTest.php
  2. 11.x core/modules/field/tests/src/Kernel/ConfigActionsTest.php
  3. 11.x core/modules/contact/tests/src/Kernel/ConfigActionsTest.php
  4. 11.x core/modules/node/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
  7. 11.x core/modules/layout_builder/tests/src/Kernel/ConfigActionsTest.php

Namespace

Drupal\Tests\language\Kernel

File

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

View source
<?php

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

use Drupal\Core\Config\Action\ConfigActionManager;
use Drupal\KernelTests\KernelTestBase;
use Drupal\language\Entity\ConfigurableLanguage;

/**
 * @group language
 */
class ConfigActionsTest extends KernelTestBase {
    
    /**
     * {@inheritdoc}
     */
    protected static $modules = [
        'language',
    ];
    private readonly ConfigActionManager $configActionManager;
    
    /**
     * {@inheritdoc}
     */
    protected function setUp() : void {
        parent::setUp();
        $this->installConfig('language');
        $this->configActionManager = $this->container
            ->get('plugin.manager.config_action');
    }
    public function testConfigActions() : void {
        $language = ConfigurableLanguage::load('en');
        $this->assertSame('English', $language->getName());
        $this->assertSame(0, $language->getWeight());
        $this->configActionManager
            ->applyAction('entity_method:language.entity:setName', $language->getConfigDependencyName(), 'Wacky language');
        $this->configActionManager
            ->applyAction('entity_method:language.entity:setWeight', $language->getConfigDependencyName(), 39);
        $language = ConfigurableLanguage::load('en');
        $this->assertSame('Wacky language', $language->getName());
        $this->assertSame(39, $language->getWeight());
    }

}

Classes

Title Deprecated Summary
ConfigActionsTest @group language

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