public function FlagActionTest::testFlagActionsCreation in Flag 8.4
Tests that flag actions are added and removed properly.
File
- tests/
src/ Kernel/ FlagActionTest.php, line 62
Class
- FlagActionTest
- Test flag actions are added/removed when flags are added/deleted.
Namespace
Drupal\Tests\flag\KernelCode
public function testFlagActionsCreation() {
$selfies_flag = Flag::create([
'id' => 'selfies',
'label' => $this
->randomString(),
'entity_type' => 'user',
'flag_type' => 'entity:user',
'link_type' => 'reload',
'flagTypeConfig' => [],
'linkTypeConfig' => [],
]);
$selfies_flag
->save();
$flag_action = $this->entityTypeManager
->getStorage('action')
->load('flag_action.selfies_flag');
$this
->assertEquals('flag_action.selfies_flag', $flag_action
->id());
$unflag_action = $this->entityTypeManager
->getStorage('action')
->load('flag_action.selfies_unflag');
$this
->assertEquals('flag_action.selfies_unflag', $unflag_action
->id());
$selfies_flag
->delete();
$this->entityTypeManager
->getStorage('action')
->resetCache();
$this
->assertNull($this->entityTypeManager
->getStorage('action')
->load('flag_action.selfies_flag'));
$this
->assertNull($this->entityTypeManager
->getStorage('action')
->load('flag_action.selfies_unflag'));
}