From ce0cda2a1d7e9db047d9a6cf1597e56cb27f3636 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kurucz=20Istv=C3=A1n?= <kurucz.istvan@gmail.com> Date: Wed, 3 Nov 2021 01:41:57 +0100 Subject: [PATCH] Test node-type "promote", "status" and "sticky" checkbox. --- .../Kernel/MigrateNodeSettingPromoteTest.php | 37 +++++++++++++++++++ .../Kernel/MigrateNodeSettingStatusTest.php | 37 +++++++++++++++++++ .../Kernel/MigrateNodeSettingStickyTest.php | 37 +++++++++++++++++++ 3 files changed, 111 insertions(+) create mode 100644 tests/src/Kernel/MigrateNodeSettingPromoteTest.php create mode 100644 tests/src/Kernel/MigrateNodeSettingStatusTest.php create mode 100644 tests/src/Kernel/MigrateNodeSettingStickyTest.php diff --git a/tests/src/Kernel/MigrateNodeSettingPromoteTest.php b/tests/src/Kernel/MigrateNodeSettingPromoteTest.php new file mode 100644 index 0000000..aa07579 --- /dev/null +++ b/tests/src/Kernel/MigrateNodeSettingPromoteTest.php @@ -0,0 +1,37 @@ +<?php + +namespace Drupal\Tests\migrate_drupal_d5\Kernel; + +use Drupal\Core\Field\Entity\BaseFieldOverride; + +/** + * @group migrate_drupal_5 + */ +class MigrateNodeSettingPromoteTest extends MigrateDrupal5TestBase { + + protected static $modules = ['node', 'text', 'menu_ui']; + + /** + * {@inheritdoc} + */ + protected function setUp(): void { + parent::setUp(); + $this->installConfig(['node']); + $this->executeMigration('d5_node_type'); + $this->executeMigration('d5_node_setting_promote'); + } + + /** + * Tests migration of the "promote" checkbox's settings for "page" node type. + */ + public function testPageNodeTypePromote() { + $this->assertSame(0, BaseFieldOverride::load('node.page.promote')->getDefaultValueLiteral()[0]['value']); + } + + /** + * Tests migration of the "promote" checkbox's settings for "book" node type. + */ + public function testBookNodeTypePromote() { + $this->assertSame(1, BaseFieldOverride::load('node.book.promote')->getDefaultValueLiteral()[0]['value']); + } +} diff --git a/tests/src/Kernel/MigrateNodeSettingStatusTest.php b/tests/src/Kernel/MigrateNodeSettingStatusTest.php new file mode 100644 index 0000000..d4b291a --- /dev/null +++ b/tests/src/Kernel/MigrateNodeSettingStatusTest.php @@ -0,0 +1,37 @@ +<?php + +namespace Drupal\Tests\migrate_drupal_d5\Kernel; + +use Drupal\Core\Field\Entity\BaseFieldOverride; + +/** + * @group migrate_drupal_5 + */ +class MigrateNodeSettingStatusTest extends MigrateDrupal5TestBase { + + protected static $modules = ['node', 'text', 'menu_ui']; + + /** + * {@inheritdoc} + */ + protected function setUp(): void { + parent::setUp(); + $this->installConfig(['node']); + $this->executeMigration('d5_node_type'); + $this->executeMigration('d5_node_setting_status'); + } + + /** + * Tests migration of the "status" checkbox's settings for "page" node type. + */ + public function testPageNodeTypeStatus() { + $this->assertSame(0, BaseFieldOverride::load('node.page.status')->getDefaultValueLiteral()[0]['value']); + } + + /** + * Tests migration of the "status" checkbox's settings for "book" node type. + */ + public function testBookNodeTypeStatus() { + $this->assertSame(1, BaseFieldOverride::load('node.book.status')->getDefaultValueLiteral()[0]['value']); + } +} diff --git a/tests/src/Kernel/MigrateNodeSettingStickyTest.php b/tests/src/Kernel/MigrateNodeSettingStickyTest.php new file mode 100644 index 0000000..496a80d --- /dev/null +++ b/tests/src/Kernel/MigrateNodeSettingStickyTest.php @@ -0,0 +1,37 @@ +<?php + +namespace Drupal\Tests\migrate_drupal_d5\Kernel; + +use Drupal\Core\Field\Entity\BaseFieldOverride; + +/** + * @group migrate_drupal_5 + */ +class MigrateNodeSettingStickyTest extends MigrateDrupal5TestBase { + + protected static $modules = ['node', 'text', 'menu_ui']; + + /** + * {@inheritdoc} + */ + protected function setUp(): void { + parent::setUp(); + $this->installConfig(['node']); + $this->executeMigration('d5_node_type'); + $this->executeMigration('d5_node_setting_sticky'); + } + + /** + * Tests migration of the "sticky" checkbox's settings for "page" node type. + */ + public function testPageNodeTypeSticky() { + $this->assertSame(0, BaseFieldOverride::load('node.page.sticky')->getDefaultValueLiteral()[0]['value']); + } + + /** + * Tests migration of the "sticky" checkbox's settings for "book" node type. + */ + public function testBookNodeTypeSticky() { + $this->assertSame(1, BaseFieldOverride::load('node.book.sticky')->getDefaultValueLiteral()[0]['value']); + } +} -- GitLab