View source  
  <?php
namespace Drupal\Tests\action\Kernel\Migrate\d6;
use Drupal\system\Entity\Action;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
class MigrateActionsTest extends MigrateDrupal6TestBase {
  protected static $modules = [
    'action',
    'comment',
    'node',
  ];
  
  protected function setUp() : void {
    parent::setUp();
    $this
      ->executeMigration('d6_action');
  }
  
  public function testActions() {
    
    $this
      ->assertEntity('node_publish_action', 'Publish post', 'node', []);
    $this
      ->assertEntity('node_make_sticky_action', 'Make post sticky', 'node', []);
    $this
      ->assertEntity('user_block_user_action', 'Block current user', 'user', []);
    $this
      ->assertEntity('comment_publish_action', 'Publish comment', 'comment', []);
    
    $this
      ->assertEntity('unpublish_comment_containing_keyword_s_', 'Unpublish comment containing keyword(s)', 'comment', [
      "keywords" => [
        0 => "drupal",
      ],
    ]);
    $this
      ->assertEntity('change_the_author_of_a_post', 'Change the author of a post', 'node', [
      "owner_uid" => "2",
    ]);
    $this
      ->assertEntity('unpublish_post_containing_keyword_s_', 'Unpublish post containing keyword(s)', 'node', [
      "keywords" => [
        0 => "drupal",
      ],
    ]);
    $this
      ->assertEntity('display_a_message_to_the_user', 'Display a message to the user', 'system', [
      "message" => "Drupal migration test",
    ]);
    $this
      ->assertEntity('send_e_mail', 'Send e-mail', 'system', [
      "recipient" => "test@example.com",
      "subject" => "Drupal migration test",
      "message" => "Drupal migration test",
    ]);
    $this
      ->assertEntity('redirect_to_url', 'Redirect to URL', 'system', [
      "url" => "https://www.drupal.org",
    ]);
  }
  
  protected function assertEntity($id, $label, $type, $configuration) {
    $action = Action::load($id);
    $this
      ->assertInstanceOf(Action::class, $action);
    
    $this
      ->assertSame($id, $action
      ->id());
    $this
      ->assertSame($label, $action
      ->label());
    $this
      ->assertSame($type, $action
      ->getType());
    $this
      ->assertSame($configuration, $action
      ->get('configuration'));
  }
}