3 namespace Drupal\Tests\system\Functional\Update;
5 use Drupal\FunctionalTests\Update\UpdatePathTestBase;
6 use Drupal\system\Entity\Action;
9 * Tests upgrading comment and node actions to generic entity ones.
14 class UpdateActionsWithEntityPluginsTest extends UpdatePathTestBase {
19 protected function setDatabaseDumpFiles() {
20 $this->databaseDumpFiles = [__DIR__ . '/../../../../tests/fixtures/update/drupal-8.bare.standard.php.gz'];
24 * Tests upgrading comment and node actions to generic entity ones.
26 * @see system_post_update_change_action_plugins()
28 public function testUpdateActionsWithEntityPlugins() {
29 $old_new_action_id_map = [
30 'comment_publish_action' => ['comment_publish_action', 'entity:publish_action:comment'],
31 'comment_unpublish_action' => ['comment_unpublish_action', 'entity:unpublish_action:comment'],
32 'comment_save_action' => ['comment_save_action', 'entity:save_action:comment'],
33 'node_publish_action' => ['node_publish_action', 'entity:publish_action:node'],
34 'node_unpublish_action' => ['node_unpublish_action', 'entity:unpublish_action:node'],
35 'node_save_action' => ['node_save_action', 'entity:save_action:node'],
38 foreach ($old_new_action_id_map as $key => list($before, $after)) {
39 $config = \Drupal::configFactory()->get('system.action.' . $key);
40 $this->assertSame($before, $config->get('plugin'));
45 foreach ($old_new_action_id_map as $key => list($before, $after)) {
46 /** @var \Drupal\system\Entity\Action $action */
47 $action = Action::load($key);
48 $this->assertSame($after, $action->getPlugin()->getPluginId());
49 $config = \Drupal::configFactory()->get('system.action.' . $key);
50 $this->assertSame($after, $config->get('plugin'));
52 // Check that the type the action is based on will be a module dependency.
53 $this->assertArraySubset(['module' => [$action->getPluginDefinition()['type']]], $action->getDependencies());
58 * Tests upgrading comment and node delete actions to generic entity ones.
60 * @see system_post_update_change_delete_action_plugins()
62 public function testUpdateDeleteActionsWithEntityPlugins() {
63 // comment_delete_actions is not part of the dump files.
65 'node_delete_action' => ['node_delete_action', 'entity:delete_action:node'],
68 foreach ($array as $key => list($before, $after)) {
69 /** @var \Drupal\system\Entity\Action $action */
70 $action = Action::load($key);
71 $this->assertSame($before, $action->getPlugin()->getPluginId());
76 foreach ($array as $key => list($before, $after)) {
77 /** @var \Drupal\system\Entity\Action $action */
78 $action = Action::load($key);
79 $this->assertSame($after, $action->getPlugin()->getPluginId());
81 // Check that the type the action is based on will be a module dependency.
82 $this->assertArraySubset(['module' => [$action->getPluginDefinition()['type']]], $action->getDependencies());