3 namespace Drupal\Tests\action\Kernel\Migrate\d7;
5 use Drupal\system\Entity\Action;
6 use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
9 * Tests migration of action items.
13 class MigrateActionsTest extends MigrateDrupal7TestBase {
15 public static $modules = ['action', 'comment', 'node'];
20 protected function setUp() {
22 $this->executeMigration('d7_action');
26 * Test Drupal 7 action migration to Drupal 8.
28 public function testActions() {
29 // Test default actions.
30 $this->assertEntity('node_publish_action', 'Publish content', 'node', []);
31 $this->assertEntity('node_make_sticky_action', 'Make content sticky', 'node', []);
32 $this->assertEntity('user_block_user_action', 'Block current user', 'user', []);
33 $this->assertEntity('comment_publish_action', 'Publish comment', 'comment', []);
35 // Test advanced actions.
36 $this->assertEntity('unpublish_comment_containing_keyword_s_', 'Unpublish comment containing keyword(s)', 'comment', ["keywords" => [0 => "drupal"]]);
37 $this->assertEntity('change_the_author_of_content', 'Change the author of content', 'node', ["owner_uid" => "2"]);
38 $this->assertEntity('unpublish_content_containing_keyword_s_', 'Unpublish content containing keyword(s)', 'node', ["keywords" => [0 => "drupal"]]);
39 $this->assertEntity('display_a_message_to_the_user', 'Display a message to the user', 'system', ["message" => "Drupal migration test"]);
40 $this->assertEntity('send_e_mail', 'Send e-mail', 'system', [
41 "recipient" => "test@example.com",
42 "subject" => "Drupal migration test",
43 "message" => "Drupal migration test",
45 $this->assertEntity('redirect_to_url', 'Redirect to URL', 'system', ["url" => "https://www.drupal.org"]);
50 * Asserts various aspects of an Action entity.
53 * The expected Action ID.
54 * @param string $label
55 * The expected Action label.
57 * The expected Action type.
58 * @param array $configuration
59 * The expected Action configuration.
61 protected function assertEntity($id, $label, $type, $configuration) {
62 $action = Action::load($id);
64 $this->assertTrue($action instanceof Action);
65 /** @var \Drupal\system\Entity\Action $action */
66 $this->assertIdentical($id, $action->id());
67 $this->assertIdentical($label, $action->label());
68 $this->assertIdentical($type, $action->getType());
69 $this->assertIdentical($configuration, $action->get('configuration'));