public function EntityCloneActionTest::testActionEntityClone in Entity Clone 8
Test action entity clone.
File
- tests/
src/ Functional/ EntityCloneActionTest.php, line 58
Class
- EntityCloneActionTest
- Create an action and test a clone.
Namespace
Drupal\Tests\entity_clone\FunctionalCode
public function testActionEntityClone() {
foreach (\Drupal::service('plugin.manager.action')
->getDefinitions() as $id => $definition) {
if (is_subclass_of($definition['class'], '\\Drupal\\Core\\Plugin\\PluginFormInterface') && $definition['label'] == 'Send email') {
$action_key = $id;
break;
}
}
$edit = [
'label' => 'Test send email action for clone',
'id' => 'test_send_email_for_clone',
'recipient' => 'test@recipient.com',
'subject' => 'test subject',
'message' => 'test message',
];
$this
->drupalPostForm("admin/config/system/actions/add/{$action_key}", $edit, t('Save'));
$actions = \Drupal::entityTypeManager()
->getStorage('action')
->loadByProperties([
'id' => $edit['id'],
]);
$action = reset($actions);
$edit = [
'label' => 'Test send email action cloned',
'id' => 'test_send_email_cloned',
];
$this
->drupalPostForm('entity_clone/action/' . $action
->id(), $edit, t('Clone'));
$actions = \Drupal::entityTypeManager()
->getStorage('action')
->loadByProperties([
'id' => $edit['id'],
]);
$action = reset($actions);
$this
->assertInstanceOf(Action::class, $action, 'Test action cloned found in database.');
}