Same name in other branches
- 8.x-1.x tests/src/Functional/EntityCloneActionTest.php \Drupal\Tests\entity_clone\Functional\EntityCloneActionTest
Create an action and test a clone.
@group entity_clone
Hierarchy
- class \Drupal\Tests\entity_clone\Functional\EntityCloneActionTest extends \Drupal\Tests\BrowserTestBase uses \Drupal\Core\StringTranslation\StringTranslationTrait
Expanded class hierarchy of EntityCloneActionTest
Fichier
-
tests/
src/ Functional/ EntityCloneActionTest.php, line 14
Namespace
Drupal\Tests\entity_clone\FunctionalView source
class EntityCloneActionTest extends BrowserTestBase {
use StringTranslationTrait;
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'entity_clone',
'action',
];
/**
* Theme to enable by default.
*
* @var string
*/
protected $defaultTheme = 'claro';
/**
* Permissions to grant admin user.
*
* @var array
*/
protected $permissions = [
'administer actions',
'clone action entity',
];
/**
* An administrative user with permission to configure actions settings.
*
* @var \Drupal\user\UserInterface
*/
protected $adminUser;
/**
* Sets the test up.
*/
protected function setUp() : void {
parent::setUp();
$this->adminUser = $this->drupalCreateUser($this->permissions);
$this->drupalLogin($this->adminUser);
}
/**
* Test action entity clone.
*/
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->drupalGet("admin/config/system/actions/add/{$action_key}");
$this->submitForm($edit, $this->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->drupalGet('entity_clone/action/' . $action->id());
$this->submitForm($edit, $this->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.');
}
}
Members
Titre Trier par ordre décroissant | Modifiers | Object type | Résumé |
---|---|---|---|
EntityCloneActionTest::$adminUser | protected | property | An administrative user with permission to configure actions settings. |
EntityCloneActionTest::$defaultTheme | protected | property | Theme to enable by default. |
EntityCloneActionTest::$modules | protected static | property | Modules to enable. |
EntityCloneActionTest::$permissions | protected | property | Permissions to grant admin user. |
EntityCloneActionTest::setUp | protected | function | Sets the test up. |
EntityCloneActionTest::testActionEntityClone | public | function | Test action entity clone. |