function EntityMethodConfigActionsTest::testSetStatus

@testWith [true, "setStatus", false, false] [false, "setStatus", true, true] [true, "disable", [], false] [false, "enable", [], true]

File

core/tests/Drupal/KernelTests/Core/Recipe/EntityMethodConfigActionsTest.php, line 121

Class

EntityMethodConfigActionsTest
@group Recipe

Namespace

Drupal\KernelTests\Core\Recipe

Code

public function testSetStatus(bool $initial_status, string $action_name, array|bool $value, bool $expected_status) : void {
    $storage = $this->container
        ->get(EntityTypeManagerInterface::class)
        ->getStorage('config_test');
    $entity = $storage->create([
        'id' => 'foo',
        'label' => 'Behold!',
        'status' => $initial_status,
    ]);
    $this->assertSame($initial_status, $entity->status());
    $entity->save();
    $this->configActionManager
        ->applyAction("entity_method:config_test.dynamic:{$action_name}", $entity->getConfigDependencyName(), $value);
    $this->assertSame($expected_status, $storage->load('foo')
        ->status());
}

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