function EntityMethodConfigActionsTest::testSetStatus

Tests set status.

Attributes

#[TestWith([ TRUE, "setStatus", FALSE, FALSE, ])] #[TestWith([ FALSE, "setStatus", TRUE, TRUE, ])] #[TestWith([ TRUE, "disable", [], FALSE, ])] #[TestWith([ FALSE, "enable", [], TRUE, ])]

File

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

Class

EntityMethodConfigActionsTest
Tests entity method config actions.

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.