90b256fb1447a23974bee66048e509110fe7fb6d
[yaffs-website] / web / core / modules / comment / tests / src / Kernel / Migrate / d6 / MigrateCommentVariableInstanceTest.php
1 <?php
2
3 namespace Drupal\Tests\comment\Kernel\Migrate\d6;
4
5 use Drupal\comment\CommentManagerInterface;
6 use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
7 use Drupal\node\Entity\Node;
8
9 /**
10  * Upgrade comment variables to field.instance.node.*.comment.yml.
11  *
12  * @group migrate_drupal_6
13  */
14 class MigrateCommentVariableInstanceTest extends MigrateDrupal6TestBase {
15
16   /**
17    * {@inheritdoc}
18    */
19   public static $modules = ['comment', 'menu_ui'];
20
21   /**
22    * {@inheritdoc}
23    */
24   protected function setUp() {
25     parent::setUp();
26     $this->installConfig(['comment']);
27     $this->migrateContentTypes();
28     $this->executeMigrations([
29       'd6_comment_type',
30       'd6_comment_field',
31       'd6_comment_field_instance',
32     ]);
33   }
34
35   /**
36    * Test the migrated field instance values.
37    */
38   public function testCommentFieldInstance() {
39     $node = Node::create(['type' => 'page']);
40     $this->assertIdentical(0, $node->comment->status);
41     $this->assertIdentical('comment', $node->comment->getFieldDefinition()->getName());
42     $settings = $node->comment->getFieldDefinition()->getSettings();
43     $this->assertIdentical(CommentManagerInterface::COMMENT_MODE_THREADED, $settings['default_mode']);
44     $this->assertIdentical(50, $settings['per_page']);
45     $this->assertFalse($settings['anonymous']);
46     $this->assertFalse($settings['form_location']);
47     $this->assertTrue($settings['preview']);
48
49     $node = Node::create(['type' => 'story']);
50     $this->assertIdentical(2, $node->comment_no_subject->status);
51     $this->assertIdentical('comment_no_subject', $node->comment_no_subject->getFieldDefinition()->getName());
52     $settings = $node->comment_no_subject->getFieldDefinition()->getSettings();
53     $this->assertIdentical(CommentManagerInterface::COMMENT_MODE_FLAT, $settings['default_mode']);
54     $this->assertIdentical(70, $settings['per_page']);
55     $this->assertTrue($settings['anonymous']);
56     $this->assertFalse($settings['form_location']);
57     $this->assertFalse($settings['preview']);
58   }
59
60 }