Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / action / tests / src / Kernel / Migrate / d7 / MigrateActionsTest.php
1 <?php
2
3 namespace Drupal\Tests\action\Kernel\Migrate\d7;
4
5 use Drupal\system\Entity\Action;
6 use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
7
8 /**
9  * Tests migration of action items.
10  *
11  * @group action
12  */
13 class MigrateActionsTest extends MigrateDrupal7TestBase {
14
15   public static $modules = ['action', 'comment', 'node'];
16
17   /**
18    * {@inheritdoc}
19    */
20   protected function setUp() {
21     parent::setUp();
22     $this->executeMigration('d7_action');
23   }
24
25   /**
26    * Test Drupal 7 action migration to Drupal 8.
27    */
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', []);
34
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",
44     ]);
45     $this->assertEntity('redirect_to_url', 'Redirect to URL', 'system', ["url" => "https://www.drupal.org"]);
46
47   }
48
49   /**
50    * Asserts various aspects of an Action entity.
51    *
52    * @param string $id
53    *   The expected Action ID.
54    * @param string $label
55    *   The expected Action label.
56    * @param string $type
57    *   The expected Action type.
58    * @param array $configuration
59    *   The expected Action configuration.
60    */
61   protected function assertEntity($id, $label, $type, $configuration) {
62     $action = Action::load($id);
63
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'));
70   }
71
72 }